Completed
Pull Request — master (#60)
by ARCANEDEV
08:31
created

Transfer::all()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 1
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
     |  Main Functions
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * List all Transfers.
37
     * @link   https://stripe.com/docs/api/php#list_transfers
38
     *
39
     * @param  array|null         $params
40
     * @param  array|string|null  $options
41
     *
42
     * @return \Arcanedev\Stripe\Collection|array
43
     */
44 2
    public static function all($params = [], $options = null)
45
    {
46 2
        return self::scopedAll($params, $options);
47
    }
48
49
    /**
50
     * Retrieve a Transfer.
51
     * @link   https://stripe.com/docs/api/php#retrieve_transfer
52
     *
53
     * @param  string             $id
54
     * @param  array|string|null  $options
55
     *
56
     * @return self
57
     */
58 6
    public static function retrieve($id, $options = null)
59
    {
60 6
        return self::scopedRetrieve($id, $options);
61
    }
62
63
    /**
64
     * Create a transfer.
65
     * @link   https://stripe.com/docs/api/php#create_transfer
66
     *
67
     * @param  array|null         $params
68
     * @param  array|string|null  $options
69
     *
70
     * @return self|array
71
     */
72 10
    public static function create($params = [], $options = null)
73
    {
74 10
        return self::scopedCreate($params, $options);
75
    }
76
77
    /**
78
     * Update a Transfer.
79
     * @link   https://stripe.com/docs/api/php#update_transfer
80
     *
81
     * @param  string             $id
82
     * @param  array|null         $params
83
     * @param  array|string|null  $options
84
     *
85
     * @return self
86
     */
87
    public static function update($id, $params = [], $options = null)
88
    {
89
        return self::scopedUpdate($id, $params, $options);
90
    }
91
92
    /**
93
     * Update/Save a Transfer.
94
     * @link   https://stripe.com/docs/api/php#update_transfer
95
     *
96
     * @param  array|string|null  $options
97
     *
98
     * @return self
99
     */
100 4
    public function save($options = null)
101
    {
102 4
        return self::scopedSave($options);
103
    }
104
105
    /**
106
     * Cancel a Transfer.
107
     * @link   https://stripe.com/docs/api/php#cancel_transfer
108
     *
109
     * @return self
110
     */
111
    public function cancel()
112
    {
113
        list($response, $opts) = $this->request('post', $this->instanceUrl().'/cancel');
114
        $this->refreshFrom($response, $opts);
115
116
        return $this;
117
    }
118
119
    /**
120
     * Created transfer reversal.
121
     *
122
     * @param  array|null         $params
123
     * @param  array|string|null  $options
124
     *
125
     * @return \Arcanedev\Stripe\Resources\TransferReversal
126
     */
127
    public function reverse($params = [], $options = null)
128
    {
129
        list($response, $opts) = $this->request(
130
            'post', $this->instanceUrl().'/reversals', $params, $options
131
        );
132
        $this->refreshFrom($response, $opts);
133
134
        return $this;
135
    }
136
}
137