diff --git a/README.md b/README.md index 7619c75..05f4abf 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ For a full description of the response payload, please see the [official Plaid A ### Payment Initiation (UK only) -* `createRecipient(string $name, string $iban, Address $address): object` [[?]](https://plaid.com/docs/#payment-initiation) **Note:** See the **Entities** section for details about the `Address` entity needed for this method. +* `createRecipient(string $name, string $iban, PaymentAddress $address): object` [[?]](https://plaid.com/docs/#payment-initiation) **Note:** See the **Entities** section for details about the `PaymentAddress` entity needed for this method. * `getRecipient(string $recipient_id): object` [[?]](https://plaid.com/docs/#payment-initiation) * `listRecipients(): object` [[?]](https://plaid.com/docs/#payment-initiation) * `createPayment(string $recipient_id, string $reference, float $amount, string $currency): object` [[?]](https://plaid.com/docs/#payment-initiation) @@ -187,14 +187,14 @@ For a full description of the response payload, please see the [official Plaid A ## Entities -### Address +### PaymentAddress -The `TomorrowIdeas\Plaid\Entities\Address` entity is used to represent an address object for endpoints that require it. Currently, only the `createRecipient` method uses this entity. +The `TomorrowIdeas\Plaid\Entities\PaymentAddress` entity is used to represent an address object for the recipient of a payment request. Example: ```php -$address = new TomorrowIdeas\Plaid\Entities\Address("123 Elm St.", "Apt 1", "Anytown", "ABC 123", "GB"); +$address = new TomorrowIdeas\Plaid\Entities\PaymentAddress("123 Elm St.", "Apt 1", "Anytown", "ABC 123", "GB"); ``` ## Errors diff --git a/src/Entities/Address.php b/src/Entities/PaymentAddress.php similarity index 98% rename from src/Entities/Address.php rename to src/Entities/PaymentAddress.php index aced435..bf9d994 100644 --- a/src/Entities/Address.php +++ b/src/Entities/PaymentAddress.php @@ -2,7 +2,7 @@ namespace TomorrowIdeas\Plaid\Entities; -class Address +class PaymentAddress { /** * Street address. diff --git a/src/Plaid.php b/src/Plaid.php index 4f966ae..2ed1cf1 100644 --- a/src/Plaid.php +++ b/src/Plaid.php @@ -8,7 +8,7 @@ use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Shuttle\Shuttle; -use TomorrowIdeas\Plaid\Entities\Address; +use TomorrowIdeas\Plaid\Entities\PaymentAddress; class Plaid { @@ -819,10 +819,10 @@ public function getWebhookVerificationKey(string $key_id): object * * @param string $name * @param string $iban - * @param Address $address + * @param PaymentAddress $address * @return object */ - public function createRecipient(string $name, string $iban, Address $address): object + public function createRecipient(string $name, string $iban, PaymentAddress $address): object { $params = [ "name" => $name, @@ -879,7 +879,7 @@ public function createPayment(string $recipient_id, string $reference, float $am "recipient_id" => $recipient_id, "reference" => $reference, "amount" => [ - "value" => (float) $amount, + "value" => $amount, "currency" => $currency ] ]; diff --git a/tests/AddressEntityTest.php b/tests/PaymentAddressEntityTest.php similarity index 63% rename from tests/AddressEntityTest.php rename to tests/PaymentAddressEntityTest.php index 30d8709..d2f7987 100644 --- a/tests/AddressEntityTest.php +++ b/tests/PaymentAddressEntityTest.php @@ -2,16 +2,16 @@ namespace TomorrowIdeas\Plaid\Tests; -use TomorrowIdeas\Plaid\Entities\Address; +use TomorrowIdeas\Plaid\Entities\PaymentAddress; /** - * @covers TomorrowIdeas\Plaid\Entities\Address + * @covers TomorrowIdeas\Plaid\Entities\PaymentAddress */ -class AddressEntityTest extends TestCase +class PaymentAddressEntityTest extends TestCase { public function test_to_array_with_single_street(): void { - $address = new Address("123 Elm St", null, "Anytown", "ABC 123", "US"); + $address = new PaymentAddress("123 Elm St", null, "Anytown", "ABC 123", "US"); $this->assertEquals( [ @@ -26,7 +26,7 @@ public function test_to_array_with_single_street(): void public function test_to_array_with_additional_street(): void { - $address = new Address("123 Elm St", "Apt A", "Anytown", "ABC 123", "US"); + $address = new PaymentAddress("123 Elm St", "Apt A", "Anytown", "ABC 123", "US"); $this->assertEquals( [ diff --git a/tests/PaymentInitiationTest.php b/tests/PaymentInitiationTest.php index 04241f5..d505cc5 100644 --- a/tests/PaymentInitiationTest.php +++ b/tests/PaymentInitiationTest.php @@ -2,17 +2,17 @@ namespace TomorrowIdeas\Plaid\Tests; -use TomorrowIdeas\Plaid\Entities\Address; +use TomorrowIdeas\Plaid\Entities\PaymentAddress; /** * @covers TomorrowIdeas\Plaid\Plaid - * @covers TomorrowIdeas\Plaid\Entities\Address + * @covers TomorrowIdeas\Plaid\Entities\PaymentAddress */ class PaymentInitiationTest extends TestCase { public function test_create_recipient(): void { - $response = $this->getPlaidClient()->createRecipient("name", "iban", new Address("139 The Esplanade", null, "Weymouth", "DT4 7NR", "GB")); + $response = $this->getPlaidClient()->createRecipient("name", "iban", new PaymentAddress("139 The Esplanade", null, "Weymouth", "DT4 7NR", "GB")); $this->assertEquals("POST", $response->method); $this->assertEquals("2019-05-29", $response->version);