Skip to content

Commit

Permalink
Added LinkedTransactions
Browse files Browse the repository at this point in the history
  • Loading branch information
calcinai committed Oct 26, 2015
1 parent cefb08b commit 981b2b2
Show file tree
Hide file tree
Showing 2 changed files with 332 additions and 6 deletions.
7 changes: 4 additions & 3 deletions generator/generate
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ $scrape_apis = array(
'invoices',
'items',
'journals',
'linked-transactions',
'manual-journals',
'organisation',
'overpayments',
Expand Down Expand Up @@ -417,7 +418,7 @@ foreach($scrape_apis as $scrape_api) {
}

$property = null;
foreach(preg_split('/>\s*or\s*</', $column_name) as $column_name){
foreach(preg_split('/(>\s*or\s*<|\s&\s)/', $column_name) as $column_name){
//make it into another param
$column_name = str_replace(' ', '', $column_name);
$tmp_ro = $read_only;
Expand All @@ -444,7 +445,7 @@ foreach($scrape_apis as $scrape_api) {
}

// Do some processing once we are at the last node.
if($node->getNode(0)->nodeValue === $last->getNode(0)->nodeValue) {
if($node->getNode(0)->nodeValue === $last->getNode(0)->nodeValue && $primary_model instanceof ParsedObjectInterface) {
$models = array($primary_model);
if($primary_model->getName() !== $current_model->getName()) {$models[] = $current_model;}
foreach($models as $model) {
Expand Down Expand Up @@ -485,7 +486,7 @@ foreach($apis as $api){
foreach($api->getModels() as $model){

$model_class = sprintf('\\XeroPHP\\Models\\%s', $model->getClassName(true));
if(class_exists($model_class)){
if(class_exists($model_class) && method_exists($model_class, 'getProperties')){
$property_position = 0;
/** @var XeroPHP\Remote\ObjectInterface $model_class */
foreach($model_class::getProperties() as $name => $property_meta){
Expand Down
331 changes: 328 additions & 3 deletions src/XeroPHP/Models/Accounting/LinkedTransaction.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,73 @@
<?php

namespace XeroPHP\Models\Accounting;

class LinkedTransaction {
use XeroPHP\Remote;

class LinkedTransaction extends Remote\Object
{

/**
* Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY
* invoice
*
* @property string SourceTransactionID
*/

/**
* The line item identifier from the source transaction.
*
* @property string SourceLineItemID
*/

/**
* Filter by the combination of ContactID and Status. Get all the linked transactions that have been
* assigned to a particular customer and have a particular status e.g. GET
* /LinkedTransactions?ContactID=4bb34b03-3378-4bb2-a0ed-6345abf3224e&Status=APPROVED.
*
* @property string ContactID
*/

/**
* Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC
* invoice
*
* @property string TargetTransactionID
*/

/**
* The line item identifier from the target transaction. When allocating a billable expense to a target
* transaction the TargetLineItemID is optional.
*
* @property string TargetLineItemID
*/

/**
* The Xero identifier for an Linked Transaction e.g.
* /LinkedTransactions/297c2dc5-cc47-4afd-8ec8-74990b8761e9
*
* @property string LinkedTransactionID
*/

/**
* Filter by the combination of ContactID and Status. Get all the linked transactions that have been
* assigned to a particular customer and have a particular status e.g. GET
* /LinkedTransactions?ContactID=4bb34b03-3378-4bb2-a0ed-6345abf3224e&Status=APPROVED.
*
* @property string Status
*/

/**
* This will always be BILLABLEEXPENSE. More types may be added in future.
*
* @property string Type
*/

/**
* The last modified date in UTC format
*
* @property \DateTime UpdatedDateUTC
*/


const LINKED_TRANSACTION_STATUS_DRAFT = 'DRAFT';
const LINKED_TRANSACTION_STATUS_APPROVED = 'APPROVED';
Expand All @@ -11,4 +76,264 @@ class LinkedTransaction {
const LINKED_TRANSACTION_STATUS_VOIDED = 'VOIDED';


}
/**
* Get the resource uri of the class (Contacts) etc
*
* @return string
*/
public static function getResourceURI()
{
return 'LinkedTransactions';
}


/**
* Get the root node name. Just the unqualified classname
*
* @return string
*/
public static function getRootNodeName()
{
return 'LinkedTransaction';
}


/**
* Get the guid property
*
* @return string
*/
public static function getGUIDProperty()
{
return 'LinkedTransactionID';
}


/**
* Get the stem of the API (core.xro) etc
*
* @return string|null
*/
public static function getAPIStem()
{
return Remote\URL::API_CORE;
}


/**
* Get the supported methods
*/
public static function getSupportedMethods()
{
return array(
Remote\Request::METHOD_GET,
Remote\Request::METHOD_PUT,
Remote\Request::METHOD_POST,
Remote\Request::METHOD_DELETE
);
}

/**
*
* Get the properties of the object. Indexed by constants
* [0] - Mandatory
* [1] - Type
* [2] - PHP type
* [3] - Is an Array
* [4] - Saves directly
*
* @return array
*/
public static function getProperties()
{
return array(
'SourceTransactionID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'SourceLineItemID' => array (true, self::PROPERTY_TYPE_STRING, null, false, false),
'ContactID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'TargetTransactionID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'TargetLineItemID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'LinkedTransactionID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'Status' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'Type' => array (false, self::PROPERTY_TYPE_ENUM, null, false, false),
'UpdatedDateUTC' => array (false, self::PROPERTY_TYPE_TIMESTAMP, '\\DateTime', false, false)
);
}

public static function isPageable()
{
return false;
}

/**
* @return string
*/
public function getSourceTransactionID()
{
return $this->_data['SourceTransactionID'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setSourceTransactionID($value)
{
$this->propertyUpdated('SourceTransactionID', $value);
$this->_data['SourceTransactionID'] = $value;
return $this;
}

/**
* @return string
*/
public function getSourceLineItemID()
{
return $this->_data['SourceLineItemID'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setSourceLineItemID($value)
{
$this->propertyUpdated('SourceLineItemID', $value);
$this->_data['SourceLineItemID'] = $value;
return $this;
}

/**
* @return string
*/
public function getContactID()
{
return $this->_data['ContactID'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setContactID($value)
{
$this->propertyUpdated('ContactID', $value);
$this->_data['ContactID'] = $value;
return $this;
}

/**
* @return string
*/
public function getTargetTransactionID()
{
return $this->_data['TargetTransactionID'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setTargetTransactionID($value)
{
$this->propertyUpdated('TargetTransactionID', $value);
$this->_data['TargetTransactionID'] = $value;
return $this;
}

/**
* @return string
*/
public function getTargetLineItemID()
{
return $this->_data['TargetLineItemID'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setTargetLineItemID($value)
{
$this->propertyUpdated('TargetLineItemID', $value);
$this->_data['TargetLineItemID'] = $value;
return $this;
}

/**
* @return string
*/
public function getLinkedTransactionID()
{
return $this->_data['LinkedTransactionID'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setLinkedTransactionID($value)
{
$this->propertyUpdated('LinkedTransactionID', $value);
$this->_data['LinkedTransactionID'] = $value;
return $this;
}

/**
* @return string
*/
public function getStatus()
{
return $this->_data['Status'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setStatus($value)
{
$this->propertyUpdated('Status', $value);
$this->_data['Status'] = $value;
return $this;
}

/**
* @return string
*/
public function getType()
{
return $this->_data['Type'];
}

/**
* @param string $value
* @return LinkedTransaction
*/
public function setType($value)
{
$this->propertyUpdated('Type', $value);
$this->_data['Type'] = $value;
return $this;
}

/**
* @return \DateTime
*/
public function getUpdatedDateUTC()
{
return $this->_data['UpdatedDateUTC'];
}

/**
* @param \DateTime $value
* @return LinkedTransaction
*/
public function setUpdatedDateUTC(\DateTime $value)
{
$this->propertyUpdated('UpdatedDateUTC', $value);
$this->_data['UpdatedDateUTC'] = $value;
return $this;
}


}

0 comments on commit 981b2b2

Please sign in to comment.