commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
TransactionDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
20use DateTimeImmutable;
21use stdClass;
22
26final class TransactionDraftBuilder implements Builder
27{
32 private $timestamp;
33
38 private $type;
39
44 private $amount;
45
50 private $interactionId;
51
56 private $state;
57
62 private $custom;
63
68 private $interfaceId;
69
76 public function getTimestamp()
77 {
78 return $this->timestamp;
79 }
80
87 public function getType()
88 {
89 return $this->type;
90 }
91
98 public function getAmount()
99 {
100 return $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount;
101 }
102
110 public function getInteractionId()
111 {
112 return $this->interactionId;
113 }
114
121 public function getState()
122 {
123 return $this->state;
124 }
125
132 public function getCustom()
133 {
134 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
135 }
136
143 public function getInterfaceId()
144 {
145 return $this->interfaceId;
146 }
147
152 public function withTimestamp(?DateTimeImmutable $timestamp)
153 {
154 $this->timestamp = $timestamp;
155
156 return $this;
157 }
158
163 public function withType(?string $type)
164 {
165 $this->type = $type;
166
167 return $this;
168 }
169
174 public function withAmount(?Money $amount)
175 {
176 $this->amount = $amount;
177
178 return $this;
179 }
180
185 public function withInteractionId(?string $interactionId)
186 {
187 $this->interactionId = $interactionId;
188
189 return $this;
190 }
191
196 public function withState(?string $state)
197 {
198 $this->state = $state;
199
200 return $this;
201 }
202
207 public function withCustom(?CustomFieldsDraft $custom)
208 {
209 $this->custom = $custom;
210
211 return $this;
212 }
213
218 public function withInterfaceId(?string $interfaceId)
219 {
220 $this->interfaceId = $interfaceId;
221
222 return $this;
223 }
224
229 public function withAmountBuilder(?MoneyBuilder $amount)
230 {
231 $this->amount = $amount;
232
233 return $this;
234 }
235
241 {
242 $this->custom = $custom;
243
244 return $this;
245 }
246
247 public function build(): TransactionDraft
248 {
249 return new TransactionDraftModel(
250 $this->timestamp,
251 $this->type,
252 $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount,
253 $this->interactionId,
254 $this->state,
255 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom,
256 $this->interfaceId
257 );
258 }
259
260 public static function of(): TransactionDraftBuilder
261 {
262 return new self();
263 }
264}