Order   A
last analyzed

Complexity

Total Complexity 37

Size/Duplication

Total Lines 452
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 88
dl 0
loc 452
rs 9.44
c 0
b 0
f 0
wmc 37

32 Methods

Rating   Name   Duplication   Size   Complexity  
A getShoppingCart() 0 3 1
A getExpiresAt() 0 3 1
A getUnconfirmedAt() 0 3 1
A __construct() 0 6 1
A getId() 0 3 1
A getCreatedAt() 0 3 1
A setShoppingCart() 0 5 1
A setUser() 0 5 1
A addRefund() 0 5 1
A getGracePeriod() 0 3 1
A setGracePeriodMonth() 0 5 1
A getRefunds() 0 3 1
A getStatus() 0 3 1
A getUser() 0 3 1
A setId() 0 5 1
A getApiVersion() 0 3 1
A getGracePeriodMonth() 0 3 1
A setMetadata() 0 5 1
A setApiVersion() 0 5 1
A setCreatedAt() 0 5 1
A setUnconfirmedAt() 0 5 1
A getMetadata() 0 3 1
A getActionUrls() 0 3 1
A setConfiguration() 0 5 1
A setStatus() 0 5 1
A setConfirmedAt() 0 5 1
A getConfirmedAt() 0 3 1
A setActionUrls() 0 5 1
A getConfiguration() 0 3 1
A setExpiresAt() 0 5 1
A setGracePeriod() 0 5 1
A import() 0 19 6
1
<?php
2
3
namespace Pagantis\OrdersApiClient\Model;
4
5
use Pagantis\OrdersApiClient\Model\Order\ActionUrls;
6
use Pagantis\OrdersApiClient\Model\Order\Configuration;
7
use Pagantis\OrdersApiClient\Model\Order\Metadata;
8
use Pagantis\OrdersApiClient\Model\Order\Refund;
9
use Pagantis\OrdersApiClient\Model\Order\ShoppingCart;
10
use Pagantis\OrdersApiClient\Model\Order\User;
11
12
/**
13
 * Class Order
14
 *
15
 * @package Pagantis\OrdersApiClient\Model
16
 */
