2017 © Pedro Peláez
 

yii2-extension yii2-xero

An extension for using the Xero API from within Yii2

image

slightlydiff/yii2-xero

An extension for using the Xero API from within Yii2

  • Tuesday, September 13, 2016
  • by slightlydiff
  • Repository
  • 1 Watchers
  • 2 Stars
  • 111 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 4 Versions
  • 11 % Grown

The README.md

Xero API for Yii2

An extension for using the Xero API from within Yii2., (*1)

This extension is based on Xero's XeroOAuth-PHP code at https://github.com/XeroAPI/XeroOAuth-PHP, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist slightlydiff/yii2-xero "*"

or add, (*5)

"slightlydiff/yii2-xero": "*"

to the require section of your composer.json file., (*6)

Configuration

Add the following to your application conmfiguration file:, (*7)

        'xeroApi' => [
            'class' => 'slightlydiff\xero\XeroApi',
            'rsa_public_key' => '@app/config/certs/xero_publickey.cer',
            'rsa_private_key' => '@app/config/certs/xero_privatekey.pem',
            'consumer_key' => 'yourconsumerkey',
            'shared_secret' => 'yoursharedsecret',
            'useragent' => 'XeroOAuth-PHP'
        ],

modifying the above for your own Xero consumer key, shared secret and the path to you public / private key pair., (*8)

Usage

For a GET request: - The first parameter is the only required parameter and must be 'GET', 'POST', 'PUT' or 'DELETE' - The second parameter can be FALSE or a string ID if you want to get a single record by ID - The third parameter can be a date/time, in any format, if you want to fetch all records modified since that date - The fourth parameter can be an array of filters as described at https://developer.xero.com/documentation/getting-started/http-requests-and-responses/. This allows you to filter the query and order the returned data., (*9)

All parameters are optional except the first. If not parameters are passed then all records of the requested type will be returned, (*10)

For a POST or PUT request: - The first parameter must be the method, as above, and the second param must be a multidimensional array of the data being passed as in the examples below., (*11)

To create a contact see https://developer.xero.com/documentation/api/contacts/ for the format and apply as follows:, (*12)

$new_contact = array(
    array(
        "Name" => "Joe Bloggs",
        "FirstName" => "Joe",
        "LastName" => "Bloggs",
        "Addresses" => array(
            "Address" => array(
                array(
                    "AddressType" => "POSTAL",
                    "AddressLine1" => "123 Anystreet",
                    "City" => "Anytown",
                    "PostalCode" => "1234"
                ),
                array(
                    "AddressType" => "STREET",
                    "AddressLine1" => "123 Anystreet",
                    "City" => "Anytown",
                    "PostalCode" => "1234"
                )
            )
        )
    )
);
$result = $xero->Contacts('POST', $new_invoice);

To create a invoice or credit note see https://developer.xero.com/documentation/api/invoices/ for the format and apply as follows:, (*13)

$new_invoice = array(
    array(
        "Type"=>"ACCREC",
        "Contact" => array(
            "ContactID" => "[contact id]"
        ),
        "Date" => "2016-08-01",
        "DueDate" => "2016-08-30",
        "Status" => "SUBMITTED",
        "LineAmountTypes" => "Exclusive",
        "LineItems"=> array(
            "LineItem" => array(
                array(
                    "Description" => "Some product description",
                    "Quantity" => "1.0000",
                    "UnitAmount" => "123.00",
                    "AccountCode" => "200"
                )
            )
        )
    )
);
$result = $xero->Invoices('POST', $new_invoice);

To create a payment see https://developer.xero.com/documentation/api/payments/ for the format and apply as follows:, (*14)

$new_payment = array(
    array(
        "Invoice" => array(
            "InvoiceNumber" => "INV-1234"
        ),
        "Account" => array(
            "Code" => "[account code]"
        ),
        "Date" => "2016-08-30",
        "Amount"=>"123.00",
    )
);
$result = $xero->Payments('POST', $new_payment);

To get details of an account with the name "Joe Bloggs", (*15)

$result = $xero->Accounts('GET', false, false, array("Name"=>"Joe Bloggs") );

See https://developer.xero.com/documentation/api/accounts/ for a list of all parameters., (*16)

To get details of all contacts, (*17)

$result = $xero->Contacts;

To get details of all contacts modified in the last 24 hours, (*18)

$result = $xero->Contacts('GET', false, gmdate("M d Y H:i:s", (time() - (1 * 24 * 60 * 60))), false);

To get details of a contact by ID, (*19)

$result = $xero->Contacts('GET', 'contact id here', false, false);

To get details of all contacts whos name contains "Bloggs" and order the results by Name, (*20)

$result = $xero->Contacts('GET', false, false, ['where' => 'Name.Contains("Bloggs")', 'order' => 'Name DESC']);

The Versions

13/09 2016

dev-master

9999999-dev

An extension for using the Xero API from within Yii2

  Sources   Download

Apache-2.0

The Requires

 

api extension yii2 xero

13/09 2016

v1.0.2

1.0.2.0

An extension for using the Xero API from within Yii2

  Sources   Download

Apache-2.0

The Requires

 

api extension yii2 xero

07/09 2016

v1.0.1

1.0.1.0

An extension for using the Xero API from within Yii2

  Sources   Download

Apache-2.0

The Requires

 

api extension yii2 xero

23/08 2016

v1.0.0

1.0.0.0

An extension for using the Xero API from within Yii2

  Sources   Download

Apache-2.0

The Requires

 

api extension yii2 xero