commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
RecurringOrderDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
22use DateTimeImmutable;
23use stdClass;
24
28final class RecurringOrderDraftBuilder implements Builder
29{
34 private $key;
35
40 private $cart;
41
46 private $cartVersion;
47
52 private $startsAt;
53
58 private $expiresAt;
59
64 private $state;
65
70 private $custom;
71
78 public function getKey()
79 {
80 return $this->key;
81 }
82
89 public function getCart()
90 {
91 return $this->cart instanceof CartResourceIdentifierBuilder ? $this->cart->build() : $this->cart;
92 }
93
100 public function getCartVersion()
101 {
102 return $this->cartVersion;
103 }
104
111 public function getStartsAt()
112 {
113 return $this->startsAt;
114 }
115
122 public function getExpiresAt()
123 {
124 return $this->expiresAt;
125 }
126
133 public function getState()
134 {
135 return $this->state instanceof StateResourceIdentifierBuilder ? $this->state->build() : $this->state;
136 }
137
144 public function getCustom()
145 {
146 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
147 }
148
153 public function withKey(?string $key)
154 {
155 $this->key = $key;
156
157 return $this;
158 }
159
164 public function withCart(?CartResourceIdentifier $cart)
165 {
166 $this->cart = $cart;
167
168 return $this;
169 }
170
175 public function withCartVersion(?int $cartVersion)
176 {
177 $this->cartVersion = $cartVersion;
178
179 return $this;
180 }
181
186 public function withStartsAt(?DateTimeImmutable $startsAt)
187 {
188 $this->startsAt = $startsAt;
189
190 return $this;
191 }
192
197 public function withExpiresAt(?DateTimeImmutable $expiresAt)
198 {
199 $this->expiresAt = $expiresAt;
200
201 return $this;
202 }
203
208 public function withState(?StateResourceIdentifier $state)
209 {
210 $this->state = $state;
211
212 return $this;
213 }
214
219 public function withCustom(?CustomFieldsDraft $custom)
220 {
221 $this->custom = $custom;
222
223 return $this;
224 }
225
231 {
232 $this->cart = $cart;
233
234 return $this;
235 }
236
242 {
243 $this->state = $state;
244
245 return $this;
246 }
247
253 {
254 $this->custom = $custom;
255
256 return $this;
257 }
258
259 public function build(): RecurringOrderDraft
260 {
261 return new RecurringOrderDraftModel(
262 $this->key,
263 $this->cart instanceof CartResourceIdentifierBuilder ? $this->cart->build() : $this->cart,
264 $this->cartVersion,
265 $this->startsAt,
266 $this->expiresAt,
267 $this->state instanceof StateResourceIdentifierBuilder ? $this->state->build() : $this->state,
268 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
269 );
270 }
271
272 public static function of(): RecurringOrderDraftBuilder
273 {
274 return new self();
275 }
276}