commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
MyTransactionDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
20use DateTimeImmutable;
21use stdClass;
22
26final class MyTransactionDraftBuilder implements Builder
27{
32 private $timestamp;
33
38 private $type;
39
44 private $amount;
45
50 private $interactionId;
51
56 private $custom;
57
64 public function getTimestamp()
65 {
66 return $this->timestamp;
67 }
68
76 public function getType()
77 {
78 return $this->type;
79 }
80
87 public function getAmount()
88 {
89 return $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount;
90 }
91
99 public function getInteractionId()
100 {
101 return $this->interactionId;
102 }
103
110 public function getCustom()
111 {
112 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
113 }
114
119 public function withTimestamp(?DateTimeImmutable $timestamp)
120 {
121 $this->timestamp = $timestamp;
122
123 return $this;
124 }
125
130 public function withType(?string $type)
131 {
132 $this->type = $type;
133
134 return $this;
135 }
136
141 public function withAmount(?Money $amount)
142 {
143 $this->amount = $amount;
144
145 return $this;
146 }
147
152 public function withInteractionId(?string $interactionId)
153 {
154 $this->interactionId = $interactionId;
155
156 return $this;
157 }
158
163 public function withCustom(?CustomFieldsDraft $custom)
164 {
165 $this->custom = $custom;
166
167 return $this;
168 }
169
174 public function withAmountBuilder(?MoneyBuilder $amount)
175 {
176 $this->amount = $amount;
177
178 return $this;
179 }
180
186 {
187 $this->custom = $custom;
188
189 return $this;
190 }
191
192 public function build(): MyTransactionDraft
193 {
194 return new MyTransactionDraftModel(
195 $this->timestamp,
196 $this->type,
197 $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount,
198 $this->interactionId,
199 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
200 );
201 }
202
203 public static function of(): MyTransactionDraftBuilder
204 {
205 return new self();
206 }
207}