定制 ashleighsims/get-address-wrapper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ashleighsims/get-address-wrapper

Composer 安装命令:

composer require ashleighsims/get-address-wrapper

包简介

Get Address IO wrapper covering all endpoints available from the API.

README 文档

README

A simple wrapper for the GetAddress IO service. Allowing the retrieval of address information from the provided post code. as well as other services.

Installation

Before you can start using GetAddress IO you will need to register for an API key. There is a free API key that you can use for 30 days before moving onto a paid plan.

You can get an API key and find out more information here: https://getaddress.io/

Via Composer

$ composer require ashleighsims/get-address-wrapper

Laravel

If you're using this package in Laravel auto discovery has been enabled so you should be able to hit the ground running (when using Laravel 5.5 and beyond)

if you aren't using Laravel 5.5 and above you will need to manually register some bits...

Register the provider in the app.php file:

AshleighSims\GetAddressWrapper\Laravel\GetAddressWrapperServiceProvider::class

Optionally register the Facade:

'GetAddress' => AshleighSims\GetAddressWrapper\Laravel\GetAddressWrapperServiceProvider::class

Please ensure you've added the below environment variables to your .env file before starting.

Environment Variables

Add the following environment variables to your .env file.

GET_ADDRESS_BASE_URL="https://api.getaddress.io"
GET_ADDRESS_API_KEY=""
GET_ADDRESS_ADMINISTRATION_API_KEY=""
GOOGLE_PLACES_API_KEY=""

Usage

Laravel

Dependency Injection Via Controller

use AshleighSims\GetAddressWrapper\GetAddressWrapper;
...

private $getAddress;

public function __construct(GetAddressWrapper $getAddress) {
    $this->getAddress = $getAddress;
}

public function getPostcodeAddressList() {
    $response = $this->getAddress->findByPostcode()->find('SW1A 1AA');
}

...

Facade

use AshleighSims\GetAddressWrapper\Laravel\Facades\GetAddressWrapper;

...

public function getAddress() {
    $response = GetAddressWrapper::findByPostcode()->find('SW1A 1AA');
}

...

General Usage

Find

List of addresses from postcode
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->findByPostcode()->find('SW1A 1AA');

Return: Array of AshleighSims\GetAddressWrapper\Response\Address Objects

Address from postcode and building number
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->findByPostcode()->findWithNumber('SW1A 1AA', 'Buckingham Palace');

Return: Object AshleighSims\GetAddressWrapper\Response\Address

Distance

$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->distance()->between('SW1A 1AA', 'SL4 1QF');

Return: Object AshleighSims\GetAddressWrapper\Response\Distance

Autocomplete - Postcodes

$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->autoCompletePostcode()->complete('SW1A');

Return: Object AshleighSims\GetAddressWrapper\Response\GooglePlacesPostcodePrediction

Autocomplete - Places

Places
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->>autoCompletePlaces()->complete('Buckingham');

Return: Array of AshleighSims\GetAddressWrapper\Response\GooglePlacesPrediction Objects

Place Details
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->autoCompletePlaces()->findByGooglePlacesId('ChIJtV5bzSAFdkgRpwLZFPWrJgo');

Return: Object AshleighSims\GetAddressWrapper\Response\GooglePlace

Usage

Current day
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->usage()->get();

Return: Object AshleighSims\GetAddressWrapper\Response\Usage

Given date
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->usage()->getByDate('18/02/2020', 'd/m/Y');

Return: Object AshleighSims\GetAddressWrapper\Response\Usage

Date range
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->usage()->getBetween('18/02/2020', '19/02/2020', 'd/m/Y');

Return: Array of AshleighSims\GetAddressWrapper\Response\DailyUsage Objects

Private Address List

Add address
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->privateAddress()->add('SW1A 1AA', [
                                     'line1' => 'Ashleigh\'s Palace',
                                     'line2' => '',
                                     'line3' => '',
                                     'line4' => '',
                                     'locality' => '',
                                     'townOrCity' => 'London',
                                     'county' => '',
                                 ]);

Return: JSON decoded associative array

Delete address
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->privateAddress()->delete('SW1A 1AA', '1');

Return: JSON decoded associative array

Get address
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->privateAddress()->get('SW1A 1AA', '1');

Return: Object AshleighSims\GetAddressWrapper\Response\PrivateAddress

List addresses
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io');
$response = $getAddress->privateAddress()->list('SW1A 1AA');

Return: Array of AshleighSims\GetAddressWrapper\Response\PrivateAddress Objects

Change log

Please see the changelog for more information on what has changed recently.

Security

If you discover any security related issues, please email sims@ashleighsims.co.uk instead of using the issue tracker.

License

license. Please see the license file for more information.

统计信息

  • 总下载量: 561
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固