|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * To change this license header, choose License Headers in Project Properties. |
| 5 | + * To change this template file, choose Tools | Templates |
| 6 | + * and open the template in the editor. |
| 7 | + */ |
| 8 | + |
| 9 | +namespace Moip\Resource; |
| 10 | + |
| 11 | +/** |
| 12 | + * Description of Escrow |
| 13 | + * |
| 14 | + * @author caiogaspar |
| 15 | + */ |
| 16 | +class Escrow extends MoipResource { |
| 17 | + |
| 18 | + /** |
| 19 | + * @const string |
| 20 | + */ |
| 21 | + const PATH = 'escrows'; |
| 22 | + |
| 23 | + /** |
| 24 | + * Initializes new instances. |
| 25 | + */ |
| 26 | + protected function initialize() |
| 27 | + { |
| 28 | + $this->data = new stdClass(); |
| 29 | + $this->data->installmentCount = 1; |
| 30 | + $this->data->fundingInstrument = new stdClass(); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Mount payment structure. |
| 35 | + * |
| 36 | + * @param \stdClass $response |
| 37 | + * |
| 38 | + * @return Escrow |
| 39 | + */ |
| 40 | + protected function populate(stdClass $response) |
| 41 | + { |
| 42 | + $escrow = clone $this; |
| 43 | + |
| 44 | + $escrow->data->id = $this->getIfSet('id', $response); |
| 45 | + $escrow->data->status = $this->getIfSet('status', $response); |
| 46 | + $escrow->data->delayCapture = $this->getIfSet('delayCapture', $response); |
| 47 | + $escrow->data->amount = new stdClass(); |
| 48 | + $escrow->data->amount->total = $this->getIfSet('total', $response->amount); |
| 49 | + $escrow->data->amount->currency = $this->getIfSet('currency', $response->amount); |
| 50 | + $escrow->data->installmentCount = $this->getIfSet('installmentCount', $response); |
| 51 | + $escrow->data->fundingInstrument = $this->getIfSet('fundingInstrument', $response); |
| 52 | + $escrow->data->fees = $this->getIfSet('fees', $response); |
| 53 | + $escrow->data->refunds = $this->getIfSet('refunds', $response); |
| 54 | + $escrow->data->_links = $this->getIfSet('_links', $response); |
| 55 | + $escrow->data->createdAt = $this->getIfSetDateTime('createdAt', $response); |
| 56 | + $escrow->data->updatedAt = $this->getIfSetDateTime('updatedAt', $response); |
| 57 | + |
| 58 | + return $escrow; |
| 59 | + } |
| 60 | +} |
0 commit comments