@@ -4,113 +4,113 @@ |
||
| 4 | 4 | |
| 5 | 5 | class AuthorizationCodeRequest |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * The sandbox URL |
|
| 9 | - * |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - const SANDBOX_URL = 'https://sandbox-business.revolut.com'; |
|
| 7 | + /** |
|
| 8 | + * The sandbox URL |
|
| 9 | + * |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + const SANDBOX_URL = 'https://sandbox-business.revolut.com'; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * The production URL |
|
| 16 | - * |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - const PRODUCTION_URL = 'https://business.revolut.com'; |
|
| 14 | + /** |
|
| 15 | + * The production URL |
|
| 16 | + * |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + const PRODUCTION_URL = 'https://business.revolut.com'; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The app authorization endpoint |
|
| 23 | - * |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - const ENDPOINT = '/app-confirm'; |
|
| 21 | + /** |
|
| 22 | + * The app authorization endpoint |
|
| 23 | + * |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + const ENDPOINT = '/app-confirm'; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * A token repository |
|
| 30 | - * |
|
| 31 | - * @var string The client Id |
|
| 32 | - */ |
|
| 33 | - private $clientId; |
|
| 28 | + /** |
|
| 29 | + * A token repository |
|
| 30 | + * |
|
| 31 | + * @var string The client Id |
|
| 32 | + */ |
|
| 33 | + private $clientId; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * A token repository |
|
| 37 | - * |
|
| 38 | - * @var string The redirect URI |
|
| 39 | - */ |
|
| 40 | - private $redirectUri; |
|
| 35 | + /** |
|
| 36 | + * A token repository |
|
| 37 | + * |
|
| 38 | + * @var string The redirect URI |
|
| 39 | + */ |
|
| 40 | + private $redirectUri; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * A token repository |
|
| 44 | - * |
|
| 45 | - * @var bool The environment |
|
| 46 | - */ |
|
| 47 | - private $sandbox; |
|
| 42 | + /** |
|
| 43 | + * A token repository |
|
| 44 | + * |
|
| 45 | + * @var bool The environment |
|
| 46 | + */ |
|
| 47 | + private $sandbox; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * A state value |
|
| 51 | - * |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - public $state; |
|
| 49 | + /** |
|
| 50 | + * A state value |
|
| 51 | + * |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + public $state; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Create a new request |
|
| 58 | - * |
|
| 59 | - * @param string $clientId The Revolut Business Client ID |
|
| 60 | - * @param string $redirectUri The OAuth redirect URI |
|
| 61 | - * @param bool $sandbox Whether or not to use the sandbox environment |
|
| 62 | - * @return void |
|
| 63 | - */ |
|
| 64 | - public function __construct(string $clientId, string $redirectUri, bool $sandbox = true) |
|
| 65 | - { |
|
| 66 | - $this->clientId = $clientId; |
|
| 67 | - $this->redirectUri = $redirectUri; |
|
| 68 | - $this->sandbox = $sandbox; |
|
| 69 | - $this->state = $this->generateState(); |
|
| 70 | - } |
|
| 56 | + /** |
|
| 57 | + * Create a new request |
|
| 58 | + * |
|
| 59 | + * @param string $clientId The Revolut Business Client ID |
|
| 60 | + * @param string $redirectUri The OAuth redirect URI |
|
| 61 | + * @param bool $sandbox Whether or not to use the sandbox environment |
|
| 62 | + * @return void |
|
| 63 | + */ |
|
| 64 | + public function __construct(string $clientId, string $redirectUri, bool $sandbox = true) |
|
| 65 | + { |
|
| 66 | + $this->clientId = $clientId; |
|
| 67 | + $this->redirectUri = $redirectUri; |
|
| 68 | + $this->sandbox = $sandbox; |
|
| 69 | + $this->state = $this->generateState(); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Build the request |
|
| 74 | - * |
|
| 75 | - * @return string |
|
| 76 | - */ |
|
| 77 | - public function build() |
|
| 78 | - { |
|
| 79 | - return $this->baseUri() . self::ENDPOINT . '?' . $this->buildQuery(); |
|
| 80 | - } |
|
| 72 | + /** |
|
| 73 | + * Build the request |
|
| 74 | + * |
|
| 75 | + * @return string |
|
| 76 | + */ |
|
| 77 | + public function build() |
|
| 78 | + { |
|
| 79 | + return $this->baseUri() . self::ENDPOINT . '?' . $this->buildQuery(); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Build the base URI |
|
| 84 | - * |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 87 | - private function baseUri() |
|
| 88 | - { |
|
| 89 | - return $this->sandbox ? self::SANDBOX_URL : self::PRODUCTION_URL; |
|
| 90 | - } |
|
| 82 | + /** |
|
| 83 | + * Build the base URI |
|
| 84 | + * |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | + private function baseUri() |
|
| 88 | + { |
|
| 89 | + return $this->sandbox ? self::SANDBOX_URL : self::PRODUCTION_URL; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Build the query |
|
| 94 | - * |
|
| 95 | - * @return string |
|
| 96 | - */ |
|
| 97 | - private function buildQuery() |
|
| 98 | - { |
|
| 99 | - return http_build_query([ |
|
| 100 | - 'response_type' => 'request_token', |
|
| 101 | - 'client_id' => $this->clientId, |
|
| 102 | - 'redirect_uri' => $this->redirectUri, |
|
| 103 | - 'state' => $this->state |
|
| 104 | - ]); |
|
| 105 | - } |
|
| 92 | + /** |
|
| 93 | + * Build the query |
|
| 94 | + * |
|
| 95 | + * @return string |
|
| 96 | + */ |
|
| 97 | + private function buildQuery() |
|
| 98 | + { |
|
| 99 | + return http_build_query([ |
|
| 100 | + 'response_type' => 'request_token', |
|
| 101 | + 'client_id' => $this->clientId, |
|
| 102 | + 'redirect_uri' => $this->redirectUri, |
|
| 103 | + 'state' => $this->state |
|
| 104 | + ]); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Generate a state value |
|
| 109 | - * |
|
| 110 | - * @return string |
|
| 111 | - */ |
|
| 112 | - private function generateState() |
|
| 113 | - { |
|
| 114 | - return base64_encode(random_bytes(32)); |
|
| 115 | - } |
|
| 107 | + /** |
|
| 108 | + * Generate a state value |
|
| 109 | + * |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 112 | + private function generateState() |
|
| 113 | + { |
|
| 114 | + return base64_encode(random_bytes(32)); |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -7,27 +7,27 @@ |
||
| 7 | 7 | |
| 8 | 8 | class AccessToken extends Token implements PersistableToken |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name of the token |
|
| 12 | - * |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - const TYPE = 'access_token'; |
|
| 10 | + /** |
|
| 11 | + * The name of the token |
|
| 12 | + * |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + const TYPE = 'access_token'; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * The time to live in minutes |
|
| 19 | - * |
|
| 20 | - * @var int |
|
| 21 | - */ |
|
| 22 | - const TTL = 40; |
|
| 17 | + /** |
|
| 18 | + * The time to live in minutes |
|
| 19 | + * |
|
| 20 | + * @var int |
|
| 21 | + */ |
|
| 22 | + const TTL = 40; |
|
| 23 | 23 | |
| 24 | - public static function getType() |
|
| 25 | - { |
|
| 26 | - return self::TYPE; |
|
| 27 | - } |
|
| 24 | + public static function getType() |
|
| 25 | + { |
|
| 26 | + return self::TYPE; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public static function getExpiration() |
|
| 30 | - { |
|
| 31 | - return now()->addMinutes(self::TTL); |
|
| 32 | - } |
|
| 29 | + public static function getExpiration() |
|
| 30 | + { |
|
| 31 | + return now()->addMinutes(self::TTL); |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -8,143 +8,143 @@ |
||
| 8 | 8 | |
| 9 | 9 | class ClientAssertion |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * The client assertion type |
|
| 13 | - * @link https://revolut-engineering.github.io/api-docs/business-api/#oauth-exchange-authorisation-code |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - const TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * The JWT's audience parameter |
|
| 21 | - * @link https://revolut-engineering.github.io/api-docs/business-api/#authentication-setting-up-access-to-your-business-account |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - const AUDIENCE = 'https://revolut.com'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * The JWT's algorythm parameter |
|
| 29 | - * @link https://revolut-engineering.github.io/api-docs/business-api/#authentication-setting-up-access-to-your-business-account |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - const ALGORYTHM = 'RS256'; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The JWT client |
|
| 37 | - * |
|
| 38 | - * @var \firebase\JWT\JWT |
|
| 39 | - */ |
|
| 40 | - private $jwtClient; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The client ID |
|
| 44 | - * |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - public $clientId; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * The private key path |
|
| 51 | - * |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - private $privateKey; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * The redirect URI |
|
| 58 | - * |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 61 | - private $redirectUri; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Create a new client assertion |
|
| 65 | - * |
|
| 66 | - * @param string $clientId The client ID |
|
| 67 | - * @param string $privateKey The path to the private key |
|
| 68 | - * @param string $redirectUri The Oauth redirect URI |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - public function __construct(string $clientId, string $privateKey, string $redirectUri) |
|
| 72 | - { |
|
| 73 | - $this->jwtClient = new JWT; |
|
| 74 | - $this->clientId = $clientId; |
|
| 75 | - $this->privateKey = $privateKey; |
|
| 76 | - $this->redirectUri = $redirectUri; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Build the JWT |
|
| 81 | - * |
|
| 82 | - * @return string The assertion string |
|
| 83 | - * @throws \tbclla\Revolut\Exceptions\ConfigurationException |
|
| 84 | - */ |
|
| 85 | - public function build() |
|
| 86 | - { |
|
| 87 | - try { |
|
| 88 | - return $this->jwtClient->encode($this->buildPayload(), $this->getPrivateKey(), self::ALGORYTHM); |
|
| 89 | - } catch (Exception $e) { |
|
| 90 | - throw new ConfigurationException('Failed to create JWT - ' . $e->getMessage(), null, $e); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Build the payload for the JWT |
|
| 96 | - * |
|
| 97 | - * @return array |
|
| 98 | - */ |
|
| 99 | - private function buildPayload() |
|
| 100 | - { |
|
| 101 | - return [ |
|
| 102 | - 'sub' => $this->clientId, |
|
| 103 | - 'iss' => $this->getIssuer(), |
|
| 104 | - 'exp' => self::getExpiration(), |
|
| 105 | - 'aud' => self::AUDIENCE, |
|
| 106 | - ]; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Get the contents of the private key |
|
| 111 | - * |
|
| 112 | - * @return string |
|
| 113 | - * @throws \tbclla\Revolut\Exceptions\ConfigurationException |
|
| 114 | - */ |
|
| 115 | - private function getPrivateKey() |
|
| 116 | - { |
|
| 117 | - try { |
|
| 118 | - return file_get_contents($this->privateKey); |
|
| 119 | - } catch (Exception $e) { |
|
| 120 | - throw new ConfigurationException('Private Key not configured correctly! ' . $e->getMessage(), null, $e); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Get the JWT issuer |
|
| 126 | - * |
|
| 127 | - * @return string |
|
| 128 | - * @throws \tbclla\Revolut\Exceptions\ConfigurationException |
|
| 129 | - */ |
|
| 130 | - private function getIssuer() |
|
| 131 | - { |
|
| 132 | - $domain = parse_url($this->redirectUri); |
|
| 133 | - |
|
| 134 | - if (empty($domain['host'])) { |
|
| 135 | - throw new ConfigurationException('Invalid redirect URI.'); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $domain['host']; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Get the expiration time in the form of a unix timestamp |
|
| 143 | - * |
|
| 144 | - * @return int |
|
| 145 | - */ |
|
| 146 | - private static function getExpiration() |
|
| 147 | - { |
|
| 148 | - return time() + (60 * 5); |
|
| 149 | - } |
|
| 11 | + /** |
|
| 12 | + * The client assertion type |
|
| 13 | + * @link https://revolut-engineering.github.io/api-docs/business-api/#oauth-exchange-authorisation-code |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + const TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * The JWT's audience parameter |
|
| 21 | + * @link https://revolut-engineering.github.io/api-docs/business-api/#authentication-setting-up-access-to-your-business-account |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + const AUDIENCE = 'https://revolut.com'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * The JWT's algorythm parameter |
|
| 29 | + * @link https://revolut-engineering.github.io/api-docs/business-api/#authentication-setting-up-access-to-your-business-account |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + const ALGORYTHM = 'RS256'; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The JWT client |
|
| 37 | + * |
|
| 38 | + * @var \firebase\JWT\JWT |
|
| 39 | + */ |
|
| 40 | + private $jwtClient; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The client ID |
|
| 44 | + * |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + public $clientId; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * The private key path |
|
| 51 | + * |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + private $privateKey; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * The redirect URI |
|
| 58 | + * |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | + private $redirectUri; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Create a new client assertion |
|
| 65 | + * |
|
| 66 | + * @param string $clientId The client ID |
|
| 67 | + * @param string $privateKey The path to the private key |
|
| 68 | + * @param string $redirectUri The Oauth redirect URI |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + public function __construct(string $clientId, string $privateKey, string $redirectUri) |
|
| 72 | + { |
|
| 73 | + $this->jwtClient = new JWT; |
|
| 74 | + $this->clientId = $clientId; |
|
| 75 | + $this->privateKey = $privateKey; |
|
| 76 | + $this->redirectUri = $redirectUri; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Build the JWT |
|
| 81 | + * |
|
| 82 | + * @return string The assertion string |
|
| 83 | + * @throws \tbclla\Revolut\Exceptions\ConfigurationException |
|
| 84 | + */ |
|
| 85 | + public function build() |
|
| 86 | + { |
|
| 87 | + try { |
|
| 88 | + return $this->jwtClient->encode($this->buildPayload(), $this->getPrivateKey(), self::ALGORYTHM); |
|
| 89 | + } catch (Exception $e) { |
|
| 90 | + throw new ConfigurationException('Failed to create JWT - ' . $e->getMessage(), null, $e); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Build the payload for the JWT |
|
| 96 | + * |
|
| 97 | + * @return array |
|
| 98 | + */ |
|
| 99 | + private function buildPayload() |
|
| 100 | + { |
|
| 101 | + return [ |
|
| 102 | + 'sub' => $this->clientId, |
|
| 103 | + 'iss' => $this->getIssuer(), |
|
| 104 | + 'exp' => self::getExpiration(), |
|
| 105 | + 'aud' => self::AUDIENCE, |
|
| 106 | + ]; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Get the contents of the private key |
|
| 111 | + * |
|
| 112 | + * @return string |
|
| 113 | + * @throws \tbclla\Revolut\Exceptions\ConfigurationException |
|
| 114 | + */ |
|
| 115 | + private function getPrivateKey() |
|
| 116 | + { |
|
| 117 | + try { |
|
| 118 | + return file_get_contents($this->privateKey); |
|
| 119 | + } catch (Exception $e) { |
|
| 120 | + throw new ConfigurationException('Private Key not configured correctly! ' . $e->getMessage(), null, $e); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Get the JWT issuer |
|
| 126 | + * |
|
| 127 | + * @return string |
|
| 128 | + * @throws \tbclla\Revolut\Exceptions\ConfigurationException |
|
| 129 | + */ |
|
| 130 | + private function getIssuer() |
|
| 131 | + { |
|
| 132 | + $domain = parse_url($this->redirectUri); |
|
| 133 | + |
|
| 134 | + if (empty($domain['host'])) { |
|
| 135 | + throw new ConfigurationException('Invalid redirect URI.'); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $domain['host']; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Get the expiration time in the form of a unix timestamp |
|
| 143 | + * |
|
| 144 | + * @return int |
|
| 145 | + */ |
|
| 146 | + private static function getExpiration() |
|
| 147 | + { |
|
| 148 | + return time() + (60 * 5); |
|
| 149 | + } |
|
| 150 | 150 | } |
@@ -4,100 +4,100 @@ |
||
| 4 | 4 | |
| 5 | 5 | class TransferBuilder extends Builder |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * The source account ID |
|
| 9 | - * |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - public $source_account_id; |
|
| 7 | + /** |
|
| 8 | + * The source account ID |
|
| 9 | + * |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + public $source_account_id; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * The target account ID |
|
| 16 | - * |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - public $target_account_id; |
|
| 14 | + /** |
|
| 15 | + * The target account ID |
|
| 16 | + * |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + public $target_account_id; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The amount |
|
| 23 | - * |
|
| 24 | - * @var float |
|
| 25 | - */ |
|
| 26 | - public $amount; |
|
| 21 | + /** |
|
| 22 | + * The amount |
|
| 23 | + * |
|
| 24 | + * @var float |
|
| 25 | + */ |
|
| 26 | + public $amount; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * The currency in 3-letter ISO format |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public $currency; |
|
| 28 | + /** |
|
| 29 | + * The currency in 3-letter ISO format |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public $currency; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * An optional reference |
|
| 37 | - * |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - public $reference; |
|
| 35 | + /** |
|
| 36 | + * An optional reference |
|
| 37 | + * |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + public $reference; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The unique request ID |
|
| 44 | - * |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - public $request_id; |
|
| 42 | + /** |
|
| 43 | + * The unique request ID |
|
| 44 | + * |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + public $request_id; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Set the source account ID |
|
| 51 | - * |
|
| 52 | - * @param string $id |
|
| 53 | - * @return self |
|
| 54 | - */ |
|
| 55 | - public function sourceAccount(string $id) |
|
| 56 | - { |
|
| 57 | - return $this->setAttribute('source_account_id', $id); |
|
| 58 | - } |
|
| 49 | + /** |
|
| 50 | + * Set the source account ID |
|
| 51 | + * |
|
| 52 | + * @param string $id |
|
| 53 | + * @return self |
|
| 54 | + */ |
|
| 55 | + public function sourceAccount(string $id) |
|
| 56 | + { |
|
| 57 | + return $this->setAttribute('source_account_id', $id); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Set the target account ID |
|
| 62 | - * |
|
| 63 | - * @param string $id |
|
| 64 | - * @return self |
|
| 65 | - */ |
|
| 66 | - public function targetAccount(string $id) |
|
| 67 | - { |
|
| 68 | - return $this->setAttribute('target_account_id', $id); |
|
| 69 | - } |
|
| 60 | + /** |
|
| 61 | + * Set the target account ID |
|
| 62 | + * |
|
| 63 | + * @param string $id |
|
| 64 | + * @return self |
|
| 65 | + */ |
|
| 66 | + public function targetAccount(string $id) |
|
| 67 | + { |
|
| 68 | + return $this->setAttribute('target_account_id', $id); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Set the transfer amount |
|
| 73 | - * |
|
| 74 | - * @param float $amount |
|
| 75 | - * @return self |
|
| 76 | - */ |
|
| 77 | - public function amount(float $amount) |
|
| 78 | - { |
|
| 79 | - return $this->setAttribute('amount', $amount); |
|
| 80 | - } |
|
| 71 | + /** |
|
| 72 | + * Set the transfer amount |
|
| 73 | + * |
|
| 74 | + * @param float $amount |
|
| 75 | + * @return self |
|
| 76 | + */ |
|
| 77 | + public function amount(float $amount) |
|
| 78 | + { |
|
| 79 | + return $this->setAttribute('amount', $amount); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Set the transfer currency |
|
| 84 | - * |
|
| 85 | - * @param string $currency |
|
| 86 | - * @return self |
|
| 87 | - */ |
|
| 88 | - public function currency(string $currency) |
|
| 89 | - { |
|
| 90 | - return $this->setAttribute('currency', $currency); |
|
| 91 | - } |
|
| 82 | + /** |
|
| 83 | + * Set the transfer currency |
|
| 84 | + * |
|
| 85 | + * @param string $currency |
|
| 86 | + * @return self |
|
| 87 | + */ |
|
| 88 | + public function currency(string $currency) |
|
| 89 | + { |
|
| 90 | + return $this->setAttribute('currency', $currency); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Set the optional transfer reference |
|
| 95 | - * |
|
| 96 | - * @param string $reference |
|
| 97 | - * @return self |
|
| 98 | - */ |
|
| 99 | - public function reference(string $reference) |
|
| 100 | - { |
|
| 101 | - return $this->setAttribute('reference', $reference); |
|
| 102 | - } |
|
| 93 | + /** |
|
| 94 | + * Set the optional transfer reference |
|
| 95 | + * |
|
| 96 | + * @param string $reference |
|
| 97 | + * @return self |
|
| 98 | + */ |
|
| 99 | + public function reference(string $reference) |
|
| 100 | + { |
|
| 101 | + return $this->setAttribute('reference', $reference); |
|
| 102 | + } |
|
| 103 | 103 | } |
@@ -4,85 +4,85 @@ |
||
| 4 | 4 | |
| 5 | 5 | class ExchangeBuilder extends Builder |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Information about the account you want to exchange from |
|
| 9 | - * |
|
| 10 | - * @var array |
|
| 11 | - */ |
|
| 12 | - public $from; |
|
| 7 | + /** |
|
| 8 | + * Information about the account you want to exchange from |
|
| 9 | + * |
|
| 10 | + * @var array |
|
| 11 | + */ |
|
| 12 | + public $from; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Information about the account you want to exchange to |
|
| 16 | - * |
|
| 17 | - * @var array |
|
| 18 | - */ |
|
| 19 | - public $to; |
|
| 14 | + /** |
|
| 15 | + * Information about the account you want to exchange to |
|
| 16 | + * |
|
| 17 | + * @var array |
|
| 18 | + */ |
|
| 19 | + public $to; |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * An optional reference |
|
| 24 | - * |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - public $reference; |
|
| 22 | + /** |
|
| 23 | + * An optional reference |
|
| 24 | + * |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + public $reference; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Set the outgoing account |
|
| 31 | - * |
|
| 32 | - * @param string $accountId the account ID |
|
| 33 | - * @param string $currency the account currency |
|
| 34 | - * @param float $amount the amount of currency to sell (only when selling) |
|
| 35 | - * @return self |
|
| 36 | - */ |
|
| 37 | - public function from(string $accountId, string $currency, float $amount = null) |
|
| 38 | - { |
|
| 39 | - return $this->setAccount('from', $accountId, $currency, $amount); |
|
| 40 | - } |
|
| 29 | + /** |
|
| 30 | + * Set the outgoing account |
|
| 31 | + * |
|
| 32 | + * @param string $accountId the account ID |
|
| 33 | + * @param string $currency the account currency |
|
| 34 | + * @param float $amount the amount of currency to sell (only when selling) |
|
| 35 | + * @return self |
|
| 36 | + */ |
|
| 37 | + public function from(string $accountId, string $currency, float $amount = null) |
|
| 38 | + { |
|
| 39 | + return $this->setAccount('from', $accountId, $currency, $amount); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set the receiving account |
|
| 44 | - * |
|
| 45 | - * @param string $accountId the account ID |
|
| 46 | - * @param string $currency the account currency |
|
| 47 | - * @param float $amount the amount of currency to buy (only when buying) |
|
| 48 | - * @return self |
|
| 49 | - */ |
|
| 50 | - public function to(string $accountId, string $currency, float $amount = null) |
|
| 51 | - { |
|
| 52 | - return $this->setAccount('to', $accountId, $currency, $amount); |
|
| 53 | - } |
|
| 42 | + /** |
|
| 43 | + * Set the receiving account |
|
| 44 | + * |
|
| 45 | + * @param string $accountId the account ID |
|
| 46 | + * @param string $currency the account currency |
|
| 47 | + * @param float $amount the amount of currency to buy (only when buying) |
|
| 48 | + * @return self |
|
| 49 | + */ |
|
| 50 | + public function to(string $accountId, string $currency, float $amount = null) |
|
| 51 | + { |
|
| 52 | + return $this->setAccount('to', $accountId, $currency, $amount); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Set an optional reference |
|
| 57 | - * |
|
| 58 | - * @param string $reference |
|
| 59 | - * @return self |
|
| 60 | - */ |
|
| 61 | - public function reference(string $reference) |
|
| 62 | - { |
|
| 63 | - return $this->setAttribute('reference', $reference); |
|
| 64 | - } |
|
| 55 | + /** |
|
| 56 | + * Set an optional reference |
|
| 57 | + * |
|
| 58 | + * @param string $reference |
|
| 59 | + * @return self |
|
| 60 | + */ |
|
| 61 | + public function reference(string $reference) |
|
| 62 | + { |
|
| 63 | + return $this->setAttribute('reference', $reference); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Set the account information |
|
| 68 | - * |
|
| 69 | - * @param string $type |
|
| 70 | - * @param string $accountId |
|
| 71 | - * @param string $currency |
|
| 72 | - * @param float $amount |
|
| 73 | - * @return self |
|
| 74 | - */ |
|
| 75 | - private function setAccount(string $type, string $accountId, string $currency, $amount) |
|
| 76 | - { |
|
| 77 | - $account = [ |
|
| 78 | - 'account_id' => $accountId, |
|
| 79 | - 'currency' => $currency, |
|
| 80 | - ]; |
|
| 66 | + /** |
|
| 67 | + * Set the account information |
|
| 68 | + * |
|
| 69 | + * @param string $type |
|
| 70 | + * @param string $accountId |
|
| 71 | + * @param string $currency |
|
| 72 | + * @param float $amount |
|
| 73 | + * @return self |
|
| 74 | + */ |
|
| 75 | + private function setAccount(string $type, string $accountId, string $currency, $amount) |
|
| 76 | + { |
|
| 77 | + $account = [ |
|
| 78 | + 'account_id' => $accountId, |
|
| 79 | + 'currency' => $currency, |
|
| 80 | + ]; |
|
| 81 | 81 | |
| 82 | - if ($amount) { |
|
| 83 | - $account['amount'] = $amount; |
|
| 84 | - } |
|
| 82 | + if ($amount) { |
|
| 83 | + $account['amount'] = $amount; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $this->setAttribute($type, $account); |
|
| 87 | - } |
|
| 86 | + return $this->setAttribute($type, $account); |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -6,83 +6,83 @@ |
||
| 6 | 6 | |
| 7 | 7 | abstract Class Builder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The API resource |
|
| 11 | - * |
|
| 12 | - * @var \tbclla\Revolut\Interfaces\Buildable |
|
| 13 | - */ |
|
| 14 | - protected $resource; |
|
| 9 | + /** |
|
| 10 | + * The API resource |
|
| 11 | + * |
|
| 12 | + * @var \tbclla\Revolut\Interfaces\Buildable |
|
| 13 | + */ |
|
| 14 | + protected $resource; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The unique ID of the request |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $request_id; |
|
| 16 | + /** |
|
| 17 | + * The unique ID of the request |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $request_id; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Create a new builder instance |
|
| 25 | - * |
|
| 26 | - * @param \tbclla\Revolut\Resources\Resource $resource |
|
| 27 | - * @param string $requestId |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function __construct(Buildable $resource, string $requestId = null) |
|
| 31 | - { |
|
| 32 | - $this->resource = $resource; |
|
| 33 | - $this->request_id = $requestId; |
|
| 34 | - } |
|
| 23 | + /** |
|
| 24 | + * Create a new builder instance |
|
| 25 | + * |
|
| 26 | + * @param \tbclla\Revolut\Resources\Resource $resource |
|
| 27 | + * @param string $requestId |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function __construct(Buildable $resource, string $requestId = null) |
|
| 31 | + { |
|
| 32 | + $this->resource = $resource; |
|
| 33 | + $this->request_id = $requestId; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Execute the create request |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - public function create() |
|
| 42 | - { |
|
| 43 | - return $this->resource->create($this->toArray()); |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * Execute the create request |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + public function create() |
|
| 42 | + { |
|
| 43 | + return $this->resource->create($this->toArray()); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Set the unique equest ID |
|
| 48 | - * |
|
| 49 | - * @param string $id |
|
| 50 | - * @return self |
|
| 51 | - */ |
|
| 52 | - public function requestId(string $id) |
|
| 53 | - { |
|
| 54 | - return $this->setAttribute('request_id', $id); |
|
| 55 | - } |
|
| 46 | + /** |
|
| 47 | + * Set the unique equest ID |
|
| 48 | + * |
|
| 49 | + * @param string $id |
|
| 50 | + * @return self |
|
| 51 | + */ |
|
| 52 | + public function requestId(string $id) |
|
| 53 | + { |
|
| 54 | + return $this->setAttribute('request_id', $id); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Set the value of an attribute |
|
| 59 | - * |
|
| 60 | - * @param string $attribute |
|
| 61 | - * @param mixed $value |
|
| 62 | - * @return self |
|
| 63 | - */ |
|
| 64 | - protected function setAttribute(string $attribute, $value) |
|
| 65 | - { |
|
| 66 | - $this->$attribute = $value; |
|
| 57 | + /** |
|
| 58 | + * Set the value of an attribute |
|
| 59 | + * |
|
| 60 | + * @param string $attribute |
|
| 61 | + * @param mixed $value |
|
| 62 | + * @return self |
|
| 63 | + */ |
|
| 64 | + protected function setAttribute(string $attribute, $value) |
|
| 65 | + { |
|
| 66 | + $this->$attribute = $value; |
|
| 67 | 67 | |
| 68 | - return $this; |
|
| 69 | - } |
|
| 68 | + return $this; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Build the request data array |
|
| 73 | - * |
|
| 74 | - * @return array |
|
| 75 | - */ |
|
| 76 | - public function toArray() |
|
| 77 | - { |
|
| 78 | - $data = []; |
|
| 71 | + /** |
|
| 72 | + * Build the request data array |
|
| 73 | + * |
|
| 74 | + * @return array |
|
| 75 | + */ |
|
| 76 | + public function toArray() |
|
| 77 | + { |
|
| 78 | + $data = []; |
|
| 79 | 79 | |
| 80 | - foreach (get_object_vars($this) as $attribute => $value) { |
|
| 81 | - if ($attribute != 'resource' and !empty($value)) { |
|
| 82 | - $data[$attribute] = $value; |
|
| 83 | - } |
|
| 84 | - } |
|
| 80 | + foreach (get_object_vars($this) as $attribute => $value) { |
|
| 81 | + if ($attribute != 'resource' and !empty($value)) { |
|
| 82 | + $data[$attribute] = $value; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $data; |
|
| 87 | - } |
|
| 86 | + return $data; |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -4,68 +4,68 @@ |
||
| 4 | 4 | |
| 5 | 5 | class PaymentDraftBuilder extends Builder |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * An optional title |
|
| 9 | - * |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - public $title; |
|
| 7 | + /** |
|
| 8 | + * An optional title |
|
| 9 | + * |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + public $title; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * An optional future date |
|
| 16 | - * |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - public $schedule_for; |
|
| 14 | + /** |
|
| 15 | + * An optional future date |
|
| 16 | + * |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + public $schedule_for; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The payments included in the draft |
|
| 23 | - * |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - public $payments; |
|
| 21 | + /** |
|
| 22 | + * The payments included in the draft |
|
| 23 | + * |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + public $payments; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Set an optional title for the draft |
|
| 30 | - * |
|
| 31 | - * @param string $title |
|
| 32 | - * @return self |
|
| 33 | - */ |
|
| 34 | - public function title(string $title) |
|
| 35 | - { |
|
| 36 | - return $this->setAttribute('title', $title); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * Set an optional title for the draft |
|
| 30 | + * |
|
| 31 | + * @param string $title |
|
| 32 | + * @return self |
|
| 33 | + */ |
|
| 34 | + public function title(string $title) |
|
| 35 | + { |
|
| 36 | + return $this->setAttribute('title', $title); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Set an optional future date to schedule the payments |
|
| 41 | - * |
|
| 42 | - * @param string $date |
|
| 43 | - * @return self |
|
| 44 | - */ |
|
| 45 | - public function schedule(string $date) |
|
| 46 | - { |
|
| 47 | - return $this->setAttribute('schedule_for', $date); |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * Set an optional future date to schedule the payments |
|
| 41 | + * |
|
| 42 | + * @param string $date |
|
| 43 | + * @return self |
|
| 44 | + */ |
|
| 45 | + public function schedule(string $date) |
|
| 46 | + { |
|
| 47 | + return $this->setAttribute('schedule_for', $date); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Set the payments included in the draft |
|
| 52 | - * |
|
| 53 | - * @param array $payments |
|
| 54 | - * @return self |
|
| 55 | - */ |
|
| 56 | - public function payments(array $payments) |
|
| 57 | - { |
|
| 58 | - return $this->setAttribute('payments', $payments); |
|
| 59 | - } |
|
| 50 | + /** |
|
| 51 | + * Set the payments included in the draft |
|
| 52 | + * |
|
| 53 | + * @param array $payments |
|
| 54 | + * @return self |
|
| 55 | + */ |
|
| 56 | + public function payments(array $payments) |
|
| 57 | + { |
|
| 58 | + return $this->setAttribute('payments', $payments); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Add a payment to the draft |
|
| 63 | - * |
|
| 64 | - * @param array $payment |
|
| 65 | - * @return self |
|
| 66 | - */ |
|
| 67 | - public function addPayment(array $payment) |
|
| 68 | - { |
|
| 69 | - return $this->payments(array_merge($this->payments ?? [], $payment)); |
|
| 70 | - } |
|
| 61 | + /** |
|
| 62 | + * Add a payment to the draft |
|
| 63 | + * |
|
| 64 | + * @param array $payment |
|
| 65 | + * @return self |
|
| 66 | + */ |
|
| 67 | + public function addPayment(array $payment) |
|
| 68 | + { |
|
| 69 | + return $this->payments(array_merge($this->payments ?? [], $payment)); |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -4,118 +4,118 @@ |
||
| 4 | 4 | |
| 5 | 5 | class PaymentBuilder extends Builder |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * The ID of the account to pay from |
|
| 9 | - * |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - public $account_id; |
|
| 7 | + /** |
|
| 8 | + * The ID of the account to pay from |
|
| 9 | + * |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + public $account_id; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * The receiving party |
|
| 16 | - * |
|
| 17 | - * @var array |
|
| 18 | - */ |
|
| 19 | - public $receiver; |
|
| 14 | + /** |
|
| 15 | + * The receiving party |
|
| 16 | + * |
|
| 17 | + * @var array |
|
| 18 | + */ |
|
| 19 | + public $receiver; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The payment amount |
|
| 23 | - * |
|
| 24 | - * @var float |
|
| 25 | - */ |
|
| 26 | - public $amount; |
|
| 21 | + /** |
|
| 22 | + * The payment amount |
|
| 23 | + * |
|
| 24 | + * @var float |
|
| 25 | + */ |
|
| 26 | + public $amount; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * The payment currency |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public $currency; |
|
| 28 | + /** |
|
| 29 | + * The payment currency |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public $currency; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * An optional payment reference |
|
| 37 | - * |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - public $reference; |
|
| 35 | + /** |
|
| 36 | + * An optional payment reference |
|
| 37 | + * |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + public $reference; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * An optional date to schedule the payment |
|
| 44 | - * |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - public $schedule_for; |
|
| 42 | + /** |
|
| 43 | + * An optional date to schedule the payment |
|
| 44 | + * |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + public $schedule_for; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Set the outgoing account ID |
|
| 51 | - * |
|
| 52 | - * @param string $accountId the ID of the account to pay from |
|
| 53 | - * @return self |
|
| 54 | - */ |
|
| 55 | - public function account(string $accountId) |
|
| 56 | - { |
|
| 57 | - return $this->setAttribute('account_id', $accountId); |
|
| 58 | - } |
|
| 49 | + /** |
|
| 50 | + * Set the outgoing account ID |
|
| 51 | + * |
|
| 52 | + * @param string $accountId the ID of the account to pay from |
|
| 53 | + * @return self |
|
| 54 | + */ |
|
| 55 | + public function account(string $accountId) |
|
| 56 | + { |
|
| 57 | + return $this->setAttribute('account_id', $accountId); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Set the receiver of the payment |
|
| 62 | - * |
|
| 63 | - * @param string $counterpartyId the ID of the receiving counterparty |
|
| 64 | - * @param string $accountId the ID of the receiving counterparty's account, only for payments to business counterparties |
|
| 65 | - * @return self |
|
| 66 | - */ |
|
| 67 | - public function receiver(string $counterpartyId, string $accountId = null) |
|
| 68 | - { |
|
| 69 | - $receiver = ['counterparty_id' => $counterpartyId]; |
|
| 60 | + /** |
|
| 61 | + * Set the receiver of the payment |
|
| 62 | + * |
|
| 63 | + * @param string $counterpartyId the ID of the receiving counterparty |
|
| 64 | + * @param string $accountId the ID of the receiving counterparty's account, only for payments to business counterparties |
|
| 65 | + * @return self |
|
| 66 | + */ |
|
| 67 | + public function receiver(string $counterpartyId, string $accountId = null) |
|
| 68 | + { |
|
| 69 | + $receiver = ['counterparty_id' => $counterpartyId]; |
|
| 70 | 70 | |
| 71 | - if ($accountId) { |
|
| 72 | - $receiver['account_id'] = $accountId; |
|
| 73 | - } |
|
| 71 | + if ($accountId) { |
|
| 72 | + $receiver['account_id'] = $accountId; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return $this->setAttribute('receiver', $receiver); |
|
| 76 | - } |
|
| 75 | + return $this->setAttribute('receiver', $receiver); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Set the transaction amount |
|
| 80 | - * |
|
| 81 | - * @param float $amount |
|
| 82 | - * @return self |
|
| 83 | - */ |
|
| 84 | - public function amount(float $amount) |
|
| 85 | - { |
|
| 86 | - return $this->setAttribute('amount', $amount); |
|
| 87 | - } |
|
| 78 | + /** |
|
| 79 | + * Set the transaction amount |
|
| 80 | + * |
|
| 81 | + * @param float $amount |
|
| 82 | + * @return self |
|
| 83 | + */ |
|
| 84 | + public function amount(float $amount) |
|
| 85 | + { |
|
| 86 | + return $this->setAttribute('amount', $amount); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Set the transaction currency |
|
| 91 | - * |
|
| 92 | - * @param float $amount |
|
| 93 | - * @return self |
|
| 94 | - */ |
|
| 95 | - public function currency(string $currency) |
|
| 96 | - { |
|
| 97 | - return $this->setAttribute('currency', $currency); |
|
| 98 | - } |
|
| 89 | + /** |
|
| 90 | + * Set the transaction currency |
|
| 91 | + * |
|
| 92 | + * @param float $amount |
|
| 93 | + * @return self |
|
| 94 | + */ |
|
| 95 | + public function currency(string $currency) |
|
| 96 | + { |
|
| 97 | + return $this->setAttribute('currency', $currency); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Set an optional textual reference shown on the transaction |
|
| 102 | - * |
|
| 103 | - * @param string $reference |
|
| 104 | - * @return self |
|
| 105 | - */ |
|
| 106 | - public function reference(string $reference) |
|
| 107 | - { |
|
| 108 | - return $this->setAttribute('reference', $reference); |
|
| 109 | - } |
|
| 100 | + /** |
|
| 101 | + * Set an optional textual reference shown on the transaction |
|
| 102 | + * |
|
| 103 | + * @param string $reference |
|
| 104 | + * @return self |
|
| 105 | + */ |
|
| 106 | + public function reference(string $reference) |
|
| 107 | + { |
|
| 108 | + return $this->setAttribute('reference', $reference); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Set an optional date to schedule the payment |
|
| 113 | - * |
|
| 114 | - * @param string $date |
|
| 115 | - * @return self |
|
| 116 | - */ |
|
| 117 | - public function schedule(string $date) |
|
| 118 | - { |
|
| 119 | - return $this->setAttribute('schedule_for', $date); |
|
| 120 | - } |
|
| 111 | + /** |
|
| 112 | + * Set an optional date to schedule the payment |
|
| 113 | + * |
|
| 114 | + * @param string $date |
|
| 115 | + * @return self |
|
| 116 | + */ |
|
| 117 | + public function schedule(string $date) |
|
| 118 | + { |
|
| 119 | + return $this->setAttribute('schedule_for', $date); |
|
| 120 | + } |
|
| 121 | 121 | } |
@@ -4,375 +4,375 @@ |
||
| 4 | 4 | |
| 5 | 5 | class CounterpartyBuilder extends Builder |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * The profile type of a Revolut counterparty |
|
| 9 | - * |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - public $profile_type; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * The name of a Revolut counterparty |
|
| 16 | - * |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - public $name; |
|
| 7 | + /** |
|
| 8 | + * The profile type of a Revolut counterparty |
|
| 9 | + * |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + public $profile_type; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * The name of a Revolut counterparty |
|
| 16 | + * |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + public $name; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The phone number of a counterparty |
|
| 23 | - * |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - public $phone; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * The email address of a counterparty |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public $email; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The first and last name of an external counterparty |
|
| 37 | - * |
|
| 38 | - * @var array |
|
| 39 | - */ |
|
| 40 | - public $individual_name; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The company name of an external counterparty |
|
| 44 | - * |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - public $company_name; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * The bank country of an external counterparty |
|
| 51 | - * |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - public $bank_country; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * The currency of an external counterparty's account |
|
| 58 | - * |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 61 | - public $currency; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * The address of an external counterparty |
|
| 65 | - * |
|
| 66 | - * @var array |
|
| 67 | - */ |
|
| 68 | - public $address; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * The account number of an external counterparty |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - */ |
|
| 75 | - public $account_number; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * The routing number of an external counterparty |
|
| 79 | - * |
|
| 80 | - * @var string |
|
| 81 | - */ |
|
| 82 | - public $routing_number; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * The sort code of an external counterparty |
|
| 86 | - * |
|
| 87 | - * @var string |
|
| 88 | - */ |
|
| 89 | - public $sort_code; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * The International Bank Account Number (IBAN) of an external counterparty |
|
| 93 | - * |
|
| 94 | - * @var string |
|
| 95 | - */ |
|
| 96 | - public $iban; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * The Business Identifier Code (BIC) of an external counterparty |
|
| 100 | - * |
|
| 101 | - * @var string |
|
| 102 | - */ |
|
| 103 | - public $bic; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The 'Clave Bancaria Estandarizada' (CLABE) for an external counterparty |
|
| 107 | - * |
|
| 108 | - * @var string |
|
| 109 | - */ |
|
| 110 | - public $clabe; |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Create a 'personal' Revolut counterparty |
|
| 114 | - * |
|
| 115 | - * @param string $name The full name of the party |
|
| 116 | - * @param string $phone The phone number of the party in international format, starting with '+' |
|
| 117 | - * @return self |
|
| 118 | - */ |
|
| 119 | - public function personal(string $name, string $phone) |
|
| 120 | - { |
|
| 121 | - return $this->profileType('personal') |
|
| 122 | - ->name($name) |
|
| 123 | - ->phone($phone); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Create a 'business' Revolut counterparty |
|
| 128 | - * |
|
| 129 | - * @param string $email The email address of the party |
|
| 130 | - * @return self |
|
| 131 | - */ |
|
| 132 | - public function business(string $email) |
|
| 133 | - { |
|
| 134 | - return $this->profileType('business')->email($email); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Set the profile type of a Revolut counterparty |
|
| 140 | - * |
|
| 141 | - * @param string $type |
|
| 142 | - * @return self |
|
| 143 | - */ |
|
| 144 | - public function profileType(string $type) |
|
| 145 | - { |
|
| 146 | - return $this->setAttribute('profile_type', $type); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Set the name of a 'personal' Revolut counterparty |
|
| 151 | - * |
|
| 152 | - * @param string $name |
|
| 153 | - * @return self |
|
| 154 | - */ |
|
| 155 | - public function name(string $name) |
|
| 156 | - { |
|
| 157 | - return $this->setAttribute('name', $name); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Set the phone number of a 'personal' Revolut counterparty |
|
| 162 | - * |
|
| 163 | - * @param string $phone |
|
| 164 | - * @return self |
|
| 165 | - */ |
|
| 166 | - public function phone(string $phone) |
|
| 167 | - { |
|
| 168 | - return $this->setAttribute('phone', $phone); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Set the email address of a 'business' Revolut counterparty |
|
| 173 | - * |
|
| 174 | - * @param string $email |
|
| 175 | - * @return self |
|
| 176 | - */ |
|
| 177 | - public function email(string $email) |
|
| 178 | - { |
|
| 179 | - return $this->setAttribute('email', $email); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Set the first and last name of an external Revolut counterparty |
|
| 184 | - * |
|
| 185 | - * @param string $first The first name |
|
| 186 | - * @param string $last The last name |
|
| 187 | - * @return self |
|
| 188 | - */ |
|
| 189 | - public function individualName(string $first, string $last) |
|
| 190 | - { |
|
| 191 | - return $this->setAttribute('individual_name', [ |
|
| 192 | - 'first_name' => $first, |
|
| 193 | - 'last_name' => $last, |
|
| 194 | - ]); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * Set the name of the company of an external Revolut counterparty |
|
| 199 | - * |
|
| 200 | - * @param string $name The company name |
|
| 201 | - * @return self |
|
| 202 | - */ |
|
| 203 | - public function companyName(string $name) |
|
| 204 | - { |
|
| 205 | - return $this->setAttribute('company_name', $name); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Set the bank country of an external Revolut counterparty |
|
| 210 | - * |
|
| 211 | - * @param string $country The country in 2-letter ISO format |
|
| 212 | - * @return self |
|
| 213 | - */ |
|
| 214 | - public function bankCountry(string $country) |
|
| 215 | - { |
|
| 216 | - return $this->setAttribute('bank_country', $country); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Set the currency for an external Revolut counterparty's account |
|
| 221 | - * |
|
| 222 | - * @param string $currency The currency in 3-leltter ISO format |
|
| 223 | - * @return self |
|
| 224 | - */ |
|
| 225 | - public function currency(string $currency) |
|
| 226 | - { |
|
| 227 | - return $this->setAttribute('currency', $currency); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Set the first line of the address for an external Revolut counterparty |
|
| 232 | - * |
|
| 233 | - * @param string $streetLine1 |
|
| 234 | - * @return self |
|
| 235 | - */ |
|
| 236 | - public function streetLine1(string $streetLine1) |
|
| 237 | - { |
|
| 238 | - return $this->address(['street_line_1' => $streetLine1]); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Set the second line of the address for an external Revolut counterparty |
|
| 243 | - * |
|
| 244 | - * @param string $streetLine1 |
|
| 245 | - * @return self |
|
| 246 | - */ |
|
| 247 | - public function streetLine2(string $streetLine2) |
|
| 248 | - { |
|
| 249 | - return $this->address(['street_line_2' => $streetLine2]); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Set the region of an external Revolut counterparty |
|
| 254 | - * |
|
| 255 | - * @param string $region |
|
| 256 | - * @return self |
|
| 257 | - */ |
|
| 258 | - public function region(string $region) |
|
| 259 | - { |
|
| 260 | - return $this->address(['region' => $region]); |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Set the city of an external Revolut counterparty |
|
| 265 | - * |
|
| 266 | - * @param string $city |
|
| 267 | - * @return self |
|
| 268 | - */ |
|
| 269 | - public function city(string $city) |
|
| 270 | - { |
|
| 271 | - return $this->address(['city' => $city]); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Set the country of an external Revolut counterparty |
|
| 276 | - * |
|
| 277 | - * @param string $country The country in 2-letter ISO format |
|
| 278 | - * @return self |
|
| 279 | - */ |
|
| 280 | - public function country(string $country) |
|
| 281 | - { |
|
| 282 | - return $this->address(['country' => $country]); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * Set the postcode of an external Revolut counterparty |
|
| 287 | - * |
|
| 288 | - * @param string $postcode |
|
| 289 | - * @return self |
|
| 290 | - */ |
|
| 291 | - public function postcode(string $postcode) |
|
| 292 | - { |
|
| 293 | - return $this->address(['postcode' => $postcode]); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Set the address of an external Revolut counterparty |
|
| 298 | - * |
|
| 299 | - * @param array $data |
|
| 300 | - * @return self |
|
| 301 | - */ |
|
| 302 | - public function address(array $data) |
|
| 303 | - { |
|
| 304 | - return $this->setAttribute('address', array_merge($this->address ?? [], $data)); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * Set the account number of an external Revolut counterparty |
|
| 309 | - * Required for GBP, USD accounts |
|
| 310 | - * |
|
| 311 | - * @param string $accountNumber |
|
| 312 | - * @return self |
|
| 313 | - */ |
|
| 314 | - public function accountNumber(string $accountNumber) |
|
| 315 | - { |
|
| 316 | - return $this->setAttribute('account_no', $accountNumber); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * Set the routing number of an external Revolut counterparty |
|
| 321 | - * Required for USD accounts |
|
| 322 | - * |
|
| 323 | - * @param string $routingNumber |
|
| 324 | - * @return self |
|
| 325 | - */ |
|
| 326 | - public function routingNumber(string $routingNumber) |
|
| 327 | - { |
|
| 328 | - return $this->setAttribute('routing_number', $routingNumber); |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * Set the sort code of an external Revolut counterparty |
|
| 333 | - * Required for USD accounts |
|
| 334 | - * |
|
| 335 | - * @param string $sortCode |
|
| 336 | - * @return self |
|
| 337 | - */ |
|
| 338 | - public function sortCode(string $sortCode) |
|
| 339 | - { |
|
| 340 | - return $this->setAttribute('sort_code', $sortCode); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * Set the IBAN number of an external Revolut counterparty |
|
| 345 | - * Required for IBAN countries |
|
| 346 | - * |
|
| 347 | - * @param string $iban |
|
| 348 | - * @return self |
|
| 349 | - */ |
|
| 350 | - public function iban(string $iban) |
|
| 351 | - { |
|
| 352 | - return $this->setAttribute('iban', $iban); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Set the BIC/SWIFT code of an external Revolut counterparty |
|
| 357 | - * Required for SWIFT & SWIFT MX |
|
| 358 | - * |
|
| 359 | - * @param string $bic |
|
| 360 | - * @return self |
|
| 361 | - */ |
|
| 362 | - public function bic(string $bic) |
|
| 363 | - { |
|
| 364 | - return $this->setAttribute('bic', $bic); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Set the CLABE number of an external Revolut counterparty |
|
| 369 | - * Required for SWIFT MX |
|
| 370 | - * |
|
| 371 | - * @param string $clabe |
|
| 372 | - * @return self |
|
| 373 | - */ |
|
| 374 | - public function clabe(string $clabe) |
|
| 375 | - { |
|
| 376 | - return $this->setAttribute('clabe', $clabe); |
|
| 377 | - } |
|
| 21 | + /** |
|
| 22 | + * The phone number of a counterparty |
|
| 23 | + * |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + public $phone; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * The email address of a counterparty |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public $email; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The first and last name of an external counterparty |
|
| 37 | + * |
|
| 38 | + * @var array |
|
| 39 | + */ |
|
| 40 | + public $individual_name; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The company name of an external counterparty |
|
| 44 | + * |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + public $company_name; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * The bank country of an external counterparty |
|
| 51 | + * |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + public $bank_country; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * The currency of an external counterparty's account |
|
| 58 | + * |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | + public $currency; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * The address of an external counterparty |
|
| 65 | + * |
|
| 66 | + * @var array |
|
| 67 | + */ |
|
| 68 | + public $address; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The account number of an external counterparty |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + */ |
|
| 75 | + public $account_number; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * The routing number of an external counterparty |
|
| 79 | + * |
|
| 80 | + * @var string |
|
| 81 | + */ |
|
| 82 | + public $routing_number; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * The sort code of an external counterparty |
|
| 86 | + * |
|
| 87 | + * @var string |
|
| 88 | + */ |
|
| 89 | + public $sort_code; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * The International Bank Account Number (IBAN) of an external counterparty |
|
| 93 | + * |
|
| 94 | + * @var string |
|
| 95 | + */ |
|
| 96 | + public $iban; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * The Business Identifier Code (BIC) of an external counterparty |
|
| 100 | + * |
|
| 101 | + * @var string |
|
| 102 | + */ |
|
| 103 | + public $bic; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The 'Clave Bancaria Estandarizada' (CLABE) for an external counterparty |
|
| 107 | + * |
|
| 108 | + * @var string |
|
| 109 | + */ |
|
| 110 | + public $clabe; |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Create a 'personal' Revolut counterparty |
|
| 114 | + * |
|
| 115 | + * @param string $name The full name of the party |
|
| 116 | + * @param string $phone The phone number of the party in international format, starting with '+' |
|
| 117 | + * @return self |
|
| 118 | + */ |
|
| 119 | + public function personal(string $name, string $phone) |
|
| 120 | + { |
|
| 121 | + return $this->profileType('personal') |
|
| 122 | + ->name($name) |
|
| 123 | + ->phone($phone); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Create a 'business' Revolut counterparty |
|
| 128 | + * |
|
| 129 | + * @param string $email The email address of the party |
|
| 130 | + * @return self |
|
| 131 | + */ |
|
| 132 | + public function business(string $email) |
|
| 133 | + { |
|
| 134 | + return $this->profileType('business')->email($email); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Set the profile type of a Revolut counterparty |
|
| 140 | + * |
|
| 141 | + * @param string $type |
|
| 142 | + * @return self |
|
| 143 | + */ |
|
| 144 | + public function profileType(string $type) |
|
| 145 | + { |
|
| 146 | + return $this->setAttribute('profile_type', $type); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Set the name of a 'personal' Revolut counterparty |
|
| 151 | + * |
|
| 152 | + * @param string $name |
|
| 153 | + * @return self |
|
| 154 | + */ |
|
| 155 | + public function name(string $name) |
|
| 156 | + { |
|
| 157 | + return $this->setAttribute('name', $name); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Set the phone number of a 'personal' Revolut counterparty |
|
| 162 | + * |
|
| 163 | + * @param string $phone |
|
| 164 | + * @return self |
|
| 165 | + */ |
|
| 166 | + public function phone(string $phone) |
|
| 167 | + { |
|
| 168 | + return $this->setAttribute('phone', $phone); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Set the email address of a 'business' Revolut counterparty |
|
| 173 | + * |
|
| 174 | + * @param string $email |
|
| 175 | + * @return self |
|
| 176 | + */ |
|
| 177 | + public function email(string $email) |
|
| 178 | + { |
|
| 179 | + return $this->setAttribute('email', $email); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Set the first and last name of an external Revolut counterparty |
|
| 184 | + * |
|
| 185 | + * @param string $first The first name |
|
| 186 | + * @param string $last The last name |
|
| 187 | + * @return self |
|
| 188 | + */ |
|
| 189 | + public function individualName(string $first, string $last) |
|
| 190 | + { |
|
| 191 | + return $this->setAttribute('individual_name', [ |
|
| 192 | + 'first_name' => $first, |
|
| 193 | + 'last_name' => $last, |
|
| 194 | + ]); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * Set the name of the company of an external Revolut counterparty |
|
| 199 | + * |
|
| 200 | + * @param string $name The company name |
|
| 201 | + * @return self |
|
| 202 | + */ |
|
| 203 | + public function companyName(string $name) |
|
| 204 | + { |
|
| 205 | + return $this->setAttribute('company_name', $name); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Set the bank country of an external Revolut counterparty |
|
| 210 | + * |
|
| 211 | + * @param string $country The country in 2-letter ISO format |
|
| 212 | + * @return self |
|
| 213 | + */ |
|
| 214 | + public function bankCountry(string $country) |
|
| 215 | + { |
|
| 216 | + return $this->setAttribute('bank_country', $country); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Set the currency for an external Revolut counterparty's account |
|
| 221 | + * |
|
| 222 | + * @param string $currency The currency in 3-leltter ISO format |
|
| 223 | + * @return self |
|
| 224 | + */ |
|
| 225 | + public function currency(string $currency) |
|
| 226 | + { |
|
| 227 | + return $this->setAttribute('currency', $currency); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Set the first line of the address for an external Revolut counterparty |
|
| 232 | + * |
|
| 233 | + * @param string $streetLine1 |
|
| 234 | + * @return self |
|
| 235 | + */ |
|
| 236 | + public function streetLine1(string $streetLine1) |
|
| 237 | + { |
|
| 238 | + return $this->address(['street_line_1' => $streetLine1]); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Set the second line of the address for an external Revolut counterparty |
|
| 243 | + * |
|
| 244 | + * @param string $streetLine1 |
|
| 245 | + * @return self |
|
| 246 | + */ |
|
| 247 | + public function streetLine2(string $streetLine2) |
|
| 248 | + { |
|
| 249 | + return $this->address(['street_line_2' => $streetLine2]); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Set the region of an external Revolut counterparty |
|
| 254 | + * |
|
| 255 | + * @param string $region |
|
| 256 | + * @return self |
|
| 257 | + */ |
|
| 258 | + public function region(string $region) |
|
| 259 | + { |
|
| 260 | + return $this->address(['region' => $region]); |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Set the city of an external Revolut counterparty |
|
| 265 | + * |
|
| 266 | + * @param string $city |
|
| 267 | + * @return self |
|
| 268 | + */ |
|
| 269 | + public function city(string $city) |
|
| 270 | + { |
|
| 271 | + return $this->address(['city' => $city]); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Set the country of an external Revolut counterparty |
|
| 276 | + * |
|
| 277 | + * @param string $country The country in 2-letter ISO format |
|
| 278 | + * @return self |
|
| 279 | + */ |
|
| 280 | + public function country(string $country) |
|
| 281 | + { |
|
| 282 | + return $this->address(['country' => $country]); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Set the postcode of an external Revolut counterparty |
|
| 287 | + * |
|
| 288 | + * @param string $postcode |
|
| 289 | + * @return self |
|
| 290 | + */ |
|
| 291 | + public function postcode(string $postcode) |
|
| 292 | + { |
|
| 293 | + return $this->address(['postcode' => $postcode]); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Set the address of an external Revolut counterparty |
|
| 298 | + * |
|
| 299 | + * @param array $data |
|
| 300 | + * @return self |
|
| 301 | + */ |
|
| 302 | + public function address(array $data) |
|
| 303 | + { |
|
| 304 | + return $this->setAttribute('address', array_merge($this->address ?? [], $data)); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * Set the account number of an external Revolut counterparty |
|
| 309 | + * Required for GBP, USD accounts |
|
| 310 | + * |
|
| 311 | + * @param string $accountNumber |
|
| 312 | + * @return self |
|
| 313 | + */ |
|
| 314 | + public function accountNumber(string $accountNumber) |
|
| 315 | + { |
|
| 316 | + return $this->setAttribute('account_no', $accountNumber); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * Set the routing number of an external Revolut counterparty |
|
| 321 | + * Required for USD accounts |
|
| 322 | + * |
|
| 323 | + * @param string $routingNumber |
|
| 324 | + * @return self |
|
| 325 | + */ |
|
| 326 | + public function routingNumber(string $routingNumber) |
|
| 327 | + { |
|
| 328 | + return $this->setAttribute('routing_number', $routingNumber); |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * Set the sort code of an external Revolut counterparty |
|
| 333 | + * Required for USD accounts |
|
| 334 | + * |
|
| 335 | + * @param string $sortCode |
|
| 336 | + * @return self |
|
| 337 | + */ |
|
| 338 | + public function sortCode(string $sortCode) |
|
| 339 | + { |
|
| 340 | + return $this->setAttribute('sort_code', $sortCode); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * Set the IBAN number of an external Revolut counterparty |
|
| 345 | + * Required for IBAN countries |
|
| 346 | + * |
|
| 347 | + * @param string $iban |
|
| 348 | + * @return self |
|
| 349 | + */ |
|
| 350 | + public function iban(string $iban) |
|
| 351 | + { |
|
| 352 | + return $this->setAttribute('iban', $iban); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Set the BIC/SWIFT code of an external Revolut counterparty |
|
| 357 | + * Required for SWIFT & SWIFT MX |
|
| 358 | + * |
|
| 359 | + * @param string $bic |
|
| 360 | + * @return self |
|
| 361 | + */ |
|
| 362 | + public function bic(string $bic) |
|
| 363 | + { |
|
| 364 | + return $this->setAttribute('bic', $bic); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Set the CLABE number of an external Revolut counterparty |
|
| 369 | + * Required for SWIFT MX |
|
| 370 | + * |
|
| 371 | + * @param string $clabe |
|
| 372 | + * @return self |
|
| 373 | + */ |
|
| 374 | + public function clabe(string $clabe) |
|
| 375 | + { |
|
| 376 | + return $this->setAttribute('clabe', $clabe); |
|
| 377 | + } |
|
| 378 | 378 | } |