Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Commit 0270057

Browse files
committed
Merge pull request #5 from elliotchance/release/0.5
Release/0.5
2 parents 907925f + c305968 commit 0270057

File tree

9 files changed

+970
-749
lines changed

9 files changed

+970
-749
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ Xero API
66
[![License](https://poser.pugx.org/elliotchance/xero-api/license.svg)](https://packagist.org/packages/elliotchance/xero-api)
77
[![Build Status](https://travis-ci.org/elliotchance/xero-api.svg?branch=master)](https://travis-ci.org/elliotchance/xero-api)
88

9-
**This is the community official package since Xero is unwilling to add composer support or clean up the library.** Please add existing pull requests and issues against this repository and we can all help fix it up :)
9+
**This is the community official package since Xero is unwilling to add composer
10+
support or clean up the library.** Please add existing pull requests and issues
11+
against this repository and we can all help fix it up :)
1012

11-
Semantic versions have been created for existing releases and will be created here in the future.
13+
Semantic versions have been created for existing releases and will be created
14+
based on the same version from the original repository to keep it up to date. On
15+
top of that we have patches (i.e. `0.5.1`) between Xero releases.
16+
17+
There will be a suite of tests coming soon.
1218

1319
### Installation
1420

@@ -31,7 +37,7 @@ production environment.
3137

3238
## Requirements
3339
* PHP 5+
34-
* php\_curl extension
40+
* php\_curl extension - ensure a recent version (7.30+)
3541
* php\_openssl extension
3642

3743

_config.php

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
// API versions
4444
'core_version'=> '2.0',
4545
'payroll_version'=> '1.0',
46+
'file_version' => '1.0'
4647
);
4748

4849
if (XRO_APP_TYPE=="Private"||XRO_APP_TYPE=="Partner") {

certs/ca-bundle.crt

+717-718
Large diffs are not rendered by default.

lib/XeroOAuth.php

+9-15
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ private function prepare_method($method) {
235235
* @return void response data is stored in the class variable 'response'
236236
*/
237237
private function curlit() {
238-
$this->headers = array ();
239238
$this->request_params = array();
240239

241240

@@ -367,19 +366,6 @@ private function curlit() {
367366
$this->response ['format'] = $this->format;
368367
return $code;
369368
}
370-
function MakeRequest($endpoint, $parameters, $action, $data, $app_type, $format = "xml") {
371-
$oauthObject = new OAuthSimple ();
372-
373-
// Set some standard curl options....
374-
375-
$useragent = USER_AGENT;
376-
$useragent = isset ( $useragent ) ? USER_AGENT : 'XeroOAuth-PHP';
377-
$options [CURLOPT_USERAGENT] = $useragent;
378-
$options [CURLOPT_VERBOSE] = 1;
379-
$options [CURLOPT_RETURNTRANSFER] = 1;
380-
$options [CURLOPT_SSL_VERIFYHOST] = 0;
381-
$options [CURLOPT_SSL_VERIFYPEER] = 0;
382-
}
383369

384370
/**
385371
* Make an HTTP request using this library.
@@ -400,6 +386,7 @@ function request($method, $url, $params = array(), $xml = "", $format = 'xml') {
400386
// removed these as function parameters for now
401387
$useauth = true;
402388
$multipart = false;
389+
$this->headers = array ();
403390

404391
if (isset ( $format )) {
405392
switch ($format) {
@@ -445,7 +432,10 @@ function request($method, $url, $params = array(), $xml = "", $format = 'xml') {
445432
}
446433

447434
catch ( Exception $e ) {
448-
$errorMessage = $e->getMessage ();
435+
$errorMessage = 'XeroOAuth::request() ' . $e->getMessage ();
436+
$this->response['response'] = $errorMessage;
437+
$this->response['helper'] = $url;
438+
return $this->response;
449439
}
450440
$this->format = $format;
451441

@@ -524,6 +514,10 @@ function url($request, $api = "core") {
524514
$api_stem = "payroll.xro";
525515
$api_version = $this->config ['payroll_version'];
526516
}
517+
if ($api == "file") {
518+
$api_stem = "files.xro";
519+
$api_version = $this->config ['file_version'];
520+
}
527521
}
528522
$this->config ['host'] = $this->config ['xero_url'] . $api_stem . '/' . $api_version . '/';
529523
}

partner.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
'shared_secret' => 's',
4141
// API versions
4242
'core_version' => '2.0',
43-
'payroll_version' => '1.0'
43+
'payroll_version' => '1.0',
44+
'file_version' => '1.0'
4445
);
4546

4647
if (XRO_APP_TYPE == "Private" || XRO_APP_TYPE == "Partner") {

private.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
'shared_secret' => 'YOURSECRET',
1212
// API versions
1313
'core_version' => '2.0',
14-
'payroll_version' => '1.0'
14+
'payroll_version' => '1.0',
15+
'file_version' => '1.0'
1516
);
1617

1718
if (XRO_APP_TYPE == "Private" || XRO_APP_TYPE == "Partner") {

public.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
'shared_secret' => 'YOURSECRET',
4444
// API versions
4545
'core_version' => '2.0',
46-
'payroll_version' => '1.0'
46+
'payroll_version' => '1.0',
47+
'file_version' => '1.0'
4748
);
4849

4950
if (XRO_APP_TYPE == "Private" || XRO_APP_TYPE == "Partner") {

tests/testRunner.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ function testLinks()
77
echo '<ul>
88
<li><a href="?=1">Home</a></li>
99
<li><a href="?organisation=1">Organisation</a></li>
10+
<li><a href="?organisation=1&request=json">Organisation (JSON response)</a></li>
1011
<li><a href="?accounts=1">Accounts GET</a></li>
1112
<li><a href="?accountsfilter=1">Accounts GET - Where Type is BANK</a></li>
1213
<li><a href="?banktransactions=1">BankTransactions GET</a></li>
1314
<li><a href="?banktransactions=1&method=put">BankTransactions PUT</a></li>
1415
<li><a href="?contacts=1">Contacts GET</a></li>
1516
<li><a href="?contacts=1&method=post">Contacts POST</a></li>
1617
<li><a href="?contacts=1&method=put">Contacts PUT</a></li>
18+
<li><a href="?folders=1">Folders GET</a></li>
1719
<li><a href="?payrollemployees=1">Payroll Employees GET</a></li>
1820
<li><a href="?payruns=1">Payroll Payruns GET</a></li>
21+
<li><a href="?payrollsuperfunds=1">Payroll Superfunds GET</a></li>
22+
<li><a href="?payments=1">Payments GET</a></li>
23+
<li><a href="?payments=1&method=post">Payments POST (Delete payment)</a></li>
1924
<li><a href="?invoice=1">Invoices GET (with order by Total example)</a></li>
2025
<li><a href="?invoicesfilter=1">Invoices GET - Where Contact Name contains "Martin"</a></li>
2126
<li><a href="?invoicesmodified=1">Invoices GET - If-Modified-Since</a></li>
@@ -24,7 +29,14 @@ function testLinks()
2429
<li><a href="?invoice=1&method=post">Invoices POST</a></li>
2530
<li><a href="?invoice=attachment&method=put">Invoice attachment PUT</a></li>
2631
<li><a href="?invoice=pdf">Invoice PDF</a></li>
27-
<li><a href="?trialbalance=1">Trial Balance</a></li>';
32+
<li><a href="?items=1">Items GET</a></li>
33+
<li><a href="?items=1&method=put">Items PUT</a></li>
34+
<li><a href="?trialbalance=1">Trial Balance</a></li>
35+
<li><a href="?trackingcategories=1">Tracking Categories - GET</a></li>
36+
<li><a href="?trackingcategories=1&method=getarchived">Tracking Categories - GET (+ archived)</a></li>
37+
<li><a href="?trackingcategories=1&method=put">Tracking Categories - PUT</a></li>
38+
<li><a href="?trackingcategories=1&method=archive">Tracking Categories - ARCHIVE</a></li>
39+
<li><a href="?trackingcategories=1&method=restore">Tracking Categories - restore to active</a></li>';
2840

2941
if (XRO_APP_TYPE == 'Partner') echo '<li><a href="?refresh=1">Refresh access token</a></li>';
3042
if (XRO_APP_TYPE !== 'Private' && isset($_SESSION['access_token'])) {

0 commit comments

Comments
 (0)