commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
lib
commercetools-api
src
Models
Me
MyTransactionDraftModel.php
1
<?php
2
3
declare(strict_types=1);
9
namespace
Commercetools\Api\Models\Me
;
10
11
use
Commercetools\Api\Models\Common\Money
;
12
use
Commercetools\Api\Models\Common\MoneyModel
;
13
use
Commercetools\Api\Models\Type\CustomFieldsDraft
;
14
use
Commercetools\Api\Models\Type\CustomFieldsDraftModel
;
15
use
Commercetools\Base\DateTimeImmutableCollection
;
16
use
Commercetools\Base\JsonObject
;
17
use
Commercetools\Base\JsonObjectModel
;
18
use
Commercetools\Base\MapperFactory
;
19
use DateTimeImmutable;
20
use stdClass;
21
25
final
class
MyTransactionDraftModel
extends
JsonObjectModel
implements
MyTransactionDraft
26
{
31
protected
$timestamp
;
32
37
protected
$type
;
38
43
protected
$amount
;
44
49
protected
$interactionId
;
50
55
protected
$custom
;
56
57
61
public
function
__construct
(
62
?DateTimeImmutable
$timestamp
=
null
,
63
?
string
$type
=
null
,
64
?
Money
$amount
=
null
,
65
?
string
$interactionId
=
null
,
66
?
CustomFieldsDraft
$custom
=
null
67
) {
68
$this->timestamp =
$timestamp
;
69
$this->type =
$type
;
70
$this->amount =
$amount
;
71
$this->interactionId =
$interactionId
;
72
$this->custom =
$custom
;
73
}
74
81
public
function
getTimestamp
()
82
{
83
if
(is_null($this->timestamp)) {
85
$data = $this->
raw
(self::FIELD_TIMESTAMP);
86
if
(is_null($data)) {
87
return
null
;
88
}
89
$data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
90
if
(
false
=== $data) {
91
return
null
;
92
}
93
$this->timestamp = $data;
94
}
95
96
return
$this->timestamp
;
97
}
98
106
public
function
getType
()
107
{
108
if
(is_null($this->type)) {
110
$data = $this->
raw
(self::FIELD_TYPE);
111
if
(is_null($data)) {
112
return
null
;
113
}
114
$this->type = (string) $data;
115
}
116
117
return
$this->type
;
118
}
119
126
public
function
getAmount
()
127
{
128
if
(is_null($this->amount)) {
130
$data = $this->
raw
(self::FIELD_AMOUNT);
131
if
(is_null($data)) {
132
return
null
;
133
}
134
135
$this->amount = MoneyModel::of($data);
136
}
137
138
return
$this->amount
;
139
}
140
148
public
function
getInteractionId
()
149
{
150
if
(is_null($this->interactionId)) {
152
$data = $this->
raw
(self::FIELD_INTERACTION_ID);
153
if
(is_null($data)) {
154
return
null
;
155
}
156
$this->interactionId = (string) $data;
157
}
158
159
return
$this->interactionId
;
160
}
161
168
public
function
getCustom
()
169
{
170
if
(is_null($this->custom)) {
172
$data = $this->
raw
(self::FIELD_CUSTOM);
173
if
(is_null($data)) {
174
return
null
;
175
}
176
177
$this->custom = CustomFieldsDraftModel::of($data);
178
}
179
180
return
$this->custom
;
181
}
182
183
187
public
function
setTimestamp
(?DateTimeImmutable
$timestamp
): void
188
{
189
$this->timestamp =
$timestamp
;
190
}
191
195
public
function
setType
(?
string
$type
): void
196
{
197
$this->type =
$type
;
198
}
199
203
public
function
setAmount
(?
Money
$amount
): void
204
{
205
$this->amount =
$amount
;
206
}
207
211
public
function
setInteractionId
(?
string
$interactionId
): void
212
{
213
$this->interactionId =
$interactionId
;
214
}
215
219
public
function
setCustom
(?
CustomFieldsDraft
$custom
): void
220
{
221
$this->custom =
$custom
;
222
}
223
224
225
#[\ReturnTypeWillChange]
226
public
function
jsonSerialize
()
227
{
228
$data = $this->
toArray
();
229
if
(isset($data[
MyTransactionDraft::FIELD_TIMESTAMP
]) && $data[
MyTransactionDraft::FIELD_TIMESTAMP
] instanceof \DateTimeImmutable) {
230
$data[
MyTransactionDraft::FIELD_TIMESTAMP
] = $data[
MyTransactionDraft::FIELD_TIMESTAMP
]->setTimeZone(
new
\DateTimeZone(
'UTC'
))->format(
'c'
);
231
}
232
return
(
object
) $data;
233
}
234
}
Commercetools\Api\Models\Common\MoneyModel
Definition
MoneyModel.php:21
Commercetools\Api\Models\Me\MyTransactionDraftModel
Definition
MyTransactionDraftModel.php:26
Commercetools\Api\Models\Me\MyTransactionDraftModel\setCustom
setCustom(?CustomFieldsDraft $custom)
Definition
MyTransactionDraftModel.php:219
Commercetools\Api\Models\Me\MyTransactionDraftModel\setTimestamp
setTimestamp(?DateTimeImmutable $timestamp)
Definition
MyTransactionDraftModel.php:187
Commercetools\Api\Models\Me\MyTransactionDraftModel\setAmount
setAmount(?Money $amount)
Definition
MyTransactionDraftModel.php:203
Commercetools\Api\Models\Me\MyTransactionDraftModel\__construct
__construct(?DateTimeImmutable $timestamp=null, ?string $type=null, ?Money $amount=null, ?string $interactionId=null, ?CustomFieldsDraft $custom=null)
Definition
MyTransactionDraftModel.php:61
Commercetools\Api\Models\Me\MyTransactionDraftModel\getAmount
getAmount()
Definition
MyTransactionDraftModel.php:126
Commercetools\Api\Models\Me\MyTransactionDraftModel\jsonSerialize
jsonSerialize()
Definition
MyTransactionDraftModel.php:226
Commercetools\Api\Models\Me\MyTransactionDraftModel\$interactionId
$interactionId
Definition
MyTransactionDraftModel.php:49
Commercetools\Api\Models\Me\MyTransactionDraftModel\getInteractionId
getInteractionId()
Definition
MyTransactionDraftModel.php:148
Commercetools\Api\Models\Me\MyTransactionDraftModel\setInteractionId
setInteractionId(?string $interactionId)
Definition
MyTransactionDraftModel.php:211
Commercetools\Api\Models\Me\MyTransactionDraftModel\setType
setType(?string $type)
Definition
MyTransactionDraftModel.php:195
Commercetools\Api\Models\Me\MyTransactionDraftModel\$custom
$custom
Definition
MyTransactionDraftModel.php:55
Commercetools\Api\Models\Me\MyTransactionDraftModel\getCustom
getCustom()
Definition
MyTransactionDraftModel.php:168
Commercetools\Api\Models\Me\MyTransactionDraftModel\$type
$type
Definition
MyTransactionDraftModel.php:37
Commercetools\Api\Models\Me\MyTransactionDraftModel\$timestamp
$timestamp
Definition
MyTransactionDraftModel.php:31
Commercetools\Api\Models\Me\MyTransactionDraftModel\getTimestamp
getTimestamp()
Definition
MyTransactionDraftModel.php:81
Commercetools\Api\Models\Me\MyTransactionDraftModel\$amount
$amount
Definition
MyTransactionDraftModel.php:43
Commercetools\Api\Models\Me\MyTransactionDraftModel\getType
getType()
Definition
MyTransactionDraftModel.php:106
Commercetools\Api\Models\Type\CustomFieldsDraftModel
Definition
CustomFieldsDraftModel.php:21
Commercetools\Base\BaseJsonObject\raw
raw(string $field)
Definition
BaseJsonObject.php:57
Commercetools\Base\DateTimeImmutableCollection
Definition
DateTimeImmutableCollection.php:21
Commercetools\Base\JsonObjectModel
Definition
JsonObjectModel.php:15
Commercetools\Base\JsonObjectModel\toArray
toArray()
Definition
JsonObjectModel.php:32
Commercetools\Base\MapperFactory
Definition
MapperFactory.php:16
Commercetools\Api\Models\Common\Money
Definition
Money.php:15
Commercetools\Api\Models\Me\MyTransactionDraft
Definition
MyTransactionDraft.php:18
Commercetools\Api\Models\Me\MyTransactionDraft\FIELD_TIMESTAMP
const FIELD_TIMESTAMP
Definition
MyTransactionDraft.php:19
Commercetools\Api\Models\Type\CustomFieldsDraft
Definition
CustomFieldsDraft.php:15
Commercetools\Base\JsonObject
Definition
JsonObject.php:15
Commercetools\Api\Models\Me
Definition
MyBusinessUnitAddAddressAction.php:9
Generated by
1.9.8