generated from spatie/package-skeleton-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add basic MapIt class with postcode method
- Loading branch information
1 parent
5275192
commit 6ad9af2
Showing
4 changed files
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace C6Digital\MapIt; | ||
|
||
use Illuminate\Http\Client\PendingRequest; | ||
use Illuminate\Support\Facades\Http; | ||
|
||
class MapIt | ||
{ | ||
public function __construct( | ||
protected string $key, | ||
protected string $url = 'https://mapit.mysociety.org', | ||
) {} | ||
|
||
public function postcode(string $postcode): ?array | ||
{ | ||
return $this->client()->get("/postcode/{$postcode}")->json(); | ||
} | ||
|
||
protected function client(): PendingRequest | ||
{ | ||
return Http::baseUrl($this->url) | ||
->withQueryParameters(['api_key' => $this->key]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.