@@ -10,74 +10,74 @@ |
||
10 | 10 | |
11 | 11 | class JWTCommand extends Command |
12 | 12 | { |
13 | - /** |
|
14 | - * The name and signature of the console command. |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $signature = 'revolut:jwt {--public= : The path to your public key}'; |
|
13 | + /** |
|
14 | + * The name and signature of the console command. |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $signature = 'revolut:jwt {--public= : The path to your public key}'; |
|
19 | 19 | |
20 | - /** |
|
21 | - * The console command description. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $description = "Generate a JSON Web Token for Revolut's Oauth process."; |
|
20 | + /** |
|
21 | + * The console command description. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $description = "Generate a JSON Web Token for Revolut's Oauth process."; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Execute the console command. |
|
29 | - * |
|
30 | - * @return mixed |
|
31 | - */ |
|
32 | - public function handle() |
|
33 | - { |
|
34 | - // build the JWT |
|
35 | - $jwt = $this->buildJWT(); |
|
27 | + /** |
|
28 | + * Execute the console command. |
|
29 | + * |
|
30 | + * @return mixed |
|
31 | + */ |
|
32 | + public function handle() |
|
33 | + { |
|
34 | + // build the JWT |
|
35 | + $jwt = $this->buildJWT(); |
|
36 | 36 | |
37 | - $this->info('Your JSON web token was created successfully:'); |
|
38 | - $this->info('<fg=black;bg=yellow>' . $jwt . '</>'); |
|
37 | + $this->info('Your JSON web token was created successfully:'); |
|
38 | + $this->info('<fg=black;bg=yellow>' . $jwt . '</>'); |
|
39 | 39 | |
40 | - // optionally, verify the key |
|
41 | - $key = $this->checkPublicKey($this->option('public') ?? null); |
|
40 | + // optionally, verify the key |
|
41 | + $key = $this->checkPublicKey($this->option('public') ?? null); |
|
42 | 42 | |
43 | - $decoded = JWT::decode($jwt, $key, [ClientAssertion::ALGORYTHM]); |
|
43 | + $decoded = JWT::decode($jwt, $key, [ClientAssertion::ALGORYTHM]); |
|
44 | 44 | |
45 | - $headers = ['parameter', 'value']; |
|
46 | - $data = [ |
|
47 | - ['issuer', $decoded->iss], |
|
48 | - ['subject', $decoded->sub], |
|
49 | - ['expiry', $decoded->exp], |
|
50 | - ['audience', $decoded->aud], |
|
51 | - ]; |
|
45 | + $headers = ['parameter', 'value']; |
|
46 | + $data = [ |
|
47 | + ['issuer', $decoded->iss], |
|
48 | + ['subject', $decoded->sub], |
|
49 | + ['expiry', $decoded->exp], |
|
50 | + ['audience', $decoded->aud], |
|
51 | + ]; |
|
52 | 52 | |
53 | - $this->info('Your JWT has been verified and is valid.'); |
|
54 | - $this->table($headers, $data); |
|
55 | - } |
|
53 | + $this->info('Your JWT has been verified and is valid.'); |
|
54 | + $this->table($headers, $data); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - private function buildJWT() |
|
61 | - { |
|
62 | - try { |
|
63 | - $clientAssertion = resolve(ClientAssertion::class); |
|
64 | - return $clientAssertion->build(); |
|
65 | - } catch (ConfigurationException $e) { |
|
66 | - $this->error($e->getMessage()); |
|
67 | - return; |
|
68 | - } |
|
69 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + private function buildJWT() |
|
61 | + { |
|
62 | + try { |
|
63 | + $clientAssertion = resolve(ClientAssertion::class); |
|
64 | + return $clientAssertion->build(); |
|
65 | + } catch (ConfigurationException $e) { |
|
66 | + $this->error($e->getMessage()); |
|
67 | + return; |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - private function checkPublicKey($key = null) |
|
75 | - { |
|
76 | - try { |
|
77 | - return file_get_contents($key ?? $this->ask('If you want to validate this JWT, enter the path to your public key')); |
|
78 | - } catch (Exception $e) { |
|
79 | - $this->error($e->getMessage()); |
|
80 | - return $this->checkPublicKey(); |
|
81 | - } |
|
82 | - } |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + private function checkPublicKey($key = null) |
|
75 | + { |
|
76 | + try { |
|
77 | + return file_get_contents($key ?? $this->ask('If you want to validate this JWT, enter the path to your public key')); |
|
78 | + } catch (Exception $e) { |
|
79 | + $this->error($e->getMessage()); |
|
80 | + return $this->checkPublicKey(); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | } |
@@ -7,55 +7,55 @@ |
||
7 | 7 | |
8 | 8 | class Payment extends Resource implements Buildable |
9 | 9 | { |
10 | - /** |
|
11 | - * The enpoint for payment requests |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - const ENDPOINT = '/pay'; |
|
10 | + /** |
|
11 | + * The enpoint for payment requests |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + const ENDPOINT = '/pay'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-create-payment Official API documentation |
|
19 | - */ |
|
20 | - public function create(array $json) |
|
21 | - { |
|
22 | - return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-create-payment Official API documentation |
|
19 | + */ |
|
20 | + public function create(array $json) |
|
21 | + { |
|
22 | + return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Schedule a payment for up to 30 days |
|
27 | - * |
|
28 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-schedule-payment Official API documentation |
|
29 | - * @param array $json The request parameters |
|
30 | - * @param string $date a future ISO date (Up to 30 days) |
|
31 | - * @return array The response body |
|
32 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
33 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
34 | - */ |
|
35 | - public function schedule(array $json, string $date) |
|
36 | - { |
|
37 | - return $this->create(array_merge($json, ['schedule_for' => $date])); |
|
38 | - } |
|
25 | + /** |
|
26 | + * Schedule a payment for up to 30 days |
|
27 | + * |
|
28 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-schedule-payment Official API documentation |
|
29 | + * @param array $json The request parameters |
|
30 | + * @param string $date a future ISO date (Up to 30 days) |
|
31 | + * @return array The response body |
|
32 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
33 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
34 | + */ |
|
35 | + public function schedule(array $json, string $date) |
|
36 | + { |
|
37 | + return $this->create(array_merge($json, ['schedule_for' => $date])); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Cancel a scheduled payment |
|
42 | - * |
|
43 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-cancel-payment Official API documentation |
|
44 | - * @param string $id The ID of the payment in UUID format |
|
45 | - * @return void |
|
46 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
47 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
48 | - */ |
|
49 | - public function cancel(string $id) : void |
|
50 | - { |
|
51 | - $this->client->delete('/transaction/' . $id); |
|
52 | - } |
|
40 | + /** |
|
41 | + * Cancel a scheduled payment |
|
42 | + * |
|
43 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-cancel-payment Official API documentation |
|
44 | + * @param string $id The ID of the payment in UUID format |
|
45 | + * @return void |
|
46 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
47 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
48 | + */ |
|
49 | + public function cancel(string $id) : void |
|
50 | + { |
|
51 | + $this->client->delete('/transaction/' . $id); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return \tbclla\Revolut\Builders\PaymentBuilder |
|
56 | - */ |
|
57 | - public function build() |
|
58 | - { |
|
59 | - return new PaymentBuilder($this, $this->client->generateRequestId()); |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return \tbclla\Revolut\Builders\PaymentBuilder |
|
56 | + */ |
|
57 | + public function build() |
|
58 | + { |
|
59 | + return new PaymentBuilder($this, $this->client->generateRequestId()); |
|
60 | + } |
|
61 | 61 | } |
@@ -7,67 +7,67 @@ |
||
7 | 7 | |
8 | 8 | class PaymentDraft extends Resource implements Buildable |
9 | 9 | { |
10 | - /** |
|
11 | - * The enpoint for payment draft requests |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - const ENDPOINT = '/payment-drafts'; |
|
10 | + /** |
|
11 | + * The enpoint for payment draft requests |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + const ENDPOINT = '/payment-drafts'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payment-drafts-create-a-payment-draft Official API documentation |
|
19 | - */ |
|
20 | - public function create(array $json) |
|
21 | - { |
|
22 | - return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payment-drafts-create-a-payment-draft Official API documentation |
|
19 | + */ |
|
20 | + public function create(array $json) |
|
21 | + { |
|
22 | + return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Get all payment drafts |
|
27 | - * |
|
28 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts Official API documentation |
|
29 | - * @return array The response body |
|
30 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
31 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
32 | - */ |
|
33 | - public function all() |
|
34 | - { |
|
35 | - return $this->client->get(self::ENDPOINT); |
|
36 | - } |
|
25 | + /** |
|
26 | + * Get all payment drafts |
|
27 | + * |
|
28 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts Official API documentation |
|
29 | + * @return array The response body |
|
30 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
31 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
32 | + */ |
|
33 | + public function all() |
|
34 | + { |
|
35 | + return $this->client->get(self::ENDPOINT); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get a payment draft by its ID |
|
40 | - * |
|
41 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts-get-payment-draft-by-id Official API documentation |
|
42 | - * @param string $id The ID of the payment draft in UUID format |
|
43 | - * @return array The response body |
|
44 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
45 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
46 | - */ |
|
47 | - public function get(string $id) |
|
48 | - { |
|
49 | - return $this->client->get(self::ENDPOINT . '/' . $id); |
|
50 | - } |
|
38 | + /** |
|
39 | + * Get a payment draft by its ID |
|
40 | + * |
|
41 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts-get-payment-draft-by-id Official API documentation |
|
42 | + * @param string $id The ID of the payment draft in UUID format |
|
43 | + * @return array The response body |
|
44 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
45 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
46 | + */ |
|
47 | + public function get(string $id) |
|
48 | + { |
|
49 | + return $this->client->get(self::ENDPOINT . '/' . $id); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Delete a payment draft by its ID |
|
54 | - * |
|
55 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts-delete-payment-draft Official API documentation |
|
56 | - * @param string $id The ID of the payment draft in UUID format |
|
57 | - * @return void |
|
58 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
59 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
60 | - */ |
|
61 | - public function delete(string $id) : void |
|
62 | - { |
|
63 | - $this->client->delete(self::ENDPOINT . '/' . $id); |
|
64 | - } |
|
52 | + /** |
|
53 | + * Delete a payment draft by its ID |
|
54 | + * |
|
55 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts-delete-payment-draft Official API documentation |
|
56 | + * @param string $id The ID of the payment draft in UUID format |
|
57 | + * @return void |
|
58 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
59 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
60 | + */ |
|
61 | + public function delete(string $id) : void |
|
62 | + { |
|
63 | + $this->client->delete(self::ENDPOINT . '/' . $id); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return \tbclla\Revolut\Builders\PaymentDraftBuilder |
|
68 | - */ |
|
69 | - public function build() |
|
70 | - { |
|
71 | - return new PaymentDraftBuilder($this); |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return \tbclla\Revolut\Builders\PaymentDraftBuilder |
|
68 | + */ |
|
69 | + public function build() |
|
70 | + { |
|
71 | + return new PaymentDraftBuilder($this); |
|
72 | + } |
|
73 | 73 | } |
@@ -6,21 +6,21 @@ |
||
6 | 6 | |
7 | 7 | abstract class Resource |
8 | 8 | { |
9 | - /** |
|
10 | - * The Revolut client |
|
11 | - * |
|
12 | - * @var \tbclla\Revolut\Client; |
|
13 | - */ |
|
14 | - protected $client; |
|
9 | + /** |
|
10 | + * The Revolut client |
|
11 | + * |
|
12 | + * @var \tbclla\Revolut\Client; |
|
13 | + */ |
|
14 | + protected $client; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Create a new API resource wrapper |
|
18 | - * |
|
19 | - * @param \tbclla\Revolut\Client $client |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function __construct(Client $client) |
|
23 | - { |
|
24 | - $this->client = $client; |
|
25 | - } |
|
16 | + /** |
|
17 | + * Create a new API resource wrapper |
|
18 | + * |
|
19 | + * @param \tbclla\Revolut\Client $client |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function __construct(Client $client) |
|
23 | + { |
|
24 | + $this->client = $client; |
|
25 | + } |
|
26 | 26 | } |
@@ -4,37 +4,37 @@ |
||
4 | 4 | |
5 | 5 | class Webhook extends Resource |
6 | 6 | { |
7 | - /** |
|
8 | - * The enpoint for webhook requests |
|
9 | - * |
|
10 | - * @var string |
|
11 | - */ |
|
12 | - const ENDPOINT = '/webhook'; |
|
7 | + /** |
|
8 | + * The enpoint for webhook requests |
|
9 | + * |
|
10 | + * @var string |
|
11 | + */ |
|
12 | + const ENDPOINT = '/webhook'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Create a webhook |
|
16 | - * |
|
17 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#web-hooks-setting-up-a-web-hook Official API documentation |
|
18 | - * @param string $url call back url of the client system, https is the supported protocol |
|
19 | - * @return array The response body |
|
20 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
21 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
22 | - */ |
|
23 | - public function create(string $url) |
|
24 | - { |
|
25 | - return $this->client->post(self::ENDPOINT, ['json' => ['url' => $url]]); |
|
26 | - } |
|
14 | + /** |
|
15 | + * Create a webhook |
|
16 | + * |
|
17 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#web-hooks-setting-up-a-web-hook Official API documentation |
|
18 | + * @param string $url call back url of the client system, https is the supported protocol |
|
19 | + * @return array The response body |
|
20 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
21 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
22 | + */ |
|
23 | + public function create(string $url) |
|
24 | + { |
|
25 | + return $this->client->post(self::ENDPOINT, ['json' => ['url' => $url]]); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Delete the webhook |
|
30 | - * |
|
31 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#web-hooks-deleting-a-web-hook Official API documentation |
|
32 | - * @return void |
|
33 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
34 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
35 | - */ |
|
36 | - public function delete() : void |
|
37 | - { |
|
38 | - $this->client->delete(self::ENDPOINT); |
|
39 | - } |
|
28 | + /** |
|
29 | + * Delete the webhook |
|
30 | + * |
|
31 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#web-hooks-deleting-a-web-hook Official API documentation |
|
32 | + * @return void |
|
33 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
34 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
35 | + */ |
|
36 | + public function delete() : void |
|
37 | + { |
|
38 | + $this->client->delete(self::ENDPOINT); |
|
39 | + } |
|
40 | 40 | } |
@@ -7,67 +7,67 @@ |
||
7 | 7 | |
8 | 8 | class Counterparty extends Resource implements Buildable |
9 | 9 | { |
10 | - /** |
|
11 | - * The enpoint for counterparty requests |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - const ENDPOINT = '/counterparty'; |
|
10 | + /** |
|
11 | + * The enpoint for counterparty requests |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + const ENDPOINT = '/counterparty'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-add-revolut-counterparty Official API documentation |
|
19 | - */ |
|
20 | - public function create(array $json) |
|
21 | - { |
|
22 | - return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-add-revolut-counterparty Official API documentation |
|
19 | + */ |
|
20 | + public function create(array $json) |
|
21 | + { |
|
22 | + return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Get all counterparties |
|
27 | - * |
|
28 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-get-counterparties Official API documentation |
|
29 | - * @return array The response body |
|
30 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
31 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
32 | - */ |
|
33 | - public function all() |
|
34 | - { |
|
35 | - return $this->client->get('/counterparties'); |
|
36 | - } |
|
25 | + /** |
|
26 | + * Get all counterparties |
|
27 | + * |
|
28 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-get-counterparties Official API documentation |
|
29 | + * @return array The response body |
|
30 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
31 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
32 | + */ |
|
33 | + public function all() |
|
34 | + { |
|
35 | + return $this->client->get('/counterparties'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get a counterparty by its ID |
|
40 | - * |
|
41 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-get-counterparty Official API documentation |
|
42 | - * @param string $id The counterpary ID in UUID format |
|
43 | - * @return array The response body |
|
44 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
45 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
46 | - */ |
|
47 | - public function get(string $id) |
|
48 | - { |
|
49 | - return $this->client->get(self::ENDPOINT . '/' . $id); |
|
50 | - } |
|
38 | + /** |
|
39 | + * Get a counterparty by its ID |
|
40 | + * |
|
41 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-get-counterparty Official API documentation |
|
42 | + * @param string $id The counterpary ID in UUID format |
|
43 | + * @return array The response body |
|
44 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
45 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
46 | + */ |
|
47 | + public function get(string $id) |
|
48 | + { |
|
49 | + return $this->client->get(self::ENDPOINT . '/' . $id); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Delete a counterparty by its ID |
|
54 | - * |
|
55 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-delete-counterparty Official API documentation |
|
56 | - * @param string $id The counterpary ID in UUID format |
|
57 | - * @return void |
|
58 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
59 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
60 | - */ |
|
61 | - public function delete(string $id) : void |
|
62 | - { |
|
63 | - $this->client->delete(self::ENDPOINT . '/' . $id); |
|
64 | - } |
|
52 | + /** |
|
53 | + * Delete a counterparty by its ID |
|
54 | + * |
|
55 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-delete-counterparty Official API documentation |
|
56 | + * @param string $id The counterpary ID in UUID format |
|
57 | + * @return void |
|
58 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
59 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
60 | + */ |
|
61 | + public function delete(string $id) : void |
|
62 | + { |
|
63 | + $this->client->delete(self::ENDPOINT . '/' . $id); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return \tbclla\Revolut\Builders\CounterpartyBuilder |
|
68 | - */ |
|
69 | - public function build() |
|
70 | - { |
|
71 | - return new CounterpartyBuilder($this); |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return \tbclla\Revolut\Builders\CounterpartyBuilder |
|
68 | + */ |
|
69 | + public function build() |
|
70 | + { |
|
71 | + return new CounterpartyBuilder($this); |
|
72 | + } |
|
73 | 73 | } |
@@ -4,61 +4,61 @@ |
||
4 | 4 | |
5 | 5 | class Transaction extends Resource |
6 | 6 | { |
7 | - /** |
|
8 | - * The enpoint for transaction requests |
|
9 | - * |
|
10 | - * @var string |
|
11 | - */ |
|
12 | - const ENDPOINT = '/transactions'; |
|
7 | + /** |
|
8 | + * The enpoint for transaction requests |
|
9 | + * |
|
10 | + * @var string |
|
11 | + */ |
|
12 | + const ENDPOINT = '/transactions'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Get up to 1000 historical transactions based on the provided query criteria |
|
16 | - * |
|
17 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transactions Official API documentation |
|
18 | - * @param array $filters accepts optional 'from', 'to', 'counterparty', 'count', type' |
|
19 | - * @param bool $useFreshToken Force the use of a new access token. |
|
20 | - * @return array The response body |
|
21 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
22 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
23 | - */ |
|
24 | - public function all(array $filters = [], $useFreshToken = false) |
|
25 | - { |
|
26 | - if ($useFreshToken) { |
|
27 | - $this->client->refreshAccessToken(); |
|
28 | - } |
|
14 | + /** |
|
15 | + * Get up to 1000 historical transactions based on the provided query criteria |
|
16 | + * |
|
17 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transactions Official API documentation |
|
18 | + * @param array $filters accepts optional 'from', 'to', 'counterparty', 'count', type' |
|
19 | + * @param bool $useFreshToken Force the use of a new access token. |
|
20 | + * @return array The response body |
|
21 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
22 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
23 | + */ |
|
24 | + public function all(array $filters = [], $useFreshToken = false) |
|
25 | + { |
|
26 | + if ($useFreshToken) { |
|
27 | + $this->client->refreshAccessToken(); |
|
28 | + } |
|
29 | 29 | |
30 | - return $this->client->get(self::ENDPOINT, ['query' => $filters]); |
|
31 | - } |
|
30 | + return $this->client->get(self::ENDPOINT, ['query' => $filters]); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Get a transaction by its ID |
|
35 | - * |
|
36 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transaction Official API documentation |
|
37 | - * @param string $id The transaction ID in UUID format |
|
38 | - * @return array The response body |
|
39 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
40 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
41 | - */ |
|
42 | - public function get(string $id) |
|
43 | - { |
|
44 | - return $this->client->get('/transaction/' . $id); |
|
45 | - } |
|
33 | + /** |
|
34 | + * Get a transaction by its ID |
|
35 | + * |
|
36 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transaction Official API documentation |
|
37 | + * @param string $id The transaction ID in UUID format |
|
38 | + * @return array The response body |
|
39 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
40 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
41 | + */ |
|
42 | + public function get(string $id) |
|
43 | + { |
|
44 | + return $this->client->get('/transaction/' . $id); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get a transaction by its request ID |
|
49 | - * |
|
50 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transaction Official API documentation |
|
51 | - * @param string $requestId The request ID |
|
52 | - * @return array The response body |
|
53 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
54 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
55 | - */ |
|
56 | - public function getByRequestId(string $requestId) |
|
57 | - { |
|
58 | - return $this->client->get('/transaction/' . $requestId, [ |
|
59 | - 'query' => [ |
|
60 | - 'id_type' => 'request_id' |
|
61 | - ] |
|
62 | - ]); |
|
63 | - } |
|
47 | + /** |
|
48 | + * Get a transaction by its request ID |
|
49 | + * |
|
50 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transaction Official API documentation |
|
51 | + * @param string $requestId The request ID |
|
52 | + * @return array The response body |
|
53 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
54 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
55 | + */ |
|
56 | + public function getByRequestId(string $requestId) |
|
57 | + { |
|
58 | + return $this->client->get('/transaction/' . $requestId, [ |
|
59 | + 'query' => [ |
|
60 | + 'id_type' => 'request_id' |
|
61 | + ] |
|
62 | + ]); |
|
63 | + } |
|
64 | 64 | } |
@@ -4,51 +4,51 @@ |
||
4 | 4 | |
5 | 5 | class Account extends Resource |
6 | 6 | { |
7 | - /** |
|
8 | - * The enpoint for account requests |
|
9 | - * |
|
10 | - * @var string |
|
11 | - */ |
|
12 | - const ENDPOINT = '/accounts'; |
|
7 | + /** |
|
8 | + * The enpoint for account requests |
|
9 | + * |
|
10 | + * @var string |
|
11 | + */ |
|
12 | + const ENDPOINT = '/accounts'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Get all accounts |
|
16 | - * |
|
17 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#accounts-get-accounts Official API documentation |
|
18 | - * @return array The response body |
|
19 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
20 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
21 | - */ |
|
22 | - public function all() |
|
23 | - { |
|
24 | - return $this->client->get(self::ENDPOINT); |
|
25 | - } |
|
14 | + /** |
|
15 | + * Get all accounts |
|
16 | + * |
|
17 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#accounts-get-accounts Official API documentation |
|
18 | + * @return array The response body |
|
19 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
20 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
21 | + */ |
|
22 | + public function all() |
|
23 | + { |
|
24 | + return $this->client->get(self::ENDPOINT); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Get an account by its ID |
|
29 | - * |
|
30 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#accounts-get-account Official API documentation |
|
31 | - * @param string $id The account ID in UUID format |
|
32 | - * @return array The response body |
|
33 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
34 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
35 | - */ |
|
36 | - public function get(string $id) |
|
37 | - { |
|
38 | - return $this->client->get(self::ENDPOINT . '/' . $id); |
|
39 | - } |
|
27 | + /** |
|
28 | + * Get an account by its ID |
|
29 | + * |
|
30 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#accounts-get-account Official API documentation |
|
31 | + * @param string $id The account ID in UUID format |
|
32 | + * @return array The response body |
|
33 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
34 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
35 | + */ |
|
36 | + public function get(string $id) |
|
37 | + { |
|
38 | + return $this->client->get(self::ENDPOINT . '/' . $id); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get the details of an account by its ID |
|
43 | - * |
|
44 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#accounts-get-account-details Official API documentation |
|
45 | - * @param string $id The account ID in UUID format |
|
46 | - * @return array The response body |
|
47 | - * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
48 | - * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
49 | - */ |
|
50 | - public function details(string $id) |
|
51 | - { |
|
52 | - return $this->client->get(self::ENDPOINT . '/' . $id . '/bank-details'); |
|
53 | - } |
|
41 | + /** |
|
42 | + * Get the details of an account by its ID |
|
43 | + * |
|
44 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#accounts-get-account-details Official API documentation |
|
45 | + * @param string $id The account ID in UUID format |
|
46 | + * @return array The response body |
|
47 | + * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
48 | + * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
49 | + */ |
|
50 | + public function details(string $id) |
|
51 | + { |
|
52 | + return $this->client->get(self::ENDPOINT . '/' . $id . '/bank-details'); |
|
53 | + } |
|
54 | 54 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class Exchange extends Resource implements Buildable |
9 | 9 | { |
10 | - /** |
|
11 | - * The enpoint for exchange requests |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - const ENDPOINT = '/exchange'; |
|
10 | + /** |
|
11 | + * The enpoint for exchange requests |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + const ENDPOINT = '/exchange'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#exchanges-exchange-currency Official API documentation |
|
19 | - */ |
|
20 | - public function create(array $json) |
|
21 | - { |
|
22 | - return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#exchanges-exchange-currency Official API documentation |
|
19 | + */ |
|
20 | + public function create(array $json) |
|
21 | + { |
|
22 | + return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @return \tbclla\Revolut\Builders\ExchangeBuilder |
|
27 | - */ |
|
28 | - public function build() |
|
29 | - { |
|
30 | - return new ExchangeBuilder($this, $this->client->generateRequestId()); |
|
31 | - } |
|
25 | + /** |
|
26 | + * @return \tbclla\Revolut\Builders\ExchangeBuilder |
|
27 | + */ |
|
28 | + public function build() |
|
29 | + { |
|
30 | + return new ExchangeBuilder($this, $this->client->generateRequestId()); |
|
31 | + } |
|
32 | 32 | } |