Completed
Push — master ( 4e804b...c0f903 )
by ARCANEDEV
6s
created

Account::delete()   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 2
Metric Value
c 2
b 0
f 2
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\Collection;
4
use Arcanedev\Stripe\Contracts\Resources\AccountInterface;
5
use Arcanedev\Stripe\StripeResource;
6
7
/**
8
 * Class     Account
9
 *
10
 * @package  Arcanedev\Stripe\Resources
11
 * @author   ARCANEDEV <[email protected]>
12
 * @link     https://stripe.com/docs/api/php#account_object
13
 *
14
 * @property  null    id
15
 * @property  string  object
16
 * @property  bool    charges_enabled
17
 * @property  string  country
18
 * @property  array   currencies_supported
19
 * @property  string  default_currency
20
 * @property  bool    details_submitted
21
 * @property  bool    transfers_enabled
22
 * @property  string  display_name
23
 * @property  string  email
24
 * @property  string  statement_descriptor
25
 * @property  string  timezone
26
 *
27
 * @todo:     Update the properties.
28
 */
29
class Account extends StripeResource implements AccountInterface
30
{
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Main Functions
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * Get the instance url.
37
     *
38
     * @return string
39
     */
40 35
    public function instanceUrl()
41
    {
42 35
        if (is_null($this['id'])) {
43 5
            return '/v1/account';
44
        }
45
46 30
        return parent::instanceUrl();
47
    }
48
49
    /* ------------------------------------------------------------------------------------------------
50
     |  CRUD Functions
51
     | ------------------------------------------------------------------------------------------------
52
     */
53
    /**
54
     * Retrieve an account.
55
     *
56
     * @link   https://stripe.com/docs/api/php#retrieve_account
57
     *
58
     * @param  string|null        $id
59
     * @param  array|string|null  $options
60
     *
61
     * @return self
62
     */
63 15
    public static function retrieve($id = null, $options = null)
64
    {
65
        if (
66 15
            ! $options &&
67 15
            is_string($id) &&
68 11
            substr($id, 0, 3) === 'sk_'
69 12
        ) {
70
            $options = $id;
71
            $id      = null;
72
        }
73
74 15
        return self::scopedRetrieve($id, $options);
75
    }
76
77
    /**
78
     * Create an account.
79
     *
80
     * @param  array|null         $params
81
     * @param  array|string|null  $options
82
     *
83
     * @return self
84
     */
85 25
    public static function create($params = null, $options = null)
86
    {
87 25
        return self::scopedCreate($params, $options);
88
    }
89
90
    /**
91
     * Save an account.
92
     *
93
     * @param  array|string|null  $options
94
     *
95
     * @return self
96
     */
97 10
    public function save($options = null)
98
    {
99 10
        return $this->scopedSave($options);
100
    }
101
102
    /**
103
     * Get all accounts.
104
     *
105
     * @param  array|null         $params
106
     * @param  array|string|null  $options
107
     *
108
     * @return Collection|array
109
     */
110
    public static function all($params = null, $options = null)
111
    {
112
        return self::scopedAll($params, $options);
113
    }
114
115
    /**
116
     * Delete an account.
117
     *
118
     * @param  array|null         $params
119
     * @param  array|string|null  $options
120
     *
121
     * @return self
122
     */
123 5
    public function delete($params = null, $options = null)
124
    {
125 5
        return $this->scopedDelete($params, $options);
126
    }
127
128
    /**
129
     * Reject an account.
130
     *
131
     * @param  array|null         $params
132
     * @param  array|string|null  $options
133
     *
134
     * @return self
135
     */
136 5
    public function reject($params = null, $options = null)
137
    {
138 5
        $url = $this->instanceUrl() . '/reject';
139
140 5
        return $this->scopedPostCall($url, $params, $options);
141
    }
142
}
143