17
class Order extends AbstractModel
18
{
19
    /**
20
     * Initial status of a order.
21
     */
22
    const STATUS_CREATED = 'CREATED';
23
24
    /**
25
     * Order has been authorized and initial payment has been approved. For finalizing the order
26
     * it's mandatory to confirm it.
27
     */
28
    const STATUS_AUTHORIZED = 'AUTHORIZED';
29
30
    /**
31
     * Order confirmed has been paid by customer and merchant has confirmed it. Payment is completed
32
     * and settlement will be created.
33
     */
34
    const STATUS_CONFIRMED = 'CONFIRMED';
35
36
    /**
37
     * Rejected by the risk engine, the transaction has been rejected and payment is no longer
38
     * expected nor possible.
39
     */
40
    const STATUS_REJECTED = 'REJECTED';
41
42
    /**
43
     * The order has been invalidated due to the expiration limit. If no action happens during the
44
     * defined time, the order could turn to invalidated.
45
     */
46
    const STATUS_INVALIDATED = 'INVALIDATED';
47
48
    /**
49
     * Undefined ERROR has occurred, please double check with the account manager or Pagantis support channels.
50
     */
51
    const STATUS_ERROR = 'ERROR';
52
53
    /**
54
     * If a order is not confirmed given the default confirmation time, defined previously, it will turn to
55
     * unconfirmed and this will refund any possible payment taken from the customer. The loan shall not be created.
56
     */
57
    const STATUS_UNCONFIRMED = 'UNCONFIRMED';
58
59
    /**
60
     * @var ActionUrls $actionUrls
61
     */
62
    protected $actionUrls;
63
64
    /**
65
     * @var string $apiVersion
66
     */
67
    protected $apiVersion;
68
69
    /**
70
     * @var Configuration $configuration
71
     */
72
    protected $configuration;
73
74
    /**
75
     * @var \DateTime $confirmedAt
76
     */
77
    protected $confirmedAt;
78
79
    /**
80
     * @var \DateTime $createdAt
81
     */
82
    protected $createdAt;
83
84
    /**
85
     * @var \DateTime $expiresAt
86
     */
87
    protected $expiresAt;
88
89
    /**
90
     * @var \DateTime $unconfirmedAt
91
     */
92
    protected $unconfirmedAt;
93
94
    /**
95
     * @var string $gracePeriod
96
     */
97
    protected $gracePeriod;
98
99
    /**
100
     * @var string $gracePeriodMonth
101
     */
102
    protected $gracePeriodMonth;
103
104
    /**
105
     * @var string $id
106
     */
107
    protected $id;
108
109
    /**
110
     * @var Metadata $metadata
111
     */
112
    protected $metadata;
113
114
    /**
115
     * @var Refund[] $refunds
116
     */
117
    protected $refunds;
118
119
    /**
120
     * @var ShoppingCart $shoppingCart
121
     */
122
    protected $shoppingCart;
123
124
    /**
125
     * @var string $status
126
     */
127
    protected $status;
128
129
    /**
130
     * @var User $user
131
     */
132
    protected $user;
133
134
    /**
135
     * Order constructor.
136
     */
137
    public function __construct()
138
    {
139
        $this->configuration = new Configuration();
140
        $this->metadata = new Metadata();
141
        $this->shoppingCart = new ShoppingCart();
142
        $this->user = new User();
143
    }
144
145
    /**
146
     * @return ActionUrls
147
     */
148
    public function getActionUrls()
149
    {
150
        return $this->actionUrls;
151
    }
152
153
    /**
154
     * @param ActionUrls $actionUrls
155
     *
156
     * @return Order
157
     */
158
    public function setActionUrls($actionUrls)
159
    {
160
        $this->actionUrls = $actionUrls;
161
162
        return $this;
163
    }
164
165
    /**
166
     * @return string
167
     */
168
    public function getApiVersion()
169
    {
170
        return $this->apiVersion;
171
    }
172
173
    /**
174
     * @param string $apiVersion
175
     *
176
     * @return Order
177
     */
178
    public function setApiVersion($apiVersion)
179
    {
180
        $this->apiVersion = $apiVersion;
181
182
        return $this;
183
    }
184
185
    /**
186
     * @return Configuration
187
     */
188
    public function getConfiguration()
189
    {
190
        return $this->configuration;
191
    }
192
193
    /**
194
     * @param Configuration $configuration
195
     *
196
     * @return Order
197
     */
198
    public function setConfiguration($configuration)
199
    {
200
        $this->configuration = $configuration;
201
202
        return $this;
203
    }
204
205
    /**
206
     * @return \DateTime
207
     */
208
    public function getConfirmedAt()
209
    {
210
        return $this->confirmedAt;
211
    }
212
213
    /**
214
     * @param \DateTime $confirmedAt
215
     *
216
     * @return Order
217
     */
218
    public function setConfirmedAt($confirmedAt)
219
    {
220
        $this->confirmedAt = $confirmedAt;
221
222
        return $this;
223
    }
224
225
    /**
226
     * @return \DateTime
227
     */
228
    public function getCreatedAt()
229
    {
230
        return $this->createdAt;
231
    }
232
233
    /**
234
     * @param \DateTime $createdAt
235
     *
236
     * @return Order
237
     */
238
    public function setCreatedAt($createdAt)
239
    {
240
        $this->createdAt = $createdAt;
241
242
        return $this;
243
    }
244
245
    /**
246
     * @return \DateTime
247
     */
248
    public function getExpiresAt()
249
    {
250
        return $this->expiresAt;
251
    }
252
253
    /**
254
     * @param \DateTime $expiresAt
255
     *
256
     * @return Order
257
     */
258
    public function setExpiresAt($expiresAt)
259
    {
260
        $this->expiresAt = $expiresAt;
261
262
        return $this;
263
    }
264
265
    /**
266
     * @return \DateTime
267
     */
268
    public function getUnconfirmedAt()
269
    {
270
        return $this->unconfirmedAt;
271
    }
272
273
    /**
274
     * @param \DateTime $unconfirmedAt
275
     *
276
     * @return Order
277
     */
278
    public function setUnconfirmedAt($unconfirmedAt)
279
    {
280
        $this->unconfirmedAt = $unconfirmedAt;
281
282
        return $this;
283
    }
284
285
    /**
286
     * @return string
287
     */
288
    public function getGracePeriod()
289
    {
290
        return $this->gracePeriod;
291
    }
292
293
    /**
294
     * @param string $gracePeriod
295
     *
296
     * @return Order
297
     */
298
    public function setGracePeriod($gracePeriod)
299
    {
300
        $this->gracePeriod = $gracePeriod;
301
302
        return $this;
303
    }
304
305
    /**
306
     * @return string
307
     */
308
    public function getGracePeriodMonth()
309
    {
310
        return $this->gracePeriodMonth;
311
    }
312
313
    /**
314
     * @param string $gracePeriodMonth
315
     *
316
     * @return Order
317
     */
318
    public function setGracePeriodMonth($gracePeriodMonth)
319
    {
320
        $this->gracePeriodMonth = $gracePeriodMonth;
321
322
        return $this;
323
    }
324
325
    /**
326
     * @return string
327
     */
328
    public function getId()
329
    {
330
        return $this->id;
331
    }
332
333
    /**
334
     * @param string $id
335
     *
336
     * @return Order
337
     */
338
    public function setId($id)
339
    {
340
        $this->id = $id;
341
342
        return $this;
343
    }
344
345
    /**
346
     * @return Metadata
347
     */
348
    public function getMetadata()
349
    {
350
        return $this->metadata;
351
    }
352
353
    /**
354
     * @param Metadata $metadata
355
     *
356
     * @return Order
357
     */
358
    public function setMetadata($metadata)
359
    {
360
        $this->metadata = $metadata;
361
362
        return $this;
363
    }
364
365
    /**
366
     * @return Refund[]
367
     */
368
    public function getRefunds()
369
    {
370
        return $this->refunds;
371
    }
372
373
    /**
374
     * @param Refund $refund
375
     *
376
     * @return $this
377
     */
378
    public function addRefund(Refund $refund)
379
    {
380
        $this->refunds[] = $refund;
381
382
        return $this;
383
    }
384
385
    /**
386
     * @return ShoppingCart
387
     */
388
    public function getShoppingCart()
389
    {
390
        return $this->shoppingCart;
391
    }
392
393
    /**
394
     * @param ShoppingCart $shoppingCart
395
     *
396
     * @return Order
397
     */
398
    public function setShoppingCart($shoppingCart)
399
    {
400
        $this->shoppingCart = $shoppingCart;
401
402
        return $this;
403
    }
404
405
    /**
406
     * @return string
407
     */
408
    public function getStatus()
409
    {
410
        return $this->status;
411
    }
412
413
    /**
414
     * @param string $status
415
     *
416
     * @return Order
417
     */
418
    public function setStatus($status)
419
    {
420
        $this->status = $status;
421
422
        return $this;
423
    }
424
425
    /**
426
     * @return User
427
     */
428
    public function getUser()
429
    {
430
        return $this->user;
431
    }
432
433
    /**
434
     * @param User $user
435
     *
436
     * @return Order
437
     */
438
    public function setUser($user)
439
    {
440
        $this->user = $user;
441
442
        return $this;
443
    }
444
445
    /**
446
     * @param \stdClass $object
447
     *
448
     * @throws \Exception
449
     */
450
    public function import($object)
451
    {
452
        $this->actionUrls = new ActionUrls();
453
        $this->configuration = new Configuration();
454
        $this->metadata = new Metadata();
455
        $this->refunds = array();
456
        $this->shoppingCart = new ShoppingCart();
457
        $this->user = new User();
458
459
        parent::import($object);
460
        $properties = get_object_vars($object);
461
        foreach ($properties as $key => $value) {
462
            if (is_array($value)) {
463
                if (is_array($this->{$key}) && $key == 'refunds') {
464
                    $this->refunds = array();
465
                    foreach ($value as $refund) {
466
                        $refundObject = new Refund();
467
                        $refundObject->import($refund);
468
                        $this->addRefund($refundObject);
469
                    }
470
                }
471
            }
472
        }
473
    }
474
}
475