Giter Club home page Giter Club logo

auspost-api-php's Introduction

Auspost API Client Library for PHP

This library is a Guzzle-based client for integrating PHP applications with Australia Post's web services.

Documentation on how to use this library can be found in the Postage Assessment Calculation and Postcode Search and the Delivery Choices specifications.

Table of Contents

Getting Started

Register to use Australia Post services

You will need to apply for an API key if you want to use the Postage Assessment Calculator and Postcode Search services. Similarly, you will also need to apply for permission to use the [Delivery Choices] dce-registration service.

Minimum requirements

  1. PHP 5.3.10 compiled with the cURL extension
  2. cURL 7.22.0

Note: The library is likely to work with earlier versions of PHP and cURL, but they have not been tested.

Install using Composer

  1. Add fontis/auspost-api-php as a Composer dependency in your project's composer.json file:
{
    "require": {
        "fontis/auspost-api-php": "*"
    }
}
  1. Download and install Composer into the repo:
$ curl -sS https://getcomposer.org/installer | php
  1. Install the library dependencies:
$ php composer.phar install
  1. Add the library to your PHP application:
require_once 'vendor/autoload.php';

Install using Git

  1. Clone this repo to an appropriate location:
$ git clone https://github.com/fontis/auspost-api-php
  1. Download and install Composer into the repo:
$ cd auspost-api-php
$ curl -sS https://getcomposer.org/installer | php
  1. Install the library dependencies:
$ php composer.phar install
  1. Add the library to your PHP application:
require_once 'vendor/autoload.php';

Quick Example

Calculate domestic parcel postage cost

<?php
require 'vendor/autoload.php';

use Auspost\Common\Auspost;
use Auspost\Postage\Enum\ServiceCode;

// Instantiate a Postage Assessment Calculator service
$client = Auspost::factory('/path/to/config.php')->get('postage');

$result = $client->calculateDomesticParcelPostage(array(
    'from_postcode' => 3000,
    'to_postocde' => 3011,
    'length' => 10,
    'width' => 10,
    'height' => 10,
    'weight' => 10,
    'service_code' => ServiceCode::AUS_PARCEL_REGULAR
));

Contributions

This project is open source. You are encouraged to fork and submit pull requests.

Guidelines

Please ensure your code adheres to the following guidelines in order for your pull request to be accepted.

  1. Follow the PHP-FIG standards recommendations - This library is written with adherence to the PSR-0, PSR-1 and PSR-2 standard recommendations.
  2. Write unit tests - Any new functionality should include corresponding tests.
  3. Add the licence header to new files - We would appreciate having licence headers been added to the top of new files.

auspost-api-php's People

Contributors

chnorton avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.