Completed
Pull Request — master (#15)
by ARCANEDEV
11:13
created

Transfer::retrieve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\TransferInterface;
4
use Arcanedev\Stripe\StripeResource;
5
6
/**
7
 * Class     Transfer
8
 *
9
 * @package  Arcanedev\Stripe\Resources
10
 * @author   ARCANEDEV <[email protected]>
11
 * @link     https://stripe.com/docs/api/php#transfer_object
12
 *
13
 * @property  string                                   id
14
 * @property  string                                   object                // 'transfer'
15
 * @property  int                                      amount
16
 * @property  int                                      amount_reversed
17
 * @property  string                                   application_fee
18
 * @property  string                                   balance_transaction
19
 * @property  int                                      created               // timestamp
20
 * @property  string                                   currency
21
 * @property  int                                      date                  // timestamp
22
 * @property  string                                   description
23
 * @property  string                                   destination
24
 * @property  string                                   destination_payment
25
 * @property  string                                   failure_code
26
 * @property  string                                   failure_message
27
 * @property  bool                                     livemode
28
 * @property  \Arcanedev\Stripe\AttachedObject         metadata
29
 * @property  \Arcanedev\Stripe\Collection             reversals
30
 * @property  bool                                     reversed
31
 * @property  string                                   source_transaction
32
 * @property  string                                   source_type           // 'card', 'bank_account', 'bitcoin_receiver', or 'alipay_account'
33
 * @property  string                                   statement_descriptor
34
 * @property  string                                   status                // 'paid', 'pending', 'in_transit', 'canceled' or 'failed'
35
 * @property  string                                   type                  //  'card', 'bank_account', or 'stripe_account'
36
 */
37
class Transfer extends StripeResource implements TransferInterface
38
{
39
    /* ------------------------------------------------------------------------------------------------
40
     |  CRUD Functions
41
     | ------------------------------------------------------------------------------------------------
42
     */
43
    /**
44
     * Retrieve a Transfer.
45
     * @link   https://stripe.com/docs/api/php#retrieve_transfer
46
     *
47
     * @param  string             $id
48
     * @param  array|string|null  $options
49
     *
50
     * @return self
51
     */
52 11
    public static function retrieve($id, $options = null)
53
    {
54 11
        return self::scopedRetrieve($id, $options);
55
    }
56
57
    /**
58
     * List all Transfers.
59
     * @link   https://stripe.com/docs/api/php#list_transfers
60
     *
61
     * @param  array|null         $params
62
     * @param  array|string|null  $options
63
     *
64
     * @return \Arcanedev\Stripe\Collection|array
65
     */
66 10
    public static function all($params = [], $options = null)
67
    {
68 10
        return self::scopedAll($params, $options);
69
    }
70
71
    /**
72
     * Create a transfer.
73
     * @link   https://stripe.com/docs/api/php#create_transfer
74
     *
75
     * @param  array|null         $params
76
     * @param  array|string|null  $options
77
     *
78
     * @return self|array
79
     */
80 30
    public static function create($params = [], $options = null)
81
    {
82 30
        return self::scopedCreate($params, $options);
83
    }
84
85
    /**
86
     * Cancel a Transfer.
87
     * @link   https://stripe.com/docs/api/php#cancel_transfer
88
     *
89
     * @return self
90
     */
91
    public function cancel()
92
    {
93
        list($response, $opts) = $this->request('post', $this->instanceUrl() . '/cancel');
94
        $this->refreshFrom($response, $opts);
95
96
        return $this;
97
    }
98
99
    /**
100
     * Created transfer reversal.
101
     *
102
     * @param  array|null         $params
103
     * @param  array|string|null  $options
104
     *
105
     * @return \Arcanedev\Stripe\Resources\TransferReversal
106
     */
107
    public function reverse($params = null, $options = null)
108
    {
109
        list($response, $opts) = $this->request(
110
            'post', $this->instanceUrl() . '/reversals', $params, $options
111
        );
112
        $this->refreshFrom($response, $opts);
113
114
        return $this;
115
    }
116
117
    /**
118
     * Update a Transfer.
119
     * @link   https://stripe.com/docs/api/php#update_transfer
120
     *
121
     * @param  array|string|null  $options
122
     *
123
     * @return self
124
     */
125 5
    public function save($options = null)
126
    {
127 5
        return self::scopedSave($options);
128
    }
129
}
130