|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stripe; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class Capability |
|
7
|
|
|
* |
|
8
|
|
|
* @package Stripe |
|
9
|
|
|
* |
|
10
|
|
|
* @property string $id |
|
11
|
|
|
* @property string $object |
|
12
|
|
|
* @property string $account |
|
13
|
|
|
* @property bool $requested |
|
14
|
|
|
* @property int $requested_at |
|
15
|
|
|
* @property mixed $requirements |
|
16
|
|
|
* @property string $status |
|
17
|
|
|
*/ |
|
18
|
|
View Code Duplication |
class Capability extends ApiResource |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
|
|
21
|
|
|
const OBJECT_NAME = "capability"; |
|
22
|
|
|
|
|
23
|
|
|
use ApiOperations\Update; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Possible string representations of a capability's status. |
|
27
|
|
|
* @link https://stripe.com/docs/api/capabilities/object#capability_object-status |
|
28
|
|
|
*/ |
|
29
|
|
|
const STATUS_ACTIVE = 'active'; |
|
30
|
|
|
const STATUS_INACTIVE = 'inactive'; |
|
31
|
|
|
const STATUS_PENDING = 'pending'; |
|
32
|
|
|
const STATUS_UNREQUESTED = 'unrequested'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return string The API URL for this Stripe account reversal. |
|
36
|
|
|
*/ |
|
37
|
|
|
public function instanceUrl() |
|
38
|
|
|
{ |
|
39
|
|
|
$id = $this['id']; |
|
40
|
|
|
$account = $this['account']; |
|
41
|
|
|
if (!$id) { |
|
42
|
|
|
throw new Error\InvalidRequest( |
|
43
|
|
|
"Could not determine which URL to request: " . |
|
44
|
|
|
"class instance has invalid ID: $id", |
|
45
|
|
|
null |
|
46
|
|
|
); |
|
47
|
|
|
} |
|
48
|
|
|
$id = Util\Util::utf8($id); |
|
49
|
|
|
$account = Util\Util::utf8($account); |
|
50
|
|
|
|
|
51
|
|
|
$base = Account::classUrl(); |
|
52
|
|
|
$accountExtn = urlencode($account); |
|
53
|
|
|
$extn = urlencode($id); |
|
54
|
|
|
return "$base/$accountExtn/capabilities/$extn"; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param array|string $_id |
|
59
|
|
|
* @param array|string|null $_opts |
|
60
|
|
|
* |
|
61
|
|
|
* @throws \Stripe\Error\InvalidRequest |
|
62
|
|
|
*/ |
|
63
|
|
|
public static function retrieve($_id, $_opts = null) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
$msg = "Capabilities cannot be accessed without an account ID. " . |
|
66
|
|
|
"Retrieve a Capability using \$account->retrieveCapability('acap_123') instead."; |
|
67
|
|
|
throw new Error\InvalidRequest($msg, null); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param string $_id |
|
72
|
|
|
* @param array|null $_params |
|
73
|
|
|
* @param array|string|null $_options |
|
74
|
|
|
* |
|
75
|
|
|
* @throws \Stripe\Error\InvalidRequest |
|
76
|
|
|
*/ |
|
77
|
|
|
public static function update($_id, $_params = null, $_options = null) |
|
|
|
|
|
|
78
|
|
|
{ |
|
79
|
|
|
$msg = "Capabilities cannot be accessed without an account ID. " . |
|
80
|
|
|
"Update a Capability using \$account->updateCapability('acap_123') instead."; |
|
81
|
|
|
throw new Error\InvalidRequest($msg, null); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.