@@ -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 private 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 private key')); |
|
| 78 | + } catch (Exception $e) { |
|
| 79 | + $this->error($e->getMessage()); |
|
| 80 | + return $this->checkPublicKey(); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -18,19 +18,19 @@ discard block |
||
| 18 | 18 | * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-add-revolut-counterparty Official API documentation |
| 19 | 19 | */ |
| 20 | 20 | public function create(array $json) |
| 21 | - { |
|
| 21 | + { |
|
| 22 | 22 | return $this->client->post(self::ENDPOINT, ['json' => $json]); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * Get all counterparties |
|
| 26 | + * Get all counterparties |
|
| 27 | 27 | * |
| 28 | 28 | * @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-get-counterparties Official API documentation |
| 29 | - * @return array |
|
| 30 | - */ |
|
| 31 | - public function all() |
|
| 32 | - { |
|
| 33 | - return $this->client->get('/counterparties'); |
|
| 29 | + * @return array |
|
| 30 | + */ |
|
| 31 | + public function all() |
|
| 32 | + { |
|
| 33 | + return $this->client->get('/counterparties'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | 43 | public function get(string $id) |
| 44 | - { |
|
| 45 | - return $this->client->get(self::ENDPOINT . '/' . $id); |
|
| 44 | + { |
|
| 45 | + return $this->client->get(self::ENDPOINT . '/' . $id); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | 55 | public function delete(string $id) : void |
| 56 | - { |
|
| 57 | - $this->client->delete(self::ENDPOINT . '/' . $id); |
|
| 56 | + { |
|
| 57 | + $this->client->delete(self::ENDPOINT . '/' . $id); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -15,43 +15,43 @@ |
||
| 15 | 15 | const ENDPOINT = '/pay'; |
| 16 | 16 | |
| 17 | 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 | - } |
|
| 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 |
|
| 32 | - */ |
|
| 33 | - public function schedule(array $json, string $date) |
|
| 34 | - { |
|
| 35 | - return $this->create(array_merge($json, ['schedule_for' => $date])); |
|
| 36 | - } |
|
| 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 |
|
| 32 | + */ |
|
| 33 | + public function schedule(array $json, string $date) |
|
| 34 | + { |
|
| 35 | + return $this->create(array_merge($json, ['schedule_for' => $date])); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Cancel a scheduled payment |
|
| 40 | - * |
|
| 41 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-cancel-payment Official API documentation |
|
| 42 | - * @param string $id The ID of the payment in UUID format |
|
| 43 | - * @return void |
|
| 44 | - */ |
|
| 45 | - public function cancel(string $id) : void |
|
| 46 | - { |
|
| 47 | - $this->client->delete('/transaction/' . $id); |
|
| 48 | - } |
|
| 38 | + /** |
|
| 39 | + * Cancel a scheduled payment |
|
| 40 | + * |
|
| 41 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#payments-cancel-payment Official API documentation |
|
| 42 | + * @param string $id The ID of the payment in UUID format |
|
| 43 | + * @return void |
|
| 44 | + */ |
|
| 45 | + public function cancel(string $id) : void |
|
| 46 | + { |
|
| 47 | + $this->client->delete('/transaction/' . $id); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return \tbclla\Revolut\Builders\PaymentBuilder |
|
| 52 | - */ |
|
| 53 | - public function build() |
|
| 54 | - { |
|
| 55 | - return new PaymentBuilder($this, $this->client->generateRequestId()); |
|
| 56 | - } |
|
| 50 | + /** |
|
| 51 | + * @return \tbclla\Revolut\Builders\PaymentBuilder |
|
| 52 | + */ |
|
| 53 | + public function build() |
|
| 54 | + { |
|
| 55 | + return new PaymentBuilder($this, $this->client->generateRequestId()); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * @return \tbclla\Revolut\Builders\ExchangeBuilder |
|
| 27 | - */ |
|
| 26 | + * @return \tbclla\Revolut\Builders\ExchangeBuilder |
|
| 27 | + */ |
|
| 28 | 28 | public function build() |
| 29 | 29 | { |
| 30 | 30 | return new ExchangeBuilder($this, $this->client->generateRequestId()); |
@@ -15,18 +15,18 @@ |
||
| 15 | 15 | const ENDPOINT = '/transfer'; |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * @see https://revolut-engineering.github.io/api-docs/business-api/#transfers-create-transfer Official API documentation |
|
| 19 | - */ |
|
| 20 | - public function create(array $json) |
|
| 21 | - { |
|
| 22 | - return $this->client->post(self::ENDPOINT, ['json' => $json]); |
|
| 23 | - } |
|
| 18 | + * @see https://revolut-engineering.github.io/api-docs/business-api/#transfers-create-transfer 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\TransferBuilder |
|
| 27 | - */ |
|
| 28 | - public function build() |
|
| 29 | - { |
|
| 30 | - return new TransferBuilder($this, $this->client->generateRequestId()); |
|
| 31 | - } |
|
| 25 | + /** |
|
| 26 | + * @return \tbclla\Revolut\Builders\TransferBuilder |
|
| 27 | + */ |
|
| 28 | + public function build() |
|
| 29 | + { |
|
| 30 | + return new TransferBuilder($this, $this->client->generateRequestId()); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -58,8 +58,8 @@ |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | - * @return \tbclla\Revolut\Builders\PaymentDraftBuilder |
|
| 62 | - */ |
|
| 61 | + * @return \tbclla\Revolut\Builders\PaymentDraftBuilder |
|
| 62 | + */ |
|
| 63 | 63 | public function build() |
| 64 | 64 | { |
| 65 | 65 | return new PaymentDraftBuilder($this); |