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
Payment
TransactionDraftModel.php
1
<?php
2
3
declare(strict_types=1);
9
namespace
Commercetools\Api\Models\Payment
;
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
TransactionDraftModel
extends
JsonObjectModel
implements
TransactionDraft
26
{
31
protected
$timestamp
;
32
37
protected
$type
;
38
43
protected
$amount
;
44
49
protected
$interactionId
;
50
55
protected
$state
;
56
61
protected
$custom
;
62
63
67
public
function
__construct
(
68
?DateTimeImmutable
$timestamp
=
null
,
69
?
string
$type
=
null
,
70
?
Money
$amount
=
null
,
71
?
string
$interactionId
=
null
,
72
?
string
$state
=
null
,
73
?
CustomFieldsDraft
$custom
=
null
74
) {
75
$this->timestamp =
$timestamp
;
76
$this->type =
$type
;
77
$this->amount =
$amount
;
78
$this->interactionId =
$interactionId
;
79
$this->state =
$state
;
80
$this->custom =
$custom
;
81
}
82
89
public
function
getTimestamp
()
90
{
91
if
(is_null($this->timestamp)) {
93
$data = $this->
raw
(self::FIELD_TIMESTAMP);
94
if
(is_null($data)) {
95
return
null
;
96
}
97
$data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
98
if
(
false
=== $data) {
99
return
null
;
100
}
101
$this->timestamp = $data;
102
}
103
104
return
$this->timestamp
;
105
}
106
113
public
function
getType
()
114
{
115
if
(is_null($this->type)) {
117
$data = $this->
raw
(self::FIELD_TYPE);
118
if
(is_null($data)) {
119
return
null
;
120
}
121
$this->type = (string) $data;
122
}
123
124
return
$this->type
;
125
}
126
133
public
function
getAmount
()
134
{
135
if
(is_null($this->amount)) {
137
$data = $this->
raw
(self::FIELD_AMOUNT);
138
if
(is_null($data)) {
139
return
null
;
140
}
141
142
$this->amount = MoneyModel::of($data);
143
}
144
145
return
$this->amount
;
146
}
147
155
public
function
getInteractionId
()
156
{
157
if
(is_null($this->interactionId)) {
159
$data = $this->
raw
(self::FIELD_INTERACTION_ID);
160
if
(is_null($data)) {
161
return
null
;
162
}
163
$this->interactionId = (string) $data;
164
}
165
166
return
$this->interactionId
;
167
}
168
175
public
function
getState
()
176
{
177
if
(is_null($this->state)) {
179
$data = $this->
raw
(self::FIELD_STATE);
180
if
(is_null($data)) {
181
return
null
;
182
}
183
$this->state = (string) $data;
184
}
185
186
return
$this->state
;
187
}
188
195
public
function
getCustom
()
196
{
197
if
(is_null($this->custom)) {
199
$data = $this->
raw
(self::FIELD_CUSTOM);
200
if
(is_null($data)) {
201
return
null
;
202
}
203
204
$this->custom = CustomFieldsDraftModel::of($data);
205
}
206
207
return
$this->custom
;
208
}
209
210
214
public
function
setTimestamp
(?DateTimeImmutable
$timestamp
): void
215
{
216
$this->timestamp =
$timestamp
;
217
}
218
222
public
function
setType
(?
string
$type
): void
223
{
224
$this->type =
$type
;
225
}
226
230
public
function
setAmount
(?
Money
$amount
): void
231
{
232
$this->amount =
$amount
;
233
}
234
238
public
function
setInteractionId
(?
string
$interactionId
): void
239
{
240
$this->interactionId =
$interactionId
;
241
}
242
246
public
function
setState
(?
string
$state
): void
247
{
248
$this->state =
$state
;
249
}
250
254
public
function
setCustom
(?
CustomFieldsDraft
$custom
): void
255
{
256
$this->custom =
$custom
;
257
}
258
259
260
#[\ReturnTypeWillChange]
261
public
function
jsonSerialize
()
262
{
263
$data = $this->
toArray
();
264
if
(isset($data[
TransactionDraft::FIELD_TIMESTAMP
]) && $data[
TransactionDraft::FIELD_TIMESTAMP
] instanceof \DateTimeImmutable) {
265
$data[
TransactionDraft::FIELD_TIMESTAMP
] = $data[
TransactionDraft::FIELD_TIMESTAMP
]->setTimeZone(
new
\DateTimeZone(
'UTC'
))->format(
'c'
);
266
}
267
return
(
object
) $data;
268
}
269
}
Commercetools\Api\Models\Common\MoneyModel
Definition
MoneyModel.php:21
Commercetools\Api\Models\Payment\TransactionDraftModel
Definition
TransactionDraftModel.php:26
Commercetools\Api\Models\Payment\TransactionDraftModel\setCustom
setCustom(?CustomFieldsDraft $custom)
Definition
TransactionDraftModel.php:254
Commercetools\Api\Models\Payment\TransactionDraftModel\$type
$type
Definition
TransactionDraftModel.php:37
Commercetools\Api\Models\Payment\TransactionDraftModel\$custom
$custom
Definition
TransactionDraftModel.php:61
Commercetools\Api\Models\Payment\TransactionDraftModel\getTimestamp
getTimestamp()
Definition
TransactionDraftModel.php:89
Commercetools\Api\Models\Payment\TransactionDraftModel\getAmount
getAmount()
Definition
TransactionDraftModel.php:133
Commercetools\Api\Models\Payment\TransactionDraftModel\setInteractionId
setInteractionId(?string $interactionId)
Definition
TransactionDraftModel.php:238
Commercetools\Api\Models\Payment\TransactionDraftModel\jsonSerialize
jsonSerialize()
Definition
TransactionDraftModel.php:261
Commercetools\Api\Models\Payment\TransactionDraftModel\getType
getType()
Definition
TransactionDraftModel.php:113
Commercetools\Api\Models\Payment\TransactionDraftModel\getInteractionId
getInteractionId()
Definition
TransactionDraftModel.php:155
Commercetools\Api\Models\Payment\TransactionDraftModel\setState
setState(?string $state)
Definition
TransactionDraftModel.php:246
Commercetools\Api\Models\Payment\TransactionDraftModel\setAmount
setAmount(?Money $amount)
Definition
TransactionDraftModel.php:230
Commercetools\Api\Models\Payment\TransactionDraftModel\getCustom
getCustom()
Definition
TransactionDraftModel.php:195
Commercetools\Api\Models\Payment\TransactionDraftModel\getState
getState()
Definition
TransactionDraftModel.php:175
Commercetools\Api\Models\Payment\TransactionDraftModel\setTimestamp
setTimestamp(?DateTimeImmutable $timestamp)
Definition
TransactionDraftModel.php:214
Commercetools\Api\Models\Payment\TransactionDraftModel\$amount
$amount
Definition
TransactionDraftModel.php:43
Commercetools\Api\Models\Payment\TransactionDraftModel\$timestamp
$timestamp
Definition
TransactionDraftModel.php:31
Commercetools\Api\Models\Payment\TransactionDraftModel\setType
setType(?string $type)
Definition
TransactionDraftModel.php:222
Commercetools\Api\Models\Payment\TransactionDraftModel\__construct
__construct(?DateTimeImmutable $timestamp=null, ?string $type=null, ?Money $amount=null, ?string $interactionId=null, ?string $state=null, ?CustomFieldsDraft $custom=null)
Definition
TransactionDraftModel.php:67
Commercetools\Api\Models\Payment\TransactionDraftModel\$state
$state
Definition
TransactionDraftModel.php:55
Commercetools\Api\Models\Payment\TransactionDraftModel\$interactionId
$interactionId
Definition
TransactionDraftModel.php:49
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\Payment\TransactionDraft
Definition
TransactionDraft.php:18
Commercetools\Api\Models\Payment\TransactionDraft\FIELD_TIMESTAMP
const FIELD_TIMESTAMP
Definition
TransactionDraft.php:19
Commercetools\Api\Models\Type\CustomFieldsDraft
Definition
CustomFieldsDraft.php:15
Commercetools\Base\JsonObject
Definition
JsonObject.php:15
Commercetools\Api\Models\Payment
Definition
Payment.php:9
Generated by
1.9.8