commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
TransactionDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
20 use DateTimeImmutable;
21 use stdClass;
22 
26 final 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 
70  public function getTimestamp()
71  {
72  return $this->timestamp;
73  }
74 
81  public function getType()
82  {
83  return $this->type;
84  }
85 
92  public function getAmount()
93  {
94  return $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount;
95  }
96 
104  public function getInteractionId()
105  {
106  return $this->interactionId;
107  }
108 
115  public function getState()
116  {
117  return $this->state;
118  }
119 
126  public function getCustom()
127  {
128  return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
129  }
130 
135  public function withTimestamp(?DateTimeImmutable $timestamp)
136  {
137  $this->timestamp = $timestamp;
138 
139  return $this;
140  }
141 
146  public function withType(?string $type)
147  {
148  $this->type = $type;
149 
150  return $this;
151  }
152 
157  public function withAmount(?Money $amount)
158  {
159  $this->amount = $amount;
160 
161  return $this;
162  }
163 
168  public function withInteractionId(?string $interactionId)
169  {
170  $this->interactionId = $interactionId;
171 
172  return $this;
173  }
174 
179  public function withState(?string $state)
180  {
181  $this->state = $state;
182 
183  return $this;
184  }
185 
190  public function withCustom(?CustomFieldsDraft $custom)
191  {
192  $this->custom = $custom;
193 
194  return $this;
195  }
196 
201  public function withAmountBuilder(?MoneyBuilder $amount)
202  {
203  $this->amount = $amount;
204 
205  return $this;
206  }
207 
212  public function withCustomBuilder(?CustomFieldsDraftBuilder $custom)
213  {
214  $this->custom = $custom;
215 
216  return $this;
217  }
218 
219  public function build(): TransactionDraft
220  {
221  return new TransactionDraftModel(
222  $this->timestamp,
223  $this->type,
224  $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount,
225  $this->interactionId,
226  $this->state,
227  $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
228  );
229  }
230 
231  public static function of(): TransactionDraftBuilder
232  {
233  return new self();
234  }
235 }