spatie/bpost-address-webservice 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

spatie/bpost-address-webservice

最新稳定版本:1.1.0

Composer 安装命令:

composer require spatie/bpost-address-webservice

包简介

API wrapper for bpost's address webservice

README 文档

README

Latest Version on Packagist Build Status Quality Score StyleCI Total Downloads

The Belgian mail service, Bpost, has an API to

Create an \Spatie\BpostAddressWebservice\Address, and validate it.

$addressValidator = AddressValidator::create();

$address = Address::create([
    'streetName' => 'Samberstraat',
    'streetNumber' => '69',
    'boxNumber' => 'D',
    'postalCode' => '2060',
    'municipalityName' => 'Antwaarpe',
    'country' => 'BELGIE',
]);

$validatedAddress = $addressValidator->validate($address);

The validated address can contain errors and warnings. If it has any error or warning, we say that it has issues.

$validatedAddress->hasErrors(); // false

$validatedAddress->hasWarnings(); // true

$validatedAddress->hasIssues(); // true

An array of errors, warnings, or issues can be retrieved from the validated address.

$validatedAddress->errors(); // []

$validatedAddress->warnings()[0]->attribute(); // 'municipalityName'
$validatedAddress->warnings()[0]->message(); // 'anomaly_in_field'

$validatedAddress->issues()[0]->attribute(); // 'municipalityName'
$validatedAddress->issues()[0]->message(); // 'anomaly_in_field'

A validated addresses' attributes can be retrieved.

$validatedAddress->streetName; // 'Samberstraat'
$validatedAddress->streetNumber; // '69'
$validatedAddress->boxNumber; // ''
$validatedAddress->postalCode; // '2060'
$validatedAddress->municipalityName; // 'Antwaarpe'
$validatedAddress->country; // 'BELGIE'

$validatedAddress->toArray();
// [
//     'streetName' => 'SAMBERSTRAAT',
//     'streetNumber' => '69',
//     'boxNumber' => '',
//     'postalCode' => '2060',
//     'municipalityName' => 'ANTWERPEN',
//     'country' => 'BELGIE',
// ]

You can also validate up to 100 addresses at a time. An array of ValidatedAddresses will be returned.

$addressValidator = AddressValidator::create();

$validatedAddresses = $addressValidator->validateMany([
    Address::create([
        'streetName' => 'Samberstraat',
        'streetNumber' => '69',
        'boxNumber' => 'D',
        'postalCode' => '2060',
        'municipalityName' => 'Antwaarpe',
        'country' => 'BELGIE',
    ]),
    // ...
]);

Address webservice documentation is available on bpost.be.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/bpost-address-webservice

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 11.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-29