Skip to content

Commit

Permalink
fixing some ENUMs and Date deserialziing
Browse files Browse the repository at this point in the history
  • Loading branch information
SidneyAllen committed Aug 26, 2019
1 parent 534adcb commit 71c910e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 39 deletions.
14 changes: 12 additions & 2 deletions lib/AccountingObjectSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,17 @@ public static function deserialize($data, $class, $httpHeaders = null)
// this graceful.
if (!empty($data)) {

// CUSTOM Date Deserializer to allow for Xero's use of .NET JSON Date format
// CUSTOM Date Deserializer to allow for Xero's use of .NET JSON Date format
$match = preg_match( '/([\d]{13})/', $data, $date );
$timestamp = $date[1]/1000;

$datetime = new \DateTime();
$datetime->setTimestamp($timestamp);

$result = $datetime->format('Y-m-d H:i:s');

return $result;
/* OLD matching
$match = preg_match('/\/Date\((\d+)([-+])(\d+)\)\//', $data, $date);
$timestamp = $date[1]/1000;
Expand All @@ -286,7 +296,7 @@ public static function deserialize($data, $class, $httpHeaders = null)
$result = $datetime->format('Y-m-d H:i:s');
return $result;

*/
//return new \DateTime($data);
} else {
return null;
Expand Down
38 changes: 19 additions & 19 deletions lib/Api/AccountingApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -6576,31 +6576,31 @@ protected function createCreditNoteHistoryRequest($xero_tenant_id, $credit_note_
* Operation createCurrency
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currencies $currencies currencies (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency currency (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Currencies
*/
public function createCurrency($xero_tenant_id, $currencies)
public function createCurrency($xero_tenant_id, $currency)
{
list($response) = $this->createCurrencyWithHttpInfo($xero_tenant_id, $currencies);
list($response) = $this->createCurrencyWithHttpInfo($xero_tenant_id, $currency);
return $response;
}

/**
* Operation createCurrencyWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currencies $currencies (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Currencies, HTTP status code, HTTP response headers (array of strings)
*/
public function createCurrencyWithHttpInfo($xero_tenant_id, $currencies)
public function createCurrencyWithHttpInfo($xero_tenant_id, $currency)
{
$request = $this->createCurrencyRequest($xero_tenant_id, $currencies);
$request = $this->createCurrencyRequest($xero_tenant_id, $currency);

try {
$options = $this->createHttpClientOption();
Expand Down Expand Up @@ -6681,14 +6681,14 @@ public function createCurrencyWithHttpInfo($xero_tenant_id, $currencies)
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currencies $currencies (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCurrencyAsync($xero_tenant_id, $currencies)
public function createCurrencyAsync($xero_tenant_id, $currency)
{
return $this->createCurrencyAsyncWithHttpInfo($xero_tenant_id, $currencies)
return $this->createCurrencyAsyncWithHttpInfo($xero_tenant_id, $currency)
->then(
function ($response) {
return $response[0];
Expand All @@ -6702,15 +6702,15 @@ function ($response) {
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currencies $currencies (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCurrencyAsyncWithHttpInfo($xero_tenant_id, $currencies)
public function createCurrencyAsyncWithHttpInfo($xero_tenant_id, $currency)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Currencies';
$request = $this->createCurrencyRequest($xero_tenant_id, $currencies);
$request = $this->createCurrencyRequest($xero_tenant_id, $currency);

return $this->client
->sendAsync($request, $this->createHttpClientOption())
Expand Down Expand Up @@ -6750,23 +6750,23 @@ function ($exception) {
* Create request for operation 'createCurrency'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currencies $currencies (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createCurrencyRequest($xero_tenant_id, $currencies)
protected function createCurrencyRequest($xero_tenant_id, $currency)
{
// verify the required parameter 'xero_tenant_id' is set
if ($xero_tenant_id === null || (is_array($xero_tenant_id) && count($xero_tenant_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $xero_tenant_id when calling createCurrency'
);
}
// verify the required parameter 'currencies' is set
if ($currencies === null || (is_array($currencies) && count($currencies) === 0)) {
// verify the required parameter 'currency' is set
if ($currency === null || (is_array($currency) && count($currency) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $currencies when calling createCurrency'
'Missing the required parameter $currency when calling createCurrency'
);
}

Expand All @@ -6785,8 +6785,8 @@ protected function createCurrencyRequest($xero_tenant_id, $currencies)

// body params
$_tempBody = null;
if (isset($currencies)) {
$_tempBody = $currencies;
if (isset($currency)) {
$_tempBody = $currency;
}

if ($multipart) {
Expand Down
44 changes: 28 additions & 16 deletions lib/Models/Accounting/Organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,14 @@ public function getModelName()
const VERSION_USONRAMP = 'USONRAMP';
const ORGANISATION_TYPE_COMPANY = 'COMPANY';
const ORGANISATION_TYPE_CHARITY = 'CHARITY';
const ORGANISATION_TYPE_CLUBSOCIETY = 'CLUBSOCIETY';
const ORGANISATION_TYPE_CLUB_OR_SOCIETY = 'CLUB_OR_SOCIETY';
const ORGANISATION_TYPE_LOOK_THROUGH_COMPANY = 'LOOK_THROUGH_COMPANY';
const ORGANISATION_TYPE_NOT_FOR_PROFIT = 'NOT_FOR_PROFIT';
const ORGANISATION_TYPE_PARTNERSHIP = 'PARTNERSHIP';
const ORGANISATION_TYPE_PRACTICE = 'PRACTICE';
const ORGANISATION_TYPE_PERSON = 'PERSON';
const ORGANISATION_TYPE_SOLETRADER = 'SOLETRADER';
const ORGANISATION_TYPE_S_CORPORATION = 'S_CORPORATION';
const ORGANISATION_TYPE_SELF_MANAGED_SUPERANNUATION_FUND = 'SELF_MANAGED_SUPERANNUATION_FUND';
const ORGANISATION_TYPE_SOLE_TRADER = 'SOLE_TRADER';
const ORGANISATION_TYPE_SUPERANNUATION_FUND = 'SUPERANNUATION_FUND';
const ORGANISATION_TYPE_TRUST = 'TRUST';
const SALES_TAX_BASIS_PAYMENTS = 'PAYMENTS';
const SALES_TAX_BASIS_INVOICE = 'INVOICE';
Expand All @@ -355,11 +358,14 @@ public function getModelName()
const SALES_TAX_PERIOD_YEARLY = 'YEARLY';
const ORGANISATION_ENTITY_TYPE_COMPANY = 'COMPANY';
const ORGANISATION_ENTITY_TYPE_CHARITY = 'CHARITY';
const ORGANISATION_ENTITY_TYPE_CLUBSOCIETY = 'CLUBSOCIETY';
const ORGANISATION_ENTITY_TYPE_CLUB_OR_SOCIETY = 'CLUB_OR_SOCIETY';
const ORGANISATION_ENTITY_TYPE_LOOK_THROUGH_COMPANY = 'LOOK_THROUGH_COMPANY';
const ORGANISATION_ENTITY_TYPE_NOT_FOR_PROFIT = 'NOT_FOR_PROFIT';
const ORGANISATION_ENTITY_TYPE_PARTNERSHIP = 'PARTNERSHIP';
const ORGANISATION_ENTITY_TYPE_PRACTICE = 'PRACTICE';
const ORGANISATION_ENTITY_TYPE_PERSON = 'PERSON';
const ORGANISATION_ENTITY_TYPE_SOLETRADER = 'SOLETRADER';
const ORGANISATION_ENTITY_TYPE_S_CORPORATION = 'S_CORPORATION';
const ORGANISATION_ENTITY_TYPE_SELF_MANAGED_SUPERANNUATION_FUND = 'SELF_MANAGED_SUPERANNUATION_FUND';
const ORGANISATION_ENTITY_TYPE_SOLE_TRADER = 'SOLE_TRADER';
const ORGANISATION_ENTITY_TYPE_SUPERANNUATION_FUND = 'SUPERANNUATION_FUND';
const ORGANISATION_ENTITY_TYPE_TRUST = 'TRUST';
const MODEL_CLASS_DEMO = 'DEMO';
const MODEL_CLASS_TRIAL = 'TRIAL';
Expand Down Expand Up @@ -408,11 +414,14 @@ public function getOrganisationTypeAllowableValues()
return [
self::ORGANISATION_TYPE_COMPANY,
self::ORGANISATION_TYPE_CHARITY,
self::ORGANISATION_TYPE_CLUBSOCIETY,
self::ORGANISATION_TYPE_CLUB_OR_SOCIETY,
self::ORGANISATION_TYPE_LOOK_THROUGH_COMPANY,
self::ORGANISATION_TYPE_NOT_FOR_PROFIT,
self::ORGANISATION_TYPE_PARTNERSHIP,
self::ORGANISATION_TYPE_PRACTICE,
self::ORGANISATION_TYPE_PERSON,
self::ORGANISATION_TYPE_SOLETRADER,
self::ORGANISATION_TYPE_S_CORPORATION,
self::ORGANISATION_TYPE_SELF_MANAGED_SUPERANNUATION_FUND,
self::ORGANISATION_TYPE_SOLE_TRADER,
self::ORGANISATION_TYPE_SUPERANNUATION_FUND,
self::ORGANISATION_TYPE_TRUST,
];
}
Expand Down Expand Up @@ -471,11 +480,14 @@ public function getOrganisationEntityTypeAllowableValues()
return [
self::ORGANISATION_ENTITY_TYPE_COMPANY,
self::ORGANISATION_ENTITY_TYPE_CHARITY,
self::ORGANISATION_ENTITY_TYPE_CLUBSOCIETY,
self::ORGANISATION_ENTITY_TYPE_CLUB_OR_SOCIETY,
self::ORGANISATION_ENTITY_TYPE_LOOK_THROUGH_COMPANY,
self::ORGANISATION_ENTITY_TYPE_NOT_FOR_PROFIT,
self::ORGANISATION_ENTITY_TYPE_PARTNERSHIP,
self::ORGANISATION_ENTITY_TYPE_PRACTICE,
self::ORGANISATION_ENTITY_TYPE_PERSON,
self::ORGANISATION_ENTITY_TYPE_SOLETRADER,
self::ORGANISATION_ENTITY_TYPE_S_CORPORATION,
self::ORGANISATION_ENTITY_TYPE_SELF_MANAGED_SUPERANNUATION_FUND,
self::ORGANISATION_ENTITY_TYPE_SOLE_TRADER,
self::ORGANISATION_ENTITY_TYPE_SUPERANNUATION_FUND,
self::ORGANISATION_ENTITY_TYPE_TRUST,
];
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Models/Accounting/Overpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public function getModelName()

const TYPE_RECEIVE_OVERPAYMENT = 'RECEIVE-OVERPAYMENT';
const TYPE_SPEND_OVERPAYMENT = 'SPEND-OVERPAYMENT';
const TYPE_AROVERPAYMENT = 'AROVERPAYMENT';
const STATUS_AUTHORISED = 'AUTHORISED';
const STATUS_PAID = 'PAID';
const STATUS_VOIDED = 'VOIDED';
Expand All @@ -261,6 +262,7 @@ public function getTypeAllowableValues()
return [
self::TYPE_RECEIVE_OVERPAYMENT,
self::TYPE_SPEND_OVERPAYMENT,
self::TYPE_AROVERPAYMENT,
];
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Models/Accounting/Receipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function getModelName()

const STATUS_DRAFT = 'DRAFT';
const STATUS_SUBMITTED = 'SUBMITTED';
const STATUS_AUTHORIZED = 'AUTHORIZED';
const STATUS_AUTHORISED = 'AUTHORISED';
const STATUS_DECLINED = 'DECLINED';


Expand All @@ -255,7 +255,7 @@ public function getStatusAllowableValues()
return [
self::STATUS_DRAFT,
self::STATUS_SUBMITTED,
self::STATUS_AUTHORIZED,
self::STATUS_AUTHORISED,
self::STATUS_DECLINED,
];
}
Expand Down

0 comments on commit 71c910e

Please sign in to comment.