Transfer::retrieve()   A
last analyzed

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 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\Transfer as TransferContract;
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                            balance_transaction
18
 * @property  int                               created               // timestamp
19
 * @property  string                            currency
20
 * @property  int                               date                  // timestamp
21
 * @property  string                            destination
22
 * @property  string                            destination_payment
23
 * @property  bool                              livemode
24
 * @property  \Arcanedev\Stripe\AttachedObject  metadata
25
 * @property  \Arcanedev\Stripe\Collection      reversals
26
 * @property  bool                              reversed
27
 * @property  string                            source_transaction
28
 */
29
class Transfer extends StripeResource implements TransferContract
30
{
31
    /* -----------------------------------------------------------------
32
     |  Constants
33
     | -----------------------------------------------------------------
34
     */
35
36
    const PATH_REVERSALS = '/reversals';
37
38
    /* -----------------------------------------------------------------
39
     |  Main Methods
40
     | -----------------------------------------------------------------
41
     */
42
43
    /**
44
     * List all Transfers.
45
     * @link   https://stripe.com/docs/api/php#list_transfers
46
     *
47
     * @param  array|null         $params
48
     * @param  array|string|null  $options
49
     *
50
     * @return \Arcanedev\Stripe\Collection|array
51
     */
52 2
    public static function all($params = [], $options = null)
53
    {
54 2
        return self::scopedAll($params, $options);
55
    }
56
57
    /**
58
     * Retrieve a Transfer.
59
     * @link   https://stripe.com/docs/api/php#retrieve_transfer
60
     *
61
     * @param  string             $id
62
     * @param  array|string|null  $options
63
     *
64
     * @return self
65
     */
66 6
    public static function retrieve($id, $options = null)
67
    {
68 6
        return self::scopedRetrieve($id, $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 10
    public static function create($params = [], $options = null)
81
    {
82 10
        return self::scopedCreate($params, $options);
83
    }
84
85
    /**
86
     * Update a Transfer.
87
     * @link   https://stripe.com/docs/api/php#update_transfer
88
     *
89
     * @param  string             $id
90
     * @param  array|null         $params
91
     * @param  array|string|null  $options
92
     *
93
     * @return self
94
     */
95
    public static function update($id, $params = [], $options = null)
96
    {
97
        return self::scopedUpdate($id, $params, $options);
98
    }
99
100
    /**
101
     * Update/Save a Transfer.
102
     * @link   https://stripe.com/docs/api/php#update_transfer
103
     *
104
     * @param  array|string|null  $options
105
     *
106
     * @return self
107
     */
108 4
    public function save($options = null)
109
    {
110 4
        return self::scopedSave($options);
111
    }
112
113
    /**
114
     * Cancel a Transfer.
115
     * @link   https://stripe.com/docs/api/php#cancel_transfer
116
     *
117
     * @return self
118
     */
119
    public function cancel()
120
    {
121
        list($response, $opts) = $this->request('post', $this->instanceUrl().'/cancel');
122
        $this->refreshFrom($response, $opts);
123
124
        return $this;
125
    }
126
127
    /**
128
     * Created transfer reversal.
129
     *
130
     * @param  array|null         $params
131
     * @param  array|string|null  $options
132
     *
133
     * @return \Arcanedev\Stripe\Resources\TransferReversal
134
     */
135
    public function reverse($params = [], $options = null)
136
    {
137
        list($response, $opts) = $this->request(
138
            'post', $this->instanceUrl().'/reversals', $params, $options
139
        );
140
        $this->refreshFrom($response, $opts);
141
142
        return $this;
143
    }
144
145
    /**
146
     * Create a transfer reversal.
147
     *
148
     * @param  string             $id
149
     * @param  array|null         $params
150
     * @param  array|string|null  $options
151
     *
152
     * @return \Arcanedev\Stripe\Resources\TransferReversal
153
     */
154 2
    public static function createReversal($id, $params = null, $options = null)
155
    {
156 2
        return self::createNestedResource($id, static::PATH_REVERSALS, $params, $options);
157
    }
158
159
    /**
160
     * Retrieve a transfer reversal.
161
     *
162
     * @param  string             $id
163
     * @param  string             $reversalId
164
     * @param  array|null         $params
165
     * @param  array|string|null  $options
166
     *
167
     * @return \Arcanedev\Stripe\Resources\TransferReversal
168
     */
169 2
    public static function retrieveReversal($id, $reversalId, $params = null, $options = null)
170
    {
171 2
        return self::retrieveNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $options);
172
    }
173
174
    /**
175
     * Update a transfer reversal.
176
     *
177
     * @param  string             $id
178
     * @param  string             $reversalId
179
     * @param  array|null         $params
180
     * @param  array|string|null  $options
181
     *
182
     * @return \Arcanedev\Stripe\Resources\TransferReversal
183
     */
184 2
    public static function updateReversal($id, $reversalId, $params = null, $options = null)
185
    {
186 2
        return self::updateNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $options);
187
    }
188
189
    /**
190
     * List all the transfer reversals.
191
     *
192
     * @param  string             $id
193
     * @param  array|null         $params
194
     * @param  array|string|null  $options
195
     *
196
     * @return \Arcanedev\Stripe\Collection
197
     */
198 2
    public static function allReversals($id, $params = null, $options = null)
199
    {
200 2
        return self::allNestedResources($id, static::PATH_REVERSALS, $params, $options);
201
    }
202
}
203