-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFednowTransfersRawService.php
More file actions
202 lines (191 loc) · 6.17 KB
/
FednowTransfersRawService.php
File metadata and controls
202 lines (191 loc) · 6.17 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
declare(strict_types=1);
namespace Increase\Services;
use Increase\Client;
use Increase\Core\Contracts\BaseResponse;
use Increase\Core\Exceptions\APIException;
use Increase\Core\Util;
use Increase\FednowTransfers\FednowTransfer;
use Increase\FednowTransfers\FednowTransferCreateParams;
use Increase\FednowTransfers\FednowTransferCreateParams\CreditorAddress;
use Increase\FednowTransfers\FednowTransferCreateParams\DebtorAddress;
use Increase\FednowTransfers\FednowTransferListParams;
use Increase\FednowTransfers\FednowTransferListParams\CreatedAt;
use Increase\FednowTransfers\FednowTransferListParams\Status;
use Increase\Page;
use Increase\RequestOptions;
use Increase\ServiceContracts\FednowTransfersRawContract;
/**
* @phpstan-import-type CreditorAddressShape from \Increase\FednowTransfers\FednowTransferCreateParams\CreditorAddress
* @phpstan-import-type DebtorAddressShape from \Increase\FednowTransfers\FednowTransferCreateParams\DebtorAddress
* @phpstan-import-type CreatedAtShape from \Increase\FednowTransfers\FednowTransferListParams\CreatedAt
* @phpstan-import-type StatusShape from \Increase\FednowTransfers\FednowTransferListParams\Status
* @phpstan-import-type RequestOpts from \Increase\RequestOptions
*/
final class FednowTransfersRawService implements FednowTransfersRawContract
{
// @phpstan-ignore-next-line
/**
* @internal
*/
public function __construct(private Client $client) {}
/**
* @api
*
* Create a FedNow Transfer
*
* @param array{
* amount: int,
* creditorName: string,
* debtorName: string,
* sourceAccountNumberID: string,
* unstructuredRemittanceInformation: string,
* accountNumber?: string,
* creditorAddress?: CreditorAddress|CreditorAddressShape,
* debtorAddress?: DebtorAddress|DebtorAddressShape,
* externalAccountID?: string,
* requireApproval?: bool,
* routingNumber?: string,
* }|FednowTransferCreateParams $params
* @param RequestOpts|null $requestOptions
*
* @return BaseResponse<FednowTransfer>
*
* @throws APIException
*/
public function create(
array|FednowTransferCreateParams $params,
RequestOptions|array|null $requestOptions = null,
): BaseResponse {
[$parsed, $options] = FednowTransferCreateParams::parseRequest(
$params,
$requestOptions,
);
// @phpstan-ignore-next-line return.type
return $this->client->request(
method: 'post',
path: 'fednow_transfers',
body: (object) $parsed,
options: $options,
convert: FednowTransfer::class,
);
}
/**
* @api
*
* Retrieve a FedNow Transfer
*
* @param string $fednowTransferID the identifier of the FedNow Transfer
* @param RequestOpts|null $requestOptions
*
* @return BaseResponse<FednowTransfer>
*
* @throws APIException
*/
public function retrieve(
string $fednowTransferID,
RequestOptions|array|null $requestOptions = null
): BaseResponse {
// @phpstan-ignore-next-line return.type
return $this->client->request(
method: 'get',
path: ['fednow_transfers/%1$s', $fednowTransferID],
options: $requestOptions,
convert: FednowTransfer::class,
);
}
/**
* @api
*
* List FedNow Transfers
*
* @param array{
* accountID?: string,
* createdAt?: CreatedAt|CreatedAtShape,
* cursor?: string,
* externalAccountID?: string,
* idempotencyKey?: string,
* limit?: int,
* status?: Status|StatusShape,
* }|FednowTransferListParams $params
* @param RequestOpts|null $requestOptions
*
* @return BaseResponse<Page<FednowTransfer>>
*
* @throws APIException
*/
public function list(
array|FednowTransferListParams $params,
RequestOptions|array|null $requestOptions = null,
): BaseResponse {
[$parsed, $options] = FednowTransferListParams::parseRequest(
$params,
$requestOptions,
);
// @phpstan-ignore-next-line return.type
return $this->client->request(
method: 'get',
path: 'fednow_transfers',
query: Util::array_transform_keys(
$parsed,
[
'accountID' => 'account_id',
'createdAt' => 'created_at',
'externalAccountID' => 'external_account_id',
'idempotencyKey' => 'idempotency_key',
],
),
options: $options,
convert: FednowTransfer::class,
page: Page::class,
);
}
/**
* @api
*
* Approve a FedNow Transfer
*
* @param string $fednowTransferID the identifier of the FedNow Transfer to approve
* @param RequestOpts|null $requestOptions
*
* @return BaseResponse<FednowTransfer>
*
* @throws APIException
*/
public function approve(
string $fednowTransferID,
RequestOptions|array|null $requestOptions = null
): BaseResponse {
// @phpstan-ignore-next-line return.type
return $this->client->request(
method: 'post',
path: ['fednow_transfers/%1$s/approve', $fednowTransferID],
options: $requestOptions,
convert: FednowTransfer::class,
);
}
/**
* @api
*
* Cancel a pending FedNow Transfer
*
* @param string $fednowTransferID the identifier of the pending FedNow Transfer to cancel
* @param RequestOpts|null $requestOptions
*
* @return BaseResponse<FednowTransfer>
*
* @throws APIException
*/
public function cancel(
string $fednowTransferID,
RequestOptions|array|null $requestOptions = null
): BaseResponse {
// @phpstan-ignore-next-line return.type
return $this->client->request(
method: 'post',
path: ['fednow_transfers/%1$s/cancel', $fednowTransferID],
options: $requestOptions,
convert: FednowTransfer::class,
);
}
}