Completed
Push — master ( 6efa89...d59b5b )
by ARCANEDEV
9s
created

src/Resources/Account.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\AccountInterface;
4
use Arcanedev\Stripe\StripeResource;
5
6
/**
7
 * Class     Account
8
 *
9
 * @package  Arcanedev\Stripe\Resources
10
 * @author   ARCANEDEV <[email protected]>
11
 * @link     https://stripe.com/docs/api/php#account_object
12
 *
13
 * @property  null                              id
14
 * @property  string                            object                   // 'account'
15
 * @property  string|null                       business_logo
16
 * @property  string                            business_name
17
 * @property  string|null                       business_url
18
 * @property  bool                              charges_enabled
19
 * @property  string                            country
20
 * @property  bool                              debit_negative_balances  // managed accounts only
21
 * @property  \Arcanedev\Stripe\StripeObject    decline_charge_on
22
 * @property  string                            default_currency
23
 * @property  bool                              details_submitted
24
 * @property  string                            display_name
25
 * @property  string                            email
26
 * @property  \Arcanedev\Stripe\Collection      external_accounts        // managed accounts only
27
 * @property  \Arcanedev\Stripe\AttachedObject  legal_entity             // managed accounts only
28
 * @property  bool                              managed
29
 * @property  string|null                       product_description      // managed accounts only
30
 * @property  string|null                       statement_descriptor
31
 * @property  string|null                       support_email
32
 * @property  string|null                       support_phone
33
 * @property  string|null                       support_url
34
 * @property  string                            timezone
35
 * @property  \Arcanedev\Stripe\AttachedObject  tos_acceptance           // managed accounts only
36
 * @property  \Arcanedev\Stripe\AttachedObject  transfer_schedule        // managed accounts only
37
 * @property  bool                              transfers_enabled
38
 * @property  \Arcanedev\Stripe\AttachedObject  verification
39
 */
40
class Account extends StripeResource implements AccountInterface
41
{
42
    /* ------------------------------------------------------------------------------------------------
43
     |  Getters & Setters
44
     | ------------------------------------------------------------------------------------------------
45
     */
46
    /**
47
     * Get the instance url.
48
     *
49
     * @return string
50
     */
51 35
    public function instanceUrl()
52
    {
53 35
        return is_null($this['id']) ? '/v1/account' : parent::instanceUrl();
54
    }
55
56
    /* ------------------------------------------------------------------------------------------------
57
     |  Main Functions
58
     | ------------------------------------------------------------------------------------------------
59
     */
60
    /**
61
     * Get all Accounts.
62
     * @link   https://stripe.com/docs/api/php#list_accounts
63
     *
64
     * @param  array|null         $params
65
     * @param  array|string|null  $options
66
     *
67
     * @return \Arcanedev\Stripe\Collection|array
68
     */
69 5
    public static function all($params = [], $options = null)
70
    {
71 5
        return self::scopedAll($params, $options);
72
    }
73
74
    /**
75
     * Retrieve an Account.
76
     * @link   https://stripe.com/docs/api/php#retrieve_account
77
     *
78
     * @param  string|null        $id
79
     * @param  array|string|null  $options
80
     *
81
     * @return self
82
     */
83 15
    public static function retrieve($id = null, $options = null)
84
    {
85
        if (
86 15
            ! $options &&
87 15
            is_string($id) &&
88 11
            substr($id, 0, 3) === 'sk_'
89 12
        ) {
90
            $options = $id;
0 ignored issues
show
Consider using a different name than the parameter $options. This often makes code more readable.
Loading history...
91
            $id      = null;
0 ignored issues
show
Consider using a different name than the parameter $id. This often makes code more readable.
Loading history...
92
        }
93
94 15
        return self::scopedRetrieve($id, $options);
95
    }
96
97
    /**
98
     * Create an Account.
99
     * @link   https://stripe.com/docs/api/php#create_account
100
     *
101
     * @param  array|null         $params
102
     * @param  array|string|null  $options
103
     *
104
     * @return self
105
     */
106 35
    public static function create($params = [], $options = null)
107
    {
108 35
        return self::scopedCreate($params, $options);
109
    }
110
111
    /**
112
     * Update an Account.
113
     * @link   https://stripe.com/docs/api/php#update_account
114
     *
115
     * @param  string             $id
116
     * @param  array|null         $params
117
     * @param  array|string|null  $options
118
     *
119
     * @return self
120
     */
121 5
    public static function update($id, $params = [], $options = null)
122
    {
123 5
        return self::scopedUpdate($id, $params, $options);
124
    }
125
126
    /**
127
     * Update/Save an Account.
128
     * @link   https://stripe.com/docs/api/php#update_account
129
     *
130
     * @param  array|string|null  $options
131
     *
132
     * @return self
133
     */
134 10
    public function save($options = null)
135
    {
136 10
        return $this->scopedSave($options);
137
    }
138
139
    /**
140
     * Delete an Account.
141
     * @link   https://stripe.com/docs/api/php#delete_account
142
     *
143
     * @param  array|null         $params
144
     * @param  array|string|null  $options
145
     *
146
     * @return self
147
     */
148 5
    public function delete($params = [], $options = null)
149
    {
150 5
        return $this->scopedDelete($params, $options);
151
    }
152
153
    /**
154
     * Reject an Account.
155
     * @link   https://stripe.com/docs/api/php#reject_account
156
     *
157
     * @param  array|null         $params
158
     * @param  array|string|null  $options
159
     *
160
     * @return self
161
     */
162 5
    public function reject($params = [], $options = null)
163
    {
164 5
        return $this->scopedPostCall(
165 5
            $this->instanceUrl() . '/reject', $params, $options
166 4
        );
167
    }
168
}
169