-
Notifications
You must be signed in to change notification settings - Fork 13
/
Accounts.php
99 lines (88 loc) · 2.75 KB
/
Accounts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* User: Don Gilbert
* Date: 3/27/2014
* Time: 4:50 PM
*/
namespace Stripe\Api;
use Stripe\Request\Accounts\CreateAccountRequest;
use Stripe\Request\Accounts\UpdateAccountRequest;
use Stripe\Request\ListRequest;
use Stripe\Response\Accounts\AccountResponse;
use Stripe\Response\Accounts\ListAccountsResponse;
use Stripe\Response\DeleteResponse;
class Accounts extends AbstractApi
{
const ACCOUNT_RESPONSE_CLASS = 'Stripe\Response\Accounts\AccountResponse';
const LIST_ACCOUNT_RESPONSE_CLASS = 'Stripe\Response\Accounts\ListAccountsResponse';
/**
* Retrieves default/main account
* @return AccountResponse
* @link https://stripe.com/docs/api/curl#retrieve_account
*/
public function getAccount()
{
return $this->client->get('account', self::ACCOUNT_RESPONSE_CLASS);
}
/**
* @param CreateAccountRequest $request
* @return AccountResponse
* @link https://stripe.com/docs/api#create_account
*/
public function createAccount(CreateAccountRequest $request)
{
return $this->client->post('accounts', self::ACCOUNT_RESPONSE_CLASS, $request);
}
/**
* @param string $accountId
* @return AccountResponse
* @link https://stripe.com/docs/api/curl#retrieve_account
*/
public function getConnectedAccount($accountId)
{
return $this->client->get($this->buildUrl($accountId), self::ACCOUNT_RESPONSE_CLASS);
}
/**
* @param string $accountId
* @param UpdateAccountRequest $request
* @return AccountResponse
* @link https://stripe.com/docs/api/curl#update_account
*/
public function updateAccount($accountId, UpdateAccountRequest $request)
{
return $this->client->post($this->buildUrl($accountId), self::ACCOUNT_RESPONSE_CLASS, $request);
}
/**
* @param string $accountId
* @return DeleteResponse
* @link https://stripe.com/docs/api/curl#delete_account
*/
public function deleteConnectedAccount($accountId)
{
return $this->client->delete($this->buildUrl($accountId), self::DELETE_RESPONSE_CLASS);
}
/**
* @param ListRequest $request
* @return ListAccountsResponse
* @link https://stripe.com/docs/api/curl#list_accounts
*/
public function listConnectedAccounts(ListRequest $request = null)
{
return $this->client->get('accounts', self::LIST_ACCOUNT_RESPONSE_CLASS, null, $this->listRequestToParams($request));
}
/**
* @return CreateAccountRequest
*/
public function createAccountRequest()
{
return new CreateAccountRequest();
}
/**
* @param string $customerId
* @return string
*/
protected function buildUrl($customerId)
{
return 'accounts/' . $customerId;
}
}