From bbe3bb452b5d3414fec3b9cde437ddc5206a96b1 Mon Sep 17 00:00:00 2001 From: Craig Potter Date: Mon, 15 May 2023 22:52:55 +0100 Subject: [PATCH] wip --- .github/FUNDING | 1 - .github/README.md | 43 +++++++++++++++++++++++++++++++++++++--- src/DataObjects/Firm.php | 2 +- 3 files changed, 41 insertions(+), 5 deletions(-) delete mode 100644 .github/FUNDING diff --git a/.github/FUNDING b/.github/FUNDING deleted file mode 100644 index 9640ec0..0000000 --- a/.github/FUNDING +++ /dev/null @@ -1 +0,0 @@ -ko_fi: craigpotter diff --git a/.github/README.md b/.github/README.md index a04c2e0..bf82fab 100644 --- a/.github/README.md +++ b/.github/README.md @@ -101,8 +101,8 @@ $fca = new Fca('my.email@dev.test', 'my-api-key'); $paginatedData = $fa->firm(12345)->individuals(); // Returns a Saloon response object -$paginatedData->getTotalPages(); // Returns the total number of pages -$paginatedData->getTotalResults(); // Returns the total number of results +$paginatedData->totalPages(); // Returns the total number of pages +$paginatedData->totalResults(); // Returns the total number of results foreach ($paginatedData as $page) { $paginatedData->getCurrentPage(); // Returns the current page number $individuals = $page->dto(); // Returns an array of Individual DTOs for this page @@ -115,10 +115,47 @@ foreach ($paginatedData as $page) { $individual->status; // "Approved by regulator" } } - ``` +#### Get the addresses associated with a firm by FRN +This endpoint is paginated and will return a maximum of 20 results per page. +You should loop through the pages to get all results. +```php +use CraigPotter\Fca\Fca; + +// Create a new FCA instance (This is required for all requests) +use CraigPotter\Fca\Fca; + +// Create a new FCA instance (This is required for all requests) +$fca = new Fca('my.email@dev.test', 'my-api-key'); +// 12345 is the FCA firm reference number + +$paginatedData = $fa->firm(12345)->addresses(); // Returns a Saloon response object + +$paginatedData->totalPages(); // Returns the total number of pages +$paginatedData->totalResults(); // Returns the total number of results +foreach ($paginatedData as $page) { + $paginatedData->getCurrentPage(); // Returns the current page number + $addresses = $page->dto(); // Returns an array of Address DTOs for this page + $json = $page->json(); // Returns the raw JSON response for this page + + + foreach ($addresses as $address) { + $address->website; // "www.example.org" + $address->phoneNumber; // "44123456778" + $address->type; // "Principal Place of Business" + $address->contactName; // "John Smith" + $address->addressLine1; // "1 Example Street" + $address->addressLine2; // "Aberdeen" + $address->addressLine3; // "Aberdeen" + $address->addressLine4; // "Aberdeen" + $address->town; // "Aberdeen" + $address->county; // "Aberdeenshire" + $address->country; // "United Kingdom" + $address->postcode; // "AB1 2CD" + } +} ``` ## Testing diff --git a/src/DataObjects/Firm.php b/src/DataObjects/Firm.php index 68e0f83..e74ba39 100644 --- a/src/DataObjects/Firm.php +++ b/src/DataObjects/Firm.php @@ -26,7 +26,7 @@ public static function fromResponse(Response $response): self ray($data); return new static( - $data['FRN'], + (int) $data['FRN'], $data['Organisation Name'], $data['Business Type'], $data['Status'],