/home/desid573/public_html/angel/payment/xero/lib/Api
Edit: /home/desid573/public_html/angel/payment/xero/lib/Api/AccountingApi.php (2536697B)
client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
}
/**
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* Operation createAccount
*
* Allows you to create a new chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Account $account Request of type Account (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Accounts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createAccount($xero_tenant_id, $account)
{
list($response) = $this->createAccountWithHttpInfo($xero_tenant_id, $account);
return $response;
}
/**
* Operation createAccountWithHttpInfo
*
* Allows you to create a new chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Account $account Request of type Account (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Accounts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createAccountWithHttpInfo($xero_tenant_id, $account)
{
$request = $this->createAccountRequest($xero_tenant_id, $account);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Accounts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Accounts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Accounts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createAccountAsync
*
* Allows you to create a new chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Account $account Request of type Account (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAccountAsync($xero_tenant_id, $account)
{
return $this->createAccountAsyncWithHttpInfo($xero_tenant_id, $account)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createAccountAsyncWithHttpInfo
*
* Allows you to create a new chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Account $account Request of type Account (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAccountAsyncWithHttpInfo($xero_tenant_id, $account)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$request = $this->createAccountRequest($xero_tenant_id, $account);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createAccount'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Account $account Request of type Account (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createAccountRequest($xero_tenant_id, $account)
{
// 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 createAccount'
);
}
// verify the required parameter 'account' is set
if ($account === null || (is_array($account) && count($account) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account when calling createAccount'
);
}
$resourcePath = '/Accounts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($account)) {
$_tempBody = $account;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createAccountAttachmentByFileName
*
* Allows you to create Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createAccountAttachmentByFileName($xero_tenant_id, $account_id, $file_name, $body)
{
list($response) = $this->createAccountAttachmentByFileNameWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body);
return $response;
}
/**
* Operation createAccountAttachmentByFileNameWithHttpInfo
*
* Allows you to create Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createAccountAttachmentByFileNameWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body)
{
$request = $this->createAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createAccountAttachmentByFileNameAsync
*
* Allows you to create Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAccountAttachmentByFileNameAsync($xero_tenant_id, $account_id, $file_name, $body)
{
return $this->createAccountAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createAccountAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to create Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createAccountAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createAccountAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $body)
{
// 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 createAccountAttachmentByFileName'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling createAccountAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createAccountAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createAccountAttachmentByFileName'
);
}
$resourcePath = '/Accounts/{AccountID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBankTransaction
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransaction $bank_transaction bank_transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBankTransaction($xero_tenant_id, $bank_transaction)
{
list($response) = $this->createBankTransactionWithHttpInfo($xero_tenant_id, $bank_transaction);
return $response;
}
/**
* Operation createBankTransactionWithHttpInfo
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransaction $bank_transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBankTransactionWithHttpInfo($xero_tenant_id, $bank_transaction)
{
$request = $this->createBankTransactionRequest($xero_tenant_id, $bank_transaction);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBankTransactionAsync
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransaction $bank_transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionAsync($xero_tenant_id, $bank_transaction)
{
return $this->createBankTransactionAsyncWithHttpInfo($xero_tenant_id, $bank_transaction)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBankTransactionAsyncWithHttpInfo
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransaction $bank_transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionAsyncWithHttpInfo($xero_tenant_id, $bank_transaction)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$request = $this->createBankTransactionRequest($xero_tenant_id, $bank_transaction);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBankTransaction'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransaction $bank_transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBankTransactionRequest($xero_tenant_id, $bank_transaction)
{
// 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 createBankTransaction'
);
}
// verify the required parameter 'bank_transaction' is set
if ($bank_transaction === null || (is_array($bank_transaction) && count($bank_transaction) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction when calling createBankTransaction'
);
}
$resourcePath = '/BankTransactions';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($bank_transaction)) {
$_tempBody = $bank_transaction;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBankTransactionAttachmentByFileName
*
* Allows you to createa an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBankTransactionAttachmentByFileName($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
list($response) = $this->createBankTransactionAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body);
return $response;
}
/**
* Operation createBankTransactionAttachmentByFileNameWithHttpInfo
*
* Allows you to createa an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBankTransactionAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
$request = $this->createBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBankTransactionAttachmentByFileNameAsync
*
* Allows you to createa an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionAttachmentByFileNameAsync($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
return $this->createBankTransactionAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBankTransactionAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to createa an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBankTransactionAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
// 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 createBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling createBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createBankTransactionAttachmentByFileName'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBankTransactionHistoryRecord
*
* Allows you to create history record for a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBankTransactionHistoryRecord($xero_tenant_id, $bank_transaction_id, $history_records)
{
list($response) = $this->createBankTransactionHistoryRecordWithHttpInfo($xero_tenant_id, $bank_transaction_id, $history_records);
return $response;
}
/**
* Operation createBankTransactionHistoryRecordWithHttpInfo
*
* Allows you to create history record for a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBankTransactionHistoryRecordWithHttpInfo($xero_tenant_id, $bank_transaction_id, $history_records)
{
$request = $this->createBankTransactionHistoryRecordRequest($xero_tenant_id, $bank_transaction_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBankTransactionHistoryRecordAsync
*
* Allows you to create history record for a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionHistoryRecordAsync($xero_tenant_id, $bank_transaction_id, $history_records)
{
return $this->createBankTransactionHistoryRecordAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBankTransactionHistoryRecordAsyncWithHttpInfo
*
* Allows you to create history record for a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionHistoryRecordAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createBankTransactionHistoryRecordRequest($xero_tenant_id, $bank_transaction_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBankTransactionHistoryRecord'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBankTransactionHistoryRecordRequest($xero_tenant_id, $bank_transaction_id, $history_records)
{
// 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 createBankTransactionHistoryRecord'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling createBankTransactionHistoryRecord'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createBankTransactionHistoryRecord'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBankTransactions
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions bank_transactions (required)
* @param bool $summarize_errors response format that shows validation errors for each bank transaction (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBankTransactions($xero_tenant_id, $bank_transactions, $summarize_errors = true)
{
list($response) = $this->createBankTransactionsWithHttpInfo($xero_tenant_id, $bank_transactions, $summarize_errors);
return $response;
}
/**
* Operation createBankTransactionsWithHttpInfo
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
* @param bool $summarize_errors response format that shows validation errors for each bank transaction (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBankTransactionsWithHttpInfo($xero_tenant_id, $bank_transactions, $summarize_errors = true)
{
$request = $this->createBankTransactionsRequest($xero_tenant_id, $bank_transactions, $summarize_errors);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBankTransactionsAsync
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
* @param bool $summarize_errors response format that shows validation errors for each bank transaction (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionsAsync($xero_tenant_id, $bank_transactions, $summarize_errors = true)
{
return $this->createBankTransactionsAsyncWithHttpInfo($xero_tenant_id, $bank_transactions, $summarize_errors)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBankTransactionsAsyncWithHttpInfo
*
* Allows you to create a spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
* @param bool $summarize_errors response format that shows validation errors for each bank transaction (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransactionsAsyncWithHttpInfo($xero_tenant_id, $bank_transactions, $summarize_errors = true)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$request = $this->createBankTransactionsRequest($xero_tenant_id, $bank_transactions, $summarize_errors);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBankTransactions'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
* @param bool $summarize_errors response format that shows validation errors for each bank transaction (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBankTransactionsRequest($xero_tenant_id, $bank_transactions, $summarize_errors = true)
{
// 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 createBankTransactions'
);
}
// verify the required parameter 'bank_transactions' is set
if ($bank_transactions === null || (is_array($bank_transactions) && count($bank_transactions) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transactions when calling createBankTransactions'
);
}
$resourcePath = '/BankTransactions#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($summarize_errors !== null) {
$queryParams['SummarizeErrors'] = AccountingObjectSerializer::toQueryValue($summarize_errors);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($bank_transactions)) {
$_tempBody = $bank_transactions;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBankTransfer
*
* Allows you to create a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransfers $bank_transfers bank_transfers (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransfers|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBankTransfer($xero_tenant_id, $bank_transfers)
{
list($response) = $this->createBankTransferWithHttpInfo($xero_tenant_id, $bank_transfers);
return $response;
}
/**
* Operation createBankTransferWithHttpInfo
*
* Allows you to create a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransfers $bank_transfers (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransfers|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBankTransferWithHttpInfo($xero_tenant_id, $bank_transfers)
{
$request = $this->createBankTransferRequest($xero_tenant_id, $bank_transfers);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransfers' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransfers',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBankTransferAsync
*
* Allows you to create a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransfers $bank_transfers (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransferAsync($xero_tenant_id, $bank_transfers)
{
return $this->createBankTransferAsyncWithHttpInfo($xero_tenant_id, $bank_transfers)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBankTransferAsyncWithHttpInfo
*
* Allows you to create a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransfers $bank_transfers (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransferAsyncWithHttpInfo($xero_tenant_id, $bank_transfers)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers';
$request = $this->createBankTransferRequest($xero_tenant_id, $bank_transfers);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBankTransfer'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransfers $bank_transfers (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBankTransferRequest($xero_tenant_id, $bank_transfers)
{
// 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 createBankTransfer'
);
}
// verify the required parameter 'bank_transfers' is set
if ($bank_transfers === null || (is_array($bank_transfers) && count($bank_transfers) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfers when calling createBankTransfer'
);
}
$resourcePath = '/BankTransfers';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($bank_transfers)) {
$_tempBody = $bank_transfers;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBankTransferAttachmentByFileName
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBankTransferAttachmentByFileName($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
list($response) = $this->createBankTransferAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body);
return $response;
}
/**
* Operation createBankTransferAttachmentByFileNameWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBankTransferAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
$request = $this->createBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBankTransferAttachmentByFileNameAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransferAttachmentByFileNameAsync($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
return $this->createBankTransferAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBankTransferAttachmentByFileNameAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransferAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBankTransferAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
// 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 createBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling createBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createBankTransferAttachmentByFileName'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBankTransferHistoryRecord
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBankTransferHistoryRecord($xero_tenant_id, $bank_transfer_id, $history_records)
{
list($response) = $this->createBankTransferHistoryRecordWithHttpInfo($xero_tenant_id, $bank_transfer_id, $history_records);
return $response;
}
/**
* Operation createBankTransferHistoryRecordWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBankTransferHistoryRecordWithHttpInfo($xero_tenant_id, $bank_transfer_id, $history_records)
{
$request = $this->createBankTransferHistoryRecordRequest($xero_tenant_id, $bank_transfer_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBankTransferHistoryRecordAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransferHistoryRecordAsync($xero_tenant_id, $bank_transfer_id, $history_records)
{
return $this->createBankTransferHistoryRecordAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBankTransferHistoryRecordAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBankTransferHistoryRecordAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createBankTransferHistoryRecordRequest($xero_tenant_id, $bank_transfer_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBankTransferHistoryRecord'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBankTransferHistoryRecordRequest($xero_tenant_id, $bank_transfer_id, $history_records)
{
// 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 createBankTransferHistoryRecord'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling createBankTransferHistoryRecord'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createBankTransferHistoryRecord'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBatchPayment
*
* Create one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BatchPayments $batch_payments Request of type BatchPayments containing a Payments array with one or more Payment objects (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BatchPayments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBatchPayment($xero_tenant_id, $batch_payments)
{
list($response) = $this->createBatchPaymentWithHttpInfo($xero_tenant_id, $batch_payments);
return $response;
}
/**
* Operation createBatchPaymentWithHttpInfo
*
* Create one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BatchPayments $batch_payments Request of type BatchPayments containing a Payments array with one or more Payment objects (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BatchPayments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBatchPaymentWithHttpInfo($xero_tenant_id, $batch_payments)
{
$request = $this->createBatchPaymentRequest($xero_tenant_id, $batch_payments);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BatchPayments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BatchPayments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BatchPayments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BatchPayments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBatchPaymentAsync
*
* Create one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BatchPayments $batch_payments Request of type BatchPayments containing a Payments array with one or more Payment objects (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBatchPaymentAsync($xero_tenant_id, $batch_payments)
{
return $this->createBatchPaymentAsyncWithHttpInfo($xero_tenant_id, $batch_payments)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBatchPaymentAsyncWithHttpInfo
*
* Create one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BatchPayments $batch_payments Request of type BatchPayments containing a Payments array with one or more Payment objects (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBatchPaymentAsyncWithHttpInfo($xero_tenant_id, $batch_payments)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BatchPayments';
$request = $this->createBatchPaymentRequest($xero_tenant_id, $batch_payments);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBatchPayment'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BatchPayments $batch_payments Request of type BatchPayments containing a Payments array with one or more Payment objects (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBatchPaymentRequest($xero_tenant_id, $batch_payments)
{
// 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 createBatchPayment'
);
}
// verify the required parameter 'batch_payments' is set
if ($batch_payments === null || (is_array($batch_payments) && count($batch_payments) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $batch_payments when calling createBatchPayment'
);
}
$resourcePath = '/BatchPayments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($batch_payments)) {
$_tempBody = $batch_payments;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBatchPaymentHistoryRecord
*
* Allows you to create a history record for a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBatchPaymentHistoryRecord($xero_tenant_id, $batch_payment_id, $history_records)
{
list($response) = $this->createBatchPaymentHistoryRecordWithHttpInfo($xero_tenant_id, $batch_payment_id, $history_records);
return $response;
}
/**
* Operation createBatchPaymentHistoryRecordWithHttpInfo
*
* Allows you to create a history record for a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBatchPaymentHistoryRecordWithHttpInfo($xero_tenant_id, $batch_payment_id, $history_records)
{
$request = $this->createBatchPaymentHistoryRecordRequest($xero_tenant_id, $batch_payment_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBatchPaymentHistoryRecordAsync
*
* Allows you to create a history record for a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBatchPaymentHistoryRecordAsync($xero_tenant_id, $batch_payment_id, $history_records)
{
return $this->createBatchPaymentHistoryRecordAsyncWithHttpInfo($xero_tenant_id, $batch_payment_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBatchPaymentHistoryRecordAsyncWithHttpInfo
*
* Allows you to create a history record for a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBatchPaymentHistoryRecordAsyncWithHttpInfo($xero_tenant_id, $batch_payment_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createBatchPaymentHistoryRecordRequest($xero_tenant_id, $batch_payment_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBatchPaymentHistoryRecord'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBatchPaymentHistoryRecordRequest($xero_tenant_id, $batch_payment_id, $history_records)
{
// 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 createBatchPaymentHistoryRecord'
);
}
// verify the required parameter 'batch_payment_id' is set
if ($batch_payment_id === null || (is_array($batch_payment_id) && count($batch_payment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $batch_payment_id when calling createBatchPaymentHistoryRecord'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createBatchPaymentHistoryRecord'
);
}
$resourcePath = '/BatchPayments/{BatchPaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($batch_payment_id !== null) {
$resourcePath = str_replace(
'{' . 'BatchPaymentID' . '}',
AccountingObjectSerializer::toPathValue($batch_payment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createBrandingThemePaymentServices
*
* Allow for the creation of new custom payment service for specified Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentService $payment_service payment_service (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PaymentServices|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createBrandingThemePaymentServices($xero_tenant_id, $branding_theme_id, $payment_service)
{
list($response) = $this->createBrandingThemePaymentServicesWithHttpInfo($xero_tenant_id, $branding_theme_id, $payment_service);
return $response;
}
/**
* Operation createBrandingThemePaymentServicesWithHttpInfo
*
* Allow for the creation of new custom payment service for specified Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentService $payment_service (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PaymentServices|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createBrandingThemePaymentServicesWithHttpInfo($xero_tenant_id, $branding_theme_id, $payment_service)
{
$request = $this->createBrandingThemePaymentServicesRequest($xero_tenant_id, $branding_theme_id, $payment_service);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PaymentServices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PaymentServices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createBrandingThemePaymentServicesAsync
*
* Allow for the creation of new custom payment service for specified Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentService $payment_service (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBrandingThemePaymentServicesAsync($xero_tenant_id, $branding_theme_id, $payment_service)
{
return $this->createBrandingThemePaymentServicesAsyncWithHttpInfo($xero_tenant_id, $branding_theme_id, $payment_service)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createBrandingThemePaymentServicesAsyncWithHttpInfo
*
* Allow for the creation of new custom payment service for specified Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentService $payment_service (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createBrandingThemePaymentServicesAsyncWithHttpInfo($xero_tenant_id, $branding_theme_id, $payment_service)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$request = $this->createBrandingThemePaymentServicesRequest($xero_tenant_id, $branding_theme_id, $payment_service);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createBrandingThemePaymentServices'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentService $payment_service (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createBrandingThemePaymentServicesRequest($xero_tenant_id, $branding_theme_id, $payment_service)
{
// 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 createBrandingThemePaymentServices'
);
}
// verify the required parameter 'branding_theme_id' is set
if ($branding_theme_id === null || (is_array($branding_theme_id) && count($branding_theme_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $branding_theme_id when calling createBrandingThemePaymentServices'
);
}
// verify the required parameter 'payment_service' is set
if ($payment_service === null || (is_array($payment_service) && count($payment_service) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payment_service when calling createBrandingThemePaymentServices'
);
}
$resourcePath = '/BrandingThemes/{BrandingThemeID}/PaymentServices';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($branding_theme_id !== null) {
$resourcePath = str_replace(
'{' . 'BrandingThemeID' . '}',
AccountingObjectSerializer::toPathValue($branding_theme_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($payment_service)) {
$_tempBody = $payment_service;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contact $contact contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createContact($xero_tenant_id, $contact)
{
list($response) = $this->createContactWithHttpInfo($xero_tenant_id, $contact);
return $response;
}
/**
* Operation createContactWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contact $contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createContactWithHttpInfo($xero_tenant_id, $contact)
{
$request = $this->createContactRequest($xero_tenant_id, $contact);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Contacts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Contacts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Contacts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createContactAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contact $contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactAsync($xero_tenant_id, $contact)
{
return $this->createContactAsyncWithHttpInfo($xero_tenant_id, $contact)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createContactAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contact $contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactAsyncWithHttpInfo($xero_tenant_id, $contact)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$request = $this->createContactRequest($xero_tenant_id, $contact);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createContact'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contact $contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createContactRequest($xero_tenant_id, $contact)
{
// 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 createContact'
);
}
// verify the required parameter 'contact' is set
if ($contact === null || (is_array($contact) && count($contact) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact when calling createContact'
);
}
$resourcePath = '/Contacts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($contact)) {
$_tempBody = $contact;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createContactAttachmentByFileName
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createContactAttachmentByFileName($xero_tenant_id, $contact_id, $file_name, $body)
{
list($response) = $this->createContactAttachmentByFileNameWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body);
return $response;
}
/**
* Operation createContactAttachmentByFileNameWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createContactAttachmentByFileNameWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body)
{
$request = $this->createContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createContactAttachmentByFileNameAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactAttachmentByFileNameAsync($xero_tenant_id, $contact_id, $file_name, $body)
{
return $this->createContactAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createContactAttachmentByFileNameAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createContactAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $body)
{
// 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 createContactAttachmentByFileName'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling createContactAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createContactAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createContactAttachmentByFileName'
);
}
$resourcePath = '/Contacts/{ContactID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createContactGroup
*
* Allows you to create a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of contact groups with names specified (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ContactGroups|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createContactGroup($xero_tenant_id, $contact_groups)
{
list($response) = $this->createContactGroupWithHttpInfo($xero_tenant_id, $contact_groups);
return $response;
}
/**
* Operation createContactGroupWithHttpInfo
*
* Allows you to create a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of contact groups with names specified (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ContactGroups|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createContactGroupWithHttpInfo($xero_tenant_id, $contact_groups)
{
$request = $this->createContactGroupRequest($xero_tenant_id, $contact_groups);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ContactGroups' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ContactGroups',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createContactGroupAsync
*
* Allows you to create a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of contact groups with names specified (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactGroupAsync($xero_tenant_id, $contact_groups)
{
return $this->createContactGroupAsyncWithHttpInfo($xero_tenant_id, $contact_groups)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createContactGroupAsyncWithHttpInfo
*
* Allows you to create a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of contact groups with names specified (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactGroupAsyncWithHttpInfo($xero_tenant_id, $contact_groups)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$request = $this->createContactGroupRequest($xero_tenant_id, $contact_groups);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createContactGroup'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of contact groups with names specified (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createContactGroupRequest($xero_tenant_id, $contact_groups)
{
// 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 createContactGroup'
);
}
// verify the required parameter 'contact_groups' is set
if ($contact_groups === null || (is_array($contact_groups) && count($contact_groups) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_groups when calling createContactGroup'
);
}
$resourcePath = '/ContactGroups';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($contact_groups)) {
$_tempBody = $contact_groups;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createContactGroupContacts
*
* Allows you to add Contacts to a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of contacts with ContactID to be added to ContactGroup (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createContactGroupContacts($xero_tenant_id, $contact_group_id, $contacts)
{
list($response) = $this->createContactGroupContactsWithHttpInfo($xero_tenant_id, $contact_group_id, $contacts);
return $response;
}
/**
* Operation createContactGroupContactsWithHttpInfo
*
* Allows you to add Contacts to a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of contacts with ContactID to be added to ContactGroup (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createContactGroupContactsWithHttpInfo($xero_tenant_id, $contact_group_id, $contacts)
{
$request = $this->createContactGroupContactsRequest($xero_tenant_id, $contact_group_id, $contacts);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Contacts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Contacts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Contacts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createContactGroupContactsAsync
*
* Allows you to add Contacts to a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of contacts with ContactID to be added to ContactGroup (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactGroupContactsAsync($xero_tenant_id, $contact_group_id, $contacts)
{
return $this->createContactGroupContactsAsyncWithHttpInfo($xero_tenant_id, $contact_group_id, $contacts)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createContactGroupContactsAsyncWithHttpInfo
*
* Allows you to add Contacts to a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of contacts with ContactID to be added to ContactGroup (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactGroupContactsAsyncWithHttpInfo($xero_tenant_id, $contact_group_id, $contacts)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$request = $this->createContactGroupContactsRequest($xero_tenant_id, $contact_group_id, $contacts);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createContactGroupContacts'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of contacts with ContactID to be added to ContactGroup (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createContactGroupContactsRequest($xero_tenant_id, $contact_group_id, $contacts)
{
// 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 createContactGroupContacts'
);
}
// verify the required parameter 'contact_group_id' is set
if ($contact_group_id === null || (is_array($contact_group_id) && count($contact_group_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_group_id when calling createContactGroupContacts'
);
}
// verify the required parameter 'contacts' is set
if ($contacts === null || (is_array($contacts) && count($contacts) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contacts when calling createContactGroupContacts'
);
}
$resourcePath = '/ContactGroups/{ContactGroupID}/Contacts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_group_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactGroupID' . '}',
AccountingObjectSerializer::toPathValue($contact_group_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($contacts)) {
$_tempBody = $contacts;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createContactHistory
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createContactHistory($xero_tenant_id, $contact_id, $history_records)
{
list($response) = $this->createContactHistoryWithHttpInfo($xero_tenant_id, $contact_id, $history_records);
return $response;
}
/**
* Operation createContactHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createContactHistoryWithHttpInfo($xero_tenant_id, $contact_id, $history_records)
{
$request = $this->createContactHistoryRequest($xero_tenant_id, $contact_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createContactHistoryAsync
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactHistoryAsync($xero_tenant_id, $contact_id, $history_records)
{
return $this->createContactHistoryAsyncWithHttpInfo($xero_tenant_id, $contact_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createContactHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactHistoryAsyncWithHttpInfo($xero_tenant_id, $contact_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createContactHistoryRequest($xero_tenant_id, $contact_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createContactHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createContactHistoryRequest($xero_tenant_id, $contact_id, $history_records)
{
// 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 createContactHistory'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling createContactHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createContactHistory'
);
}
$resourcePath = '/Contacts/{ContactID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createContacts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts contacts (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createContacts($xero_tenant_id, $contacts)
{
list($response) = $this->createContactsWithHttpInfo($xero_tenant_id, $contacts);
return $response;
}
/**
* Operation createContactsWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createContactsWithHttpInfo($xero_tenant_id, $contacts)
{
$request = $this->createContactsRequest($xero_tenant_id, $contacts);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Contacts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Contacts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Contacts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createContactsAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactsAsync($xero_tenant_id, $contacts)
{
return $this->createContactsAsyncWithHttpInfo($xero_tenant_id, $contacts)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createContactsAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createContactsAsyncWithHttpInfo($xero_tenant_id, $contacts)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$request = $this->createContactsRequest($xero_tenant_id, $contacts);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createContacts'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createContactsRequest($xero_tenant_id, $contacts)
{
// 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 createContacts'
);
}
// verify the required parameter 'contacts' is set
if ($contacts === null || (is_array($contacts) && count($contacts) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contacts when calling createContacts'
);
}
$resourcePath = '/Contacts#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($contacts)) {
$_tempBody = $contacts;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createCreditNote
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNote $credit_note an array of Credit Notes with a single CreditNote object. (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\CreditNotes|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createCreditNote($xero_tenant_id, $credit_note)
{
list($response) = $this->createCreditNoteWithHttpInfo($xero_tenant_id, $credit_note);
return $response;
}
/**
* Operation createCreditNoteWithHttpInfo
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNote $credit_note an array of Credit Notes with a single CreditNote object. (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\CreditNotes|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createCreditNoteWithHttpInfo($xero_tenant_id, $credit_note)
{
$request = $this->createCreditNoteRequest($xero_tenant_id, $credit_note);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\CreditNotes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\CreditNotes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createCreditNoteAsync
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNote $credit_note an array of Credit Notes with a single CreditNote object. (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteAsync($xero_tenant_id, $credit_note)
{
return $this->createCreditNoteAsyncWithHttpInfo($xero_tenant_id, $credit_note)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createCreditNoteAsyncWithHttpInfo
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNote $credit_note an array of Credit Notes with a single CreditNote object. (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteAsyncWithHttpInfo($xero_tenant_id, $credit_note)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$request = $this->createCreditNoteRequest($xero_tenant_id, $credit_note);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createCreditNote'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNote $credit_note an array of Credit Notes with a single CreditNote object. (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createCreditNoteRequest($xero_tenant_id, $credit_note)
{
// 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 createCreditNote'
);
}
// verify the required parameter 'credit_note' is set
if ($credit_note === null || (is_array($credit_note) && count($credit_note) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note when calling createCreditNote'
);
}
$resourcePath = '/CreditNotes';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($credit_note)) {
$_tempBody = $credit_note;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createCreditNoteAllocation
*
* Allows you to create Allocation on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations an array of Allocations with single Allocation object defined. (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createCreditNoteAllocation($xero_tenant_id, $credit_note_id, $allocations)
{
list($response) = $this->createCreditNoteAllocationWithHttpInfo($xero_tenant_id, $credit_note_id, $allocations);
return $response;
}
/**
* Operation createCreditNoteAllocationWithHttpInfo
*
* Allows you to create Allocation on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations an array of Allocations with single Allocation object defined. (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createCreditNoteAllocationWithHttpInfo($xero_tenant_id, $credit_note_id, $allocations)
{
$request = $this->createCreditNoteAllocationRequest($xero_tenant_id, $credit_note_id, $allocations);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Allocations' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Allocations', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Allocations',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createCreditNoteAllocationAsync
*
* Allows you to create Allocation on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations an array of Allocations with single Allocation object defined. (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteAllocationAsync($xero_tenant_id, $credit_note_id, $allocations)
{
return $this->createCreditNoteAllocationAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $allocations)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createCreditNoteAllocationAsyncWithHttpInfo
*
* Allows you to create Allocation on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations an array of Allocations with single Allocation object defined. (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteAllocationAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $allocations)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$request = $this->createCreditNoteAllocationRequest($xero_tenant_id, $credit_note_id, $allocations);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createCreditNoteAllocation'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations an array of Allocations with single Allocation object defined. (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createCreditNoteAllocationRequest($xero_tenant_id, $credit_note_id, $allocations)
{
// 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 createCreditNoteAllocation'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling createCreditNoteAllocation'
);
}
// verify the required parameter 'allocations' is set
if ($allocations === null || (is_array($allocations) && count($allocations) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $allocations when calling createCreditNoteAllocation'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/Allocations';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($allocations)) {
$_tempBody = $allocations;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createCreditNoteAttachmentByFileName
*
* Allows you to create Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createCreditNoteAttachmentByFileName($xero_tenant_id, $credit_note_id, $file_name, $body)
{
list($response) = $this->createCreditNoteAttachmentByFileNameWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body);
return $response;
}
/**
* Operation createCreditNoteAttachmentByFileNameWithHttpInfo
*
* Allows you to create Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createCreditNoteAttachmentByFileNameWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body)
{
$request = $this->createCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createCreditNoteAttachmentByFileNameAsync
*
* Allows you to create Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteAttachmentByFileNameAsync($xero_tenant_id, $credit_note_id, $file_name, $body)
{
return $this->createCreditNoteAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createCreditNoteAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to create Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createCreditNoteAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $body)
{
// 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 createCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling createCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createCreditNoteAttachmentByFileName'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createCreditNoteHistory
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createCreditNoteHistory($xero_tenant_id, $credit_note_id, $history_records)
{
list($response) = $this->createCreditNoteHistoryWithHttpInfo($xero_tenant_id, $credit_note_id, $history_records);
return $response;
}
/**
* Operation createCreditNoteHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createCreditNoteHistoryWithHttpInfo($xero_tenant_id, $credit_note_id, $history_records)
{
$request = $this->createCreditNoteHistoryRequest($xero_tenant_id, $credit_note_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createCreditNoteHistoryAsync
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteHistoryAsync($xero_tenant_id, $credit_note_id, $history_records)
{
return $this->createCreditNoteHistoryAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createCreditNoteHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNoteHistoryAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createCreditNoteHistoryRequest($xero_tenant_id, $credit_note_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createCreditNoteHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createCreditNoteHistoryRequest($xero_tenant_id, $credit_note_id, $history_records)
{
// 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 createCreditNoteHistory'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling createCreditNoteHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createCreditNoteHistory'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createCreditNotes
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes with a single CreditNote object. (required)
* @param bool $summarize_errors shows validation errors for each credit note (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\CreditNotes|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createCreditNotes($xero_tenant_id, $credit_notes, $summarize_errors = true)
{
list($response) = $this->createCreditNotesWithHttpInfo($xero_tenant_id, $credit_notes, $summarize_errors);
return $response;
}
/**
* Operation createCreditNotesWithHttpInfo
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes with a single CreditNote object. (required)
* @param bool $summarize_errors shows validation errors for each credit note (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\CreditNotes|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createCreditNotesWithHttpInfo($xero_tenant_id, $credit_notes, $summarize_errors = true)
{
$request = $this->createCreditNotesRequest($xero_tenant_id, $credit_notes, $summarize_errors);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\CreditNotes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\CreditNotes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createCreditNotesAsync
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes with a single CreditNote object. (required)
* @param bool $summarize_errors shows validation errors for each credit note (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNotesAsync($xero_tenant_id, $credit_notes, $summarize_errors = true)
{
return $this->createCreditNotesAsyncWithHttpInfo($xero_tenant_id, $credit_notes, $summarize_errors)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createCreditNotesAsyncWithHttpInfo
*
* Allows you to create a credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes with a single CreditNote object. (required)
* @param bool $summarize_errors shows validation errors for each credit note (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCreditNotesAsyncWithHttpInfo($xero_tenant_id, $credit_notes, $summarize_errors = true)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$request = $this->createCreditNotesRequest($xero_tenant_id, $credit_notes, $summarize_errors);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createCreditNotes'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes with a single CreditNote object. (required)
* @param bool $summarize_errors shows validation errors for each credit note (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createCreditNotesRequest($xero_tenant_id, $credit_notes, $summarize_errors = true)
{
// 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 createCreditNotes'
);
}
// verify the required parameter 'credit_notes' is set
if ($credit_notes === null || (is_array($credit_notes) && count($credit_notes) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_notes when calling createCreditNotes'
);
}
$resourcePath = '/CreditNotes#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($summarize_errors !== null) {
$queryParams['SummarizeErrors'] = AccountingObjectSerializer::toQueryValue($summarize_errors);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($credit_notes)) {
$_tempBody = $credit_notes;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createCurrency
*
* @param string $xero_tenant_id Xero identifier for Tenant (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, $currency)
{
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\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, $currency)
{
$request = $this->createCurrencyRequest($xero_tenant_id, $currency);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Currencies' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Currencies', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Currencies';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Currencies',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createCurrencyAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCurrencyAsync($xero_tenant_id, $currency)
{
return $this->createCurrencyAsyncWithHttpInfo($xero_tenant_id, $currency)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createCurrencyAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createCurrencyAsyncWithHttpInfo($xero_tenant_id, $currency)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Currencies';
$request = $this->createCurrencyRequest($xero_tenant_id, $currency);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createCurrency'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Currency $currency (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
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 'currency' is set
if ($currency === null || (is_array($currency) && count($currency) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $currency when calling createCurrency'
);
}
$resourcePath = '/Currencies';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($currency)) {
$_tempBody = $currency;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createEmployee
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employee $employee employee (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Employees|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createEmployee($xero_tenant_id, $employee)
{
list($response) = $this->createEmployeeWithHttpInfo($xero_tenant_id, $employee);
return $response;
}
/**
* Operation createEmployeeWithHttpInfo
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employee $employee (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Employees|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createEmployeeWithHttpInfo($xero_tenant_id, $employee)
{
$request = $this->createEmployeeRequest($xero_tenant_id, $employee);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Employees' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Employees', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Employees',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createEmployeeAsync
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employee $employee (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createEmployeeAsync($xero_tenant_id, $employee)
{
return $this->createEmployeeAsyncWithHttpInfo($xero_tenant_id, $employee)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createEmployeeAsyncWithHttpInfo
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employee $employee (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createEmployeeAsyncWithHttpInfo($xero_tenant_id, $employee)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$request = $this->createEmployeeRequest($xero_tenant_id, $employee);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createEmployee'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employee $employee (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createEmployeeRequest($xero_tenant_id, $employee)
{
// 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 createEmployee'
);
}
// verify the required parameter 'employee' is set
if ($employee === null || (is_array($employee) && count($employee) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $employee when calling createEmployee'
);
}
$resourcePath = '/Employees';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($employee)) {
$_tempBody = $employee;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createEmployees
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees employees (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Employees|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createEmployees($xero_tenant_id, $employees)
{
list($response) = $this->createEmployeesWithHttpInfo($xero_tenant_id, $employees);
return $response;
}
/**
* Operation createEmployeesWithHttpInfo
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Employees|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createEmployeesWithHttpInfo($xero_tenant_id, $employees)
{
$request = $this->createEmployeesRequest($xero_tenant_id, $employees);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Employees' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Employees', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Employees',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createEmployeesAsync
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createEmployeesAsync($xero_tenant_id, $employees)
{
return $this->createEmployeesAsyncWithHttpInfo($xero_tenant_id, $employees)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createEmployeesAsyncWithHttpInfo
*
* Allows you to create new employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createEmployeesAsyncWithHttpInfo($xero_tenant_id, $employees)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$request = $this->createEmployeesRequest($xero_tenant_id, $employees);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createEmployees'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createEmployeesRequest($xero_tenant_id, $employees)
{
// 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 createEmployees'
);
}
// verify the required parameter 'employees' is set
if ($employees === null || (is_array($employees) && count($employees) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $employees when calling createEmployees'
);
}
$resourcePath = '/Employees#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($employees)) {
$_tempBody = $employees;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createExpenseClaimHistory
*
* Allows you to create a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function createExpenseClaimHistory($xero_tenant_id, $expense_claim_id, $history_records)
{
list($response) = $this->createExpenseClaimHistoryWithHttpInfo($xero_tenant_id, $expense_claim_id, $history_records);
return $response;
}
/**
* Operation createExpenseClaimHistoryWithHttpInfo
*
* Allows you to create a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function createExpenseClaimHistoryWithHttpInfo($xero_tenant_id, $expense_claim_id, $history_records)
{
$request = $this->createExpenseClaimHistoryRequest($xero_tenant_id, $expense_claim_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createExpenseClaimHistoryAsync
*
* Allows you to create a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createExpenseClaimHistoryAsync($xero_tenant_id, $expense_claim_id, $history_records)
{
return $this->createExpenseClaimHistoryAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createExpenseClaimHistoryAsyncWithHttpInfo
*
* Allows you to create a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createExpenseClaimHistoryAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createExpenseClaimHistoryRequest($xero_tenant_id, $expense_claim_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createExpenseClaimHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createExpenseClaimHistoryRequest($xero_tenant_id, $expense_claim_id, $history_records)
{
// 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 createExpenseClaimHistory'
);
}
// verify the required parameter 'expense_claim_id' is set
if ($expense_claim_id === null || (is_array($expense_claim_id) && count($expense_claim_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $expense_claim_id when calling createExpenseClaimHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createExpenseClaimHistory'
);
}
$resourcePath = '/ExpenseClaims/{ExpenseClaimID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($expense_claim_id !== null) {
$resourcePath = str_replace(
'{' . 'ExpenseClaimID' . '}',
AccountingObjectSerializer::toPathValue($expense_claim_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createExpenseClaims
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims expense_claims (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createExpenseClaims($xero_tenant_id, $expense_claims)
{
list($response) = $this->createExpenseClaimsWithHttpInfo($xero_tenant_id, $expense_claims);
return $response;
}
/**
* Operation createExpenseClaimsWithHttpInfo
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createExpenseClaimsWithHttpInfo($xero_tenant_id, $expense_claims)
{
$request = $this->createExpenseClaimsRequest($xero_tenant_id, $expense_claims);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createExpenseClaimsAsync
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createExpenseClaimsAsync($xero_tenant_id, $expense_claims)
{
return $this->createExpenseClaimsAsyncWithHttpInfo($xero_tenant_id, $expense_claims)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createExpenseClaimsAsyncWithHttpInfo
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createExpenseClaimsAsyncWithHttpInfo($xero_tenant_id, $expense_claims)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$request = $this->createExpenseClaimsRequest($xero_tenant_id, $expense_claims);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createExpenseClaims'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createExpenseClaimsRequest($xero_tenant_id, $expense_claims)
{
// 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 createExpenseClaims'
);
}
// verify the required parameter 'expense_claims' is set
if ($expense_claims === null || (is_array($expense_claims) && count($expense_claims) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $expense_claims when calling createExpenseClaims'
);
}
$resourcePath = '/ExpenseClaims';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($expense_claims)) {
$_tempBody = $expense_claims;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createInvoice
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoice $invoice invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Invoices|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createInvoice($xero_tenant_id, $invoice)
{
list($response) = $this->createInvoiceWithHttpInfo($xero_tenant_id, $invoice);
return $response;
}
/**
* Operation createInvoiceWithHttpInfo
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoice $invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Invoices|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createInvoiceWithHttpInfo($xero_tenant_id, $invoice)
{
$request = $this->createInvoiceRequest($xero_tenant_id, $invoice);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Invoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Invoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Invoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createInvoiceAsync
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoice $invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoiceAsync($xero_tenant_id, $invoice)
{
return $this->createInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createInvoiceAsyncWithHttpInfo
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoice $invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$request = $this->createInvoiceRequest($xero_tenant_id, $invoice);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createInvoice'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoice $invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createInvoiceRequest($xero_tenant_id, $invoice)
{
// 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 createInvoice'
);
}
// verify the required parameter 'invoice' is set
if ($invoice === null || (is_array($invoice) && count($invoice) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice when calling createInvoice'
);
}
$resourcePath = '/Invoices';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($invoice)) {
$_tempBody = $invoice;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createInvoiceAttachmentByFileName
*
* Allows you to create an Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createInvoiceAttachmentByFileName($xero_tenant_id, $invoice_id, $file_name, $body)
{
list($response) = $this->createInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body);
return $response;
}
/**
* Operation createInvoiceAttachmentByFileNameWithHttpInfo
*
* Allows you to create an Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body)
{
$request = $this->createInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createInvoiceAttachmentByFileNameAsync
*
* Allows you to create an Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoiceAttachmentByFileNameAsync($xero_tenant_id, $invoice_id, $file_name, $body)
{
return $this->createInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createInvoiceAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to create an Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createInvoiceAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $body)
{
// 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 createInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling createInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createInvoiceAttachmentByFileName'
);
}
$resourcePath = '/Invoices/{InvoiceID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createInvoiceHistory
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createInvoiceHistory($xero_tenant_id, $invoice_id, $history_records)
{
list($response) = $this->createInvoiceHistoryWithHttpInfo($xero_tenant_id, $invoice_id, $history_records);
return $response;
}
/**
* Operation createInvoiceHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createInvoiceHistoryWithHttpInfo($xero_tenant_id, $invoice_id, $history_records)
{
$request = $this->createInvoiceHistoryRequest($xero_tenant_id, $invoice_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createInvoiceHistoryAsync
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoiceHistoryAsync($xero_tenant_id, $invoice_id, $history_records)
{
return $this->createInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createInvoiceHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createInvoiceHistoryRequest($xero_tenant_id, $invoice_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createInvoiceHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createInvoiceHistoryRequest($xero_tenant_id, $invoice_id, $history_records)
{
// 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 createInvoiceHistory'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling createInvoiceHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createInvoiceHistory'
);
}
$resourcePath = '/Invoices/{InvoiceID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createInvoices
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices invoices (required)
* @param bool $summarize_errors shows validation errors for each invoice (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Invoices|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createInvoices($xero_tenant_id, $invoices, $summarize_errors = true)
{
list($response) = $this->createInvoicesWithHttpInfo($xero_tenant_id, $invoices, $summarize_errors);
return $response;
}
/**
* Operation createInvoicesWithHttpInfo
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
* @param bool $summarize_errors shows validation errors for each invoice (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Invoices|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createInvoicesWithHttpInfo($xero_tenant_id, $invoices, $summarize_errors = true)
{
$request = $this->createInvoicesRequest($xero_tenant_id, $invoices, $summarize_errors);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Invoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Invoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Invoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createInvoicesAsync
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
* @param bool $summarize_errors shows validation errors for each invoice (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoicesAsync($xero_tenant_id, $invoices, $summarize_errors = true)
{
return $this->createInvoicesAsyncWithHttpInfo($xero_tenant_id, $invoices, $summarize_errors)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createInvoicesAsyncWithHttpInfo
*
* Allows you to create any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
* @param bool $summarize_errors shows validation errors for each invoice (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createInvoicesAsyncWithHttpInfo($xero_tenant_id, $invoices, $summarize_errors = true)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$request = $this->createInvoicesRequest($xero_tenant_id, $invoices, $summarize_errors);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createInvoices'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
* @param bool $summarize_errors shows validation errors for each invoice (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createInvoicesRequest($xero_tenant_id, $invoices, $summarize_errors = true)
{
// 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 createInvoices'
);
}
// verify the required parameter 'invoices' is set
if ($invoices === null || (is_array($invoices) && count($invoices) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoices when calling createInvoices'
);
}
$resourcePath = '/Invoices#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($summarize_errors !== null) {
$queryParams['SummarizeErrors'] = AccountingObjectSerializer::toQueryValue($summarize_errors);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($invoices)) {
$_tempBody = $invoices;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createItem
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Item $item item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Items|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createItem($xero_tenant_id, $item)
{
list($response) = $this->createItemWithHttpInfo($xero_tenant_id, $item);
return $response;
}
/**
* Operation createItemWithHttpInfo
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Item $item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Items|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createItemWithHttpInfo($xero_tenant_id, $item)
{
$request = $this->createItemRequest($xero_tenant_id, $item);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Items' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Items', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Items',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createItemAsync
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Item $item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createItemAsync($xero_tenant_id, $item)
{
return $this->createItemAsyncWithHttpInfo($xero_tenant_id, $item)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createItemAsyncWithHttpInfo
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Item $item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createItemAsyncWithHttpInfo($xero_tenant_id, $item)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$request = $this->createItemRequest($xero_tenant_id, $item);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createItem'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Item $item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createItemRequest($xero_tenant_id, $item)
{
// 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 createItem'
);
}
// verify the required parameter 'item' is set
if ($item === null || (is_array($item) && count($item) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $item when calling createItem'
);
}
$resourcePath = '/Items';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($item)) {
$_tempBody = $item;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createItemHistory
*
* Allows you to create a history record for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function createItemHistory($xero_tenant_id, $item_id, $history_records)
{
list($response) = $this->createItemHistoryWithHttpInfo($xero_tenant_id, $item_id, $history_records);
return $response;
}
/**
* Operation createItemHistoryWithHttpInfo
*
* Allows you to create a history record for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function createItemHistoryWithHttpInfo($xero_tenant_id, $item_id, $history_records)
{
$request = $this->createItemHistoryRequest($xero_tenant_id, $item_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createItemHistoryAsync
*
* Allows you to create a history record for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createItemHistoryAsync($xero_tenant_id, $item_id, $history_records)
{
return $this->createItemHistoryAsyncWithHttpInfo($xero_tenant_id, $item_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createItemHistoryAsyncWithHttpInfo
*
* Allows you to create a history record for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createItemHistoryAsyncWithHttpInfo($xero_tenant_id, $item_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createItemHistoryRequest($xero_tenant_id, $item_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createItemHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createItemHistoryRequest($xero_tenant_id, $item_id, $history_records)
{
// 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 createItemHistory'
);
}
// verify the required parameter 'item_id' is set
if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $item_id when calling createItemHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createItemHistory'
);
}
$resourcePath = '/Items/{ItemID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($item_id !== null) {
$resourcePath = str_replace(
'{' . 'ItemID' . '}',
AccountingObjectSerializer::toPathValue($item_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createItems
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items items (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Items|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createItems($xero_tenant_id, $items)
{
list($response) = $this->createItemsWithHttpInfo($xero_tenant_id, $items);
return $response;
}
/**
* Operation createItemsWithHttpInfo
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Items|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createItemsWithHttpInfo($xero_tenant_id, $items)
{
$request = $this->createItemsRequest($xero_tenant_id, $items);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Items' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Items', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Items',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createItemsAsync
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createItemsAsync($xero_tenant_id, $items)
{
return $this->createItemsAsyncWithHttpInfo($xero_tenant_id, $items)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createItemsAsyncWithHttpInfo
*
* Allows you to create an item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createItemsAsyncWithHttpInfo($xero_tenant_id, $items)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$request = $this->createItemsRequest($xero_tenant_id, $items);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createItems'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createItemsRequest($xero_tenant_id, $items)
{
// 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 createItems'
);
}
// verify the required parameter 'items' is set
if ($items === null || (is_array($items) && count($items) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $items when calling createItems'
);
}
$resourcePath = '/Items#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($items)) {
$_tempBody = $items;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createLinkedTransaction
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransaction $linked_transaction linked_transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createLinkedTransaction($xero_tenant_id, $linked_transaction)
{
list($response) = $this->createLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction);
return $response;
}
/**
* Operation createLinkedTransactionWithHttpInfo
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransaction $linked_transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction)
{
$request = $this->createLinkedTransactionRequest($xero_tenant_id, $linked_transaction);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createLinkedTransactionAsync
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransaction $linked_transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createLinkedTransactionAsync($xero_tenant_id, $linked_transaction)
{
return $this->createLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createLinkedTransactionAsyncWithHttpInfo
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransaction $linked_transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$request = $this->createLinkedTransactionRequest($xero_tenant_id, $linked_transaction);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createLinkedTransaction'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransaction $linked_transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createLinkedTransactionRequest($xero_tenant_id, $linked_transaction)
{
// 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 createLinkedTransaction'
);
}
// verify the required parameter 'linked_transaction' is set
if ($linked_transaction === null || (is_array($linked_transaction) && count($linked_transaction) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $linked_transaction when calling createLinkedTransaction'
);
}
$resourcePath = '/LinkedTransactions';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($linked_transaction)) {
$_tempBody = $linked_transaction;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createLinkedTransactions
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions linked_transactions (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createLinkedTransactions($xero_tenant_id, $linked_transactions)
{
list($response) = $this->createLinkedTransactionsWithHttpInfo($xero_tenant_id, $linked_transactions);
return $response;
}
/**
* Operation createLinkedTransactionsWithHttpInfo
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createLinkedTransactionsWithHttpInfo($xero_tenant_id, $linked_transactions)
{
$request = $this->createLinkedTransactionsRequest($xero_tenant_id, $linked_transactions);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createLinkedTransactionsAsync
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createLinkedTransactionsAsync($xero_tenant_id, $linked_transactions)
{
return $this->createLinkedTransactionsAsyncWithHttpInfo($xero_tenant_id, $linked_transactions)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createLinkedTransactionsAsyncWithHttpInfo
*
* Allows you to create linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createLinkedTransactionsAsyncWithHttpInfo($xero_tenant_id, $linked_transactions)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$request = $this->createLinkedTransactionsRequest($xero_tenant_id, $linked_transactions);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createLinkedTransactions'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createLinkedTransactionsRequest($xero_tenant_id, $linked_transactions)
{
// 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 createLinkedTransactions'
);
}
// verify the required parameter 'linked_transactions' is set
if ($linked_transactions === null || (is_array($linked_transactions) && count($linked_transactions) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $linked_transactions when calling createLinkedTransactions'
);
}
$resourcePath = '/LinkedTransactions#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($linked_transactions)) {
$_tempBody = $linked_transactions;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createManualJournal
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournal $manual_journal manual_journal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ManualJournals|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createManualJournal($xero_tenant_id, $manual_journal)
{
list($response) = $this->createManualJournalWithHttpInfo($xero_tenant_id, $manual_journal);
return $response;
}
/**
* Operation createManualJournalWithHttpInfo
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournal $manual_journal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ManualJournals|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createManualJournalWithHttpInfo($xero_tenant_id, $manual_journal)
{
$request = $this->createManualJournalRequest($xero_tenant_id, $manual_journal);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ManualJournals' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ManualJournals',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createManualJournalAsync
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournal $manual_journal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createManualJournalAsync($xero_tenant_id, $manual_journal)
{
return $this->createManualJournalAsyncWithHttpInfo($xero_tenant_id, $manual_journal)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createManualJournalAsyncWithHttpInfo
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournal $manual_journal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createManualJournalAsyncWithHttpInfo($xero_tenant_id, $manual_journal)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$request = $this->createManualJournalRequest($xero_tenant_id, $manual_journal);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createManualJournal'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournal $manual_journal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createManualJournalRequest($xero_tenant_id, $manual_journal)
{
// 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 createManualJournal'
);
}
// verify the required parameter 'manual_journal' is set
if ($manual_journal === null || (is_array($manual_journal) && count($manual_journal) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal when calling createManualJournal'
);
}
$resourcePath = '/ManualJournals';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($manual_journal)) {
$_tempBody = $manual_journal;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createManualJournalAttachmentByFileName
*
* Allows you to create a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createManualJournalAttachmentByFileName($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
list($response) = $this->createManualJournalAttachmentByFileNameWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body);
return $response;
}
/**
* Operation createManualJournalAttachmentByFileNameWithHttpInfo
*
* Allows you to create a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createManualJournalAttachmentByFileNameWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
$request = $this->createManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createManualJournalAttachmentByFileNameAsync
*
* Allows you to create a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createManualJournalAttachmentByFileNameAsync($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
return $this->createManualJournalAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createManualJournalAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to create a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createManualJournalAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createManualJournalAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
// 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 createManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'manual_journal_id' is set
if ($manual_journal_id === null || (is_array($manual_journal_id) && count($manual_journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal_id when calling createManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createManualJournalAttachmentByFileName'
);
}
$resourcePath = '/ManualJournals/{ManualJournalID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($manual_journal_id !== null) {
$resourcePath = str_replace(
'{' . 'ManualJournalID' . '}',
AccountingObjectSerializer::toPathValue($manual_journal_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createManualJournals
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals manual_journals (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ManualJournals|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createManualJournals($xero_tenant_id, $manual_journals)
{
list($response) = $this->createManualJournalsWithHttpInfo($xero_tenant_id, $manual_journals);
return $response;
}
/**
* Operation createManualJournalsWithHttpInfo
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ManualJournals|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createManualJournalsWithHttpInfo($xero_tenant_id, $manual_journals)
{
$request = $this->createManualJournalsRequest($xero_tenant_id, $manual_journals);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ManualJournals' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ManualJournals',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createManualJournalsAsync
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createManualJournalsAsync($xero_tenant_id, $manual_journals)
{
return $this->createManualJournalsAsyncWithHttpInfo($xero_tenant_id, $manual_journals)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createManualJournalsAsyncWithHttpInfo
*
* Allows you to create a manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createManualJournalsAsyncWithHttpInfo($xero_tenant_id, $manual_journals)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$request = $this->createManualJournalsRequest($xero_tenant_id, $manual_journals);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createManualJournals'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createManualJournalsRequest($xero_tenant_id, $manual_journals)
{
// 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 createManualJournals'
);
}
// verify the required parameter 'manual_journals' is set
if ($manual_journals === null || (is_array($manual_journals) && count($manual_journals) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journals when calling createManualJournals'
);
}
$resourcePath = '/ManualJournals#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($manual_journals)) {
$_tempBody = $manual_journals;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createOverpaymentAllocation
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocation $allocation allocation (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createOverpaymentAllocation($xero_tenant_id, $overpayment_id, $allocation)
{
list($response) = $this->createOverpaymentAllocationWithHttpInfo($xero_tenant_id, $overpayment_id, $allocation);
return $response;
}
/**
* Operation createOverpaymentAllocationWithHttpInfo
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocation $allocation (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createOverpaymentAllocationWithHttpInfo($xero_tenant_id, $overpayment_id, $allocation)
{
$request = $this->createOverpaymentAllocationRequest($xero_tenant_id, $overpayment_id, $allocation);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Allocations' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Allocations', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Allocations',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createOverpaymentAllocationAsync
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocation $allocation (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createOverpaymentAllocationAsync($xero_tenant_id, $overpayment_id, $allocation)
{
return $this->createOverpaymentAllocationAsyncWithHttpInfo($xero_tenant_id, $overpayment_id, $allocation)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createOverpaymentAllocationAsyncWithHttpInfo
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocation $allocation (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createOverpaymentAllocationAsyncWithHttpInfo($xero_tenant_id, $overpayment_id, $allocation)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$request = $this->createOverpaymentAllocationRequest($xero_tenant_id, $overpayment_id, $allocation);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createOverpaymentAllocation'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocation $allocation (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createOverpaymentAllocationRequest($xero_tenant_id, $overpayment_id, $allocation)
{
// 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 createOverpaymentAllocation'
);
}
// verify the required parameter 'overpayment_id' is set
if ($overpayment_id === null || (is_array($overpayment_id) && count($overpayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $overpayment_id when calling createOverpaymentAllocation'
);
}
// verify the required parameter 'allocation' is set
if ($allocation === null || (is_array($allocation) && count($allocation) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $allocation when calling createOverpaymentAllocation'
);
}
$resourcePath = '/Overpayments/{OverpaymentID}/Allocations';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($overpayment_id !== null) {
$resourcePath = str_replace(
'{' . 'OverpaymentID' . '}',
AccountingObjectSerializer::toPathValue($overpayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($allocation)) {
$_tempBody = $allocation;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createOverpaymentAllocations
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations allocations (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createOverpaymentAllocations($xero_tenant_id, $overpayment_id, $allocations)
{
list($response) = $this->createOverpaymentAllocationsWithHttpInfo($xero_tenant_id, $overpayment_id, $allocations);
return $response;
}
/**
* Operation createOverpaymentAllocationsWithHttpInfo
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createOverpaymentAllocationsWithHttpInfo($xero_tenant_id, $overpayment_id, $allocations)
{
$request = $this->createOverpaymentAllocationsRequest($xero_tenant_id, $overpayment_id, $allocations);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Allocations' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Allocations', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Allocations',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createOverpaymentAllocationsAsync
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createOverpaymentAllocationsAsync($xero_tenant_id, $overpayment_id, $allocations)
{
return $this->createOverpaymentAllocationsAsyncWithHttpInfo($xero_tenant_id, $overpayment_id, $allocations)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createOverpaymentAllocationsAsyncWithHttpInfo
*
* Allows you to retrieve Allocations for overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createOverpaymentAllocationsAsyncWithHttpInfo($xero_tenant_id, $overpayment_id, $allocations)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$request = $this->createOverpaymentAllocationsRequest($xero_tenant_id, $overpayment_id, $allocations);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createOverpaymentAllocations'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createOverpaymentAllocationsRequest($xero_tenant_id, $overpayment_id, $allocations)
{
// 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 createOverpaymentAllocations'
);
}
// verify the required parameter 'overpayment_id' is set
if ($overpayment_id === null || (is_array($overpayment_id) && count($overpayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $overpayment_id when calling createOverpaymentAllocations'
);
}
// verify the required parameter 'allocations' is set
if ($allocations === null || (is_array($allocations) && count($allocations) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $allocations when calling createOverpaymentAllocations'
);
}
$resourcePath = '/Overpayments/{OverpaymentID}/Allocations#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($overpayment_id !== null) {
$resourcePath = str_replace(
'{' . 'OverpaymentID' . '}',
AccountingObjectSerializer::toPathValue($overpayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($allocations)) {
$_tempBody = $allocations;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createOverpaymentHistory
*
* Allows you to create history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createOverpaymentHistory($xero_tenant_id, $overpayment_id, $history_records)
{
list($response) = $this->createOverpaymentHistoryWithHttpInfo($xero_tenant_id, $overpayment_id, $history_records);
return $response;
}
/**
* Operation createOverpaymentHistoryWithHttpInfo
*
* Allows you to create history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createOverpaymentHistoryWithHttpInfo($xero_tenant_id, $overpayment_id, $history_records)
{
$request = $this->createOverpaymentHistoryRequest($xero_tenant_id, $overpayment_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createOverpaymentHistoryAsync
*
* Allows you to create history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createOverpaymentHistoryAsync($xero_tenant_id, $overpayment_id, $history_records)
{
return $this->createOverpaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $overpayment_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createOverpaymentHistoryAsyncWithHttpInfo
*
* Allows you to create history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createOverpaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $overpayment_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createOverpaymentHistoryRequest($xero_tenant_id, $overpayment_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createOverpaymentHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createOverpaymentHistoryRequest($xero_tenant_id, $overpayment_id, $history_records)
{
// 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 createOverpaymentHistory'
);
}
// verify the required parameter 'overpayment_id' is set
if ($overpayment_id === null || (is_array($overpayment_id) && count($overpayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $overpayment_id when calling createOverpaymentHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createOverpaymentHistory'
);
}
$resourcePath = '/Overpayments/{OverpaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($overpayment_id !== null) {
$resourcePath = str_replace(
'{' . 'OverpaymentID' . '}',
AccountingObjectSerializer::toPathValue($overpayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPayment
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payment $payment payment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Payments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPayment($xero_tenant_id, $payment)
{
list($response) = $this->createPaymentWithHttpInfo($xero_tenant_id, $payment);
return $response;
}
/**
* Operation createPaymentWithHttpInfo
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payment $payment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Payments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPaymentWithHttpInfo($xero_tenant_id, $payment)
{
$request = $this->createPaymentRequest($xero_tenant_id, $payment);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Payments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Payments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Payments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPaymentAsync
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payment $payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentAsync($xero_tenant_id, $payment)
{
return $this->createPaymentAsyncWithHttpInfo($xero_tenant_id, $payment)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPaymentAsyncWithHttpInfo
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payment $payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentAsyncWithHttpInfo($xero_tenant_id, $payment)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$request = $this->createPaymentRequest($xero_tenant_id, $payment);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPayment'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payment $payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPaymentRequest($xero_tenant_id, $payment)
{
// 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 createPayment'
);
}
// verify the required parameter 'payment' is set
if ($payment === null || (is_array($payment) && count($payment) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payment when calling createPayment'
);
}
$resourcePath = '/Payments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($payment)) {
$_tempBody = $payment;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPaymentHistory
*
* Allows you to create a history record for a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPaymentHistory($xero_tenant_id, $payment_id, $history_records)
{
list($response) = $this->createPaymentHistoryWithHttpInfo($xero_tenant_id, $payment_id, $history_records);
return $response;
}
/**
* Operation createPaymentHistoryWithHttpInfo
*
* Allows you to create a history record for a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPaymentHistoryWithHttpInfo($xero_tenant_id, $payment_id, $history_records)
{
$request = $this->createPaymentHistoryRequest($xero_tenant_id, $payment_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPaymentHistoryAsync
*
* Allows you to create a history record for a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentHistoryAsync($xero_tenant_id, $payment_id, $history_records)
{
return $this->createPaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $payment_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPaymentHistoryAsyncWithHttpInfo
*
* Allows you to create a history record for a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $payment_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createPaymentHistoryRequest($xero_tenant_id, $payment_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPaymentHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPaymentHistoryRequest($xero_tenant_id, $payment_id, $history_records)
{
// 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 createPaymentHistory'
);
}
// verify the required parameter 'payment_id' is set
if ($payment_id === null || (is_array($payment_id) && count($payment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payment_id when calling createPaymentHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createPaymentHistory'
);
}
$resourcePath = '/Payments/{PaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($payment_id !== null) {
$resourcePath = str_replace(
'{' . 'PaymentID' . '}',
AccountingObjectSerializer::toPathValue($payment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPaymentService
*
* Allows you to create payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentServices $payment_services payment_services (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PaymentServices|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPaymentService($xero_tenant_id, $payment_services)
{
list($response) = $this->createPaymentServiceWithHttpInfo($xero_tenant_id, $payment_services);
return $response;
}
/**
* Operation createPaymentServiceWithHttpInfo
*
* Allows you to create payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentServices $payment_services (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PaymentServices|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPaymentServiceWithHttpInfo($xero_tenant_id, $payment_services)
{
$request = $this->createPaymentServiceRequest($xero_tenant_id, $payment_services);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PaymentServices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PaymentServices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPaymentServiceAsync
*
* Allows you to create payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentServices $payment_services (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentServiceAsync($xero_tenant_id, $payment_services)
{
return $this->createPaymentServiceAsyncWithHttpInfo($xero_tenant_id, $payment_services)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPaymentServiceAsyncWithHttpInfo
*
* Allows you to create payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentServices $payment_services (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentServiceAsyncWithHttpInfo($xero_tenant_id, $payment_services)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$request = $this->createPaymentServiceRequest($xero_tenant_id, $payment_services);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPaymentService'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PaymentServices $payment_services (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPaymentServiceRequest($xero_tenant_id, $payment_services)
{
// 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 createPaymentService'
);
}
// verify the required parameter 'payment_services' is set
if ($payment_services === null || (is_array($payment_services) && count($payment_services) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payment_services when calling createPaymentService'
);
}
$resourcePath = '/PaymentServices';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($payment_services)) {
$_tempBody = $payment_services;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPayments
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments payments (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Payments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPayments($xero_tenant_id, $payments)
{
list($response) = $this->createPaymentsWithHttpInfo($xero_tenant_id, $payments);
return $response;
}
/**
* Operation createPaymentsWithHttpInfo
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Payments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPaymentsWithHttpInfo($xero_tenant_id, $payments)
{
$request = $this->createPaymentsRequest($xero_tenant_id, $payments);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Payments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Payments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Payments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPaymentsAsync
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentsAsync($xero_tenant_id, $payments)
{
return $this->createPaymentsAsyncWithHttpInfo($xero_tenant_id, $payments)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPaymentsAsyncWithHttpInfo
*
* Allows you to create payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPaymentsAsyncWithHttpInfo($xero_tenant_id, $payments)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$request = $this->createPaymentsRequest($xero_tenant_id, $payments);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPayments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPaymentsRequest($xero_tenant_id, $payments)
{
// 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 createPayments'
);
}
// verify the required parameter 'payments' is set
if ($payments === null || (is_array($payments) && count($payments) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payments when calling createPayments'
);
}
$resourcePath = '/Payments#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($payments)) {
$_tempBody = $payments;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPrepaymentAllocation
*
* Allows you to create an Allocation for prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id prepayment_id (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations allocations (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPrepaymentAllocation($xero_tenant_id, $prepayment_id, $allocations)
{
list($response) = $this->createPrepaymentAllocationWithHttpInfo($xero_tenant_id, $prepayment_id, $allocations);
return $response;
}
/**
* Operation createPrepaymentAllocationWithHttpInfo
*
* Allows you to create an Allocation for prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Allocations|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPrepaymentAllocationWithHttpInfo($xero_tenant_id, $prepayment_id, $allocations)
{
$request = $this->createPrepaymentAllocationRequest($xero_tenant_id, $prepayment_id, $allocations);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Allocations' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Allocations', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Allocations',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPrepaymentAllocationAsync
*
* Allows you to create an Allocation for prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPrepaymentAllocationAsync($xero_tenant_id, $prepayment_id, $allocations)
{
return $this->createPrepaymentAllocationAsyncWithHttpInfo($xero_tenant_id, $prepayment_id, $allocations)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPrepaymentAllocationAsyncWithHttpInfo
*
* Allows you to create an Allocation for prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPrepaymentAllocationAsyncWithHttpInfo($xero_tenant_id, $prepayment_id, $allocations)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Allocations';
$request = $this->createPrepaymentAllocationRequest($xero_tenant_id, $prepayment_id, $allocations);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPrepaymentAllocation'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Allocations $allocations (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPrepaymentAllocationRequest($xero_tenant_id, $prepayment_id, $allocations)
{
// 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 createPrepaymentAllocation'
);
}
// verify the required parameter 'prepayment_id' is set
if ($prepayment_id === null || (is_array($prepayment_id) && count($prepayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $prepayment_id when calling createPrepaymentAllocation'
);
}
// verify the required parameter 'allocations' is set
if ($allocations === null || (is_array($allocations) && count($allocations) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $allocations when calling createPrepaymentAllocation'
);
}
$resourcePath = '/Prepayments/{PrepaymentID}/Allocations';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($prepayment_id !== null) {
$resourcePath = str_replace(
'{' . 'PrepaymentID' . '}',
AccountingObjectSerializer::toPathValue($prepayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($allocations)) {
$_tempBody = $allocations;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPrepaymentHistory
*
* Allows you to create a history record for an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPrepaymentHistory($xero_tenant_id, $prepayment_id, $history_records)
{
list($response) = $this->createPrepaymentHistoryWithHttpInfo($xero_tenant_id, $prepayment_id, $history_records);
return $response;
}
/**
* Operation createPrepaymentHistoryWithHttpInfo
*
* Allows you to create a history record for an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPrepaymentHistoryWithHttpInfo($xero_tenant_id, $prepayment_id, $history_records)
{
$request = $this->createPrepaymentHistoryRequest($xero_tenant_id, $prepayment_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPrepaymentHistoryAsync
*
* Allows you to create a history record for an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPrepaymentHistoryAsync($xero_tenant_id, $prepayment_id, $history_records)
{
return $this->createPrepaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $prepayment_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPrepaymentHistoryAsyncWithHttpInfo
*
* Allows you to create a history record for an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPrepaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $prepayment_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createPrepaymentHistoryRequest($xero_tenant_id, $prepayment_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPrepaymentHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPrepaymentHistoryRequest($xero_tenant_id, $prepayment_id, $history_records)
{
// 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 createPrepaymentHistory'
);
}
// verify the required parameter 'prepayment_id' is set
if ($prepayment_id === null || (is_array($prepayment_id) && count($prepayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $prepayment_id when calling createPrepaymentHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createPrepaymentHistory'
);
}
$resourcePath = '/Prepayments/{PrepaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($prepayment_id !== null) {
$resourcePath = str_replace(
'{' . 'PrepaymentID' . '}',
AccountingObjectSerializer::toPathValue($prepayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPurchaseOrder
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrder $purchase_order purchase_order (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPurchaseOrder($xero_tenant_id, $purchase_order)
{
list($response) = $this->createPurchaseOrderWithHttpInfo($xero_tenant_id, $purchase_order);
return $response;
}
/**
* Operation createPurchaseOrderWithHttpInfo
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrder $purchase_order (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPurchaseOrderWithHttpInfo($xero_tenant_id, $purchase_order)
{
$request = $this->createPurchaseOrderRequest($xero_tenant_id, $purchase_order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPurchaseOrderAsync
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrder $purchase_order (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPurchaseOrderAsync($xero_tenant_id, $purchase_order)
{
return $this->createPurchaseOrderAsyncWithHttpInfo($xero_tenant_id, $purchase_order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPurchaseOrderAsyncWithHttpInfo
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrder $purchase_order (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPurchaseOrderAsyncWithHttpInfo($xero_tenant_id, $purchase_order)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$request = $this->createPurchaseOrderRequest($xero_tenant_id, $purchase_order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPurchaseOrder'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrder $purchase_order (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPurchaseOrderRequest($xero_tenant_id, $purchase_order)
{
// 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 createPurchaseOrder'
);
}
// verify the required parameter 'purchase_order' is set
if ($purchase_order === null || (is_array($purchase_order) && count($purchase_order) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $purchase_order when calling createPurchaseOrder'
);
}
$resourcePath = '/PurchaseOrders';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($purchase_order)) {
$_tempBody = $purchase_order;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPurchaseOrderHistory
*
* Allows you to create HistoryRecord for purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPurchaseOrderHistory($xero_tenant_id, $purchase_order_id, $history_records)
{
list($response) = $this->createPurchaseOrderHistoryWithHttpInfo($xero_tenant_id, $purchase_order_id, $history_records);
return $response;
}
/**
* Operation createPurchaseOrderHistoryWithHttpInfo
*
* Allows you to create HistoryRecord for purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPurchaseOrderHistoryWithHttpInfo($xero_tenant_id, $purchase_order_id, $history_records)
{
$request = $this->createPurchaseOrderHistoryRequest($xero_tenant_id, $purchase_order_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPurchaseOrderHistoryAsync
*
* Allows you to create HistoryRecord for purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPurchaseOrderHistoryAsync($xero_tenant_id, $purchase_order_id, $history_records)
{
return $this->createPurchaseOrderHistoryAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPurchaseOrderHistoryAsyncWithHttpInfo
*
* Allows you to create HistoryRecord for purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPurchaseOrderHistoryAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createPurchaseOrderHistoryRequest($xero_tenant_id, $purchase_order_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPurchaseOrderHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPurchaseOrderHistoryRequest($xero_tenant_id, $purchase_order_id, $history_records)
{
// 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 createPurchaseOrderHistory'
);
}
// verify the required parameter 'purchase_order_id' is set
if ($purchase_order_id === null || (is_array($purchase_order_id) && count($purchase_order_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $purchase_order_id when calling createPurchaseOrderHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createPurchaseOrderHistory'
);
}
$resourcePath = '/PurchaseOrders/{PurchaseOrderID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($purchase_order_id !== null) {
$resourcePath = str_replace(
'{' . 'PurchaseOrderID' . '}',
AccountingObjectSerializer::toPathValue($purchase_order_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createPurchaseOrders
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders purchase_orders (required)
* @param bool $summarize_errors shows validation errors for each purchase order. (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createPurchaseOrders($xero_tenant_id, $purchase_orders, $summarize_errors = true)
{
list($response) = $this->createPurchaseOrdersWithHttpInfo($xero_tenant_id, $purchase_orders, $summarize_errors);
return $response;
}
/**
* Operation createPurchaseOrdersWithHttpInfo
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
* @param bool $summarize_errors shows validation errors for each purchase order. (optional, default to true)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createPurchaseOrdersWithHttpInfo($xero_tenant_id, $purchase_orders, $summarize_errors = true)
{
$request = $this->createPurchaseOrdersRequest($xero_tenant_id, $purchase_orders, $summarize_errors);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createPurchaseOrdersAsync
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
* @param bool $summarize_errors shows validation errors for each purchase order. (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPurchaseOrdersAsync($xero_tenant_id, $purchase_orders, $summarize_errors = true)
{
return $this->createPurchaseOrdersAsyncWithHttpInfo($xero_tenant_id, $purchase_orders, $summarize_errors)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createPurchaseOrdersAsyncWithHttpInfo
*
* Allows you to create purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
* @param bool $summarize_errors shows validation errors for each purchase order. (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createPurchaseOrdersAsyncWithHttpInfo($xero_tenant_id, $purchase_orders, $summarize_errors = true)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$request = $this->createPurchaseOrdersRequest($xero_tenant_id, $purchase_orders, $summarize_errors);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createPurchaseOrders'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
* @param bool $summarize_errors shows validation errors for each purchase order. (optional, default to true)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createPurchaseOrdersRequest($xero_tenant_id, $purchase_orders, $summarize_errors = true)
{
// 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 createPurchaseOrders'
);
}
// verify the required parameter 'purchase_orders' is set
if ($purchase_orders === null || (is_array($purchase_orders) && count($purchase_orders) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $purchase_orders when calling createPurchaseOrders'
);
}
$resourcePath = '/PurchaseOrders#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($summarize_errors !== null) {
$queryParams['SummarizeErrors'] = AccountingObjectSerializer::toQueryValue($summarize_errors);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($purchase_orders)) {
$_tempBody = $purchase_orders;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createReceipt
*
* Allows you to create draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts receipts (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Receipts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createReceipt($xero_tenant_id, $receipts)
{
list($response) = $this->createReceiptWithHttpInfo($xero_tenant_id, $receipts);
return $response;
}
/**
* Operation createReceiptWithHttpInfo
*
* Allows you to create draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Receipts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createReceiptWithHttpInfo($xero_tenant_id, $receipts)
{
$request = $this->createReceiptRequest($xero_tenant_id, $receipts);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Receipts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Receipts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Receipts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createReceiptAsync
*
* Allows you to create draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createReceiptAsync($xero_tenant_id, $receipts)
{
return $this->createReceiptAsyncWithHttpInfo($xero_tenant_id, $receipts)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createReceiptAsyncWithHttpInfo
*
* Allows you to create draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createReceiptAsyncWithHttpInfo($xero_tenant_id, $receipts)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$request = $this->createReceiptRequest($xero_tenant_id, $receipts);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createReceipt'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createReceiptRequest($xero_tenant_id, $receipts)
{
// 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 createReceipt'
);
}
// verify the required parameter 'receipts' is set
if ($receipts === null || (is_array($receipts) && count($receipts) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipts when calling createReceipt'
);
}
$resourcePath = '/Receipts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($receipts)) {
$_tempBody = $receipts;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createReceiptAttachmentByFileName
*
* Allows you to create Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createReceiptAttachmentByFileName($xero_tenant_id, $receipt_id, $file_name, $body)
{
list($response) = $this->createReceiptAttachmentByFileNameWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body);
return $response;
}
/**
* Operation createReceiptAttachmentByFileNameWithHttpInfo
*
* Allows you to create Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createReceiptAttachmentByFileNameWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body)
{
$request = $this->createReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createReceiptAttachmentByFileNameAsync
*
* Allows you to create Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createReceiptAttachmentByFileNameAsync($xero_tenant_id, $receipt_id, $file_name, $body)
{
return $this->createReceiptAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createReceiptAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to create Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createReceiptAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createReceiptAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $body)
{
// 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 createReceiptAttachmentByFileName'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling createReceiptAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createReceiptAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createReceiptAttachmentByFileName'
);
}
$resourcePath = '/Receipts/{ReceiptID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createReceiptHistory
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createReceiptHistory($xero_tenant_id, $receipt_id, $history_records)
{
list($response) = $this->createReceiptHistoryWithHttpInfo($xero_tenant_id, $receipt_id, $history_records);
return $response;
}
/**
* Operation createReceiptHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createReceiptHistoryWithHttpInfo($xero_tenant_id, $receipt_id, $history_records)
{
$request = $this->createReceiptHistoryRequest($xero_tenant_id, $receipt_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createReceiptHistoryAsync
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createReceiptHistoryAsync($xero_tenant_id, $receipt_id, $history_records)
{
return $this->createReceiptHistoryAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createReceiptHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createReceiptHistoryAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createReceiptHistoryRequest($xero_tenant_id, $receipt_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createReceiptHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createReceiptHistoryRequest($xero_tenant_id, $receipt_id, $history_records)
{
// 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 createReceiptHistory'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling createReceiptHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createReceiptHistory'
);
}
$resourcePath = '/Receipts/{ReceiptID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createRepeatingInvoiceAttachmentByFileName
*
* Allows you to create attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createRepeatingInvoiceAttachmentByFileName($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
list($response) = $this->createRepeatingInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body);
return $response;
}
/**
* Operation createRepeatingInvoiceAttachmentByFileNameWithHttpInfo
*
* Allows you to create attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createRepeatingInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
$request = $this->createRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createRepeatingInvoiceAttachmentByFileNameAsync
*
* Allows you to create attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createRepeatingInvoiceAttachmentByFileNameAsync($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
return $this->createRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to create attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->createRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createRepeatingInvoiceAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
// 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 createRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling createRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling createRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling createRepeatingInvoiceAttachmentByFileName'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createRepeatingInvoiceHistory
*
* Allows you to create history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createRepeatingInvoiceHistory($xero_tenant_id, $repeating_invoice_id, $history_records)
{
list($response) = $this->createRepeatingInvoiceHistoryWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $history_records);
return $response;
}
/**
* Operation createRepeatingInvoiceHistoryWithHttpInfo
*
* Allows you to create history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createRepeatingInvoiceHistoryWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $history_records)
{
$request = $this->createRepeatingInvoiceHistoryRequest($xero_tenant_id, $repeating_invoice_id, $history_records);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createRepeatingInvoiceHistoryAsync
*
* Allows you to create history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createRepeatingInvoiceHistoryAsync($xero_tenant_id, $repeating_invoice_id, $history_records)
{
return $this->createRepeatingInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $history_records)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createRepeatingInvoiceHistoryAsyncWithHttpInfo
*
* Allows you to create history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createRepeatingInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $history_records)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->createRepeatingInvoiceHistoryRequest($xero_tenant_id, $repeating_invoice_id, $history_records);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createRepeatingInvoiceHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords $history_records (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createRepeatingInvoiceHistoryRequest($xero_tenant_id, $repeating_invoice_id, $history_records)
{
// 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 createRepeatingInvoiceHistory'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling createRepeatingInvoiceHistory'
);
}
// verify the required parameter 'history_records' is set
if ($history_records === null || (is_array($history_records) && count($history_records) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $history_records when calling createRepeatingInvoiceHistory'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($history_records)) {
$_tempBody = $history_records;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createTaxRate
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRate $tax_rate tax_rate (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TaxRates|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createTaxRate($xero_tenant_id, $tax_rate)
{
list($response) = $this->createTaxRateWithHttpInfo($xero_tenant_id, $tax_rate);
return $response;
}
/**
* Operation createTaxRateWithHttpInfo
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRate $tax_rate (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TaxRates|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createTaxRateWithHttpInfo($xero_tenant_id, $tax_rate)
{
$request = $this->createTaxRateRequest($xero_tenant_id, $tax_rate);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TaxRates' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TaxRates', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TaxRates',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createTaxRateAsync
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRate $tax_rate (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTaxRateAsync($xero_tenant_id, $tax_rate)
{
return $this->createTaxRateAsyncWithHttpInfo($xero_tenant_id, $tax_rate)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createTaxRateAsyncWithHttpInfo
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRate $tax_rate (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTaxRateAsyncWithHttpInfo($xero_tenant_id, $tax_rate)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$request = $this->createTaxRateRequest($xero_tenant_id, $tax_rate);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createTaxRate'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRate $tax_rate (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createTaxRateRequest($xero_tenant_id, $tax_rate)
{
// 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 createTaxRate'
);
}
// verify the required parameter 'tax_rate' is set
if ($tax_rate === null || (is_array($tax_rate) && count($tax_rate) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tax_rate when calling createTaxRate'
);
}
$resourcePath = '/TaxRates';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($tax_rate)) {
$_tempBody = $tax_rate;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createTaxRates
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates tax_rates (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TaxRates|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createTaxRates($xero_tenant_id, $tax_rates)
{
list($response) = $this->createTaxRatesWithHttpInfo($xero_tenant_id, $tax_rates);
return $response;
}
/**
* Operation createTaxRatesWithHttpInfo
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TaxRates|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createTaxRatesWithHttpInfo($xero_tenant_id, $tax_rates)
{
$request = $this->createTaxRatesRequest($xero_tenant_id, $tax_rates);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TaxRates' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TaxRates', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TaxRates',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createTaxRatesAsync
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTaxRatesAsync($xero_tenant_id, $tax_rates)
{
return $this->createTaxRatesAsyncWithHttpInfo($xero_tenant_id, $tax_rates)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createTaxRatesAsyncWithHttpInfo
*
* Allows you to create Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTaxRatesAsyncWithHttpInfo($xero_tenant_id, $tax_rates)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$request = $this->createTaxRatesRequest($xero_tenant_id, $tax_rates);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createTaxRates'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createTaxRatesRequest($xero_tenant_id, $tax_rates)
{
// 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 createTaxRates'
);
}
// verify the required parameter 'tax_rates' is set
if ($tax_rates === null || (is_array($tax_rates) && count($tax_rates) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tax_rates when calling createTaxRates'
);
}
$resourcePath = '/TaxRates#bulk';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($tax_rates)) {
$_tempBody = $tax_rates;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createTrackingCategory
*
* Allows you to create tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category tracking_category (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createTrackingCategory($xero_tenant_id, $tracking_category)
{
list($response) = $this->createTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category);
return $response;
}
/**
* Operation createTrackingCategoryWithHttpInfo
*
* Allows you to create tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category)
{
$request = $this->createTrackingCategoryRequest($xero_tenant_id, $tracking_category);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createTrackingCategoryAsync
*
* Allows you to create tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTrackingCategoryAsync($xero_tenant_id, $tracking_category)
{
return $this->createTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createTrackingCategoryAsyncWithHttpInfo
*
* Allows you to create tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$request = $this->createTrackingCategoryRequest($xero_tenant_id, $tracking_category);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createTrackingCategory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createTrackingCategoryRequest($xero_tenant_id, $tracking_category)
{
// 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 createTrackingCategory'
);
}
// verify the required parameter 'tracking_category' is set
if ($tracking_category === null || (is_array($tracking_category) && count($tracking_category) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category when calling createTrackingCategory'
);
}
$resourcePath = '/TrackingCategories';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($tracking_category)) {
$_tempBody = $tracking_category;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation createTrackingOptions
*
* Allows you to create options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option tracking_option (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingOptions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function createTrackingOptions($xero_tenant_id, $tracking_category_id, $tracking_option)
{
list($response) = $this->createTrackingOptionsWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option);
return $response;
}
/**
* Operation createTrackingOptionsWithHttpInfo
*
* Allows you to create options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingOptions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function createTrackingOptionsWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option)
{
$request = $this->createTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createTrackingOptionsAsync
*
* Allows you to create options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTrackingOptionsAsync($xero_tenant_id, $tracking_category_id, $tracking_option)
{
return $this->createTrackingOptionsAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createTrackingOptionsAsyncWithHttpInfo
*
* Allows you to create options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function createTrackingOptionsAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions';
$request = $this->createTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'createTrackingOptions'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function createTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option)
{
// 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 createTrackingOptions'
);
}
// verify the required parameter 'tracking_category_id' is set
if ($tracking_category_id === null || (is_array($tracking_category_id) && count($tracking_category_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category_id when calling createTrackingOptions'
);
}
// verify the required parameter 'tracking_option' is set
if ($tracking_option === null || (is_array($tracking_option) && count($tracking_option) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_option when calling createTrackingOptions'
);
}
$resourcePath = '/TrackingCategories/{TrackingCategoryID}/Options';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($tracking_category_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingCategoryID' . '}',
AccountingObjectSerializer::toPathValue($tracking_category_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($tracking_option)) {
$_tempBody = $tracking_option;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteAccount
*
* Allows you to delete a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Accounts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function deleteAccount($xero_tenant_id, $account_id)
{
list($response) = $this->deleteAccountWithHttpInfo($xero_tenant_id, $account_id);
return $response;
}
/**
* Operation deleteAccountWithHttpInfo
*
* Allows you to delete a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Accounts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteAccountWithHttpInfo($xero_tenant_id, $account_id)
{
$request = $this->deleteAccountRequest($xero_tenant_id, $account_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Accounts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Accounts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Accounts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteAccountAsync
*
* Allows you to delete a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteAccountAsync($xero_tenant_id, $account_id)
{
return $this->deleteAccountAsyncWithHttpInfo($xero_tenant_id, $account_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteAccountAsyncWithHttpInfo
*
* Allows you to delete a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteAccountAsyncWithHttpInfo($xero_tenant_id, $account_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$request = $this->deleteAccountRequest($xero_tenant_id, $account_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deleteAccount'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deleteAccountRequest($xero_tenant_id, $account_id)
{
// 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 deleteAccount'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling deleteAccount'
);
}
$resourcePath = '/Accounts/{AccountID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteContactGroupContact
*
* Allows you to delete a specific Contact from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return void
*/
public function deleteContactGroupContact($xero_tenant_id, $contact_group_id, $contact_id)
{
$this->deleteContactGroupContactWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_id);
}
/**
* Operation deleteContactGroupContactWithHttpInfo
*
* Allows you to delete a specific Contact from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteContactGroupContactWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_id)
{
$request = $this->deleteContactGroupContactRequest($xero_tenant_id, $contact_group_id, $contact_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteContactGroupContactAsync
*
* Allows you to delete a specific Contact from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteContactGroupContactAsync($xero_tenant_id, $contact_group_id, $contact_id)
{
return $this->deleteContactGroupContactAsyncWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteContactGroupContactAsyncWithHttpInfo
*
* Allows you to delete a specific Contact from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteContactGroupContactAsyncWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_id)
{
$returnType = '';
$request = $this->deleteContactGroupContactRequest($xero_tenant_id, $contact_group_id, $contact_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
return [null, $response->getStatusCode(), $response->getHeaders()];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deleteContactGroupContact'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deleteContactGroupContactRequest($xero_tenant_id, $contact_group_id, $contact_id)
{
// 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 deleteContactGroupContact'
);
}
// verify the required parameter 'contact_group_id' is set
if ($contact_group_id === null || (is_array($contact_group_id) && count($contact_group_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_group_id when calling deleteContactGroupContact'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling deleteContactGroupContact'
);
}
$resourcePath = '/ContactGroups/{ContactGroupID}/Contacts/{ContactID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_group_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactGroupID' . '}',
AccountingObjectSerializer::toPathValue($contact_group_id),
$resourcePath
);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteContactGroupContacts
*
* Allows you to delete all Contacts from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return void
*/
public function deleteContactGroupContacts($xero_tenant_id, $contact_group_id)
{
$this->deleteContactGroupContactsWithHttpInfo($xero_tenant_id, $contact_group_id);
}
/**
* Operation deleteContactGroupContactsWithHttpInfo
*
* Allows you to delete all Contacts from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteContactGroupContactsWithHttpInfo($xero_tenant_id, $contact_group_id)
{
$request = $this->deleteContactGroupContactsRequest($xero_tenant_id, $contact_group_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
* Operation deleteContactGroupContactsAsync
*
* Allows you to delete all Contacts from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteContactGroupContactsAsync($xero_tenant_id, $contact_group_id)
{
return $this->deleteContactGroupContactsAsyncWithHttpInfo($xero_tenant_id, $contact_group_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteContactGroupContactsAsyncWithHttpInfo
*
* Allows you to delete all Contacts from a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteContactGroupContactsAsyncWithHttpInfo($xero_tenant_id, $contact_group_id)
{
$returnType = '';
$request = $this->deleteContactGroupContactsRequest($xero_tenant_id, $contact_group_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
return [null, $response->getStatusCode(), $response->getHeaders()];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deleteContactGroupContacts'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deleteContactGroupContactsRequest($xero_tenant_id, $contact_group_id)
{
// 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 deleteContactGroupContacts'
);
}
// verify the required parameter 'contact_group_id' is set
if ($contact_group_id === null || (is_array($contact_group_id) && count($contact_group_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_group_id when calling deleteContactGroupContacts'
);
}
$resourcePath = '/ContactGroups/{ContactGroupID}/Contacts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_group_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactGroupID' . '}',
AccountingObjectSerializer::toPathValue($contact_group_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
[]
);
} else {
$headers = $this->headerSelector->selectHeaders(
[],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteItem
*
* Allows you to delete a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return void
*/
public function deleteItem($xero_tenant_id, $item_id)
{
$this->deleteItemWithHttpInfo($xero_tenant_id, $item_id);
}
/**
* Operation deleteItemWithHttpInfo
*
* Allows you to delete a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteItemWithHttpInfo($xero_tenant_id, $item_id)
{
$request = $this->deleteItemRequest($xero_tenant_id, $item_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteItemAsync
*
* Allows you to delete a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteItemAsync($xero_tenant_id, $item_id)
{
return $this->deleteItemAsyncWithHttpInfo($xero_tenant_id, $item_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteItemAsyncWithHttpInfo
*
* Allows you to delete a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteItemAsyncWithHttpInfo($xero_tenant_id, $item_id)
{
$returnType = '';
$request = $this->deleteItemRequest($xero_tenant_id, $item_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
return [null, $response->getStatusCode(), $response->getHeaders()];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deleteItem'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deleteItemRequest($xero_tenant_id, $item_id)
{
// 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 deleteItem'
);
}
// verify the required parameter 'item_id' is set
if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $item_id when calling deleteItem'
);
}
$resourcePath = '/Items/{ItemID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($item_id !== null) {
$resourcePath = str_replace(
'{' . 'ItemID' . '}',
AccountingObjectSerializer::toPathValue($item_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteLinkedTransaction
*
* Allows you to delete a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return void
*/
public function deleteLinkedTransaction($xero_tenant_id, $linked_transaction_id)
{
$this->deleteLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction_id);
}
/**
* Operation deleteLinkedTransactionWithHttpInfo
*
* Allows you to delete a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction_id)
{
$request = $this->deleteLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteLinkedTransactionAsync
*
* Allows you to delete a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteLinkedTransactionAsync($xero_tenant_id, $linked_transaction_id)
{
return $this->deleteLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteLinkedTransactionAsyncWithHttpInfo
*
* Allows you to delete a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction_id)
{
$returnType = '';
$request = $this->deleteLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
return [null, $response->getStatusCode(), $response->getHeaders()];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deleteLinkedTransaction'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deleteLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id)
{
// 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 deleteLinkedTransaction'
);
}
// verify the required parameter 'linked_transaction_id' is set
if ($linked_transaction_id === null || (is_array($linked_transaction_id) && count($linked_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $linked_transaction_id when calling deleteLinkedTransaction'
);
}
$resourcePath = '/LinkedTransactions/{LinkedTransactionID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($linked_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'LinkedTransactionID' . '}',
AccountingObjectSerializer::toPathValue($linked_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deletePayment
*
* Allows you to update a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments payments (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Payments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function deletePayment($xero_tenant_id, $payment_id, $payments)
{
list($response) = $this->deletePaymentWithHttpInfo($xero_tenant_id, $payment_id, $payments);
return $response;
}
/**
* Operation deletePaymentWithHttpInfo
*
* Allows you to update a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Payments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function deletePaymentWithHttpInfo($xero_tenant_id, $payment_id, $payments)
{
$request = $this->deletePaymentRequest($xero_tenant_id, $payment_id, $payments);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Payments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Payments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Payments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deletePaymentAsync
*
* Allows you to update a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deletePaymentAsync($xero_tenant_id, $payment_id, $payments)
{
return $this->deletePaymentAsyncWithHttpInfo($xero_tenant_id, $payment_id, $payments)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deletePaymentAsyncWithHttpInfo
*
* Allows you to update a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deletePaymentAsyncWithHttpInfo($xero_tenant_id, $payment_id, $payments)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$request = $this->deletePaymentRequest($xero_tenant_id, $payment_id, $payments);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deletePayment'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Payments $payments (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deletePaymentRequest($xero_tenant_id, $payment_id, $payments)
{
// 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 deletePayment'
);
}
// verify the required parameter 'payment_id' is set
if ($payment_id === null || (is_array($payment_id) && count($payment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payment_id when calling deletePayment'
);
}
// verify the required parameter 'payments' is set
if ($payments === null || (is_array($payments) && count($payments) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payments when calling deletePayment'
);
}
$resourcePath = '/Payments/{PaymentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($payment_id !== null) {
$resourcePath = str_replace(
'{' . 'PaymentID' . '}',
AccountingObjectSerializer::toPathValue($payment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($payments)) {
$_tempBody = $payments;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteTrackingCategory
*
* Allows you to delete tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function deleteTrackingCategory($xero_tenant_id, $tracking_category_id)
{
list($response) = $this->deleteTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category_id);
return $response;
}
/**
* Operation deleteTrackingCategoryWithHttpInfo
*
* Allows you to delete tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category_id)
{
$request = $this->deleteTrackingCategoryRequest($xero_tenant_id, $tracking_category_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteTrackingCategoryAsync
*
* Allows you to delete tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteTrackingCategoryAsync($xero_tenant_id, $tracking_category_id)
{
return $this->deleteTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteTrackingCategoryAsyncWithHttpInfo
*
* Allows you to delete tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$request = $this->deleteTrackingCategoryRequest($xero_tenant_id, $tracking_category_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deleteTrackingCategory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deleteTrackingCategoryRequest($xero_tenant_id, $tracking_category_id)
{
// 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 deleteTrackingCategory'
);
}
// verify the required parameter 'tracking_category_id' is set
if ($tracking_category_id === null || (is_array($tracking_category_id) && count($tracking_category_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category_id when calling deleteTrackingCategory'
);
}
$resourcePath = '/TrackingCategories/{TrackingCategoryID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($tracking_category_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingCategoryID' . '}',
AccountingObjectSerializer::toPathValue($tracking_category_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation deleteTrackingOptions
*
* Allows you to delete a specified option for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingOptions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function deleteTrackingOptions($xero_tenant_id, $tracking_category_id, $tracking_option_id)
{
list($response) = $this->deleteTrackingOptionsWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id);
return $response;
}
/**
* Operation deleteTrackingOptionsWithHttpInfo
*
* Allows you to delete a specified option for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingOptions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteTrackingOptionsWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id)
{
$request = $this->deleteTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteTrackingOptionsAsync
*
* Allows you to delete a specified option for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteTrackingOptionsAsync($xero_tenant_id, $tracking_category_id, $tracking_option_id)
{
return $this->deleteTrackingOptionsAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteTrackingOptionsAsyncWithHttpInfo
*
* Allows you to delete a specified option for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function deleteTrackingOptionsAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions';
$request = $this->deleteTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'deleteTrackingOptions'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function deleteTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option_id)
{
// 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 deleteTrackingOptions'
);
}
// verify the required parameter 'tracking_category_id' is set
if ($tracking_category_id === null || (is_array($tracking_category_id) && count($tracking_category_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category_id when calling deleteTrackingOptions'
);
}
// verify the required parameter 'tracking_option_id' is set
if ($tracking_option_id === null || (is_array($tracking_option_id) && count($tracking_option_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_option_id when calling deleteTrackingOptions'
);
}
$resourcePath = '/TrackingCategories/{TrackingCategoryID}/Options/{TrackingOptionID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($tracking_category_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingCategoryID' . '}',
AccountingObjectSerializer::toPathValue($tracking_category_id),
$resourcePath
);
}
// path params
if ($tracking_option_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingOptionID' . '}',
AccountingObjectSerializer::toPathValue($tracking_option_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation emailInvoice
*
* Allows you to email a copy of invoice to related Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\RequestEmpty $request_empty request_empty (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return void
*/
public function emailInvoice($xero_tenant_id, $invoice_id, $request_empty)
{
$this->emailInvoiceWithHttpInfo($xero_tenant_id, $invoice_id, $request_empty);
}
/**
* Operation emailInvoiceWithHttpInfo
*
* Allows you to email a copy of invoice to related Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\RequestEmpty $request_empty (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function emailInvoiceWithHttpInfo($xero_tenant_id, $invoice_id, $request_empty)
{
$request = $this->emailInvoiceRequest($xero_tenant_id, $invoice_id, $request_empty);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation emailInvoiceAsync
*
* Allows you to email a copy of invoice to related Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\RequestEmpty $request_empty (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function emailInvoiceAsync($xero_tenant_id, $invoice_id, $request_empty)
{
return $this->emailInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $request_empty)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation emailInvoiceAsyncWithHttpInfo
*
* Allows you to email a copy of invoice to related Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\RequestEmpty $request_empty (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function emailInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $request_empty)
{
$returnType = '';
$request = $this->emailInvoiceRequest($xero_tenant_id, $invoice_id, $request_empty);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
return [null, $response->getStatusCode(), $response->getHeaders()];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'emailInvoice'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\RequestEmpty $request_empty (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function emailInvoiceRequest($xero_tenant_id, $invoice_id, $request_empty)
{
// 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 emailInvoice'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling emailInvoice'
);
}
// verify the required parameter 'request_empty' is set
if ($request_empty === null || (is_array($request_empty) && count($request_empty) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $request_empty when calling emailInvoice'
);
}
$resourcePath = '/Invoices/{InvoiceID}/Email';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($request_empty)) {
$_tempBody = $request_empty;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAccount
*
* Allows you to retrieve a single chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Accounts
*/
public function getAccount($xero_tenant_id, $account_id)
{
list($response) = $this->getAccountWithHttpInfo($xero_tenant_id, $account_id);
return $response;
}
/**
* Operation getAccountWithHttpInfo
*
* Allows you to retrieve a single chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Accounts, HTTP status code, HTTP response headers (array of strings)
*/
public function getAccountWithHttpInfo($xero_tenant_id, $account_id)
{
$request = $this->getAccountRequest($xero_tenant_id, $account_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Accounts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Accounts', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Accounts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAccountAsync
*
* Allows you to retrieve a single chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAsync($xero_tenant_id, $account_id)
{
return $this->getAccountAsyncWithHttpInfo($xero_tenant_id, $account_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAccountAsyncWithHttpInfo
*
* Allows you to retrieve a single chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAsyncWithHttpInfo($xero_tenant_id, $account_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$request = $this->getAccountRequest($xero_tenant_id, $account_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getAccount'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getAccountRequest($xero_tenant_id, $account_id)
{
// 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 getAccount'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling getAccount'
);
}
$resourcePath = '/Accounts/{AccountID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAccountAttachmentByFileName
*
* Allows you to retrieve Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getAccountAttachmentByFileName($xero_tenant_id, $account_id, $file_name, $content_type)
{
list($response) = $this->getAccountAttachmentByFileNameWithHttpInfo($xero_tenant_id, $account_id, $file_name, $content_type);
return $response;
}
/**
* Operation getAccountAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getAccountAttachmentByFileNameWithHttpInfo($xero_tenant_id, $account_id, $file_name, $content_type)
{
$request = $this->getAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAccountAttachmentByFileNameAsync
*
* Allows you to retrieve Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAttachmentByFileNameAsync($xero_tenant_id, $account_id, $file_name, $content_type)
{
return $this->getAccountAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $account_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAccountAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $account_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getAccountAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $content_type)
{
// 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 getAccountAttachmentByFileName'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling getAccountAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getAccountAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getAccountAttachmentByFileName'
);
}
$resourcePath = '/Accounts/{AccountID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAccountAttachmentById
*
* Allows you to retrieve specific Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $attachment_id Unique identifier for Attachment object (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getAccountAttachmentById($xero_tenant_id, $account_id, $attachment_id, $content_type)
{
list($response) = $this->getAccountAttachmentByIdWithHttpInfo($xero_tenant_id, $account_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getAccountAttachmentByIdWithHttpInfo
*
* Allows you to retrieve specific Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $attachment_id Unique identifier for Attachment object (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getAccountAttachmentByIdWithHttpInfo($xero_tenant_id, $account_id, $attachment_id, $content_type)
{
$request = $this->getAccountAttachmentByIdRequest($xero_tenant_id, $account_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAccountAttachmentByIdAsync
*
* Allows you to retrieve specific Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $attachment_id Unique identifier for Attachment object (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAttachmentByIdAsync($xero_tenant_id, $account_id, $attachment_id, $content_type)
{
return $this->getAccountAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $account_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAccountAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve specific Attachment on Account
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $attachment_id Unique identifier for Attachment object (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $account_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getAccountAttachmentByIdRequest($xero_tenant_id, $account_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getAccountAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $attachment_id Unique identifier for Attachment object (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getAccountAttachmentByIdRequest($xero_tenant_id, $account_id, $attachment_id, $content_type)
{
// 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 getAccountAttachmentById'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling getAccountAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getAccountAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getAccountAttachmentById'
);
}
$resourcePath = '/Accounts/{AccountID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAccountAttachments
*
* Allows you to retrieve Attachments for accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getAccountAttachments($xero_tenant_id, $account_id)
{
list($response) = $this->getAccountAttachmentsWithHttpInfo($xero_tenant_id, $account_id);
return $response;
}
/**
* Operation getAccountAttachmentsWithHttpInfo
*
* Allows you to retrieve Attachments for accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getAccountAttachmentsWithHttpInfo($xero_tenant_id, $account_id)
{
$request = $this->getAccountAttachmentsRequest($xero_tenant_id, $account_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAccountAttachmentsAsync
*
* Allows you to retrieve Attachments for accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAttachmentsAsync($xero_tenant_id, $account_id)
{
return $this->getAccountAttachmentsAsyncWithHttpInfo($xero_tenant_id, $account_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAccountAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve Attachments for accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountAttachmentsAsyncWithHttpInfo($xero_tenant_id, $account_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getAccountAttachmentsRequest($xero_tenant_id, $account_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getAccountAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getAccountAttachmentsRequest($xero_tenant_id, $account_id)
{
// 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 getAccountAttachments'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling getAccountAttachments'
);
}
$resourcePath = '/Accounts/{AccountID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getAccounts
*
* Allows you to retrieve the full chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Accounts
*/
public function getAccounts($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
list($response) = $this->getAccountsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order);
return $response;
}
/**
* Operation getAccountsWithHttpInfo
*
* Allows you to retrieve the full chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Accounts, HTTP status code, HTTP response headers (array of strings)
*/
public function getAccountsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$request = $this->getAccountsRequest($xero_tenant_id, $if_modified_since, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Accounts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Accounts', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Accounts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAccountsAsync
*
* Allows you to retrieve the full chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
return $this->getAccountsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAccountsAsyncWithHttpInfo
*
* Allows you to retrieve the full chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getAccountsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$request = $this->getAccountsRequest($xero_tenant_id, $if_modified_since, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getAccounts'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getAccountsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
// 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 getAccounts'
);
}
$resourcePath = '/Accounts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransaction
*
* Allows you to retrieve a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransactions
*/
public function getBankTransaction($xero_tenant_id, $bank_transaction_id)
{
list($response) = $this->getBankTransactionWithHttpInfo($xero_tenant_id, $bank_transaction_id);
return $response;
}
/**
* Operation getBankTransactionWithHttpInfo
*
* Allows you to retrieve a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransactions, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransactionWithHttpInfo($xero_tenant_id, $bank_transaction_id)
{
$request = $this->getBankTransactionRequest($xero_tenant_id, $bank_transaction_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransactionAsync
*
* Allows you to retrieve a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAsync($xero_tenant_id, $bank_transaction_id)
{
return $this->getBankTransactionAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransactionAsyncWithHttpInfo
*
* Allows you to retrieve a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$request = $this->getBankTransactionRequest($xero_tenant_id, $bank_transaction_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransaction'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransactionRequest($xero_tenant_id, $bank_transaction_id)
{
// 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 getBankTransaction'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling getBankTransaction'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransactionAttachmentByFileName
*
* Allows you to retrieve Attachments on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getBankTransactionAttachmentByFileName($xero_tenant_id, $bank_transaction_id, $file_name, $content_type)
{
list($response) = $this->getBankTransactionAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $content_type);
return $response;
}
/**
* Operation getBankTransactionAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve Attachments on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransactionAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $content_type)
{
$request = $this->getBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransactionAttachmentByFileNameAsync
*
* Allows you to retrieve Attachments on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAttachmentByFileNameAsync($xero_tenant_id, $bank_transaction_id, $file_name, $content_type)
{
return $this->getBankTransactionAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransactionAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransactionAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $content_type)
{
// 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 getBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling getBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getBankTransactionAttachmentByFileName'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransactionAttachmentById
*
* Allows you to retrieve Attachments on a specific BankTransaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $attachment_id Xero generated unique identifier for an attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getBankTransactionAttachmentById($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type)
{
list($response) = $this->getBankTransactionAttachmentByIdWithHttpInfo($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getBankTransactionAttachmentByIdWithHttpInfo
*
* Allows you to retrieve Attachments on a specific BankTransaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $attachment_id Xero generated unique identifier for an attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransactionAttachmentByIdWithHttpInfo($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type)
{
$request = $this->getBankTransactionAttachmentByIdRequest($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransactionAttachmentByIdAsync
*
* Allows you to retrieve Attachments on a specific BankTransaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $attachment_id Xero generated unique identifier for an attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAttachmentByIdAsync($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type)
{
return $this->getBankTransactionAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransactionAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on a specific BankTransaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $attachment_id Xero generated unique identifier for an attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getBankTransactionAttachmentByIdRequest($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransactionAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $attachment_id Xero generated unique identifier for an attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransactionAttachmentByIdRequest($xero_tenant_id, $bank_transaction_id, $attachment_id, $content_type)
{
// 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 getBankTransactionAttachmentById'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling getBankTransactionAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getBankTransactionAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getBankTransactionAttachmentById'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransactionAttachments
*
* Allows you to retrieve any attachments to bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getBankTransactionAttachments($xero_tenant_id, $bank_transaction_id)
{
list($response) = $this->getBankTransactionAttachmentsWithHttpInfo($xero_tenant_id, $bank_transaction_id);
return $response;
}
/**
* Operation getBankTransactionAttachmentsWithHttpInfo
*
* Allows you to retrieve any attachments to bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransactionAttachmentsWithHttpInfo($xero_tenant_id, $bank_transaction_id)
{
$request = $this->getBankTransactionAttachmentsRequest($xero_tenant_id, $bank_transaction_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransactionAttachmentsAsync
*
* Allows you to retrieve any attachments to bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAttachmentsAsync($xero_tenant_id, $bank_transaction_id)
{
return $this->getBankTransactionAttachmentsAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransactionAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve any attachments to bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionAttachmentsAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getBankTransactionAttachmentsRequest($xero_tenant_id, $bank_transaction_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransactionAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransactionAttachmentsRequest($xero_tenant_id, $bank_transaction_id)
{
// 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 getBankTransactionAttachments'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling getBankTransactionAttachments'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransactions
*
* Allows you to retrieve any spend or receive money transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 bank transactions will be returned in a single API call with line items shown for each bank transaction (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransactions
*/
public function getBankTransactions($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
list($response) = $this->getBankTransactionsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
return $response;
}
/**
* Operation getBankTransactionsWithHttpInfo
*
* Allows you to retrieve any spend or receive money transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 bank transactions will be returned in a single API call with line items shown for each bank transaction (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransactions, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransactionsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
$request = $this->getBankTransactionsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransactionsAsync
*
* Allows you to retrieve any spend or receive money transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 bank transactions will be returned in a single API call with line items shown for each bank transaction (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
return $this->getBankTransactionsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransactionsAsyncWithHttpInfo
*
* Allows you to retrieve any spend or receive money transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 bank transactions will be returned in a single API call with line items shown for each bank transaction (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$request = $this->getBankTransactionsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransactions'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 bank transactions will be returned in a single API call with line items shown for each bank transaction (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransactionsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
// 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 getBankTransactions'
);
}
$resourcePath = '/BankTransactions';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// query params
if ($unitdp !== null) {
$queryParams['unitdp'] = AccountingObjectSerializer::toQueryValue($unitdp);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransactionsHistory
*
* Allows you to retrieve history from a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getBankTransactionsHistory($xero_tenant_id, $bank_transaction_id)
{
list($response) = $this->getBankTransactionsHistoryWithHttpInfo($xero_tenant_id, $bank_transaction_id);
return $response;
}
/**
* Operation getBankTransactionsHistoryWithHttpInfo
*
* Allows you to retrieve history from a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransactionsHistoryWithHttpInfo($xero_tenant_id, $bank_transaction_id)
{
$request = $this->getBankTransactionsHistoryRequest($xero_tenant_id, $bank_transaction_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransactionsHistoryAsync
*
* Allows you to retrieve history from a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionsHistoryAsync($xero_tenant_id, $bank_transaction_id)
{
return $this->getBankTransactionsHistoryAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransactionsHistoryAsyncWithHttpInfo
*
* Allows you to retrieve history from a bank transactions
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransactionsHistoryAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getBankTransactionsHistoryRequest($xero_tenant_id, $bank_transaction_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransactionsHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransactionsHistoryRequest($xero_tenant_id, $bank_transaction_id)
{
// 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 getBankTransactionsHistory'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling getBankTransactionsHistory'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransfer
*
* Allows you to retrieve any bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransfers
*/
public function getBankTransfer($xero_tenant_id, $bank_transfer_id)
{
list($response) = $this->getBankTransferWithHttpInfo($xero_tenant_id, $bank_transfer_id);
return $response;
}
/**
* Operation getBankTransferWithHttpInfo
*
* Allows you to retrieve any bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransfers, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransferWithHttpInfo($xero_tenant_id, $bank_transfer_id)
{
$request = $this->getBankTransferRequest($xero_tenant_id, $bank_transfer_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransfers' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransfers',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransferAsync
*
* Allows you to retrieve any bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAsync($xero_tenant_id, $bank_transfer_id)
{
return $this->getBankTransferAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransferAsyncWithHttpInfo
*
* Allows you to retrieve any bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers';
$request = $this->getBankTransferRequest($xero_tenant_id, $bank_transfer_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransfer'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransferRequest($xero_tenant_id, $bank_transfer_id)
{
// 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 getBankTransfer'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling getBankTransfer'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransferAttachmentByFileName
*
* Allows you to retrieve Attachments on BankTransfer by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getBankTransferAttachmentByFileName($xero_tenant_id, $bank_transfer_id, $file_name, $content_type)
{
list($response) = $this->getBankTransferAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $content_type);
return $response;
}
/**
* Operation getBankTransferAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve Attachments on BankTransfer by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransferAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $content_type)
{
$request = $this->getBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransferAttachmentByFileNameAsync
*
* Allows you to retrieve Attachments on BankTransfer by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAttachmentByFileNameAsync($xero_tenant_id, $bank_transfer_id, $file_name, $content_type)
{
return $this->getBankTransferAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransferAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on BankTransfer by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransferAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $content_type)
{
// 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 getBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling getBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getBankTransferAttachmentByFileName'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransferAttachmentById
*
* Allows you to retrieve Attachments on BankTransfer
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $attachment_id Xero generated unique identifier for an Attachment to a bank transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getBankTransferAttachmentById($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type)
{
list($response) = $this->getBankTransferAttachmentByIdWithHttpInfo($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getBankTransferAttachmentByIdWithHttpInfo
*
* Allows you to retrieve Attachments on BankTransfer
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $attachment_id Xero generated unique identifier for an Attachment to a bank transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransferAttachmentByIdWithHttpInfo($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type)
{
$request = $this->getBankTransferAttachmentByIdRequest($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransferAttachmentByIdAsync
*
* Allows you to retrieve Attachments on BankTransfer
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $attachment_id Xero generated unique identifier for an Attachment to a bank transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAttachmentByIdAsync($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type)
{
return $this->getBankTransferAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransferAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on BankTransfer
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $attachment_id Xero generated unique identifier for an Attachment to a bank transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getBankTransferAttachmentByIdRequest($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransferAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $attachment_id Xero generated unique identifier for an Attachment to a bank transfer (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransferAttachmentByIdRequest($xero_tenant_id, $bank_transfer_id, $attachment_id, $content_type)
{
// 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 getBankTransferAttachmentById'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling getBankTransferAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getBankTransferAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getBankTransferAttachmentById'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransferAttachments
*
* Allows you to retrieve Attachments from bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getBankTransferAttachments($xero_tenant_id, $bank_transfer_id)
{
list($response) = $this->getBankTransferAttachmentsWithHttpInfo($xero_tenant_id, $bank_transfer_id);
return $response;
}
/**
* Operation getBankTransferAttachmentsWithHttpInfo
*
* Allows you to retrieve Attachments from bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransferAttachmentsWithHttpInfo($xero_tenant_id, $bank_transfer_id)
{
$request = $this->getBankTransferAttachmentsRequest($xero_tenant_id, $bank_transfer_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransferAttachmentsAsync
*
* Allows you to retrieve Attachments from bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAttachmentsAsync($xero_tenant_id, $bank_transfer_id)
{
return $this->getBankTransferAttachmentsAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransferAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve Attachments from bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferAttachmentsAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getBankTransferAttachmentsRequest($xero_tenant_id, $bank_transfer_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransferAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransferAttachmentsRequest($xero_tenant_id, $bank_transfer_id)
{
// 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 getBankTransferAttachments'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling getBankTransferAttachments'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransferHistory
*
* Allows you to retrieve history from a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getBankTransferHistory($xero_tenant_id, $bank_transfer_id)
{
list($response) = $this->getBankTransferHistoryWithHttpInfo($xero_tenant_id, $bank_transfer_id);
return $response;
}
/**
* Operation getBankTransferHistoryWithHttpInfo
*
* Allows you to retrieve history from a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransferHistoryWithHttpInfo($xero_tenant_id, $bank_transfer_id)
{
$request = $this->getBankTransferHistoryRequest($xero_tenant_id, $bank_transfer_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransferHistoryAsync
*
* Allows you to retrieve history from a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferHistoryAsync($xero_tenant_id, $bank_transfer_id)
{
return $this->getBankTransferHistoryAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransferHistoryAsyncWithHttpInfo
*
* Allows you to retrieve history from a bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransferHistoryAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getBankTransferHistoryRequest($xero_tenant_id, $bank_transfer_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransferHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransferHistoryRequest($xero_tenant_id, $bank_transfer_id)
{
// 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 getBankTransferHistory'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling getBankTransferHistory'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBankTransfers
*
* Allows you to retrieve all bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransfers
*/
public function getBankTransfers($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
list($response) = $this->getBankTransfersWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order);
return $response;
}
/**
* Operation getBankTransfersWithHttpInfo
*
* Allows you to retrieve all bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransfers, HTTP status code, HTTP response headers (array of strings)
*/
public function getBankTransfersWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$request = $this->getBankTransfersRequest($xero_tenant_id, $if_modified_since, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransfers' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransfers',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBankTransfersAsync
*
* Allows you to retrieve all bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransfersAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
return $this->getBankTransfersAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBankTransfersAsyncWithHttpInfo
*
* Allows you to retrieve all bank transfers
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBankTransfersAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransfers';
$request = $this->getBankTransfersRequest($xero_tenant_id, $if_modified_since, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBankTransfers'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBankTransfersRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
// 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 getBankTransfers'
);
}
$resourcePath = '/BankTransfers';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBatchPaymentHistory
*
* Allows you to retrieve history from a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getBatchPaymentHistory($xero_tenant_id, $batch_payment_id)
{
list($response) = $this->getBatchPaymentHistoryWithHttpInfo($xero_tenant_id, $batch_payment_id);
return $response;
}
/**
* Operation getBatchPaymentHistoryWithHttpInfo
*
* Allows you to retrieve history from a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getBatchPaymentHistoryWithHttpInfo($xero_tenant_id, $batch_payment_id)
{
$request = $this->getBatchPaymentHistoryRequest($xero_tenant_id, $batch_payment_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBatchPaymentHistoryAsync
*
* Allows you to retrieve history from a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBatchPaymentHistoryAsync($xero_tenant_id, $batch_payment_id)
{
return $this->getBatchPaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $batch_payment_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBatchPaymentHistoryAsyncWithHttpInfo
*
* Allows you to retrieve history from a Batch Payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBatchPaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $batch_payment_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getBatchPaymentHistoryRequest($xero_tenant_id, $batch_payment_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBatchPaymentHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $batch_payment_id Unique identifier for BatchPayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBatchPaymentHistoryRequest($xero_tenant_id, $batch_payment_id)
{
// 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 getBatchPaymentHistory'
);
}
// verify the required parameter 'batch_payment_id' is set
if ($batch_payment_id === null || (is_array($batch_payment_id) && count($batch_payment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $batch_payment_id when calling getBatchPaymentHistory'
);
}
$resourcePath = '/BatchPayments/{BatchPaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($batch_payment_id !== null) {
$resourcePath = str_replace(
'{' . 'BatchPaymentID' . '}',
AccountingObjectSerializer::toPathValue($batch_payment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBatchPayments
*
* Retrieve either one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BatchPayments
*/
public function getBatchPayments($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
list($response) = $this->getBatchPaymentsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order);
return $response;
}
/**
* Operation getBatchPaymentsWithHttpInfo
*
* Retrieve either one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BatchPayments, HTTP status code, HTTP response headers (array of strings)
*/
public function getBatchPaymentsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$request = $this->getBatchPaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BatchPayments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BatchPayments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BatchPayments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BatchPayments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBatchPaymentsAsync
*
* Retrieve either one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBatchPaymentsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
return $this->getBatchPaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBatchPaymentsAsyncWithHttpInfo
*
* Retrieve either one or many BatchPayments for invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBatchPaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BatchPayments';
$request = $this->getBatchPaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBatchPayments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBatchPaymentsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
// 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 getBatchPayments'
);
}
$resourcePath = '/BatchPayments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBrandingTheme
*
* Allows you to retrieve a specific BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BrandingThemes
*/
public function getBrandingTheme($xero_tenant_id, $branding_theme_id)
{
list($response) = $this->getBrandingThemeWithHttpInfo($xero_tenant_id, $branding_theme_id);
return $response;
}
/**
* Operation getBrandingThemeWithHttpInfo
*
* Allows you to retrieve a specific BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BrandingThemes, HTTP status code, HTTP response headers (array of strings)
*/
public function getBrandingThemeWithHttpInfo($xero_tenant_id, $branding_theme_id)
{
$request = $this->getBrandingThemeRequest($xero_tenant_id, $branding_theme_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBrandingThemeAsync
*
* Allows you to retrieve a specific BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBrandingThemeAsync($xero_tenant_id, $branding_theme_id)
{
return $this->getBrandingThemeAsyncWithHttpInfo($xero_tenant_id, $branding_theme_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBrandingThemeAsyncWithHttpInfo
*
* Allows you to retrieve a specific BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBrandingThemeAsyncWithHttpInfo($xero_tenant_id, $branding_theme_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes';
$request = $this->getBrandingThemeRequest($xero_tenant_id, $branding_theme_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBrandingTheme'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBrandingThemeRequest($xero_tenant_id, $branding_theme_id)
{
// 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 getBrandingTheme'
);
}
// verify the required parameter 'branding_theme_id' is set
if ($branding_theme_id === null || (is_array($branding_theme_id) && count($branding_theme_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $branding_theme_id when calling getBrandingTheme'
);
}
$resourcePath = '/BrandingThemes/{BrandingThemeID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($branding_theme_id !== null) {
$resourcePath = str_replace(
'{' . 'BrandingThemeID' . '}',
AccountingObjectSerializer::toPathValue($branding_theme_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBrandingThemePaymentServices
*
* Allows you to retrieve the Payment services for a Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PaymentServices
*/
public function getBrandingThemePaymentServices($xero_tenant_id, $branding_theme_id)
{
list($response) = $this->getBrandingThemePaymentServicesWithHttpInfo($xero_tenant_id, $branding_theme_id);
return $response;
}
/**
* Operation getBrandingThemePaymentServicesWithHttpInfo
*
* Allows you to retrieve the Payment services for a Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PaymentServices, HTTP status code, HTTP response headers (array of strings)
*/
public function getBrandingThemePaymentServicesWithHttpInfo($xero_tenant_id, $branding_theme_id)
{
$request = $this->getBrandingThemePaymentServicesRequest($xero_tenant_id, $branding_theme_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PaymentServices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PaymentServices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBrandingThemePaymentServicesAsync
*
* Allows you to retrieve the Payment services for a Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBrandingThemePaymentServicesAsync($xero_tenant_id, $branding_theme_id)
{
return $this->getBrandingThemePaymentServicesAsyncWithHttpInfo($xero_tenant_id, $branding_theme_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBrandingThemePaymentServicesAsyncWithHttpInfo
*
* Allows you to retrieve the Payment services for a Branding Theme
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBrandingThemePaymentServicesAsyncWithHttpInfo($xero_tenant_id, $branding_theme_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$request = $this->getBrandingThemePaymentServicesRequest($xero_tenant_id, $branding_theme_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBrandingThemePaymentServices'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $branding_theme_id Unique identifier for a Branding Theme (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBrandingThemePaymentServicesRequest($xero_tenant_id, $branding_theme_id)
{
// 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 getBrandingThemePaymentServices'
);
}
// verify the required parameter 'branding_theme_id' is set
if ($branding_theme_id === null || (is_array($branding_theme_id) && count($branding_theme_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $branding_theme_id when calling getBrandingThemePaymentServices'
);
}
$resourcePath = '/BrandingThemes/{BrandingThemeID}/PaymentServices';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($branding_theme_id !== null) {
$resourcePath = str_replace(
'{' . 'BrandingThemeID' . '}',
AccountingObjectSerializer::toPathValue($branding_theme_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getBrandingThemes
*
* Allows you to retrieve all the BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BrandingThemes
*/
public function getBrandingThemes($xero_tenant_id)
{
list($response) = $this->getBrandingThemesWithHttpInfo($xero_tenant_id);
return $response;
}
/**
* Operation getBrandingThemesWithHttpInfo
*
* Allows you to retrieve all the BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BrandingThemes, HTTP status code, HTTP response headers (array of strings)
*/
public function getBrandingThemesWithHttpInfo($xero_tenant_id)
{
$request = $this->getBrandingThemesRequest($xero_tenant_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getBrandingThemesAsync
*
* Allows you to retrieve all the BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBrandingThemesAsync($xero_tenant_id)
{
return $this->getBrandingThemesAsyncWithHttpInfo($xero_tenant_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getBrandingThemesAsyncWithHttpInfo
*
* Allows you to retrieve all the BrandingThemes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getBrandingThemesAsyncWithHttpInfo($xero_tenant_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BrandingThemes';
$request = $this->getBrandingThemesRequest($xero_tenant_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getBrandingThemes'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getBrandingThemesRequest($xero_tenant_id)
{
// 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 getBrandingThemes'
);
}
$resourcePath = '/BrandingThemes';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContact
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Contacts
*/
public function getContact($xero_tenant_id, $contact_id)
{
list($response) = $this->getContactWithHttpInfo($xero_tenant_id, $contact_id);
return $response;
}
/**
* Operation getContactWithHttpInfo
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Contacts, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactWithHttpInfo($xero_tenant_id, $contact_id)
{
$request = $this->getContactRequest($xero_tenant_id, $contact_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Contacts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Contacts', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Contacts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactAsync
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAsync($xero_tenant_id, $contact_id)
{
return $this->getContactAsyncWithHttpInfo($xero_tenant_id, $contact_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactAsyncWithHttpInfo
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAsyncWithHttpInfo($xero_tenant_id, $contact_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$request = $this->getContactRequest($xero_tenant_id, $contact_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContact'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactRequest($xero_tenant_id, $contact_id)
{
// 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 getContact'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getContact'
);
}
$resourcePath = '/Contacts/{ContactID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContactAttachmentByFileName
*
* Allows you to retrieve Attachments on Contacts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getContactAttachmentByFileName($xero_tenant_id, $contact_id, $file_name, $content_type)
{
list($response) = $this->getContactAttachmentByFileNameWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $content_type);
return $response;
}
/**
* Operation getContactAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve Attachments on Contacts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactAttachmentByFileNameWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $content_type)
{
$request = $this->getContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactAttachmentByFileNameAsync
*
* Allows you to retrieve Attachments on Contacts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAttachmentByFileNameAsync($xero_tenant_id, $contact_id, $file_name, $content_type)
{
return $this->getContactAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on Contacts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContactAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $content_type)
{
// 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 getContactAttachmentByFileName'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getContactAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getContactAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getContactAttachmentByFileName'
);
}
$resourcePath = '/Contacts/{ContactID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContactAttachmentById
*
* Allows you to retrieve Attachments on Contacts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getContactAttachmentById($xero_tenant_id, $contact_id, $attachment_id, $content_type)
{
list($response) = $this->getContactAttachmentByIdWithHttpInfo($xero_tenant_id, $contact_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getContactAttachmentByIdWithHttpInfo
*
* Allows you to retrieve Attachments on Contacts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactAttachmentByIdWithHttpInfo($xero_tenant_id, $contact_id, $attachment_id, $content_type)
{
$request = $this->getContactAttachmentByIdRequest($xero_tenant_id, $contact_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactAttachmentByIdAsync
*
* Allows you to retrieve Attachments on Contacts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAttachmentByIdAsync($xero_tenant_id, $contact_id, $attachment_id, $content_type)
{
return $this->getContactAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $contact_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on Contacts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $contact_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getContactAttachmentByIdRequest($xero_tenant_id, $contact_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContactAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactAttachmentByIdRequest($xero_tenant_id, $contact_id, $attachment_id, $content_type)
{
// 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 getContactAttachmentById'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getContactAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getContactAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getContactAttachmentById'
);
}
$resourcePath = '/Contacts/{ContactID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContactAttachments
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getContactAttachments($xero_tenant_id, $contact_id)
{
list($response) = $this->getContactAttachmentsWithHttpInfo($xero_tenant_id, $contact_id);
return $response;
}
/**
* Operation getContactAttachmentsWithHttpInfo
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactAttachmentsWithHttpInfo($xero_tenant_id, $contact_id)
{
$request = $this->getContactAttachmentsRequest($xero_tenant_id, $contact_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactAttachmentsAsync
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAttachmentsAsync($xero_tenant_id, $contact_id)
{
return $this->getContactAttachmentsAsyncWithHttpInfo($xero_tenant_id, $contact_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactAttachmentsAsyncWithHttpInfo($xero_tenant_id, $contact_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getContactAttachmentsRequest($xero_tenant_id, $contact_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContactAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactAttachmentsRequest($xero_tenant_id, $contact_id)
{
// 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 getContactAttachments'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getContactAttachments'
);
}
$resourcePath = '/Contacts/{ContactID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContactCISSettings
*
* Allows you to retrieve CISSettings for a contact in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\CISSettings
*/
public function getContactCISSettings($xero_tenant_id, $contact_id)
{
list($response) = $this->getContactCISSettingsWithHttpInfo($xero_tenant_id, $contact_id);
return $response;
}
/**
* Operation getContactCISSettingsWithHttpInfo
*
* Allows you to retrieve CISSettings for a contact in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\CISSettings, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactCISSettingsWithHttpInfo($xero_tenant_id, $contact_id)
{
$request = $this->getContactCISSettingsRequest($xero_tenant_id, $contact_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\CISSettings' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\CISSettings', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CISSettings';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\CISSettings',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactCISSettingsAsync
*
* Allows you to retrieve CISSettings for a contact in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactCISSettingsAsync($xero_tenant_id, $contact_id)
{
return $this->getContactCISSettingsAsyncWithHttpInfo($xero_tenant_id, $contact_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactCISSettingsAsyncWithHttpInfo
*
* Allows you to retrieve CISSettings for a contact in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactCISSettingsAsyncWithHttpInfo($xero_tenant_id, $contact_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CISSettings';
$request = $this->getContactCISSettingsRequest($xero_tenant_id, $contact_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContactCISSettings'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactCISSettingsRequest($xero_tenant_id, $contact_id)
{
// 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 getContactCISSettings'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getContactCISSettings'
);
}
$resourcePath = '/Contacts/{ContactID}/CISSettings';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContactGroup
*
* Allows you to retrieve a unique Contract Group by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ContactGroups
*/
public function getContactGroup($xero_tenant_id, $contact_group_id)
{
list($response) = $this->getContactGroupWithHttpInfo($xero_tenant_id, $contact_group_id);
return $response;
}
/**
* Operation getContactGroupWithHttpInfo
*
* Allows you to retrieve a unique Contract Group by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ContactGroups, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactGroupWithHttpInfo($xero_tenant_id, $contact_group_id)
{
$request = $this->getContactGroupRequest($xero_tenant_id, $contact_group_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ContactGroups' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ContactGroups',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactGroupAsync
*
* Allows you to retrieve a unique Contract Group by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactGroupAsync($xero_tenant_id, $contact_group_id)
{
return $this->getContactGroupAsyncWithHttpInfo($xero_tenant_id, $contact_group_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactGroupAsyncWithHttpInfo
*
* Allows you to retrieve a unique Contract Group by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactGroupAsyncWithHttpInfo($xero_tenant_id, $contact_group_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$request = $this->getContactGroupRequest($xero_tenant_id, $contact_group_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContactGroup'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactGroupRequest($xero_tenant_id, $contact_group_id)
{
// 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 getContactGroup'
);
}
// verify the required parameter 'contact_group_id' is set
if ($contact_group_id === null || (is_array($contact_group_id) && count($contact_group_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_group_id when calling getContactGroup'
);
}
$resourcePath = '/ContactGroups/{ContactGroupID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_group_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactGroupID' . '}',
AccountingObjectSerializer::toPathValue($contact_group_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContactGroups
*
* Allows you to retrieve the ContactID and Name of all the contacts in a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ContactGroups
*/
public function getContactGroups($xero_tenant_id, $where = null, $order = null)
{
list($response) = $this->getContactGroupsWithHttpInfo($xero_tenant_id, $where, $order);
return $response;
}
/**
* Operation getContactGroupsWithHttpInfo
*
* Allows you to retrieve the ContactID and Name of all the contacts in a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ContactGroups, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactGroupsWithHttpInfo($xero_tenant_id, $where = null, $order = null)
{
$request = $this->getContactGroupsRequest($xero_tenant_id, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ContactGroups' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ContactGroups',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactGroupsAsync
*
* Allows you to retrieve the ContactID and Name of all the contacts in a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactGroupsAsync($xero_tenant_id, $where = null, $order = null)
{
return $this->getContactGroupsAsyncWithHttpInfo($xero_tenant_id, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactGroupsAsyncWithHttpInfo
*
* Allows you to retrieve the ContactID and Name of all the contacts in a contact group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactGroupsAsyncWithHttpInfo($xero_tenant_id, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$request = $this->getContactGroupsRequest($xero_tenant_id, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContactGroups'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactGroupsRequest($xero_tenant_id, $where = null, $order = null)
{
// 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 getContactGroups'
);
}
$resourcePath = '/ContactGroups';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContactHistory
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getContactHistory($xero_tenant_id, $contact_id)
{
list($response) = $this->getContactHistoryWithHttpInfo($xero_tenant_id, $contact_id);
return $response;
}
/**
* Operation getContactHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactHistoryWithHttpInfo($xero_tenant_id, $contact_id)
{
$request = $this->getContactHistoryRequest($xero_tenant_id, $contact_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactHistoryAsync
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactHistoryAsync($xero_tenant_id, $contact_id)
{
return $this->getContactHistoryAsyncWithHttpInfo($xero_tenant_id, $contact_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an Contact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactHistoryAsyncWithHttpInfo($xero_tenant_id, $contact_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getContactHistoryRequest($xero_tenant_id, $contact_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContactHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactHistoryRequest($xero_tenant_id, $contact_id)
{
// 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 getContactHistory'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getContactHistory'
);
}
$resourcePath = '/Contacts/{ContactID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getContacts
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. (optional)
* @param int $page e.g. page=1 - Up to 100 contacts will be returned in a single API call. (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Contacts
*/
public function getContacts($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $page = null, $include_archived = null)
{
list($response) = $this->getContactsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $page, $include_archived);
return $response;
}
/**
* Operation getContactsWithHttpInfo
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. (optional)
* @param int $page e.g. page=1 - Up to 100 contacts will be returned in a single API call. (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Contacts, HTTP status code, HTTP response headers (array of strings)
*/
public function getContactsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $page = null, $include_archived = null)
{
$request = $this->getContactsRequest($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $page, $include_archived);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Contacts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Contacts', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Contacts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getContactsAsync
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. (optional)
* @param int $page e.g. page=1 - Up to 100 contacts will be returned in a single API call. (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $page = null, $include_archived = null)
{
return $this->getContactsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $page, $include_archived)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getContactsAsyncWithHttpInfo
*
* Allows you to retrieve, add and update contacts in a Xero organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. (optional)
* @param int $page e.g. page=1 - Up to 100 contacts will be returned in a single API call. (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getContactsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $page = null, $include_archived = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$request = $this->getContactsRequest($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $page, $include_archived);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getContacts'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. (optional)
* @param int $page e.g. page=1 - Up to 100 contacts will be returned in a single API call. (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getContactsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $page = null, $include_archived = null)
{
// 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 getContacts'
);
}
$resourcePath = '/Contacts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if (is_array($i_ds)) {
$i_ds = AccountingObjectSerializer::serializeCollection($i_ds, 'multi', true);
}
if ($i_ds !== null) {
$queryParams['IDs'] = AccountingObjectSerializer::toQueryValue($i_ds);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// query params
if ($include_archived !== null) {
$queryParams['includeArchived'] = AccountingObjectSerializer::toQueryValue($include_archived);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCreditNote
*
* Allows you to retrieve a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\CreditNotes
*/
public function getCreditNote($xero_tenant_id, $credit_note_id)
{
list($response) = $this->getCreditNoteWithHttpInfo($xero_tenant_id, $credit_note_id);
return $response;
}
/**
* Operation getCreditNoteWithHttpInfo
*
* Allows you to retrieve a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\CreditNotes, HTTP status code, HTTP response headers (array of strings)
*/
public function getCreditNoteWithHttpInfo($xero_tenant_id, $credit_note_id)
{
$request = $this->getCreditNoteRequest($xero_tenant_id, $credit_note_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\CreditNotes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\CreditNotes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCreditNoteAsync
*
* Allows you to retrieve a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAsync($xero_tenant_id, $credit_note_id)
{
return $this->getCreditNoteAsyncWithHttpInfo($xero_tenant_id, $credit_note_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCreditNoteAsyncWithHttpInfo
*
* Allows you to retrieve a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAsyncWithHttpInfo($xero_tenant_id, $credit_note_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$request = $this->getCreditNoteRequest($xero_tenant_id, $credit_note_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCreditNote'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCreditNoteRequest($xero_tenant_id, $credit_note_id)
{
// 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 getCreditNote'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling getCreditNote'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCreditNoteAsPdf
*
* Allows you to retrieve Credit Note as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getCreditNoteAsPdf($xero_tenant_id, $credit_note_id, $content_type)
{
list($response) = $this->getCreditNoteAsPdfWithHttpInfo($xero_tenant_id, $credit_note_id, $content_type);
return $response;
}
/**
* Operation getCreditNoteAsPdfWithHttpInfo
*
* Allows you to retrieve Credit Note as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getCreditNoteAsPdfWithHttpInfo($xero_tenant_id, $credit_note_id, $content_type)
{
$request = $this->getCreditNoteAsPdfRequest($xero_tenant_id, $credit_note_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCreditNoteAsPdfAsync
*
* Allows you to retrieve Credit Note as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAsPdfAsync($xero_tenant_id, $credit_note_id, $content_type)
{
return $this->getCreditNoteAsPdfAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCreditNoteAsPdfAsyncWithHttpInfo
*
* Allows you to retrieve Credit Note as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAsPdfAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getCreditNoteAsPdfRequest($xero_tenant_id, $credit_note_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCreditNoteAsPdf'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCreditNoteAsPdfRequest($xero_tenant_id, $credit_note_id, $content_type)
{
// 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 getCreditNoteAsPdf'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling getCreditNoteAsPdf'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getCreditNoteAsPdf'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/pdf';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCreditNoteAttachmentByFileName
*
* Allows you to retrieve Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getCreditNoteAttachmentByFileName($xero_tenant_id, $credit_note_id, $file_name, $content_type)
{
list($response) = $this->getCreditNoteAttachmentByFileNameWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $content_type);
return $response;
}
/**
* Operation getCreditNoteAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getCreditNoteAttachmentByFileNameWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $content_type)
{
$request = $this->getCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCreditNoteAttachmentByFileNameAsync
*
* Allows you to retrieve Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAttachmentByFileNameAsync($xero_tenant_id, $credit_note_id, $file_name, $content_type)
{
return $this->getCreditNoteAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCreditNoteAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCreditNoteAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $content_type)
{
// 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 getCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling getCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getCreditNoteAttachmentByFileName'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCreditNoteAttachmentById
*
* Allows you to retrieve Attachments on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getCreditNoteAttachmentById($xero_tenant_id, $credit_note_id, $attachment_id, $content_type)
{
list($response) = $this->getCreditNoteAttachmentByIdWithHttpInfo($xero_tenant_id, $credit_note_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getCreditNoteAttachmentByIdWithHttpInfo
*
* Allows you to retrieve Attachments on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getCreditNoteAttachmentByIdWithHttpInfo($xero_tenant_id, $credit_note_id, $attachment_id, $content_type)
{
$request = $this->getCreditNoteAttachmentByIdRequest($xero_tenant_id, $credit_note_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCreditNoteAttachmentByIdAsync
*
* Allows you to retrieve Attachments on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAttachmentByIdAsync($xero_tenant_id, $credit_note_id, $attachment_id, $content_type)
{
return $this->getCreditNoteAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCreditNoteAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getCreditNoteAttachmentByIdRequest($xero_tenant_id, $credit_note_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCreditNoteAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCreditNoteAttachmentByIdRequest($xero_tenant_id, $credit_note_id, $attachment_id, $content_type)
{
// 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 getCreditNoteAttachmentById'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling getCreditNoteAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getCreditNoteAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getCreditNoteAttachmentById'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCreditNoteAttachments
*
* Allows you to retrieve Attachments for credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getCreditNoteAttachments($xero_tenant_id, $credit_note_id)
{
list($response) = $this->getCreditNoteAttachmentsWithHttpInfo($xero_tenant_id, $credit_note_id);
return $response;
}
/**
* Operation getCreditNoteAttachmentsWithHttpInfo
*
* Allows you to retrieve Attachments for credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getCreditNoteAttachmentsWithHttpInfo($xero_tenant_id, $credit_note_id)
{
$request = $this->getCreditNoteAttachmentsRequest($xero_tenant_id, $credit_note_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCreditNoteAttachmentsAsync
*
* Allows you to retrieve Attachments for credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAttachmentsAsync($xero_tenant_id, $credit_note_id)
{
return $this->getCreditNoteAttachmentsAsyncWithHttpInfo($xero_tenant_id, $credit_note_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCreditNoteAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve Attachments for credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteAttachmentsAsyncWithHttpInfo($xero_tenant_id, $credit_note_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getCreditNoteAttachmentsRequest($xero_tenant_id, $credit_note_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCreditNoteAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCreditNoteAttachmentsRequest($xero_tenant_id, $credit_note_id)
{
// 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 getCreditNoteAttachments'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling getCreditNoteAttachments'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCreditNoteHistory
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getCreditNoteHistory($xero_tenant_id, $credit_note_id)
{
list($response) = $this->getCreditNoteHistoryWithHttpInfo($xero_tenant_id, $credit_note_id);
return $response;
}
/**
* Operation getCreditNoteHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getCreditNoteHistoryWithHttpInfo($xero_tenant_id, $credit_note_id)
{
$request = $this->getCreditNoteHistoryRequest($xero_tenant_id, $credit_note_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCreditNoteHistoryAsync
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteHistoryAsync($xero_tenant_id, $credit_note_id)
{
return $this->getCreditNoteHistoryAsyncWithHttpInfo($xero_tenant_id, $credit_note_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCreditNoteHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an CreditNote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNoteHistoryAsyncWithHttpInfo($xero_tenant_id, $credit_note_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getCreditNoteHistoryRequest($xero_tenant_id, $credit_note_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCreditNoteHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCreditNoteHistoryRequest($xero_tenant_id, $credit_note_id)
{
// 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 getCreditNoteHistory'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling getCreditNoteHistory'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCreditNotes
*
* Allows you to retrieve any credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 credit notes will be returned in a single API call with line items shown for each credit note (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\CreditNotes
*/
public function getCreditNotes($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
list($response) = $this->getCreditNotesWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page);
return $response;
}
/**
* Operation getCreditNotesWithHttpInfo
*
* Allows you to retrieve any credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 credit notes will be returned in a single API call with line items shown for each credit note (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\CreditNotes, HTTP status code, HTTP response headers (array of strings)
*/
public function getCreditNotesWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
$request = $this->getCreditNotesRequest($xero_tenant_id, $if_modified_since, $where, $order, $page);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\CreditNotes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\CreditNotes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCreditNotesAsync
*
* Allows you to retrieve any credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 credit notes will be returned in a single API call with line items shown for each credit note (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNotesAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
return $this->getCreditNotesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCreditNotesAsyncWithHttpInfo
*
* Allows you to retrieve any credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 credit notes will be returned in a single API call with line items shown for each credit note (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCreditNotesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$request = $this->getCreditNotesRequest($xero_tenant_id, $if_modified_since, $where, $order, $page);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCreditNotes'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 credit notes will be returned in a single API call with line items shown for each credit note (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCreditNotesRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
// 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 getCreditNotes'
);
}
$resourcePath = '/CreditNotes';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getCurrencies
*
* Allows you to retrieve currencies for your organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Currencies
*/
public function getCurrencies($xero_tenant_id, $where = null, $order = null)
{
list($response) = $this->getCurrenciesWithHttpInfo($xero_tenant_id, $where, $order);
return $response;
}
/**
* Operation getCurrenciesWithHttpInfo
*
* Allows you to retrieve currencies for your organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @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 getCurrenciesWithHttpInfo($xero_tenant_id, $where = null, $order = null)
{
$request = $this->getCurrenciesRequest($xero_tenant_id, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Currencies' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Currencies', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Currencies';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Currencies',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getCurrenciesAsync
*
* Allows you to retrieve currencies for your organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCurrenciesAsync($xero_tenant_id, $where = null, $order = null)
{
return $this->getCurrenciesAsyncWithHttpInfo($xero_tenant_id, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getCurrenciesAsyncWithHttpInfo
*
* Allows you to retrieve currencies for your organisation
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getCurrenciesAsyncWithHttpInfo($xero_tenant_id, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Currencies';
$request = $this->getCurrenciesRequest($xero_tenant_id, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getCurrencies'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getCurrenciesRequest($xero_tenant_id, $where = null, $order = null)
{
// 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 getCurrencies'
);
}
$resourcePath = '/Currencies';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getEmployee
*
* Allows you to retrieve a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Employees
*/
public function getEmployee($xero_tenant_id, $employee_id)
{
list($response) = $this->getEmployeeWithHttpInfo($xero_tenant_id, $employee_id);
return $response;
}
/**
* Operation getEmployeeWithHttpInfo
*
* Allows you to retrieve a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Employees, HTTP status code, HTTP response headers (array of strings)
*/
public function getEmployeeWithHttpInfo($xero_tenant_id, $employee_id)
{
$request = $this->getEmployeeRequest($xero_tenant_id, $employee_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Employees' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Employees', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Employees',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getEmployeeAsync
*
* Allows you to retrieve a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getEmployeeAsync($xero_tenant_id, $employee_id)
{
return $this->getEmployeeAsyncWithHttpInfo($xero_tenant_id, $employee_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getEmployeeAsyncWithHttpInfo
*
* Allows you to retrieve a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getEmployeeAsyncWithHttpInfo($xero_tenant_id, $employee_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$request = $this->getEmployeeRequest($xero_tenant_id, $employee_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getEmployee'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getEmployeeRequest($xero_tenant_id, $employee_id)
{
// 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 getEmployee'
);
}
// verify the required parameter 'employee_id' is set
if ($employee_id === null || (is_array($employee_id) && count($employee_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $employee_id when calling getEmployee'
);
}
$resourcePath = '/Employees/{EmployeeID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($employee_id !== null) {
$resourcePath = str_replace(
'{' . 'EmployeeID' . '}',
AccountingObjectSerializer::toPathValue($employee_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getEmployees
*
* Allows you to retrieve employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Employees
*/
public function getEmployees($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
list($response) = $this->getEmployeesWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order);
return $response;
}
/**
* Operation getEmployeesWithHttpInfo
*
* Allows you to retrieve employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Employees, HTTP status code, HTTP response headers (array of strings)
*/
public function getEmployeesWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$request = $this->getEmployeesRequest($xero_tenant_id, $if_modified_since, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Employees' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Employees', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Employees',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getEmployeesAsync
*
* Allows you to retrieve employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getEmployeesAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
return $this->getEmployeesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getEmployeesAsyncWithHttpInfo
*
* Allows you to retrieve employees used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getEmployeesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$request = $this->getEmployeesRequest($xero_tenant_id, $if_modified_since, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getEmployees'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getEmployeesRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
// 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 getEmployees'
);
}
$resourcePath = '/Employees';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getExpenseClaim
*
* Allows you to retrieve a specified expense claim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims
*/
public function getExpenseClaim($xero_tenant_id, $expense_claim_id)
{
list($response) = $this->getExpenseClaimWithHttpInfo($xero_tenant_id, $expense_claim_id);
return $response;
}
/**
* Operation getExpenseClaimWithHttpInfo
*
* Allows you to retrieve a specified expense claim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims, HTTP status code, HTTP response headers (array of strings)
*/
public function getExpenseClaimWithHttpInfo($xero_tenant_id, $expense_claim_id)
{
$request = $this->getExpenseClaimRequest($xero_tenant_id, $expense_claim_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getExpenseClaimAsync
*
* Allows you to retrieve a specified expense claim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getExpenseClaimAsync($xero_tenant_id, $expense_claim_id)
{
return $this->getExpenseClaimAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getExpenseClaimAsyncWithHttpInfo
*
* Allows you to retrieve a specified expense claim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getExpenseClaimAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$request = $this->getExpenseClaimRequest($xero_tenant_id, $expense_claim_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getExpenseClaim'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getExpenseClaimRequest($xero_tenant_id, $expense_claim_id)
{
// 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 getExpenseClaim'
);
}
// verify the required parameter 'expense_claim_id' is set
if ($expense_claim_id === null || (is_array($expense_claim_id) && count($expense_claim_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $expense_claim_id when calling getExpenseClaim'
);
}
$resourcePath = '/ExpenseClaims/{ExpenseClaimID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($expense_claim_id !== null) {
$resourcePath = str_replace(
'{' . 'ExpenseClaimID' . '}',
AccountingObjectSerializer::toPathValue($expense_claim_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getExpenseClaimHistory
*
* Allows you to retrieve a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getExpenseClaimHistory($xero_tenant_id, $expense_claim_id)
{
list($response) = $this->getExpenseClaimHistoryWithHttpInfo($xero_tenant_id, $expense_claim_id);
return $response;
}
/**
* Operation getExpenseClaimHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getExpenseClaimHistoryWithHttpInfo($xero_tenant_id, $expense_claim_id)
{
$request = $this->getExpenseClaimHistoryRequest($xero_tenant_id, $expense_claim_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getExpenseClaimHistoryAsync
*
* Allows you to retrieve a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getExpenseClaimHistoryAsync($xero_tenant_id, $expense_claim_id)
{
return $this->getExpenseClaimHistoryAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getExpenseClaimHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an ExpenseClaim
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getExpenseClaimHistoryAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getExpenseClaimHistoryRequest($xero_tenant_id, $expense_claim_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getExpenseClaimHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getExpenseClaimHistoryRequest($xero_tenant_id, $expense_claim_id)
{
// 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 getExpenseClaimHistory'
);
}
// verify the required parameter 'expense_claim_id' is set
if ($expense_claim_id === null || (is_array($expense_claim_id) && count($expense_claim_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $expense_claim_id when calling getExpenseClaimHistory'
);
}
$resourcePath = '/ExpenseClaims/{ExpenseClaimID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($expense_claim_id !== null) {
$resourcePath = str_replace(
'{' . 'ExpenseClaimID' . '}',
AccountingObjectSerializer::toPathValue($expense_claim_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getExpenseClaims
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims
*/
public function getExpenseClaims($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
list($response) = $this->getExpenseClaimsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order);
return $response;
}
/**
* Operation getExpenseClaimsWithHttpInfo
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims, HTTP status code, HTTP response headers (array of strings)
*/
public function getExpenseClaimsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$request = $this->getExpenseClaimsRequest($xero_tenant_id, $if_modified_since, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getExpenseClaimsAsync
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getExpenseClaimsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
return $this->getExpenseClaimsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getExpenseClaimsAsyncWithHttpInfo
*
* Allows you to retrieve expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getExpenseClaimsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$request = $this->getExpenseClaimsRequest($xero_tenant_id, $if_modified_since, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getExpenseClaims'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getExpenseClaimsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
// 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 getExpenseClaims'
);
}
$resourcePath = '/ExpenseClaims';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoice
*
* Allows you to retrieve a specified sales invoice or purchase bill
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Invoices
*/
public function getInvoice($xero_tenant_id, $invoice_id)
{
list($response) = $this->getInvoiceWithHttpInfo($xero_tenant_id, $invoice_id);
return $response;
}
/**
* Operation getInvoiceWithHttpInfo
*
* Allows you to retrieve a specified sales invoice or purchase bill
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Invoices, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoiceWithHttpInfo($xero_tenant_id, $invoice_id)
{
$request = $this->getInvoiceRequest($xero_tenant_id, $invoice_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Invoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Invoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Invoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoiceAsync
*
* Allows you to retrieve a specified sales invoice or purchase bill
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAsync($xero_tenant_id, $invoice_id)
{
return $this->getInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoiceAsyncWithHttpInfo
*
* Allows you to retrieve a specified sales invoice or purchase bill
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$request = $this->getInvoiceRequest($xero_tenant_id, $invoice_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoice'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoiceRequest($xero_tenant_id, $invoice_id)
{
// 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 getInvoice'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling getInvoice'
);
}
$resourcePath = '/Invoices/{InvoiceID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoiceAsPdf
*
* Allows you to retrieve invoices or purchase bills as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getInvoiceAsPdf($xero_tenant_id, $invoice_id, $content_type)
{
list($response) = $this->getInvoiceAsPdfWithHttpInfo($xero_tenant_id, $invoice_id, $content_type);
return $response;
}
/**
* Operation getInvoiceAsPdfWithHttpInfo
*
* Allows you to retrieve invoices or purchase bills as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoiceAsPdfWithHttpInfo($xero_tenant_id, $invoice_id, $content_type)
{
$request = $this->getInvoiceAsPdfRequest($xero_tenant_id, $invoice_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoiceAsPdfAsync
*
* Allows you to retrieve invoices or purchase bills as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAsPdfAsync($xero_tenant_id, $invoice_id, $content_type)
{
return $this->getInvoiceAsPdfAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoiceAsPdfAsyncWithHttpInfo
*
* Allows you to retrieve invoices or purchase bills as PDF files
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAsPdfAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getInvoiceAsPdfRequest($xero_tenant_id, $invoice_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoiceAsPdf'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoiceAsPdfRequest($xero_tenant_id, $invoice_id, $content_type)
{
// 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 getInvoiceAsPdf'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling getInvoiceAsPdf'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getInvoiceAsPdf'
);
}
$resourcePath = '/Invoices/{InvoiceID}/pdf';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoiceAttachmentByFileName
*
* Allows you to retrieve Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getInvoiceAttachmentByFileName($xero_tenant_id, $invoice_id, $file_name, $content_type)
{
list($response) = $this->getInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $content_type);
return $response;
}
/**
* Operation getInvoiceAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $content_type)
{
$request = $this->getInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoiceAttachmentByFileNameAsync
*
* Allows you to retrieve Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAttachmentByFileNameAsync($xero_tenant_id, $invoice_id, $file_name, $content_type)
{
return $this->getInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoiceAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoiceAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $content_type)
{
// 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 getInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling getInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getInvoiceAttachmentByFileName'
);
}
$resourcePath = '/Invoices/{InvoiceID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoiceAttachmentById
*
* Allows you to retrieve a specified Attachment on invoices or purchase bills by it's ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $attachment_id Unique identifier for an Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getInvoiceAttachmentById($xero_tenant_id, $invoice_id, $attachment_id, $content_type)
{
list($response) = $this->getInvoiceAttachmentByIdWithHttpInfo($xero_tenant_id, $invoice_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getInvoiceAttachmentByIdWithHttpInfo
*
* Allows you to retrieve a specified Attachment on invoices or purchase bills by it's ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $attachment_id Unique identifier for an Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoiceAttachmentByIdWithHttpInfo($xero_tenant_id, $invoice_id, $attachment_id, $content_type)
{
$request = $this->getInvoiceAttachmentByIdRequest($xero_tenant_id, $invoice_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoiceAttachmentByIdAsync
*
* Allows you to retrieve a specified Attachment on invoices or purchase bills by it's ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $attachment_id Unique identifier for an Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAttachmentByIdAsync($xero_tenant_id, $invoice_id, $attachment_id, $content_type)
{
return $this->getInvoiceAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoiceAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve a specified Attachment on invoices or purchase bills by it's ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $attachment_id Unique identifier for an Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getInvoiceAttachmentByIdRequest($xero_tenant_id, $invoice_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoiceAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $attachment_id Unique identifier for an Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoiceAttachmentByIdRequest($xero_tenant_id, $invoice_id, $attachment_id, $content_type)
{
// 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 getInvoiceAttachmentById'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling getInvoiceAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getInvoiceAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getInvoiceAttachmentById'
);
}
$resourcePath = '/Invoices/{InvoiceID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoiceAttachments
*
* Allows you to retrieve Attachments on invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getInvoiceAttachments($xero_tenant_id, $invoice_id)
{
list($response) = $this->getInvoiceAttachmentsWithHttpInfo($xero_tenant_id, $invoice_id);
return $response;
}
/**
* Operation getInvoiceAttachmentsWithHttpInfo
*
* Allows you to retrieve Attachments on invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoiceAttachmentsWithHttpInfo($xero_tenant_id, $invoice_id)
{
$request = $this->getInvoiceAttachmentsRequest($xero_tenant_id, $invoice_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoiceAttachmentsAsync
*
* Allows you to retrieve Attachments on invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAttachmentsAsync($xero_tenant_id, $invoice_id)
{
return $this->getInvoiceAttachmentsAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoiceAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceAttachmentsAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getInvoiceAttachmentsRequest($xero_tenant_id, $invoice_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoiceAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoiceAttachmentsRequest($xero_tenant_id, $invoice_id)
{
// 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 getInvoiceAttachments'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling getInvoiceAttachments'
);
}
$resourcePath = '/Invoices/{InvoiceID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoiceHistory
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getInvoiceHistory($xero_tenant_id, $invoice_id)
{
list($response) = $this->getInvoiceHistoryWithHttpInfo($xero_tenant_id, $invoice_id);
return $response;
}
/**
* Operation getInvoiceHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoiceHistoryWithHttpInfo($xero_tenant_id, $invoice_id)
{
$request = $this->getInvoiceHistoryRequest($xero_tenant_id, $invoice_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoiceHistoryAsync
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceHistoryAsync($xero_tenant_id, $invoice_id)
{
return $this->getInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoiceHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getInvoiceHistoryRequest($xero_tenant_id, $invoice_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoiceHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoiceHistoryRequest($xero_tenant_id, $invoice_id)
{
// 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 getInvoiceHistory'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling getInvoiceHistory'
);
}
$resourcePath = '/Invoices/{InvoiceID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoiceReminders
*
* Allows you to retrieve invoice reminder settings
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\InvoiceReminders
*/
public function getInvoiceReminders($xero_tenant_id)
{
list($response) = $this->getInvoiceRemindersWithHttpInfo($xero_tenant_id);
return $response;
}
/**
* Operation getInvoiceRemindersWithHttpInfo
*
* Allows you to retrieve invoice reminder settings
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\InvoiceReminders, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoiceRemindersWithHttpInfo($xero_tenant_id)
{
$request = $this->getInvoiceRemindersRequest($xero_tenant_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\InvoiceReminders' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\InvoiceReminders', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\InvoiceReminders';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\InvoiceReminders',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoiceRemindersAsync
*
* Allows you to retrieve invoice reminder settings
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceRemindersAsync($xero_tenant_id)
{
return $this->getInvoiceRemindersAsyncWithHttpInfo($xero_tenant_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoiceRemindersAsyncWithHttpInfo
*
* Allows you to retrieve invoice reminder settings
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoiceRemindersAsyncWithHttpInfo($xero_tenant_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\InvoiceReminders';
$request = $this->getInvoiceRemindersRequest($xero_tenant_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoiceReminders'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoiceRemindersRequest($xero_tenant_id)
{
// 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 getInvoiceReminders'
);
}
$resourcePath = '/InvoiceReminders/Settings';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getInvoices
*
* Allows you to retrieve any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma-separated list of InvoicesIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $invoice_numbers Filter by a comma-separated list of InvoiceNumbers. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $contact_i_ds Filter by a comma-separated list of ContactIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $statuses Filter by a comma-separated list Statuses. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param int $page e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
* @param bool $created_by_my_app When set to true you'll only retrieve Invoices created by your app (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Invoices
*/
public function getInvoices($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $invoice_numbers = null, $contact_i_ds = null, $statuses = null, $page = null, $include_archived = null, $created_by_my_app = null, $unitdp = null)
{
list($response) = $this->getInvoicesWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $invoice_numbers, $contact_i_ds, $statuses, $page, $include_archived, $created_by_my_app, $unitdp);
return $response;
}
/**
* Operation getInvoicesWithHttpInfo
*
* Allows you to retrieve any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma-separated list of InvoicesIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $invoice_numbers Filter by a comma-separated list of InvoiceNumbers. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $contact_i_ds Filter by a comma-separated list of ContactIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $statuses Filter by a comma-separated list Statuses. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param int $page e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
* @param bool $created_by_my_app When set to true you'll only retrieve Invoices created by your app (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Invoices, HTTP status code, HTTP response headers (array of strings)
*/
public function getInvoicesWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $invoice_numbers = null, $contact_i_ds = null, $statuses = null, $page = null, $include_archived = null, $created_by_my_app = null, $unitdp = null)
{
$request = $this->getInvoicesRequest($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $invoice_numbers, $contact_i_ds, $statuses, $page, $include_archived, $created_by_my_app, $unitdp);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Invoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Invoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Invoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getInvoicesAsync
*
* Allows you to retrieve any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma-separated list of InvoicesIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $invoice_numbers Filter by a comma-separated list of InvoiceNumbers. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $contact_i_ds Filter by a comma-separated list of ContactIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $statuses Filter by a comma-separated list Statuses. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param int $page e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
* @param bool $created_by_my_app When set to true you'll only retrieve Invoices created by your app (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoicesAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $invoice_numbers = null, $contact_i_ds = null, $statuses = null, $page = null, $include_archived = null, $created_by_my_app = null, $unitdp = null)
{
return $this->getInvoicesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $invoice_numbers, $contact_i_ds, $statuses, $page, $include_archived, $created_by_my_app, $unitdp)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getInvoicesAsyncWithHttpInfo
*
* Allows you to retrieve any sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma-separated list of InvoicesIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $invoice_numbers Filter by a comma-separated list of InvoiceNumbers. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $contact_i_ds Filter by a comma-separated list of ContactIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $statuses Filter by a comma-separated list Statuses. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param int $page e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
* @param bool $created_by_my_app When set to true you'll only retrieve Invoices created by your app (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getInvoicesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $invoice_numbers = null, $contact_i_ds = null, $statuses = null, $page = null, $include_archived = null, $created_by_my_app = null, $unitdp = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$request = $this->getInvoicesRequest($xero_tenant_id, $if_modified_since, $where, $order, $i_ds, $invoice_numbers, $contact_i_ds, $statuses, $page, $include_archived, $created_by_my_app, $unitdp);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getInvoices'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string[] $i_ds Filter by a comma-separated list of InvoicesIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $invoice_numbers Filter by a comma-separated list of InvoiceNumbers. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $contact_i_ds Filter by a comma-separated list of ContactIDs. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param string[] $statuses Filter by a comma-separated list Statuses. For faster response times we recommend using these explicit parameters instead of passing OR conditions into the Where filter. (optional)
* @param int $page e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice (optional)
* @param bool $include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response (optional)
* @param bool $created_by_my_app When set to true you'll only retrieve Invoices created by your app (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getInvoicesRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $i_ds = null, $invoice_numbers = null, $contact_i_ds = null, $statuses = null, $page = null, $include_archived = null, $created_by_my_app = null, $unitdp = null)
{
// 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 getInvoices'
);
}
$resourcePath = '/Invoices';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if (is_array($i_ds)) {
$i_ds = AccountingObjectSerializer::serializeCollection($i_ds, 'multi', true);
}
if ($i_ds !== null) {
$queryParams['IDs'] = AccountingObjectSerializer::toQueryValue($i_ds);
}
// query params
if (is_array($invoice_numbers)) {
$invoice_numbers = AccountingObjectSerializer::serializeCollection($invoice_numbers, 'multi', true);
}
if ($invoice_numbers !== null) {
$queryParams['InvoiceNumbers'] = AccountingObjectSerializer::toQueryValue($invoice_numbers);
}
// query params
if (is_array($contact_i_ds)) {
$contact_i_ds = AccountingObjectSerializer::serializeCollection($contact_i_ds, 'multi', true);
}
if ($contact_i_ds !== null) {
$queryParams['ContactIDs'] = AccountingObjectSerializer::toQueryValue($contact_i_ds);
}
// query params
if (is_array($statuses)) {
$statuses = AccountingObjectSerializer::serializeCollection($statuses, 'multi', true);
}
if ($statuses !== null) {
$queryParams['Statuses'] = AccountingObjectSerializer::toQueryValue($statuses);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// query params
if ($include_archived !== null) {
$queryParams['includeArchived'] = AccountingObjectSerializer::toQueryValue($include_archived);
}
// query params
if ($created_by_my_app !== null) {
$queryParams['createdByMyApp'] = AccountingObjectSerializer::toQueryValue($created_by_my_app);
}
// query params
if ($unitdp !== null) {
$queryParams['unitdp'] = AccountingObjectSerializer::toQueryValue($unitdp);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getItem
*
* Allows you to retrieve a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Items
*/
public function getItem($xero_tenant_id, $item_id)
{
list($response) = $this->getItemWithHttpInfo($xero_tenant_id, $item_id);
return $response;
}
/**
* Operation getItemWithHttpInfo
*
* Allows you to retrieve a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Items, HTTP status code, HTTP response headers (array of strings)
*/
public function getItemWithHttpInfo($xero_tenant_id, $item_id)
{
$request = $this->getItemRequest($xero_tenant_id, $item_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Items' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Items', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Items',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getItemAsync
*
* Allows you to retrieve a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getItemAsync($xero_tenant_id, $item_id)
{
return $this->getItemAsyncWithHttpInfo($xero_tenant_id, $item_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getItemAsyncWithHttpInfo
*
* Allows you to retrieve a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getItemAsyncWithHttpInfo($xero_tenant_id, $item_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$request = $this->getItemRequest($xero_tenant_id, $item_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getItem'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getItemRequest($xero_tenant_id, $item_id)
{
// 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 getItem'
);
}
// verify the required parameter 'item_id' is set
if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $item_id when calling getItem'
);
}
$resourcePath = '/Items/{ItemID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($item_id !== null) {
$resourcePath = str_replace(
'{' . 'ItemID' . '}',
AccountingObjectSerializer::toPathValue($item_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getItemHistory
*
* Allows you to retrieve history for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getItemHistory($xero_tenant_id, $item_id)
{
list($response) = $this->getItemHistoryWithHttpInfo($xero_tenant_id, $item_id);
return $response;
}
/**
* Operation getItemHistoryWithHttpInfo
*
* Allows you to retrieve history for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getItemHistoryWithHttpInfo($xero_tenant_id, $item_id)
{
$request = $this->getItemHistoryRequest($xero_tenant_id, $item_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getItemHistoryAsync
*
* Allows you to retrieve history for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getItemHistoryAsync($xero_tenant_id, $item_id)
{
return $this->getItemHistoryAsyncWithHttpInfo($xero_tenant_id, $item_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getItemHistoryAsyncWithHttpInfo
*
* Allows you to retrieve history for items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getItemHistoryAsyncWithHttpInfo($xero_tenant_id, $item_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getItemHistoryRequest($xero_tenant_id, $item_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getItemHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getItemHistoryRequest($xero_tenant_id, $item_id)
{
// 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 getItemHistory'
);
}
// verify the required parameter 'item_id' is set
if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $item_id when calling getItemHistory'
);
}
$resourcePath = '/Items/{ItemID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($item_id !== null) {
$resourcePath = str_replace(
'{' . 'ItemID' . '}',
AccountingObjectSerializer::toPathValue($item_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getItems
*
* Allows you to retrieve any items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Items
*/
public function getItems($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
list($response) = $this->getItemsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $unitdp);
return $response;
}
/**
* Operation getItemsWithHttpInfo
*
* Allows you to retrieve any items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Items, HTTP status code, HTTP response headers (array of strings)
*/
public function getItemsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
$request = $this->getItemsRequest($xero_tenant_id, $if_modified_since, $where, $order, $unitdp);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Items' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Items', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Items',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getItemsAsync
*
* Allows you to retrieve any items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getItemsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
return $this->getItemsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $unitdp)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getItemsAsyncWithHttpInfo
*
* Allows you to retrieve any items
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getItemsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$request = $this->getItemsRequest($xero_tenant_id, $if_modified_since, $where, $order, $unitdp);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getItems'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getItemsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
// 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 getItems'
);
}
$resourcePath = '/Items';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($unitdp !== null) {
$queryParams['unitdp'] = AccountingObjectSerializer::toQueryValue($unitdp);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getJournal
*
* Allows you to retrieve a specified journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $journal_id Unique identifier for a Journal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Journals
*/
public function getJournal($xero_tenant_id, $journal_id)
{
list($response) = $this->getJournalWithHttpInfo($xero_tenant_id, $journal_id);
return $response;
}
/**
* Operation getJournalWithHttpInfo
*
* Allows you to retrieve a specified journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $journal_id Unique identifier for a Journal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Journals, HTTP status code, HTTP response headers (array of strings)
*/
public function getJournalWithHttpInfo($xero_tenant_id, $journal_id)
{
$request = $this->getJournalRequest($xero_tenant_id, $journal_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Journals' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Journals', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Journals';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Journals',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getJournalAsync
*
* Allows you to retrieve a specified journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $journal_id Unique identifier for a Journal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getJournalAsync($xero_tenant_id, $journal_id)
{
return $this->getJournalAsyncWithHttpInfo($xero_tenant_id, $journal_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getJournalAsyncWithHttpInfo
*
* Allows you to retrieve a specified journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $journal_id Unique identifier for a Journal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getJournalAsyncWithHttpInfo($xero_tenant_id, $journal_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Journals';
$request = $this->getJournalRequest($xero_tenant_id, $journal_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getJournal'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $journal_id Unique identifier for a Journal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getJournalRequest($xero_tenant_id, $journal_id)
{
// 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 getJournal'
);
}
// verify the required parameter 'journal_id' is set
if ($journal_id === null || (is_array($journal_id) && count($journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $journal_id when calling getJournal'
);
}
$resourcePath = '/Journals/{JournalID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($journal_id !== null) {
$resourcePath = str_replace(
'{' . 'JournalID' . '}',
AccountingObjectSerializer::toPathValue($journal_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getJournals
*
* Allows you to retrieve any journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param int $offset Offset by a specified journal number. e.g. journals with a JournalNumber greater than the offset will be returned (optional)
* @param bool $payments_only Filter to retrieve journals on a cash basis. Journals are returned on an accrual basis by default. (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Journals
*/
public function getJournals($xero_tenant_id, $if_modified_since = null, $offset = null, $payments_only = null)
{
list($response) = $this->getJournalsWithHttpInfo($xero_tenant_id, $if_modified_since, $offset, $payments_only);
return $response;
}
/**
* Operation getJournalsWithHttpInfo
*
* Allows you to retrieve any journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param int $offset Offset by a specified journal number. e.g. journals with a JournalNumber greater than the offset will be returned (optional)
* @param bool $payments_only Filter to retrieve journals on a cash basis. Journals are returned on an accrual basis by default. (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Journals, HTTP status code, HTTP response headers (array of strings)
*/
public function getJournalsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $offset = null, $payments_only = null)
{
$request = $this->getJournalsRequest($xero_tenant_id, $if_modified_since, $offset, $payments_only);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Journals' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Journals', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Journals';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Journals',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getJournalsAsync
*
* Allows you to retrieve any journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param int $offset Offset by a specified journal number. e.g. journals with a JournalNumber greater than the offset will be returned (optional)
* @param bool $payments_only Filter to retrieve journals on a cash basis. Journals are returned on an accrual basis by default. (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getJournalsAsync($xero_tenant_id, $if_modified_since = null, $offset = null, $payments_only = null)
{
return $this->getJournalsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $offset, $payments_only)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getJournalsAsyncWithHttpInfo
*
* Allows you to retrieve any journals.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param int $offset Offset by a specified journal number. e.g. journals with a JournalNumber greater than the offset will be returned (optional)
* @param bool $payments_only Filter to retrieve journals on a cash basis. Journals are returned on an accrual basis by default. (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getJournalsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $offset = null, $payments_only = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Journals';
$request = $this->getJournalsRequest($xero_tenant_id, $if_modified_since, $offset, $payments_only);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getJournals'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param int $offset Offset by a specified journal number. e.g. journals with a JournalNumber greater than the offset will be returned (optional)
* @param bool $payments_only Filter to retrieve journals on a cash basis. Journals are returned on an accrual basis by default. (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getJournalsRequest($xero_tenant_id, $if_modified_since = null, $offset = null, $payments_only = null)
{
// 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 getJournals'
);
}
$resourcePath = '/Journals';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($offset !== null) {
$queryParams['offset'] = AccountingObjectSerializer::toQueryValue($offset);
}
// query params
if ($payments_only !== null) {
$queryParams['paymentsOnly'] = AccountingObjectSerializer::toQueryValue($payments_only);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getLinkedTransaction
*
* Allows you to retrieve a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions
*/
public function getLinkedTransaction($xero_tenant_id, $linked_transaction_id)
{
list($response) = $this->getLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction_id);
return $response;
}
/**
* Operation getLinkedTransactionWithHttpInfo
*
* Allows you to retrieve a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions, HTTP status code, HTTP response headers (array of strings)
*/
public function getLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction_id)
{
$request = $this->getLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getLinkedTransactionAsync
*
* Allows you to retrieve a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getLinkedTransactionAsync($xero_tenant_id, $linked_transaction_id)
{
return $this->getLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getLinkedTransactionAsyncWithHttpInfo
*
* Allows you to retrieve a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$request = $this->getLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getLinkedTransaction'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id)
{
// 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 getLinkedTransaction'
);
}
// verify the required parameter 'linked_transaction_id' is set
if ($linked_transaction_id === null || (is_array($linked_transaction_id) && count($linked_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $linked_transaction_id when calling getLinkedTransaction'
);
}
$resourcePath = '/LinkedTransactions/{LinkedTransactionID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($linked_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'LinkedTransactionID' . '}',
AccountingObjectSerializer::toPathValue($linked_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getLinkedTransactions
*
* Retrieve linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param int $page Up to 100 linked transactions will be returned in a single API call. Use the page parameter to specify the page to be returned e.g. page=1. (optional)
* @param string $linked_transaction_id The Xero identifier for an Linked Transaction (optional)
* @param string $source_transaction_id Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY invoice (optional)
* @param string $contact_id Filter by the ContactID. Get all the linked transactions that have been assigned to a particular customer. (optional)
* @param string $status 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. (optional)
* @param string $target_transaction_id Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions
*/
public function getLinkedTransactions($xero_tenant_id, $page = null, $linked_transaction_id = null, $source_transaction_id = null, $contact_id = null, $status = null, $target_transaction_id = null)
{
list($response) = $this->getLinkedTransactionsWithHttpInfo($xero_tenant_id, $page, $linked_transaction_id, $source_transaction_id, $contact_id, $status, $target_transaction_id);
return $response;
}
/**
* Operation getLinkedTransactionsWithHttpInfo
*
* Retrieve linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param int $page Up to 100 linked transactions will be returned in a single API call. Use the page parameter to specify the page to be returned e.g. page=1. (optional)
* @param string $linked_transaction_id The Xero identifier for an Linked Transaction (optional)
* @param string $source_transaction_id Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY invoice (optional)
* @param string $contact_id Filter by the ContactID. Get all the linked transactions that have been assigned to a particular customer. (optional)
* @param string $status 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. (optional)
* @param string $target_transaction_id Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions, HTTP status code, HTTP response headers (array of strings)
*/
public function getLinkedTransactionsWithHttpInfo($xero_tenant_id, $page = null, $linked_transaction_id = null, $source_transaction_id = null, $contact_id = null, $status = null, $target_transaction_id = null)
{
$request = $this->getLinkedTransactionsRequest($xero_tenant_id, $page, $linked_transaction_id, $source_transaction_id, $contact_id, $status, $target_transaction_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getLinkedTransactionsAsync
*
* Retrieve linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param int $page Up to 100 linked transactions will be returned in a single API call. Use the page parameter to specify the page to be returned e.g. page=1. (optional)
* @param string $linked_transaction_id The Xero identifier for an Linked Transaction (optional)
* @param string $source_transaction_id Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY invoice (optional)
* @param string $contact_id Filter by the ContactID. Get all the linked transactions that have been assigned to a particular customer. (optional)
* @param string $status 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. (optional)
* @param string $target_transaction_id Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getLinkedTransactionsAsync($xero_tenant_id, $page = null, $linked_transaction_id = null, $source_transaction_id = null, $contact_id = null, $status = null, $target_transaction_id = null)
{
return $this->getLinkedTransactionsAsyncWithHttpInfo($xero_tenant_id, $page, $linked_transaction_id, $source_transaction_id, $contact_id, $status, $target_transaction_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getLinkedTransactionsAsyncWithHttpInfo
*
* Retrieve linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param int $page Up to 100 linked transactions will be returned in a single API call. Use the page parameter to specify the page to be returned e.g. page=1. (optional)
* @param string $linked_transaction_id The Xero identifier for an Linked Transaction (optional)
* @param string $source_transaction_id Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY invoice (optional)
* @param string $contact_id Filter by the ContactID. Get all the linked transactions that have been assigned to a particular customer. (optional)
* @param string $status 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. (optional)
* @param string $target_transaction_id Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getLinkedTransactionsAsyncWithHttpInfo($xero_tenant_id, $page = null, $linked_transaction_id = null, $source_transaction_id = null, $contact_id = null, $status = null, $target_transaction_id = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$request = $this->getLinkedTransactionsRequest($xero_tenant_id, $page, $linked_transaction_id, $source_transaction_id, $contact_id, $status, $target_transaction_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getLinkedTransactions'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param int $page Up to 100 linked transactions will be returned in a single API call. Use the page parameter to specify the page to be returned e.g. page=1. (optional)
* @param string $linked_transaction_id The Xero identifier for an Linked Transaction (optional)
* @param string $source_transaction_id Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY invoice (optional)
* @param string $contact_id Filter by the ContactID. Get all the linked transactions that have been assigned to a particular customer. (optional)
* @param string $status 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. (optional)
* @param string $target_transaction_id Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getLinkedTransactionsRequest($xero_tenant_id, $page = null, $linked_transaction_id = null, $source_transaction_id = null, $contact_id = null, $status = null, $target_transaction_id = null)
{
// 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 getLinkedTransactions'
);
}
$resourcePath = '/LinkedTransactions';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// query params
if ($linked_transaction_id !== null) {
$queryParams['LinkedTransactionID'] = AccountingObjectSerializer::toQueryValue($linked_transaction_id);
}
// query params
if ($source_transaction_id !== null) {
$queryParams['SourceTransactionID'] = AccountingObjectSerializer::toQueryValue($source_transaction_id);
}
// query params
if ($contact_id !== null) {
$queryParams['ContactID'] = AccountingObjectSerializer::toQueryValue($contact_id);
}
// query params
if ($status !== null) {
$queryParams['Status'] = AccountingObjectSerializer::toQueryValue($status);
}
// query params
if ($target_transaction_id !== null) {
$queryParams['TargetTransactionID'] = AccountingObjectSerializer::toQueryValue($target_transaction_id);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getManualJournal
*
* Allows you to retrieve a specified manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ManualJournals
*/
public function getManualJournal($xero_tenant_id, $manual_journal_id)
{
list($response) = $this->getManualJournalWithHttpInfo($xero_tenant_id, $manual_journal_id);
return $response;
}
/**
* Operation getManualJournalWithHttpInfo
*
* Allows you to retrieve a specified manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ManualJournals, HTTP status code, HTTP response headers (array of strings)
*/
public function getManualJournalWithHttpInfo($xero_tenant_id, $manual_journal_id)
{
$request = $this->getManualJournalRequest($xero_tenant_id, $manual_journal_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ManualJournals' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ManualJournals',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getManualJournalAsync
*
* Allows you to retrieve a specified manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAsync($xero_tenant_id, $manual_journal_id)
{
return $this->getManualJournalAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getManualJournalAsyncWithHttpInfo
*
* Allows you to retrieve a specified manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$request = $this->getManualJournalRequest($xero_tenant_id, $manual_journal_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getManualJournal'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getManualJournalRequest($xero_tenant_id, $manual_journal_id)
{
// 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 getManualJournal'
);
}
// verify the required parameter 'manual_journal_id' is set
if ($manual_journal_id === null || (is_array($manual_journal_id) && count($manual_journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal_id when calling getManualJournal'
);
}
$resourcePath = '/ManualJournals/{ManualJournalID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($manual_journal_id !== null) {
$resourcePath = str_replace(
'{' . 'ManualJournalID' . '}',
AccountingObjectSerializer::toPathValue($manual_journal_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getManualJournalAttachmentByFileName
*
* Allows you to retrieve specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getManualJournalAttachmentByFileName($xero_tenant_id, $manual_journal_id, $file_name, $content_type)
{
list($response) = $this->getManualJournalAttachmentByFileNameWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $content_type);
return $response;
}
/**
* Operation getManualJournalAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getManualJournalAttachmentByFileNameWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $content_type)
{
$request = $this->getManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getManualJournalAttachmentByFileNameAsync
*
* Allows you to retrieve specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAttachmentByFileNameAsync($xero_tenant_id, $manual_journal_id, $file_name, $content_type)
{
return $this->getManualJournalAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getManualJournalAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getManualJournalAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $content_type)
{
// 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 getManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'manual_journal_id' is set
if ($manual_journal_id === null || (is_array($manual_journal_id) && count($manual_journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal_id when calling getManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getManualJournalAttachmentByFileName'
);
}
$resourcePath = '/ManualJournals/{ManualJournalID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($manual_journal_id !== null) {
$resourcePath = str_replace(
'{' . 'ManualJournalID' . '}',
AccountingObjectSerializer::toPathValue($manual_journal_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getManualJournalAttachmentById
*
* Allows you to retrieve specified Attachment on ManualJournals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getManualJournalAttachmentById($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type)
{
list($response) = $this->getManualJournalAttachmentByIdWithHttpInfo($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getManualJournalAttachmentByIdWithHttpInfo
*
* Allows you to retrieve specified Attachment on ManualJournals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getManualJournalAttachmentByIdWithHttpInfo($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type)
{
$request = $this->getManualJournalAttachmentByIdRequest($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getManualJournalAttachmentByIdAsync
*
* Allows you to retrieve specified Attachment on ManualJournals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAttachmentByIdAsync($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type)
{
return $this->getManualJournalAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getManualJournalAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve specified Attachment on ManualJournals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getManualJournalAttachmentByIdRequest($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getManualJournalAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getManualJournalAttachmentByIdRequest($xero_tenant_id, $manual_journal_id, $attachment_id, $content_type)
{
// 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 getManualJournalAttachmentById'
);
}
// verify the required parameter 'manual_journal_id' is set
if ($manual_journal_id === null || (is_array($manual_journal_id) && count($manual_journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal_id when calling getManualJournalAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getManualJournalAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getManualJournalAttachmentById'
);
}
$resourcePath = '/ManualJournals/{ManualJournalID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($manual_journal_id !== null) {
$resourcePath = str_replace(
'{' . 'ManualJournalID' . '}',
AccountingObjectSerializer::toPathValue($manual_journal_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getManualJournalAttachments
*
* Allows you to retrieve Attachment for manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getManualJournalAttachments($xero_tenant_id, $manual_journal_id)
{
list($response) = $this->getManualJournalAttachmentsWithHttpInfo($xero_tenant_id, $manual_journal_id);
return $response;
}
/**
* Operation getManualJournalAttachmentsWithHttpInfo
*
* Allows you to retrieve Attachment for manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getManualJournalAttachmentsWithHttpInfo($xero_tenant_id, $manual_journal_id)
{
$request = $this->getManualJournalAttachmentsRequest($xero_tenant_id, $manual_journal_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getManualJournalAttachmentsAsync
*
* Allows you to retrieve Attachment for manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAttachmentsAsync($xero_tenant_id, $manual_journal_id)
{
return $this->getManualJournalAttachmentsAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getManualJournalAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve Attachment for manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalAttachmentsAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getManualJournalAttachmentsRequest($xero_tenant_id, $manual_journal_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getManualJournalAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getManualJournalAttachmentsRequest($xero_tenant_id, $manual_journal_id)
{
// 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 getManualJournalAttachments'
);
}
// verify the required parameter 'manual_journal_id' is set
if ($manual_journal_id === null || (is_array($manual_journal_id) && count($manual_journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal_id when calling getManualJournalAttachments'
);
}
$resourcePath = '/ManualJournals/{ManualJournalID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($manual_journal_id !== null) {
$resourcePath = str_replace(
'{' . 'ManualJournalID' . '}',
AccountingObjectSerializer::toPathValue($manual_journal_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getManualJournals
*
* Allows you to retrieve any manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 manual journals will be returned in a single API call with line items shown for each overpayment (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ManualJournals
*/
public function getManualJournals($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
list($response) = $this->getManualJournalsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page);
return $response;
}
/**
* Operation getManualJournalsWithHttpInfo
*
* Allows you to retrieve any manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 manual journals will be returned in a single API call with line items shown for each overpayment (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ManualJournals, HTTP status code, HTTP response headers (array of strings)
*/
public function getManualJournalsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
$request = $this->getManualJournalsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ManualJournals' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ManualJournals',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getManualJournalsAsync
*
* Allows you to retrieve any manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 manual journals will be returned in a single API call with line items shown for each overpayment (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
return $this->getManualJournalsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getManualJournalsAsyncWithHttpInfo
*
* Allows you to retrieve any manual journals
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 manual journals will be returned in a single API call with line items shown for each overpayment (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getManualJournalsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$request = $this->getManualJournalsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getManualJournals'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 manual journals will be returned in a single API call with line items shown for each overpayment (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getManualJournalsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null)
{
// 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 getManualJournals'
);
}
$resourcePath = '/ManualJournals';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getOnlineInvoice
*
* Allows you to retrieve a URL to an online invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\OnlineInvoices
*/
public function getOnlineInvoice($xero_tenant_id, $invoice_id)
{
list($response) = $this->getOnlineInvoiceWithHttpInfo($xero_tenant_id, $invoice_id);
return $response;
}
/**
* Operation getOnlineInvoiceWithHttpInfo
*
* Allows you to retrieve a URL to an online invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\OnlineInvoices, HTTP status code, HTTP response headers (array of strings)
*/
public function getOnlineInvoiceWithHttpInfo($xero_tenant_id, $invoice_id)
{
$request = $this->getOnlineInvoiceRequest($xero_tenant_id, $invoice_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\OnlineInvoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\OnlineInvoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\OnlineInvoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\OnlineInvoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getOnlineInvoiceAsync
*
* Allows you to retrieve a URL to an online invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOnlineInvoiceAsync($xero_tenant_id, $invoice_id)
{
return $this->getOnlineInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getOnlineInvoiceAsyncWithHttpInfo
*
* Allows you to retrieve a URL to an online invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOnlineInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\OnlineInvoices';
$request = $this->getOnlineInvoiceRequest($xero_tenant_id, $invoice_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getOnlineInvoice'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getOnlineInvoiceRequest($xero_tenant_id, $invoice_id)
{
// 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 getOnlineInvoice'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling getOnlineInvoice'
);
}
$resourcePath = '/Invoices/{InvoiceID}/OnlineInvoice';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getOrganisationCISSettings
*
* Allows you To verify if an organisation is using contruction industry scheme, you can retrieve the CIS settings for the organistaion.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $organisation_id organisation_id (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\CISOrgSetting
*/
public function getOrganisationCISSettings($xero_tenant_id, $organisation_id)
{
list($response) = $this->getOrganisationCISSettingsWithHttpInfo($xero_tenant_id, $organisation_id);
return $response;
}
/**
* Operation getOrganisationCISSettingsWithHttpInfo
*
* Allows you To verify if an organisation is using contruction industry scheme, you can retrieve the CIS settings for the organistaion.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $organisation_id (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\CISOrgSetting, HTTP status code, HTTP response headers (array of strings)
*/
public function getOrganisationCISSettingsWithHttpInfo($xero_tenant_id, $organisation_id)
{
$request = $this->getOrganisationCISSettingsRequest($xero_tenant_id, $organisation_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\CISOrgSetting' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\CISOrgSetting', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CISOrgSetting';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\CISOrgSetting',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getOrganisationCISSettingsAsync
*
* Allows you To verify if an organisation is using contruction industry scheme, you can retrieve the CIS settings for the organistaion.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $organisation_id (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOrganisationCISSettingsAsync($xero_tenant_id, $organisation_id)
{
return $this->getOrganisationCISSettingsAsyncWithHttpInfo($xero_tenant_id, $organisation_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getOrganisationCISSettingsAsyncWithHttpInfo
*
* Allows you To verify if an organisation is using contruction industry scheme, you can retrieve the CIS settings for the organistaion.
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $organisation_id (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOrganisationCISSettingsAsyncWithHttpInfo($xero_tenant_id, $organisation_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CISOrgSetting';
$request = $this->getOrganisationCISSettingsRequest($xero_tenant_id, $organisation_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getOrganisationCISSettings'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $organisation_id (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getOrganisationCISSettingsRequest($xero_tenant_id, $organisation_id)
{
// 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 getOrganisationCISSettings'
);
}
// verify the required parameter 'organisation_id' is set
if ($organisation_id === null || (is_array($organisation_id) && count($organisation_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $organisation_id when calling getOrganisationCISSettings'
);
}
$resourcePath = '/Organisation/{OrganisationID}/CISSettings';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($organisation_id !== null) {
$resourcePath = str_replace(
'{' . 'OrganisationID' . '}',
AccountingObjectSerializer::toPathValue($organisation_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getOrganisations
*
* Allows you to retrieve Organisation details
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Organisations
*/
public function getOrganisations($xero_tenant_id)
{
list($response) = $this->getOrganisationsWithHttpInfo($xero_tenant_id);
return $response;
}
/**
* Operation getOrganisationsWithHttpInfo
*
* Allows you to retrieve Organisation details
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Organisations, HTTP status code, HTTP response headers (array of strings)
*/
public function getOrganisationsWithHttpInfo($xero_tenant_id)
{
$request = $this->getOrganisationsRequest($xero_tenant_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Organisations' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Organisations', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Organisations';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Organisations',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getOrganisationsAsync
*
* Allows you to retrieve Organisation details
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOrganisationsAsync($xero_tenant_id)
{
return $this->getOrganisationsAsyncWithHttpInfo($xero_tenant_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getOrganisationsAsyncWithHttpInfo
*
* Allows you to retrieve Organisation details
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOrganisationsAsyncWithHttpInfo($xero_tenant_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Organisations';
$request = $this->getOrganisationsRequest($xero_tenant_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getOrganisations'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getOrganisationsRequest($xero_tenant_id)
{
// 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 getOrganisations'
);
}
$resourcePath = '/Organisation';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getOverpayment
*
* Allows you to retrieve a specified overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Overpayments
*/
public function getOverpayment($xero_tenant_id, $overpayment_id)
{
list($response) = $this->getOverpaymentWithHttpInfo($xero_tenant_id, $overpayment_id);
return $response;
}
/**
* Operation getOverpaymentWithHttpInfo
*
* Allows you to retrieve a specified overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Overpayments, HTTP status code, HTTP response headers (array of strings)
*/
public function getOverpaymentWithHttpInfo($xero_tenant_id, $overpayment_id)
{
$request = $this->getOverpaymentRequest($xero_tenant_id, $overpayment_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Overpayments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Overpayments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Overpayments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Overpayments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getOverpaymentAsync
*
* Allows you to retrieve a specified overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOverpaymentAsync($xero_tenant_id, $overpayment_id)
{
return $this->getOverpaymentAsyncWithHttpInfo($xero_tenant_id, $overpayment_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getOverpaymentAsyncWithHttpInfo
*
* Allows you to retrieve a specified overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOverpaymentAsyncWithHttpInfo($xero_tenant_id, $overpayment_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Overpayments';
$request = $this->getOverpaymentRequest($xero_tenant_id, $overpayment_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getOverpayment'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getOverpaymentRequest($xero_tenant_id, $overpayment_id)
{
// 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 getOverpayment'
);
}
// verify the required parameter 'overpayment_id' is set
if ($overpayment_id === null || (is_array($overpayment_id) && count($overpayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $overpayment_id when calling getOverpayment'
);
}
$resourcePath = '/Overpayments/{OverpaymentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($overpayment_id !== null) {
$resourcePath = str_replace(
'{' . 'OverpaymentID' . '}',
AccountingObjectSerializer::toPathValue($overpayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getOverpaymentHistory
*
* Allows you to retrieve a history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getOverpaymentHistory($xero_tenant_id, $overpayment_id)
{
list($response) = $this->getOverpaymentHistoryWithHttpInfo($xero_tenant_id, $overpayment_id);
return $response;
}
/**
* Operation getOverpaymentHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getOverpaymentHistoryWithHttpInfo($xero_tenant_id, $overpayment_id)
{
$request = $this->getOverpaymentHistoryRequest($xero_tenant_id, $overpayment_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getOverpaymentHistoryAsync
*
* Allows you to retrieve a history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOverpaymentHistoryAsync($xero_tenant_id, $overpayment_id)
{
return $this->getOverpaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $overpayment_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getOverpaymentHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an Overpayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOverpaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $overpayment_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getOverpaymentHistoryRequest($xero_tenant_id, $overpayment_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getOverpaymentHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $overpayment_id Unique identifier for a Overpayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getOverpaymentHistoryRequest($xero_tenant_id, $overpayment_id)
{
// 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 getOverpaymentHistory'
);
}
// verify the required parameter 'overpayment_id' is set
if ($overpayment_id === null || (is_array($overpayment_id) && count($overpayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $overpayment_id when calling getOverpaymentHistory'
);
}
$resourcePath = '/Overpayments/{OverpaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($overpayment_id !== null) {
$resourcePath = str_replace(
'{' . 'OverpaymentID' . '}',
AccountingObjectSerializer::toPathValue($overpayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getOverpayments
*
* Allows you to retrieve overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 overpayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Overpayments
*/
public function getOverpayments($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
list($response) = $this->getOverpaymentsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
return $response;
}
/**
* Operation getOverpaymentsWithHttpInfo
*
* Allows you to retrieve overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 overpayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Overpayments, HTTP status code, HTTP response headers (array of strings)
*/
public function getOverpaymentsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
$request = $this->getOverpaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Overpayments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Overpayments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Overpayments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Overpayments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getOverpaymentsAsync
*
* Allows you to retrieve overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 overpayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOverpaymentsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
return $this->getOverpaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getOverpaymentsAsyncWithHttpInfo
*
* Allows you to retrieve overpayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 overpayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getOverpaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Overpayments';
$request = $this->getOverpaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getOverpayments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 overpayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getOverpaymentsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
// 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 getOverpayments'
);
}
$resourcePath = '/Overpayments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// query params
if ($unitdp !== null) {
$queryParams['unitdp'] = AccountingObjectSerializer::toQueryValue($unitdp);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPayment
*
* Allows you to retrieve a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Payments
*/
public function getPayment($xero_tenant_id, $payment_id)
{
list($response) = $this->getPaymentWithHttpInfo($xero_tenant_id, $payment_id);
return $response;
}
/**
* Operation getPaymentWithHttpInfo
*
* Allows you to retrieve a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Payments, HTTP status code, HTTP response headers (array of strings)
*/
public function getPaymentWithHttpInfo($xero_tenant_id, $payment_id)
{
$request = $this->getPaymentRequest($xero_tenant_id, $payment_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Payments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Payments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Payments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPaymentAsync
*
* Allows you to retrieve a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentAsync($xero_tenant_id, $payment_id)
{
return $this->getPaymentAsyncWithHttpInfo($xero_tenant_id, $payment_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPaymentAsyncWithHttpInfo
*
* Allows you to retrieve a specified payment for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentAsyncWithHttpInfo($xero_tenant_id, $payment_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$request = $this->getPaymentRequest($xero_tenant_id, $payment_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPayment'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPaymentRequest($xero_tenant_id, $payment_id)
{
// 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 getPayment'
);
}
// verify the required parameter 'payment_id' is set
if ($payment_id === null || (is_array($payment_id) && count($payment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payment_id when calling getPayment'
);
}
$resourcePath = '/Payments/{PaymentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($payment_id !== null) {
$resourcePath = str_replace(
'{' . 'PaymentID' . '}',
AccountingObjectSerializer::toPathValue($payment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPaymentHistory
*
* Allows you to retrieve history records of a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getPaymentHistory($xero_tenant_id, $payment_id)
{
list($response) = $this->getPaymentHistoryWithHttpInfo($xero_tenant_id, $payment_id);
return $response;
}
/**
* Operation getPaymentHistoryWithHttpInfo
*
* Allows you to retrieve history records of a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getPaymentHistoryWithHttpInfo($xero_tenant_id, $payment_id)
{
$request = $this->getPaymentHistoryRequest($xero_tenant_id, $payment_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPaymentHistoryAsync
*
* Allows you to retrieve history records of a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentHistoryAsync($xero_tenant_id, $payment_id)
{
return $this->getPaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $payment_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPaymentHistoryAsyncWithHttpInfo
*
* Allows you to retrieve history records of a payment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $payment_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getPaymentHistoryRequest($xero_tenant_id, $payment_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPaymentHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $payment_id Unique identifier for a Payment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPaymentHistoryRequest($xero_tenant_id, $payment_id)
{
// 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 getPaymentHistory'
);
}
// verify the required parameter 'payment_id' is set
if ($payment_id === null || (is_array($payment_id) && count($payment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $payment_id when calling getPaymentHistory'
);
}
$resourcePath = '/Payments/{PaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($payment_id !== null) {
$resourcePath = str_replace(
'{' . 'PaymentID' . '}',
AccountingObjectSerializer::toPathValue($payment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPaymentServices
*
* Allows you to retrieve payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PaymentServices
*/
public function getPaymentServices($xero_tenant_id)
{
list($response) = $this->getPaymentServicesWithHttpInfo($xero_tenant_id);
return $response;
}
/**
* Operation getPaymentServicesWithHttpInfo
*
* Allows you to retrieve payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PaymentServices, HTTP status code, HTTP response headers (array of strings)
*/
public function getPaymentServicesWithHttpInfo($xero_tenant_id)
{
$request = $this->getPaymentServicesRequest($xero_tenant_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PaymentServices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PaymentServices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPaymentServicesAsync
*
* Allows you to retrieve payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentServicesAsync($xero_tenant_id)
{
return $this->getPaymentServicesAsyncWithHttpInfo($xero_tenant_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPaymentServicesAsyncWithHttpInfo
*
* Allows you to retrieve payment services
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentServicesAsyncWithHttpInfo($xero_tenant_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PaymentServices';
$request = $this->getPaymentServicesRequest($xero_tenant_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPaymentServices'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPaymentServicesRequest($xero_tenant_id)
{
// 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 getPaymentServices'
);
}
$resourcePath = '/PaymentServices';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPayments
*
* Allows you to retrieve payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Payments
*/
public function getPayments($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
list($response) = $this->getPaymentsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order);
return $response;
}
/**
* Operation getPaymentsWithHttpInfo
*
* Allows you to retrieve payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Payments, HTTP status code, HTTP response headers (array of strings)
*/
public function getPaymentsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$request = $this->getPaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Payments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Payments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Payments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPaymentsAsync
*
* Allows you to retrieve payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
return $this->getPaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPaymentsAsyncWithHttpInfo
*
* Allows you to retrieve payments for invoices and credit notes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Payments';
$request = $this->getPaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPayments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPaymentsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
// 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 getPayments'
);
}
$resourcePath = '/Payments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPrepayment
*
* Allows you to retrieve a specified prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Prepayments
*/
public function getPrepayment($xero_tenant_id, $prepayment_id)
{
list($response) = $this->getPrepaymentWithHttpInfo($xero_tenant_id, $prepayment_id);
return $response;
}
/**
* Operation getPrepaymentWithHttpInfo
*
* Allows you to retrieve a specified prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Prepayments, HTTP status code, HTTP response headers (array of strings)
*/
public function getPrepaymentWithHttpInfo($xero_tenant_id, $prepayment_id)
{
$request = $this->getPrepaymentRequest($xero_tenant_id, $prepayment_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Prepayments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Prepayments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Prepayments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Prepayments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPrepaymentAsync
*
* Allows you to retrieve a specified prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPrepaymentAsync($xero_tenant_id, $prepayment_id)
{
return $this->getPrepaymentAsyncWithHttpInfo($xero_tenant_id, $prepayment_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPrepaymentAsyncWithHttpInfo
*
* Allows you to retrieve a specified prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPrepaymentAsyncWithHttpInfo($xero_tenant_id, $prepayment_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Prepayments';
$request = $this->getPrepaymentRequest($xero_tenant_id, $prepayment_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPrepayment'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPrepaymentRequest($xero_tenant_id, $prepayment_id)
{
// 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 getPrepayment'
);
}
// verify the required parameter 'prepayment_id' is set
if ($prepayment_id === null || (is_array($prepayment_id) && count($prepayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $prepayment_id when calling getPrepayment'
);
}
$resourcePath = '/Prepayments/{PrepaymentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($prepayment_id !== null) {
$resourcePath = str_replace(
'{' . 'PrepaymentID' . '}',
AccountingObjectSerializer::toPathValue($prepayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPrepaymentHistory
*
* Allows you to retrieve a history records of an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getPrepaymentHistory($xero_tenant_id, $prepayment_id)
{
list($response) = $this->getPrepaymentHistoryWithHttpInfo($xero_tenant_id, $prepayment_id);
return $response;
}
/**
* Operation getPrepaymentHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getPrepaymentHistoryWithHttpInfo($xero_tenant_id, $prepayment_id)
{
$request = $this->getPrepaymentHistoryRequest($xero_tenant_id, $prepayment_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPrepaymentHistoryAsync
*
* Allows you to retrieve a history records of an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPrepaymentHistoryAsync($xero_tenant_id, $prepayment_id)
{
return $this->getPrepaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $prepayment_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPrepaymentHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an Prepayment
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPrepaymentHistoryAsyncWithHttpInfo($xero_tenant_id, $prepayment_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getPrepaymentHistoryRequest($xero_tenant_id, $prepayment_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPrepaymentHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $prepayment_id Unique identifier for a PrePayment (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPrepaymentHistoryRequest($xero_tenant_id, $prepayment_id)
{
// 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 getPrepaymentHistory'
);
}
// verify the required parameter 'prepayment_id' is set
if ($prepayment_id === null || (is_array($prepayment_id) && count($prepayment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $prepayment_id when calling getPrepaymentHistory'
);
}
$resourcePath = '/Prepayments/{PrepaymentID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($prepayment_id !== null) {
$resourcePath = str_replace(
'{' . 'PrepaymentID' . '}',
AccountingObjectSerializer::toPathValue($prepayment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPrepayments
*
* Allows you to retrieve prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 prepayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Prepayments
*/
public function getPrepayments($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
list($response) = $this->getPrepaymentsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
return $response;
}
/**
* Operation getPrepaymentsWithHttpInfo
*
* Allows you to retrieve prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 prepayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Prepayments, HTTP status code, HTTP response headers (array of strings)
*/
public function getPrepaymentsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
$request = $this->getPrepaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Prepayments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Prepayments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Prepayments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Prepayments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPrepaymentsAsync
*
* Allows you to retrieve prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 prepayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPrepaymentsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
return $this->getPrepaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPrepaymentsAsyncWithHttpInfo
*
* Allows you to retrieve prepayments
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 prepayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPrepaymentsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Prepayments';
$request = $this->getPrepaymentsRequest($xero_tenant_id, $if_modified_since, $where, $order, $page, $unitdp);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPrepayments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $page e.g. page=1 – Up to 100 prepayments will be returned in a single API call with line items shown for each overpayment (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPrepaymentsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $page = null, $unitdp = null)
{
// 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 getPrepayments'
);
}
$resourcePath = '/Prepayments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// query params
if ($unitdp !== null) {
$queryParams['unitdp'] = AccountingObjectSerializer::toQueryValue($unitdp);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPurchaseOrder
*
* Allows you to retrieve a specified purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders
*/
public function getPurchaseOrder($xero_tenant_id, $purchase_order_id)
{
list($response) = $this->getPurchaseOrderWithHttpInfo($xero_tenant_id, $purchase_order_id);
return $response;
}
/**
* Operation getPurchaseOrderWithHttpInfo
*
* Allows you to retrieve a specified purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders, HTTP status code, HTTP response headers (array of strings)
*/
public function getPurchaseOrderWithHttpInfo($xero_tenant_id, $purchase_order_id)
{
$request = $this->getPurchaseOrderRequest($xero_tenant_id, $purchase_order_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPurchaseOrderAsync
*
* Allows you to retrieve a specified purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPurchaseOrderAsync($xero_tenant_id, $purchase_order_id)
{
return $this->getPurchaseOrderAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPurchaseOrderAsyncWithHttpInfo
*
* Allows you to retrieve a specified purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPurchaseOrderAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$request = $this->getPurchaseOrderRequest($xero_tenant_id, $purchase_order_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPurchaseOrder'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPurchaseOrderRequest($xero_tenant_id, $purchase_order_id)
{
// 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 getPurchaseOrder'
);
}
// verify the required parameter 'purchase_order_id' is set
if ($purchase_order_id === null || (is_array($purchase_order_id) && count($purchase_order_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $purchase_order_id when calling getPurchaseOrder'
);
}
$resourcePath = '/PurchaseOrders/{PurchaseOrderID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($purchase_order_id !== null) {
$resourcePath = str_replace(
'{' . 'PurchaseOrderID' . '}',
AccountingObjectSerializer::toPathValue($purchase_order_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPurchaseOrderHistory
*
* Allows you to retrieve history for PurchaseOrder
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getPurchaseOrderHistory($xero_tenant_id, $purchase_order_id)
{
list($response) = $this->getPurchaseOrderHistoryWithHttpInfo($xero_tenant_id, $purchase_order_id);
return $response;
}
/**
* Operation getPurchaseOrderHistoryWithHttpInfo
*
* Allows you to retrieve history for PurchaseOrder
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getPurchaseOrderHistoryWithHttpInfo($xero_tenant_id, $purchase_order_id)
{
$request = $this->getPurchaseOrderHistoryRequest($xero_tenant_id, $purchase_order_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPurchaseOrderHistoryAsync
*
* Allows you to retrieve history for PurchaseOrder
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPurchaseOrderHistoryAsync($xero_tenant_id, $purchase_order_id)
{
return $this->getPurchaseOrderHistoryAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPurchaseOrderHistoryAsyncWithHttpInfo
*
* Allows you to retrieve history for PurchaseOrder
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPurchaseOrderHistoryAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getPurchaseOrderHistoryRequest($xero_tenant_id, $purchase_order_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPurchaseOrderHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPurchaseOrderHistoryRequest($xero_tenant_id, $purchase_order_id)
{
// 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 getPurchaseOrderHistory'
);
}
// verify the required parameter 'purchase_order_id' is set
if ($purchase_order_id === null || (is_array($purchase_order_id) && count($purchase_order_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $purchase_order_id when calling getPurchaseOrderHistory'
);
}
$resourcePath = '/PurchaseOrders/{PurchaseOrderID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($purchase_order_id !== null) {
$resourcePath = str_replace(
'{' . 'PurchaseOrderID' . '}',
AccountingObjectSerializer::toPathValue($purchase_order_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getPurchaseOrders
*
* Allows you to retrieve purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $status Filter by purchase order status (optional)
* @param string $date_from Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $date_to Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $order Order by an any element (optional)
* @param int $page To specify a page, append the page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned. (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders
*/
public function getPurchaseOrders($xero_tenant_id, $if_modified_since = null, $status = null, $date_from = null, $date_to = null, $order = null, $page = null)
{
list($response) = $this->getPurchaseOrdersWithHttpInfo($xero_tenant_id, $if_modified_since, $status, $date_from, $date_to, $order, $page);
return $response;
}
/**
* Operation getPurchaseOrdersWithHttpInfo
*
* Allows you to retrieve purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $status Filter by purchase order status (optional)
* @param string $date_from Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $date_to Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $order Order by an any element (optional)
* @param int $page To specify a page, append the page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned. (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders, HTTP status code, HTTP response headers (array of strings)
*/
public function getPurchaseOrdersWithHttpInfo($xero_tenant_id, $if_modified_since = null, $status = null, $date_from = null, $date_to = null, $order = null, $page = null)
{
$request = $this->getPurchaseOrdersRequest($xero_tenant_id, $if_modified_since, $status, $date_from, $date_to, $order, $page);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getPurchaseOrdersAsync
*
* Allows you to retrieve purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $status Filter by purchase order status (optional)
* @param string $date_from Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $date_to Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $order Order by an any element (optional)
* @param int $page To specify a page, append the page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned. (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPurchaseOrdersAsync($xero_tenant_id, $if_modified_since = null, $status = null, $date_from = null, $date_to = null, $order = null, $page = null)
{
return $this->getPurchaseOrdersAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $status, $date_from, $date_to, $order, $page)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getPurchaseOrdersAsyncWithHttpInfo
*
* Allows you to retrieve purchase orders
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $status Filter by purchase order status (optional)
* @param string $date_from Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $date_to Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $order Order by an any element (optional)
* @param int $page To specify a page, append the page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned. (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getPurchaseOrdersAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $status = null, $date_from = null, $date_to = null, $order = null, $page = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$request = $this->getPurchaseOrdersRequest($xero_tenant_id, $if_modified_since, $status, $date_from, $date_to, $order, $page);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getPurchaseOrders'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $status Filter by purchase order status (optional)
* @param string $date_from Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $date_to Filter by purchase order date (e.g. GET https://.../PurchaseOrders?DateFrom=2015-12-01&DateTo=2015-12-31 (optional)
* @param string $order Order by an any element (optional)
* @param int $page To specify a page, append the page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned. (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getPurchaseOrdersRequest($xero_tenant_id, $if_modified_since = null, $status = null, $date_from = null, $date_to = null, $order = null, $page = null)
{
// 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 getPurchaseOrders'
);
}
$resourcePath = '/PurchaseOrders';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($status !== null) {
$queryParams['Status'] = AccountingObjectSerializer::toQueryValue($status);
}
// query params
if ($date_from !== null) {
$queryParams['DateFrom'] = AccountingObjectSerializer::toQueryValue($date_from);
}
// query params
if ($date_to !== null) {
$queryParams['DateTo'] = AccountingObjectSerializer::toQueryValue($date_to);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getQuote
*
* Allows you to retrieve a specified quote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $quote_id Unique identifier for an Quote (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Quotes
*/
public function getQuote($xero_tenant_id, $quote_id)
{
list($response) = $this->getQuoteWithHttpInfo($xero_tenant_id, $quote_id);
return $response;
}
/**
* Operation getQuoteWithHttpInfo
*
* Allows you to retrieve a specified quote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $quote_id Unique identifier for an Quote (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Quotes, HTTP status code, HTTP response headers (array of strings)
*/
public function getQuoteWithHttpInfo($xero_tenant_id, $quote_id)
{
$request = $this->getQuoteRequest($xero_tenant_id, $quote_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Quotes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Quotes', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Quotes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Quotes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getQuoteAsync
*
* Allows you to retrieve a specified quote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $quote_id Unique identifier for an Quote (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getQuoteAsync($xero_tenant_id, $quote_id)
{
return $this->getQuoteAsyncWithHttpInfo($xero_tenant_id, $quote_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getQuoteAsyncWithHttpInfo
*
* Allows you to retrieve a specified quote
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $quote_id Unique identifier for an Quote (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getQuoteAsyncWithHttpInfo($xero_tenant_id, $quote_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Quotes';
$request = $this->getQuoteRequest($xero_tenant_id, $quote_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getQuote'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $quote_id Unique identifier for an Quote (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getQuoteRequest($xero_tenant_id, $quote_id)
{
// 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 getQuote'
);
}
// verify the required parameter 'quote_id' is set
if ($quote_id === null || (is_array($quote_id) && count($quote_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $quote_id when calling getQuote'
);
}
$resourcePath = '/Quotes/{QuoteID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($quote_id !== null) {
$resourcePath = str_replace(
'{' . 'QuoteID' . '}',
AccountingObjectSerializer::toPathValue($quote_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getQuotes
*
* Allows you to retrieve any sales quotes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param \DateTime $date_from Filter for quotes after a particular date (optional)
* @param \DateTime $date_to Filter for quotes before a particular date (optional)
* @param \DateTime $expiry_date_from Filter for quotes expiring after a particular date (optional)
* @param \DateTime $expiry_date_to Filter for quotes before a particular date (optional)
* @param string $contact_id Filter for quotes belonging to a particular contact (optional)
* @param string $status Filter for quotes of a particular Status (optional)
* @param int $page e.g. page=1 – Up to 100 Quotes will be returned in a single API call with line items shown for each quote (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Quotes
*/
public function getQuotes($xero_tenant_id, $if_modified_since = null, $date_from = null, $date_to = null, $expiry_date_from = null, $expiry_date_to = null, $contact_id = null, $status = null, $page = null, $order = null)
{
list($response) = $this->getQuotesWithHttpInfo($xero_tenant_id, $if_modified_since, $date_from, $date_to, $expiry_date_from, $expiry_date_to, $contact_id, $status, $page, $order);
return $response;
}
/**
* Operation getQuotesWithHttpInfo
*
* Allows you to retrieve any sales quotes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param \DateTime $date_from Filter for quotes after a particular date (optional)
* @param \DateTime $date_to Filter for quotes before a particular date (optional)
* @param \DateTime $expiry_date_from Filter for quotes expiring after a particular date (optional)
* @param \DateTime $expiry_date_to Filter for quotes before a particular date (optional)
* @param string $contact_id Filter for quotes belonging to a particular contact (optional)
* @param string $status Filter for quotes of a particular Status (optional)
* @param int $page e.g. page=1 – Up to 100 Quotes will be returned in a single API call with line items shown for each quote (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Quotes, HTTP status code, HTTP response headers (array of strings)
*/
public function getQuotesWithHttpInfo($xero_tenant_id, $if_modified_since = null, $date_from = null, $date_to = null, $expiry_date_from = null, $expiry_date_to = null, $contact_id = null, $status = null, $page = null, $order = null)
{
$request = $this->getQuotesRequest($xero_tenant_id, $if_modified_since, $date_from, $date_to, $expiry_date_from, $expiry_date_to, $contact_id, $status, $page, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Quotes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Quotes', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Quotes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Quotes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getQuotesAsync
*
* Allows you to retrieve any sales quotes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param \DateTime $date_from Filter for quotes after a particular date (optional)
* @param \DateTime $date_to Filter for quotes before a particular date (optional)
* @param \DateTime $expiry_date_from Filter for quotes expiring after a particular date (optional)
* @param \DateTime $expiry_date_to Filter for quotes before a particular date (optional)
* @param string $contact_id Filter for quotes belonging to a particular contact (optional)
* @param string $status Filter for quotes of a particular Status (optional)
* @param int $page e.g. page=1 – Up to 100 Quotes will be returned in a single API call with line items shown for each quote (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getQuotesAsync($xero_tenant_id, $if_modified_since = null, $date_from = null, $date_to = null, $expiry_date_from = null, $expiry_date_to = null, $contact_id = null, $status = null, $page = null, $order = null)
{
return $this->getQuotesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $date_from, $date_to, $expiry_date_from, $expiry_date_to, $contact_id, $status, $page, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getQuotesAsyncWithHttpInfo
*
* Allows you to retrieve any sales quotes
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param \DateTime $date_from Filter for quotes after a particular date (optional)
* @param \DateTime $date_to Filter for quotes before a particular date (optional)
* @param \DateTime $expiry_date_from Filter for quotes expiring after a particular date (optional)
* @param \DateTime $expiry_date_to Filter for quotes before a particular date (optional)
* @param string $contact_id Filter for quotes belonging to a particular contact (optional)
* @param string $status Filter for quotes of a particular Status (optional)
* @param int $page e.g. page=1 – Up to 100 Quotes will be returned in a single API call with line items shown for each quote (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getQuotesAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $date_from = null, $date_to = null, $expiry_date_from = null, $expiry_date_to = null, $contact_id = null, $status = null, $page = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Quotes';
$request = $this->getQuotesRequest($xero_tenant_id, $if_modified_since, $date_from, $date_to, $expiry_date_from, $expiry_date_to, $contact_id, $status, $page, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getQuotes'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param \DateTime $date_from Filter for quotes after a particular date (optional)
* @param \DateTime $date_to Filter for quotes before a particular date (optional)
* @param \DateTime $expiry_date_from Filter for quotes expiring after a particular date (optional)
* @param \DateTime $expiry_date_to Filter for quotes before a particular date (optional)
* @param string $contact_id Filter for quotes belonging to a particular contact (optional)
* @param string $status Filter for quotes of a particular Status (optional)
* @param int $page e.g. page=1 – Up to 100 Quotes will be returned in a single API call with line items shown for each quote (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getQuotesRequest($xero_tenant_id, $if_modified_since = null, $date_from = null, $date_to = null, $expiry_date_from = null, $expiry_date_to = null, $contact_id = null, $status = null, $page = null, $order = null)
{
// 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 getQuotes'
);
}
$resourcePath = '/Quotes';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($date_from !== null) {
$queryParams['DateFrom'] = AccountingObjectSerializer::toQueryValue($date_from);
}
// query params
if ($date_to !== null) {
$queryParams['DateTo'] = AccountingObjectSerializer::toQueryValue($date_to);
}
// query params
if ($expiry_date_from !== null) {
$queryParams['ExpiryDateFrom'] = AccountingObjectSerializer::toQueryValue($expiry_date_from);
}
// query params
if ($expiry_date_to !== null) {
$queryParams['ExpiryDateTo'] = AccountingObjectSerializer::toQueryValue($expiry_date_to);
}
// query params
if ($contact_id !== null) {
$queryParams['ContactID'] = AccountingObjectSerializer::toQueryValue($contact_id);
}
// query params
if ($status !== null) {
$queryParams['Status'] = AccountingObjectSerializer::toQueryValue($status);
}
// query params
if ($page !== null) {
$queryParams['page'] = AccountingObjectSerializer::toQueryValue($page);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReceipt
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Receipts
*/
public function getReceipt($xero_tenant_id, $receipt_id)
{
list($response) = $this->getReceiptWithHttpInfo($xero_tenant_id, $receipt_id);
return $response;
}
/**
* Operation getReceiptWithHttpInfo
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Receipts, HTTP status code, HTTP response headers (array of strings)
*/
public function getReceiptWithHttpInfo($xero_tenant_id, $receipt_id)
{
$request = $this->getReceiptRequest($xero_tenant_id, $receipt_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Receipts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Receipts', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Receipts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReceiptAsync
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAsync($xero_tenant_id, $receipt_id)
{
return $this->getReceiptAsyncWithHttpInfo($xero_tenant_id, $receipt_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReceiptAsyncWithHttpInfo
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAsyncWithHttpInfo($xero_tenant_id, $receipt_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$request = $this->getReceiptRequest($xero_tenant_id, $receipt_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReceipt'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReceiptRequest($xero_tenant_id, $receipt_id)
{
// 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 getReceipt'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling getReceipt'
);
}
$resourcePath = '/Receipts/{ReceiptID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReceiptAttachmentByFileName
*
* Allows you to retrieve Attachments on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getReceiptAttachmentByFileName($xero_tenant_id, $receipt_id, $file_name, $content_type)
{
list($response) = $this->getReceiptAttachmentByFileNameWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $content_type);
return $response;
}
/**
* Operation getReceiptAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve Attachments on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getReceiptAttachmentByFileNameWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $content_type)
{
$request = $this->getReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReceiptAttachmentByFileNameAsync
*
* Allows you to retrieve Attachments on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAttachmentByFileNameAsync($xero_tenant_id, $receipt_id, $file_name, $content_type)
{
return $this->getReceiptAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReceiptAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReceiptAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $content_type)
{
// 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 getReceiptAttachmentByFileName'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling getReceiptAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getReceiptAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getReceiptAttachmentByFileName'
);
}
$resourcePath = '/Receipts/{ReceiptID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReceiptAttachmentById
*
* Allows you to retrieve Attachments on expense claim receipts by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getReceiptAttachmentById($xero_tenant_id, $receipt_id, $attachment_id, $content_type)
{
list($response) = $this->getReceiptAttachmentByIdWithHttpInfo($xero_tenant_id, $receipt_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getReceiptAttachmentByIdWithHttpInfo
*
* Allows you to retrieve Attachments on expense claim receipts by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getReceiptAttachmentByIdWithHttpInfo($xero_tenant_id, $receipt_id, $attachment_id, $content_type)
{
$request = $this->getReceiptAttachmentByIdRequest($xero_tenant_id, $receipt_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReceiptAttachmentByIdAsync
*
* Allows you to retrieve Attachments on expense claim receipts by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAttachmentByIdAsync($xero_tenant_id, $receipt_id, $attachment_id, $content_type)
{
return $this->getReceiptAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReceiptAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on expense claim receipts by ID
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getReceiptAttachmentByIdRequest($xero_tenant_id, $receipt_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReceiptAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReceiptAttachmentByIdRequest($xero_tenant_id, $receipt_id, $attachment_id, $content_type)
{
// 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 getReceiptAttachmentById'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling getReceiptAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getReceiptAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getReceiptAttachmentById'
);
}
$resourcePath = '/Receipts/{ReceiptID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReceiptAttachments
*
* Allows you to retrieve Attachments for expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getReceiptAttachments($xero_tenant_id, $receipt_id)
{
list($response) = $this->getReceiptAttachmentsWithHttpInfo($xero_tenant_id, $receipt_id);
return $response;
}
/**
* Operation getReceiptAttachmentsWithHttpInfo
*
* Allows you to retrieve Attachments for expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getReceiptAttachmentsWithHttpInfo($xero_tenant_id, $receipt_id)
{
$request = $this->getReceiptAttachmentsRequest($xero_tenant_id, $receipt_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReceiptAttachmentsAsync
*
* Allows you to retrieve Attachments for expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAttachmentsAsync($xero_tenant_id, $receipt_id)
{
return $this->getReceiptAttachmentsAsyncWithHttpInfo($xero_tenant_id, $receipt_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReceiptAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve Attachments for expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptAttachmentsAsyncWithHttpInfo($xero_tenant_id, $receipt_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getReceiptAttachmentsRequest($xero_tenant_id, $receipt_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReceiptAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReceiptAttachmentsRequest($xero_tenant_id, $receipt_id)
{
// 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 getReceiptAttachments'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling getReceiptAttachments'
);
}
$resourcePath = '/Receipts/{ReceiptID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReceiptHistory
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getReceiptHistory($xero_tenant_id, $receipt_id)
{
list($response) = $this->getReceiptHistoryWithHttpInfo($xero_tenant_id, $receipt_id);
return $response;
}
/**
* Operation getReceiptHistoryWithHttpInfo
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getReceiptHistoryWithHttpInfo($xero_tenant_id, $receipt_id)
{
$request = $this->getReceiptHistoryRequest($xero_tenant_id, $receipt_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReceiptHistoryAsync
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptHistoryAsync($xero_tenant_id, $receipt_id)
{
return $this->getReceiptHistoryAsyncWithHttpInfo($xero_tenant_id, $receipt_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReceiptHistoryAsyncWithHttpInfo
*
* Allows you to retrieve a history records of an Receipt
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptHistoryAsyncWithHttpInfo($xero_tenant_id, $receipt_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getReceiptHistoryRequest($xero_tenant_id, $receipt_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReceiptHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReceiptHistoryRequest($xero_tenant_id, $receipt_id)
{
// 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 getReceiptHistory'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling getReceiptHistory'
);
}
$resourcePath = '/Receipts/{ReceiptID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReceipts
*
* Allows you to retrieve draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Receipts
*/
public function getReceipts($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
list($response) = $this->getReceiptsWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $unitdp);
return $response;
}
/**
* Operation getReceiptsWithHttpInfo
*
* Allows you to retrieve draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Receipts, HTTP status code, HTTP response headers (array of strings)
*/
public function getReceiptsWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
$request = $this->getReceiptsRequest($xero_tenant_id, $if_modified_since, $where, $order, $unitdp);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Receipts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Receipts', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Receipts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReceiptsAsync
*
* Allows you to retrieve draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptsAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
return $this->getReceiptsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order, $unitdp)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReceiptsAsyncWithHttpInfo
*
* Allows you to retrieve draft expense claim receipts for any user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReceiptsAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$request = $this->getReceiptsRequest($xero_tenant_id, $if_modified_since, $where, $order, $unitdp);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReceipts'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param int $unitdp e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReceiptsRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null, $unitdp = null)
{
// 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 getReceipts'
);
}
$resourcePath = '/Receipts';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($unitdp !== null) {
$queryParams['unitdp'] = AccountingObjectSerializer::toQueryValue($unitdp);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getRepeatingInvoice
*
* Allows you to retrieve a specified repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices
*/
public function getRepeatingInvoice($xero_tenant_id, $repeating_invoice_id)
{
list($response) = $this->getRepeatingInvoiceWithHttpInfo($xero_tenant_id, $repeating_invoice_id);
return $response;
}
/**
* Operation getRepeatingInvoiceWithHttpInfo
*
* Allows you to retrieve a specified repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices, HTTP status code, HTTP response headers (array of strings)
*/
public function getRepeatingInvoiceWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
{
$request = $this->getRepeatingInvoiceRequest($xero_tenant_id, $repeating_invoice_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getRepeatingInvoiceAsync
*
* Allows you to retrieve a specified repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAsync($xero_tenant_id, $repeating_invoice_id)
{
return $this->getRepeatingInvoiceAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getRepeatingInvoiceAsyncWithHttpInfo
*
* Allows you to retrieve a specified repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices';
$request = $this->getRepeatingInvoiceRequest($xero_tenant_id, $repeating_invoice_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getRepeatingInvoice'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getRepeatingInvoiceRequest($xero_tenant_id, $repeating_invoice_id)
{
// 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 getRepeatingInvoice'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling getRepeatingInvoice'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getRepeatingInvoiceAttachmentByFileName
*
* Allows you to retrieve specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getRepeatingInvoiceAttachmentByFileName($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type)
{
list($response) = $this->getRepeatingInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type);
return $response;
}
/**
* Operation getRepeatingInvoiceAttachmentByFileNameWithHttpInfo
*
* Allows you to retrieve specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getRepeatingInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type)
{
$request = $this->getRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getRepeatingInvoiceAttachmentByFileNameAsync
*
* Allows you to retrieve specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAttachmentByFileNameAsync($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type)
{
return $this->getRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to retrieve specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getRepeatingInvoiceAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $content_type)
{
// 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 getRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling getRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling getRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getRepeatingInvoiceAttachmentByFileName'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getRepeatingInvoiceAttachmentById
*
* Allows you to retrieve a specified Attachments on repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \SplFileObject
*/
public function getRepeatingInvoiceAttachmentById($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type)
{
list($response) = $this->getRepeatingInvoiceAttachmentByIdWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type);
return $response;
}
/**
* Operation getRepeatingInvoiceAttachmentByIdWithHttpInfo
*
* Allows you to retrieve a specified Attachments on repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings)
*/
public function getRepeatingInvoiceAttachmentByIdWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type)
{
$request = $this->getRepeatingInvoiceAttachmentByIdRequest($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\SplFileObject' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\SplFileObject', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\SplFileObject';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\SplFileObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getRepeatingInvoiceAttachmentByIdAsync
*
* Allows you to retrieve a specified Attachments on repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAttachmentByIdAsync($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type)
{
return $this->getRepeatingInvoiceAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getRepeatingInvoiceAttachmentByIdAsyncWithHttpInfo
*
* Allows you to retrieve a specified Attachments on repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAttachmentByIdAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type)
{
$returnType = '\SplFileObject';
$request = $this->getRepeatingInvoiceAttachmentByIdRequest($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getRepeatingInvoiceAttachmentById'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $attachment_id Unique identifier for a Attachment (required)
* @param string $content_type The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getRepeatingInvoiceAttachmentByIdRequest($xero_tenant_id, $repeating_invoice_id, $attachment_id, $content_type)
{
// 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 getRepeatingInvoiceAttachmentById'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling getRepeatingInvoiceAttachmentById'
);
}
// verify the required parameter 'attachment_id' is set
if ($attachment_id === null || (is_array($attachment_id) && count($attachment_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $attachment_id when calling getRepeatingInvoiceAttachmentById'
);
}
// verify the required parameter 'content_type' is set
if ($content_type === null || (is_array($content_type) && count($content_type) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $content_type when calling getRepeatingInvoiceAttachmentById'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{AttachmentID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($content_type !== null) {
$headerParams['contentType'] = AccountingObjectSerializer::toHeaderValue($content_type);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// path params
if ($attachment_id !== null) {
$resourcePath = str_replace(
'{' . 'AttachmentID' . '}',
AccountingObjectSerializer::toPathValue($attachment_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/octet-stream']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/octet-stream'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getRepeatingInvoiceAttachments
*
* Allows you to retrieve Attachments on repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments
*/
public function getRepeatingInvoiceAttachments($xero_tenant_id, $repeating_invoice_id)
{
list($response) = $this->getRepeatingInvoiceAttachmentsWithHttpInfo($xero_tenant_id, $repeating_invoice_id);
return $response;
}
/**
* Operation getRepeatingInvoiceAttachmentsWithHttpInfo
*
* Allows you to retrieve Attachments on repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments, HTTP status code, HTTP response headers (array of strings)
*/
public function getRepeatingInvoiceAttachmentsWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
{
$request = $this->getRepeatingInvoiceAttachmentsRequest($xero_tenant_id, $repeating_invoice_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getRepeatingInvoiceAttachmentsAsync
*
* Allows you to retrieve Attachments on repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAttachmentsAsync($xero_tenant_id, $repeating_invoice_id)
{
return $this->getRepeatingInvoiceAttachmentsAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getRepeatingInvoiceAttachmentsAsyncWithHttpInfo
*
* Allows you to retrieve Attachments on repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceAttachmentsAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->getRepeatingInvoiceAttachmentsRequest($xero_tenant_id, $repeating_invoice_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getRepeatingInvoiceAttachments'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getRepeatingInvoiceAttachmentsRequest($xero_tenant_id, $repeating_invoice_id)
{
// 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 getRepeatingInvoiceAttachments'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling getRepeatingInvoiceAttachments'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getRepeatingInvoiceHistory
*
* Allows you to retrieve history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords
*/
public function getRepeatingInvoiceHistory($xero_tenant_id, $repeating_invoice_id)
{
list($response) = $this->getRepeatingInvoiceHistoryWithHttpInfo($xero_tenant_id, $repeating_invoice_id);
return $response;
}
/**
* Operation getRepeatingInvoiceHistoryWithHttpInfo
*
* Allows you to retrieve history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\HistoryRecords, HTTP status code, HTTP response headers (array of strings)
*/
public function getRepeatingInvoiceHistoryWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
{
$request = $this->getRepeatingInvoiceHistoryRequest($xero_tenant_id, $repeating_invoice_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getRepeatingInvoiceHistoryAsync
*
* Allows you to retrieve history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceHistoryAsync($xero_tenant_id, $repeating_invoice_id)
{
return $this->getRepeatingInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getRepeatingInvoiceHistoryAsyncWithHttpInfo
*
* Allows you to retrieve history for a repeating invoice
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoiceHistoryAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\HistoryRecords';
$request = $this->getRepeatingInvoiceHistoryRequest($xero_tenant_id, $repeating_invoice_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getRepeatingInvoiceHistory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getRepeatingInvoiceHistoryRequest($xero_tenant_id, $repeating_invoice_id)
{
// 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 getRepeatingInvoiceHistory'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling getRepeatingInvoiceHistory'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}/History';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getRepeatingInvoices
*
* Allows you to retrieve any repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices
*/
public function getRepeatingInvoices($xero_tenant_id, $where = null, $order = null)
{
list($response) = $this->getRepeatingInvoicesWithHttpInfo($xero_tenant_id, $where, $order);
return $response;
}
/**
* Operation getRepeatingInvoicesWithHttpInfo
*
* Allows you to retrieve any repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices, HTTP status code, HTTP response headers (array of strings)
*/
public function getRepeatingInvoicesWithHttpInfo($xero_tenant_id, $where = null, $order = null)
{
$request = $this->getRepeatingInvoicesRequest($xero_tenant_id, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getRepeatingInvoicesAsync
*
* Allows you to retrieve any repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoicesAsync($xero_tenant_id, $where = null, $order = null)
{
return $this->getRepeatingInvoicesAsyncWithHttpInfo($xero_tenant_id, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getRepeatingInvoicesAsyncWithHttpInfo
*
* Allows you to retrieve any repeating invoices
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getRepeatingInvoicesAsyncWithHttpInfo($xero_tenant_id, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\RepeatingInvoices';
$request = $this->getRepeatingInvoicesRequest($xero_tenant_id, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getRepeatingInvoices'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getRepeatingInvoicesRequest($xero_tenant_id, $where = null, $order = null)
{
// 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 getRepeatingInvoices'
);
}
$resourcePath = '/RepeatingInvoices';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportAgedPayablesByContact
*
* Allows you to retrieve report for AgedPayablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Payables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Payables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Payables By Contact report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportAgedPayablesByContact($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
list($response) = $this->getReportAgedPayablesByContactWithHttpInfo($xero_tenant_id, $contact_id, $date, $from_date, $to_date);
return $response;
}
/**
* Operation getReportAgedPayablesByContactWithHttpInfo
*
* Allows you to retrieve report for AgedPayablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Payables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Payables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Payables By Contact report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportAgedPayablesByContactWithHttpInfo($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
$request = $this->getReportAgedPayablesByContactRequest($xero_tenant_id, $contact_id, $date, $from_date, $to_date);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportAgedPayablesByContactAsync
*
* Allows you to retrieve report for AgedPayablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Payables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Payables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Payables By Contact report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportAgedPayablesByContactAsync($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
return $this->getReportAgedPayablesByContactAsyncWithHttpInfo($xero_tenant_id, $contact_id, $date, $from_date, $to_date)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportAgedPayablesByContactAsyncWithHttpInfo
*
* Allows you to retrieve report for AgedPayablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Payables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Payables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Payables By Contact report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportAgedPayablesByContactAsyncWithHttpInfo($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportAgedPayablesByContactRequest($xero_tenant_id, $contact_id, $date, $from_date, $to_date);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportAgedPayablesByContact'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Payables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Payables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Payables By Contact report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportAgedPayablesByContactRequest($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
// 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 getReportAgedPayablesByContact'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getReportAgedPayablesByContact'
);
}
$resourcePath = '/Reports/AgedPayablesByContact';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($contact_id !== null) {
$queryParams['contactId'] = AccountingObjectSerializer::toQueryValue($contact_id);
}
// query params
if ($date !== null) {
$queryParams['date'] = AccountingObjectSerializer::toQueryValue($date);
}
// query params
if ($from_date !== null) {
$queryParams['fromDate'] = AccountingObjectSerializer::toQueryValue($from_date);
}
// query params
if ($to_date !== null) {
$queryParams['toDate'] = AccountingObjectSerializer::toQueryValue($to_date);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportAgedReceivablesByContact
*
* Allows you to retrieve report for AgedReceivablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Receivables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Receivables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Receivables By Contact report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportAgedReceivablesByContact($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
list($response) = $this->getReportAgedReceivablesByContactWithHttpInfo($xero_tenant_id, $contact_id, $date, $from_date, $to_date);
return $response;
}
/**
* Operation getReportAgedReceivablesByContactWithHttpInfo
*
* Allows you to retrieve report for AgedReceivablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Receivables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Receivables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Receivables By Contact report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportAgedReceivablesByContactWithHttpInfo($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
$request = $this->getReportAgedReceivablesByContactRequest($xero_tenant_id, $contact_id, $date, $from_date, $to_date);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportAgedReceivablesByContactAsync
*
* Allows you to retrieve report for AgedReceivablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Receivables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Receivables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Receivables By Contact report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportAgedReceivablesByContactAsync($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
return $this->getReportAgedReceivablesByContactAsyncWithHttpInfo($xero_tenant_id, $contact_id, $date, $from_date, $to_date)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportAgedReceivablesByContactAsyncWithHttpInfo
*
* Allows you to retrieve report for AgedReceivablesByContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Receivables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Receivables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Receivables By Contact report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportAgedReceivablesByContactAsyncWithHttpInfo($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportAgedReceivablesByContactRequest($xero_tenant_id, $contact_id, $date, $from_date, $to_date);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportAgedReceivablesByContact'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \DateTime $date The date of the Aged Receivables By Contact report (optional)
* @param \DateTime $from_date The from date of the Aged Receivables By Contact report (optional)
* @param \DateTime $to_date The to date of the Aged Receivables By Contact report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportAgedReceivablesByContactRequest($xero_tenant_id, $contact_id, $date = null, $from_date = null, $to_date = null)
{
// 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 getReportAgedReceivablesByContact'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling getReportAgedReceivablesByContact'
);
}
$resourcePath = '/Reports/AgedReceivablesByContact';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($contact_id !== null) {
$queryParams['contactId'] = AccountingObjectSerializer::toQueryValue($contact_id);
}
// query params
if ($date !== null) {
$queryParams['date'] = AccountingObjectSerializer::toQueryValue($date);
}
// query params
if ($from_date !== null) {
$queryParams['fromDate'] = AccountingObjectSerializer::toQueryValue($from_date);
}
// query params
if ($to_date !== null) {
$queryParams['toDate'] = AccountingObjectSerializer::toQueryValue($to_date);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportBASorGST
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_id Unique identifier for a Report (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportBASorGST($xero_tenant_id, $report_id)
{
list($response) = $this->getReportBASorGSTWithHttpInfo($xero_tenant_id, $report_id);
return $response;
}
/**
* Operation getReportBASorGSTWithHttpInfo
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_id Unique identifier for a Report (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportBASorGSTWithHttpInfo($xero_tenant_id, $report_id)
{
$request = $this->getReportBASorGSTRequest($xero_tenant_id, $report_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportBASorGSTAsync
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_id Unique identifier for a Report (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBASorGSTAsync($xero_tenant_id, $report_id)
{
return $this->getReportBASorGSTAsyncWithHttpInfo($xero_tenant_id, $report_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportBASorGSTAsyncWithHttpInfo
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_id Unique identifier for a Report (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBASorGSTAsyncWithHttpInfo($xero_tenant_id, $report_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportBASorGSTRequest($xero_tenant_id, $report_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportBASorGST'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_id Unique identifier for a Report (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportBASorGSTRequest($xero_tenant_id, $report_id)
{
// 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 getReportBASorGST'
);
}
// verify the required parameter 'report_id' is set
if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $report_id when calling getReportBASorGST'
);
}
$resourcePath = '/Reports/{ReportID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($report_id !== null) {
$resourcePath = str_replace(
'{' . 'ReportID' . '}',
AccountingObjectSerializer::toPathValue($report_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportBASorGSTList
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportBASorGSTList($xero_tenant_id)
{
list($response) = $this->getReportBASorGSTListWithHttpInfo($xero_tenant_id);
return $response;
}
/**
* Operation getReportBASorGSTListWithHttpInfo
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportBASorGSTListWithHttpInfo($xero_tenant_id)
{
$request = $this->getReportBASorGSTListRequest($xero_tenant_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportBASorGSTListAsync
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBASorGSTListAsync($xero_tenant_id)
{
return $this->getReportBASorGSTListAsyncWithHttpInfo($xero_tenant_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportBASorGSTListAsyncWithHttpInfo
*
* Allows you to retrieve report for BAS only valid for AU orgs
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBASorGSTListAsyncWithHttpInfo($xero_tenant_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportBASorGSTListRequest($xero_tenant_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportBASorGSTList'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportBASorGSTListRequest($xero_tenant_id)
{
// 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 getReportBASorGSTList'
);
}
$resourcePath = '/Reports';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportBalanceSheet
*
* Allows you to retrieve report for BalanceSheet
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $date The date of the Balance Sheet report (optional)
* @param int $periods The number of periods for the Balance Sheet report (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_option_id1 The tracking option 1 for the Balance Sheet report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the Balance Sheet report (optional)
* @param bool $standard_layout The standard layout boolean for the Balance Sheet report (optional)
* @param bool $payments_only return a cash basis for the Balance Sheet report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportBalanceSheet($xero_tenant_id, $date = null, $periods = null, $timeframe = null, $tracking_option_id1 = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
list($response) = $this->getReportBalanceSheetWithHttpInfo($xero_tenant_id, $date, $periods, $timeframe, $tracking_option_id1, $tracking_option_id2, $standard_layout, $payments_only);
return $response;
}
/**
* Operation getReportBalanceSheetWithHttpInfo
*
* Allows you to retrieve report for BalanceSheet
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $date The date of the Balance Sheet report (optional)
* @param int $periods The number of periods for the Balance Sheet report (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_option_id1 The tracking option 1 for the Balance Sheet report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the Balance Sheet report (optional)
* @param bool $standard_layout The standard layout boolean for the Balance Sheet report (optional)
* @param bool $payments_only return a cash basis for the Balance Sheet report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportBalanceSheetWithHttpInfo($xero_tenant_id, $date = null, $periods = null, $timeframe = null, $tracking_option_id1 = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
$request = $this->getReportBalanceSheetRequest($xero_tenant_id, $date, $periods, $timeframe, $tracking_option_id1, $tracking_option_id2, $standard_layout, $payments_only);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportBalanceSheetAsync
*
* Allows you to retrieve report for BalanceSheet
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $date The date of the Balance Sheet report (optional)
* @param int $periods The number of periods for the Balance Sheet report (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_option_id1 The tracking option 1 for the Balance Sheet report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the Balance Sheet report (optional)
* @param bool $standard_layout The standard layout boolean for the Balance Sheet report (optional)
* @param bool $payments_only return a cash basis for the Balance Sheet report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBalanceSheetAsync($xero_tenant_id, $date = null, $periods = null, $timeframe = null, $tracking_option_id1 = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
return $this->getReportBalanceSheetAsyncWithHttpInfo($xero_tenant_id, $date, $periods, $timeframe, $tracking_option_id1, $tracking_option_id2, $standard_layout, $payments_only)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportBalanceSheetAsyncWithHttpInfo
*
* Allows you to retrieve report for BalanceSheet
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $date The date of the Balance Sheet report (optional)
* @param int $periods The number of periods for the Balance Sheet report (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_option_id1 The tracking option 1 for the Balance Sheet report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the Balance Sheet report (optional)
* @param bool $standard_layout The standard layout boolean for the Balance Sheet report (optional)
* @param bool $payments_only return a cash basis for the Balance Sheet report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBalanceSheetAsyncWithHttpInfo($xero_tenant_id, $date = null, $periods = null, $timeframe = null, $tracking_option_id1 = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportBalanceSheetRequest($xero_tenant_id, $date, $periods, $timeframe, $tracking_option_id1, $tracking_option_id2, $standard_layout, $payments_only);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportBalanceSheet'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $date The date of the Balance Sheet report (optional)
* @param int $periods The number of periods for the Balance Sheet report (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_option_id1 The tracking option 1 for the Balance Sheet report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the Balance Sheet report (optional)
* @param bool $standard_layout The standard layout boolean for the Balance Sheet report (optional)
* @param bool $payments_only return a cash basis for the Balance Sheet report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportBalanceSheetRequest($xero_tenant_id, $date = null, $periods = null, $timeframe = null, $tracking_option_id1 = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
// 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 getReportBalanceSheet'
);
}
$resourcePath = '/Reports/BalanceSheet';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($date !== null) {
$queryParams['date'] = AccountingObjectSerializer::toQueryValue($date);
}
// query params
if ($periods !== null) {
$queryParams['periods'] = AccountingObjectSerializer::toQueryValue($periods);
}
// query params
if ($timeframe !== null) {
$queryParams['timeframe'] = AccountingObjectSerializer::toQueryValue($timeframe);
}
// query params
if ($tracking_option_id1 !== null) {
$queryParams['trackingOptionID1'] = AccountingObjectSerializer::toQueryValue($tracking_option_id1);
}
// query params
if ($tracking_option_id2 !== null) {
$queryParams['trackingOptionID2'] = AccountingObjectSerializer::toQueryValue($tracking_option_id2);
}
// query params
if ($standard_layout !== null) {
$queryParams['standardLayout'] = AccountingObjectSerializer::toQueryValue($standard_layout);
}
// query params
if ($payments_only !== null) {
$queryParams['paymentsOnly'] = AccountingObjectSerializer::toQueryValue($payments_only);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportBankSummary
*
* Allows you to retrieve report for BankSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportBankSummary($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
list($response) = $this->getReportBankSummaryWithHttpInfo($xero_tenant_id, $date, $period, $timeframe);
return $response;
}
/**
* Operation getReportBankSummaryWithHttpInfo
*
* Allows you to retrieve report for BankSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportBankSummaryWithHttpInfo($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
$request = $this->getReportBankSummaryRequest($xero_tenant_id, $date, $period, $timeframe);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportBankSummaryAsync
*
* Allows you to retrieve report for BankSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBankSummaryAsync($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
return $this->getReportBankSummaryAsyncWithHttpInfo($xero_tenant_id, $date, $period, $timeframe)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportBankSummaryAsyncWithHttpInfo
*
* Allows you to retrieve report for BankSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBankSummaryAsyncWithHttpInfo($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportBankSummaryRequest($xero_tenant_id, $date, $period, $timeframe);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportBankSummary'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportBankSummaryRequest($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
// 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 getReportBankSummary'
);
}
$resourcePath = '/Reports/BankSummary';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($date !== null) {
$queryParams['date'] = AccountingObjectSerializer::toQueryValue($date);
}
// query params
if ($period !== null) {
$queryParams['period'] = AccountingObjectSerializer::toQueryValue($period);
}
// query params
if ($timeframe !== null) {
$queryParams['timeframe'] = AccountingObjectSerializer::toQueryValue($timeframe);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportBudgetSummary
*
* Allows you to retrieve report for Budget Summary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportBudgetSummary($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
list($response) = $this->getReportBudgetSummaryWithHttpInfo($xero_tenant_id, $date, $period, $timeframe);
return $response;
}
/**
* Operation getReportBudgetSummaryWithHttpInfo
*
* Allows you to retrieve report for Budget Summary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportBudgetSummaryWithHttpInfo($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
$request = $this->getReportBudgetSummaryRequest($xero_tenant_id, $date, $period, $timeframe);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportBudgetSummaryAsync
*
* Allows you to retrieve report for Budget Summary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBudgetSummaryAsync($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
return $this->getReportBudgetSummaryAsyncWithHttpInfo($xero_tenant_id, $date, $period, $timeframe)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportBudgetSummaryAsyncWithHttpInfo
*
* Allows you to retrieve report for Budget Summary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportBudgetSummaryAsyncWithHttpInfo($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportBudgetSummaryRequest($xero_tenant_id, $date, $period, $timeframe);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportBudgetSummary'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
* @param int $period The number of periods to compare (integer between 1 and 12) (optional)
* @param int $timeframe The period size to compare to (1=month, 3=quarter, 12=year) (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportBudgetSummaryRequest($xero_tenant_id, $date = null, $period = null, $timeframe = null)
{
// 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 getReportBudgetSummary'
);
}
$resourcePath = '/Reports/BudgetSummary';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($date !== null) {
$queryParams['date'] = AccountingObjectSerializer::toQueryValue($date);
}
// query params
if ($period !== null) {
$queryParams['period'] = AccountingObjectSerializer::toQueryValue($period);
}
// query params
if ($timeframe !== null) {
$queryParams['timeframe'] = AccountingObjectSerializer::toQueryValue($timeframe);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportExecutiveSummary
*
* Allows you to retrieve report for ExecutiveSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportExecutiveSummary($xero_tenant_id, $date = null)
{
list($response) = $this->getReportExecutiveSummaryWithHttpInfo($xero_tenant_id, $date);
return $response;
}
/**
* Operation getReportExecutiveSummaryWithHttpInfo
*
* Allows you to retrieve report for ExecutiveSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportExecutiveSummaryWithHttpInfo($xero_tenant_id, $date = null)
{
$request = $this->getReportExecutiveSummaryRequest($xero_tenant_id, $date);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportExecutiveSummaryAsync
*
* Allows you to retrieve report for ExecutiveSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportExecutiveSummaryAsync($xero_tenant_id, $date = null)
{
return $this->getReportExecutiveSummaryAsyncWithHttpInfo($xero_tenant_id, $date)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportExecutiveSummaryAsyncWithHttpInfo
*
* Allows you to retrieve report for ExecutiveSummary
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportExecutiveSummaryAsyncWithHttpInfo($xero_tenant_id, $date = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportExecutiveSummaryRequest($xero_tenant_id, $date);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportExecutiveSummary'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Bank Summary report e.g. 2018-03-31 (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportExecutiveSummaryRequest($xero_tenant_id, $date = null)
{
// 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 getReportExecutiveSummary'
);
}
$resourcePath = '/Reports/ExecutiveSummary';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($date !== null) {
$queryParams['date'] = AccountingObjectSerializer::toQueryValue($date);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportProfitAndLoss
*
* Allows you to retrieve report for ProfitAndLoss
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $from_date The from date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param \DateTime $to_date The to date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param int $periods The number of periods to compare (integer between 1 and 12) (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_category_id The trackingCategory 1 for the ProfitAndLoss report (optional)
* @param string $tracking_category_id2 The trackingCategory 2 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id The tracking option 1 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the ProfitAndLoss report (optional)
* @param bool $standard_layout Return the standard layout for the ProfitAndLoss report (optional)
* @param bool $payments_only Return cash only basis for the ProfitAndLoss report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportProfitAndLoss($xero_tenant_id, $from_date = null, $to_date = null, $periods = null, $timeframe = null, $tracking_category_id = null, $tracking_category_id2 = null, $tracking_option_id = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
list($response) = $this->getReportProfitAndLossWithHttpInfo($xero_tenant_id, $from_date, $to_date, $periods, $timeframe, $tracking_category_id, $tracking_category_id2, $tracking_option_id, $tracking_option_id2, $standard_layout, $payments_only);
return $response;
}
/**
* Operation getReportProfitAndLossWithHttpInfo
*
* Allows you to retrieve report for ProfitAndLoss
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $from_date The from date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param \DateTime $to_date The to date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param int $periods The number of periods to compare (integer between 1 and 12) (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_category_id The trackingCategory 1 for the ProfitAndLoss report (optional)
* @param string $tracking_category_id2 The trackingCategory 2 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id The tracking option 1 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the ProfitAndLoss report (optional)
* @param bool $standard_layout Return the standard layout for the ProfitAndLoss report (optional)
* @param bool $payments_only Return cash only basis for the ProfitAndLoss report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportProfitAndLossWithHttpInfo($xero_tenant_id, $from_date = null, $to_date = null, $periods = null, $timeframe = null, $tracking_category_id = null, $tracking_category_id2 = null, $tracking_option_id = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
$request = $this->getReportProfitAndLossRequest($xero_tenant_id, $from_date, $to_date, $periods, $timeframe, $tracking_category_id, $tracking_category_id2, $tracking_option_id, $tracking_option_id2, $standard_layout, $payments_only);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportProfitAndLossAsync
*
* Allows you to retrieve report for ProfitAndLoss
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $from_date The from date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param \DateTime $to_date The to date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param int $periods The number of periods to compare (integer between 1 and 12) (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_category_id The trackingCategory 1 for the ProfitAndLoss report (optional)
* @param string $tracking_category_id2 The trackingCategory 2 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id The tracking option 1 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the ProfitAndLoss report (optional)
* @param bool $standard_layout Return the standard layout for the ProfitAndLoss report (optional)
* @param bool $payments_only Return cash only basis for the ProfitAndLoss report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportProfitAndLossAsync($xero_tenant_id, $from_date = null, $to_date = null, $periods = null, $timeframe = null, $tracking_category_id = null, $tracking_category_id2 = null, $tracking_option_id = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
return $this->getReportProfitAndLossAsyncWithHttpInfo($xero_tenant_id, $from_date, $to_date, $periods, $timeframe, $tracking_category_id, $tracking_category_id2, $tracking_option_id, $tracking_option_id2, $standard_layout, $payments_only)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportProfitAndLossAsyncWithHttpInfo
*
* Allows you to retrieve report for ProfitAndLoss
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $from_date The from date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param \DateTime $to_date The to date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param int $periods The number of periods to compare (integer between 1 and 12) (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_category_id The trackingCategory 1 for the ProfitAndLoss report (optional)
* @param string $tracking_category_id2 The trackingCategory 2 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id The tracking option 1 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the ProfitAndLoss report (optional)
* @param bool $standard_layout Return the standard layout for the ProfitAndLoss report (optional)
* @param bool $payments_only Return cash only basis for the ProfitAndLoss report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportProfitAndLossAsyncWithHttpInfo($xero_tenant_id, $from_date = null, $to_date = null, $periods = null, $timeframe = null, $tracking_category_id = null, $tracking_category_id2 = null, $tracking_option_id = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportProfitAndLossRequest($xero_tenant_id, $from_date, $to_date, $periods, $timeframe, $tracking_category_id, $tracking_category_id2, $tracking_option_id, $tracking_option_id2, $standard_layout, $payments_only);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportProfitAndLoss'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $from_date The from date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param \DateTime $to_date The to date for the ProfitAndLoss report e.g. 2018-03-31 (optional)
* @param int $periods The number of periods to compare (integer between 1 and 12) (optional)
* @param string $timeframe The period size to compare to (MONTH, QUARTER, YEAR) (optional)
* @param string $tracking_category_id The trackingCategory 1 for the ProfitAndLoss report (optional)
* @param string $tracking_category_id2 The trackingCategory 2 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id The tracking option 1 for the ProfitAndLoss report (optional)
* @param string $tracking_option_id2 The tracking option 2 for the ProfitAndLoss report (optional)
* @param bool $standard_layout Return the standard layout for the ProfitAndLoss report (optional)
* @param bool $payments_only Return cash only basis for the ProfitAndLoss report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportProfitAndLossRequest($xero_tenant_id, $from_date = null, $to_date = null, $periods = null, $timeframe = null, $tracking_category_id = null, $tracking_category_id2 = null, $tracking_option_id = null, $tracking_option_id2 = null, $standard_layout = null, $payments_only = null)
{
// 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 getReportProfitAndLoss'
);
}
$resourcePath = '/Reports/ProfitAndLoss';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($from_date !== null) {
$queryParams['fromDate'] = AccountingObjectSerializer::toQueryValue($from_date);
}
// query params
if ($to_date !== null) {
$queryParams['toDate'] = AccountingObjectSerializer::toQueryValue($to_date);
}
// query params
if ($periods !== null) {
$queryParams['periods'] = AccountingObjectSerializer::toQueryValue($periods);
}
// query params
if ($timeframe !== null) {
$queryParams['timeframe'] = AccountingObjectSerializer::toQueryValue($timeframe);
}
// query params
if ($tracking_category_id !== null) {
$queryParams['trackingCategoryID'] = AccountingObjectSerializer::toQueryValue($tracking_category_id);
}
// query params
if ($tracking_category_id2 !== null) {
$queryParams['trackingCategoryID2'] = AccountingObjectSerializer::toQueryValue($tracking_category_id2);
}
// query params
if ($tracking_option_id !== null) {
$queryParams['trackingOptionID'] = AccountingObjectSerializer::toQueryValue($tracking_option_id);
}
// query params
if ($tracking_option_id2 !== null) {
$queryParams['trackingOptionID2'] = AccountingObjectSerializer::toQueryValue($tracking_option_id2);
}
// query params
if ($standard_layout !== null) {
$queryParams['standardLayout'] = AccountingObjectSerializer::toQueryValue($standard_layout);
}
// query params
if ($payments_only !== null) {
$queryParams['paymentsOnly'] = AccountingObjectSerializer::toQueryValue($payments_only);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportTenNinetyNine
*
* Allows you to retrieve report for TenNinetyNine
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_year The year of the 1099 report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Reports
*/
public function getReportTenNinetyNine($xero_tenant_id, $report_year = null)
{
list($response) = $this->getReportTenNinetyNineWithHttpInfo($xero_tenant_id, $report_year);
return $response;
}
/**
* Operation getReportTenNinetyNineWithHttpInfo
*
* Allows you to retrieve report for TenNinetyNine
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_year The year of the 1099 report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Reports, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportTenNinetyNineWithHttpInfo($xero_tenant_id, $report_year = null)
{
$request = $this->getReportTenNinetyNineRequest($xero_tenant_id, $report_year);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Reports' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Reports', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Reports';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Reports',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportTenNinetyNineAsync
*
* Allows you to retrieve report for TenNinetyNine
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_year The year of the 1099 report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportTenNinetyNineAsync($xero_tenant_id, $report_year = null)
{
return $this->getReportTenNinetyNineAsyncWithHttpInfo($xero_tenant_id, $report_year)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportTenNinetyNineAsyncWithHttpInfo
*
* Allows you to retrieve report for TenNinetyNine
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_year The year of the 1099 report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportTenNinetyNineAsyncWithHttpInfo($xero_tenant_id, $report_year = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Reports';
$request = $this->getReportTenNinetyNineRequest($xero_tenant_id, $report_year);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportTenNinetyNine'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $report_year The year of the 1099 report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportTenNinetyNineRequest($xero_tenant_id, $report_year = null)
{
// 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 getReportTenNinetyNine'
);
}
$resourcePath = '/Reports/TenNinetyNine';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($report_year !== null) {
$queryParams['reportYear'] = AccountingObjectSerializer::toQueryValue($report_year);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getReportTrialBalance
*
* Allows you to retrieve report for TrialBalance
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Trial Balance report e.g. 2018-03-31 (optional)
* @param bool $payments_only Return cash only basis for the Trial Balance report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows
*/
public function getReportTrialBalance($xero_tenant_id, $date = null, $payments_only = null)
{
list($response) = $this->getReportTrialBalanceWithHttpInfo($xero_tenant_id, $date, $payments_only);
return $response;
}
/**
* Operation getReportTrialBalanceWithHttpInfo
*
* Allows you to retrieve report for TrialBalance
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Trial Balance report e.g. 2018-03-31 (optional)
* @param bool $payments_only Return cash only basis for the Trial Balance report (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ReportWithRows, HTTP status code, HTTP response headers (array of strings)
*/
public function getReportTrialBalanceWithHttpInfo($xero_tenant_id, $date = null, $payments_only = null)
{
$request = $this->getReportTrialBalanceRequest($xero_tenant_id, $date, $payments_only);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getReportTrialBalanceAsync
*
* Allows you to retrieve report for TrialBalance
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Trial Balance report e.g. 2018-03-31 (optional)
* @param bool $payments_only Return cash only basis for the Trial Balance report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportTrialBalanceAsync($xero_tenant_id, $date = null, $payments_only = null)
{
return $this->getReportTrialBalanceAsyncWithHttpInfo($xero_tenant_id, $date, $payments_only)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getReportTrialBalanceAsyncWithHttpInfo
*
* Allows you to retrieve report for TrialBalance
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Trial Balance report e.g. 2018-03-31 (optional)
* @param bool $payments_only Return cash only basis for the Trial Balance report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getReportTrialBalanceAsyncWithHttpInfo($xero_tenant_id, $date = null, $payments_only = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ReportWithRows';
$request = $this->getReportTrialBalanceRequest($xero_tenant_id, $date, $payments_only);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getReportTrialBalance'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $date The date for the Trial Balance report e.g. 2018-03-31 (optional)
* @param bool $payments_only Return cash only basis for the Trial Balance report (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getReportTrialBalanceRequest($xero_tenant_id, $date = null, $payments_only = null)
{
// 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 getReportTrialBalance'
);
}
$resourcePath = '/Reports/TrialBalance';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($date !== null) {
$queryParams['date'] = AccountingObjectSerializer::toQueryValue($date);
}
// query params
if ($payments_only !== null) {
$queryParams['paymentsOnly'] = AccountingObjectSerializer::toQueryValue($payments_only);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getTaxRates
*
* Allows you to retrieve Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string $tax_type Filter by tax type (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TaxRates
*/
public function getTaxRates($xero_tenant_id, $where = null, $order = null, $tax_type = null)
{
list($response) = $this->getTaxRatesWithHttpInfo($xero_tenant_id, $where, $order, $tax_type);
return $response;
}
/**
* Operation getTaxRatesWithHttpInfo
*
* Allows you to retrieve Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string $tax_type Filter by tax type (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TaxRates, HTTP status code, HTTP response headers (array of strings)
*/
public function getTaxRatesWithHttpInfo($xero_tenant_id, $where = null, $order = null, $tax_type = null)
{
$request = $this->getTaxRatesRequest($xero_tenant_id, $where, $order, $tax_type);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TaxRates' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TaxRates', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TaxRates',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getTaxRatesAsync
*
* Allows you to retrieve Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string $tax_type Filter by tax type (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getTaxRatesAsync($xero_tenant_id, $where = null, $order = null, $tax_type = null)
{
return $this->getTaxRatesAsyncWithHttpInfo($xero_tenant_id, $where, $order, $tax_type)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getTaxRatesAsyncWithHttpInfo
*
* Allows you to retrieve Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string $tax_type Filter by tax type (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getTaxRatesAsyncWithHttpInfo($xero_tenant_id, $where = null, $order = null, $tax_type = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$request = $this->getTaxRatesRequest($xero_tenant_id, $where, $order, $tax_type);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getTaxRates'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param string $tax_type Filter by tax type (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getTaxRatesRequest($xero_tenant_id, $where = null, $order = null, $tax_type = null)
{
// 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 getTaxRates'
);
}
$resourcePath = '/TaxRates';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($tax_type !== null) {
$queryParams['TaxType'] = AccountingObjectSerializer::toQueryValue($tax_type);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getTrackingCategories
*
* Allows you to retrieve tracking categories and options
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param bool $include_archived e.g. includeArchived=true - Categories and options with a status of ARCHIVED will be included in the response (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories
*/
public function getTrackingCategories($xero_tenant_id, $where = null, $order = null, $include_archived = null)
{
list($response) = $this->getTrackingCategoriesWithHttpInfo($xero_tenant_id, $where, $order, $include_archived);
return $response;
}
/**
* Operation getTrackingCategoriesWithHttpInfo
*
* Allows you to retrieve tracking categories and options
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param bool $include_archived e.g. includeArchived=true - Categories and options with a status of ARCHIVED will be included in the response (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories, HTTP status code, HTTP response headers (array of strings)
*/
public function getTrackingCategoriesWithHttpInfo($xero_tenant_id, $where = null, $order = null, $include_archived = null)
{
$request = $this->getTrackingCategoriesRequest($xero_tenant_id, $where, $order, $include_archived);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getTrackingCategoriesAsync
*
* Allows you to retrieve tracking categories and options
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param bool $include_archived e.g. includeArchived=true - Categories and options with a status of ARCHIVED will be included in the response (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getTrackingCategoriesAsync($xero_tenant_id, $where = null, $order = null, $include_archived = null)
{
return $this->getTrackingCategoriesAsyncWithHttpInfo($xero_tenant_id, $where, $order, $include_archived)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getTrackingCategoriesAsyncWithHttpInfo
*
* Allows you to retrieve tracking categories and options
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param bool $include_archived e.g. includeArchived=true - Categories and options with a status of ARCHIVED will be included in the response (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getTrackingCategoriesAsyncWithHttpInfo($xero_tenant_id, $where = null, $order = null, $include_archived = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$request = $this->getTrackingCategoriesRequest($xero_tenant_id, $where, $order, $include_archived);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getTrackingCategories'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
* @param bool $include_archived e.g. includeArchived=true - Categories and options with a status of ARCHIVED will be included in the response (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getTrackingCategoriesRequest($xero_tenant_id, $where = null, $order = null, $include_archived = null)
{
// 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 getTrackingCategories'
);
}
$resourcePath = '/TrackingCategories';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// query params
if ($include_archived !== null) {
$queryParams['includeArchived'] = AccountingObjectSerializer::toQueryValue($include_archived);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getTrackingCategory
*
* Allows you to retrieve tracking categories and options for specified category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories
*/
public function getTrackingCategory($xero_tenant_id, $tracking_category_id)
{
list($response) = $this->getTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category_id);
return $response;
}
/**
* Operation getTrackingCategoryWithHttpInfo
*
* Allows you to retrieve tracking categories and options for specified category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories, HTTP status code, HTTP response headers (array of strings)
*/
public function getTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category_id)
{
$request = $this->getTrackingCategoryRequest($xero_tenant_id, $tracking_category_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getTrackingCategoryAsync
*
* Allows you to retrieve tracking categories and options for specified category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getTrackingCategoryAsync($xero_tenant_id, $tracking_category_id)
{
return $this->getTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getTrackingCategoryAsyncWithHttpInfo
*
* Allows you to retrieve tracking categories and options for specified category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$request = $this->getTrackingCategoryRequest($xero_tenant_id, $tracking_category_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getTrackingCategory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getTrackingCategoryRequest($xero_tenant_id, $tracking_category_id)
{
// 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 getTrackingCategory'
);
}
// verify the required parameter 'tracking_category_id' is set
if ($tracking_category_id === null || (is_array($tracking_category_id) && count($tracking_category_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category_id when calling getTrackingCategory'
);
}
$resourcePath = '/TrackingCategories/{TrackingCategoryID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($tracking_category_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingCategoryID' . '}',
AccountingObjectSerializer::toPathValue($tracking_category_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getUser
*
* Allows you to retrieve a specified user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $user_id Unique identifier for a User (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Users
*/
public function getUser($xero_tenant_id, $user_id)
{
list($response) = $this->getUserWithHttpInfo($xero_tenant_id, $user_id);
return $response;
}
/**
* Operation getUserWithHttpInfo
*
* Allows you to retrieve a specified user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $user_id Unique identifier for a User (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Users, HTTP status code, HTTP response headers (array of strings)
*/
public function getUserWithHttpInfo($xero_tenant_id, $user_id)
{
$request = $this->getUserRequest($xero_tenant_id, $user_id);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Users' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Users', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Users';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Users',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getUserAsync
*
* Allows you to retrieve a specified user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $user_id Unique identifier for a User (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getUserAsync($xero_tenant_id, $user_id)
{
return $this->getUserAsyncWithHttpInfo($xero_tenant_id, $user_id)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getUserAsyncWithHttpInfo
*
* Allows you to retrieve a specified user
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $user_id Unique identifier for a User (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getUserAsyncWithHttpInfo($xero_tenant_id, $user_id)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Users';
$request = $this->getUserRequest($xero_tenant_id, $user_id);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getUser'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $user_id Unique identifier for a User (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getUserRequest($xero_tenant_id, $user_id)
{
// 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 getUser'
);
}
// verify the required parameter 'user_id' is set
if ($user_id === null || (is_array($user_id) && count($user_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $user_id when calling getUser'
);
}
$resourcePath = '/Users/{UserID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($user_id !== null) {
$resourcePath = str_replace(
'{' . 'UserID' . '}',
AccountingObjectSerializer::toPathValue($user_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation getUsers
*
* Allows you to retrieve users
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Users
*/
public function getUsers($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
list($response) = $this->getUsersWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order);
return $response;
}
/**
* Operation getUsersWithHttpInfo
*
* Allows you to retrieve users
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Users, HTTP status code, HTTP response headers (array of strings)
*/
public function getUsersWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$request = $this->getUsersRequest($xero_tenant_id, $if_modified_since, $where, $order);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Users' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Users', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Users';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Users',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getUsersAsync
*
* Allows you to retrieve users
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getUsersAsync($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
return $this->getUsersAsyncWithHttpInfo($xero_tenant_id, $if_modified_since, $where, $order)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getUsersAsyncWithHttpInfo
*
* Allows you to retrieve users
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getUsersAsyncWithHttpInfo($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Users';
$request = $this->getUsersRequest($xero_tenant_id, $if_modified_since, $where, $order);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'getUsers'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \DateTime $if_modified_since Only records created or modified since this timestamp will be returned (optional)
* @param string $where Filter by an any element (optional)
* @param string $order Order by an any element (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getUsersRequest($xero_tenant_id, $if_modified_since = null, $where = null, $order = null)
{
// 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 getUsers'
);
}
$resourcePath = '/Users';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if ($where !== null) {
$queryParams['where'] = AccountingObjectSerializer::toQueryValue($where);
}
// query params
if ($order !== null) {
$queryParams['order'] = AccountingObjectSerializer::toQueryValue($order);
}
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// header params
if ($if_modified_since !== null) {
$headerParams['If-Modified-Since'] = AccountingObjectSerializer::toHeaderValue($if_modified_since);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateAccount
*
* Allows you to update a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Accounts $accounts Request of type Accounts array with one Account (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Accounts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateAccount($xero_tenant_id, $account_id, $accounts)
{
list($response) = $this->updateAccountWithHttpInfo($xero_tenant_id, $account_id, $accounts);
return $response;
}
/**
* Operation updateAccountWithHttpInfo
*
* Allows you to update a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Accounts $accounts Request of type Accounts array with one Account (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Accounts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateAccountWithHttpInfo($xero_tenant_id, $account_id, $accounts)
{
$request = $this->updateAccountRequest($xero_tenant_id, $account_id, $accounts);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Accounts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Accounts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Accounts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateAccountAsync
*
* Allows you to update a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Accounts $accounts Request of type Accounts array with one Account (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateAccountAsync($xero_tenant_id, $account_id, $accounts)
{
return $this->updateAccountAsyncWithHttpInfo($xero_tenant_id, $account_id, $accounts)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateAccountAsyncWithHttpInfo
*
* Allows you to update a chart of accounts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Accounts $accounts Request of type Accounts array with one Account (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateAccountAsyncWithHttpInfo($xero_tenant_id, $account_id, $accounts)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Accounts';
$request = $this->updateAccountRequest($xero_tenant_id, $account_id, $accounts);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateAccount'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for retrieving single object (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Accounts $accounts Request of type Accounts array with one Account (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateAccountRequest($xero_tenant_id, $account_id, $accounts)
{
// 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 updateAccount'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling updateAccount'
);
}
// verify the required parameter 'accounts' is set
if ($accounts === null || (is_array($accounts) && count($accounts) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $accounts when calling updateAccount'
);
}
$resourcePath = '/Accounts/{AccountID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($accounts)) {
$_tempBody = $accounts;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateAccountAttachmentByFileName
*
* Allows you to update Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateAccountAttachmentByFileName($xero_tenant_id, $account_id, $file_name, $body)
{
list($response) = $this->updateAccountAttachmentByFileNameWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body);
return $response;
}
/**
* Operation updateAccountAttachmentByFileNameWithHttpInfo
*
* Allows you to update Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateAccountAttachmentByFileNameWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body)
{
$request = $this->updateAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateAccountAttachmentByFileNameAsync
*
* Allows you to update Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateAccountAttachmentByFileNameAsync($xero_tenant_id, $account_id, $file_name, $body)
{
return $this->updateAccountAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateAccountAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to update Attachment on Account by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateAccountAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $account_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateAccountAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $account_id Unique identifier for Account object (required)
* @param string $file_name Name of the attachment (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateAccountAttachmentByFileNameRequest($xero_tenant_id, $account_id, $file_name, $body)
{
// 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 updateAccountAttachmentByFileName'
);
}
// verify the required parameter 'account_id' is set
if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $account_id when calling updateAccountAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateAccountAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateAccountAttachmentByFileName'
);
}
$resourcePath = '/Accounts/{AccountID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($account_id !== null) {
$resourcePath = str_replace(
'{' . 'AccountID' . '}',
AccountingObjectSerializer::toPathValue($account_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateBankTransaction
*
* Allows you to update a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions bank_transactions (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\BankTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateBankTransaction($xero_tenant_id, $bank_transaction_id, $bank_transactions)
{
list($response) = $this->updateBankTransactionWithHttpInfo($xero_tenant_id, $bank_transaction_id, $bank_transactions);
return $response;
}
/**
* Operation updateBankTransactionWithHttpInfo
*
* Allows you to update a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\BankTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateBankTransactionWithHttpInfo($xero_tenant_id, $bank_transaction_id, $bank_transactions)
{
$request = $this->updateBankTransactionRequest($xero_tenant_id, $bank_transaction_id, $bank_transactions);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\BankTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\BankTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateBankTransactionAsync
*
* Allows you to update a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBankTransactionAsync($xero_tenant_id, $bank_transaction_id, $bank_transactions)
{
return $this->updateBankTransactionAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $bank_transactions)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateBankTransactionAsyncWithHttpInfo
*
* Allows you to update a single spend or receive money transaction
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBankTransactionAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $bank_transactions)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\BankTransactions';
$request = $this->updateBankTransactionRequest($xero_tenant_id, $bank_transaction_id, $bank_transactions);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateBankTransaction'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\BankTransactions $bank_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateBankTransactionRequest($xero_tenant_id, $bank_transaction_id, $bank_transactions)
{
// 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 updateBankTransaction'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling updateBankTransaction'
);
}
// verify the required parameter 'bank_transactions' is set
if ($bank_transactions === null || (is_array($bank_transactions) && count($bank_transactions) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transactions when calling updateBankTransaction'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($bank_transactions)) {
$_tempBody = $bank_transactions;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateBankTransactionAttachmentByFileName
*
* Allows you to update an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateBankTransactionAttachmentByFileName($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
list($response) = $this->updateBankTransactionAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body);
return $response;
}
/**
* Operation updateBankTransactionAttachmentByFileNameWithHttpInfo
*
* Allows you to update an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateBankTransactionAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
$request = $this->updateBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateBankTransactionAttachmentByFileNameAsync
*
* Allows you to update an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBankTransactionAttachmentByFileNameAsync($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
return $this->updateBankTransactionAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateBankTransactionAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to update an Attachment on BankTransaction by Filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBankTransactionAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateBankTransactionAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transaction_id Xero generated unique identifier for a bank transaction (required)
* @param string $file_name The name of the file being attached (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateBankTransactionAttachmentByFileNameRequest($xero_tenant_id, $bank_transaction_id, $file_name, $body)
{
// 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 updateBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'bank_transaction_id' is set
if ($bank_transaction_id === null || (is_array($bank_transaction_id) && count($bank_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transaction_id when calling updateBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateBankTransactionAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateBankTransactionAttachmentByFileName'
);
}
$resourcePath = '/BankTransactions/{BankTransactionID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransactionID' . '}',
AccountingObjectSerializer::toPathValue($bank_transaction_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateBankTransferAttachmentByFileName
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateBankTransferAttachmentByFileName($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
list($response) = $this->updateBankTransferAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body);
return $response;
}
/**
* Operation updateBankTransferAttachmentByFileNameWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateBankTransferAttachmentByFileNameWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
$request = $this->updateBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateBankTransferAttachmentByFileNameAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBankTransferAttachmentByFileNameAsync($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
return $this->updateBankTransferAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateBankTransferAttachmentByFileNameAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateBankTransferAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateBankTransferAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $bank_transfer_id Xero generated unique identifier for a bank transfer (required)
* @param string $file_name The name of the file being attached to a Bank Transfer (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateBankTransferAttachmentByFileNameRequest($xero_tenant_id, $bank_transfer_id, $file_name, $body)
{
// 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 updateBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'bank_transfer_id' is set
if ($bank_transfer_id === null || (is_array($bank_transfer_id) && count($bank_transfer_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $bank_transfer_id when calling updateBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateBankTransferAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateBankTransferAttachmentByFileName'
);
}
$resourcePath = '/BankTransfers/{BankTransferID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($bank_transfer_id !== null) {
$resourcePath = str_replace(
'{' . 'BankTransferID' . '}',
AccountingObjectSerializer::toPathValue($bank_transfer_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateContact
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of Contacts containing single Contact object with properties to update (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateContact($xero_tenant_id, $contact_id, $contacts)
{
list($response) = $this->updateContactWithHttpInfo($xero_tenant_id, $contact_id, $contacts);
return $response;
}
/**
* Operation updateContactWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of Contacts containing single Contact object with properties to update (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Contacts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateContactWithHttpInfo($xero_tenant_id, $contact_id, $contacts)
{
$request = $this->updateContactRequest($xero_tenant_id, $contact_id, $contacts);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Contacts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Contacts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Contacts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateContactAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of Contacts containing single Contact object with properties to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateContactAsync($xero_tenant_id, $contact_id, $contacts)
{
return $this->updateContactAsyncWithHttpInfo($xero_tenant_id, $contact_id, $contacts)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateContactAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of Contacts containing single Contact object with properties to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateContactAsyncWithHttpInfo($xero_tenant_id, $contact_id, $contacts)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Contacts';
$request = $this->updateContactRequest($xero_tenant_id, $contact_id, $contacts);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateContact'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Contacts $contacts an array of Contacts containing single Contact object with properties to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateContactRequest($xero_tenant_id, $contact_id, $contacts)
{
// 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 updateContact'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling updateContact'
);
}
// verify the required parameter 'contacts' is set
if ($contacts === null || (is_array($contacts) && count($contacts) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contacts when calling updateContact'
);
}
$resourcePath = '/Contacts/{ContactID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($contacts)) {
$_tempBody = $contacts;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateContactAttachmentByFileName
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateContactAttachmentByFileName($xero_tenant_id, $contact_id, $file_name, $body)
{
list($response) = $this->updateContactAttachmentByFileNameWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body);
return $response;
}
/**
* Operation updateContactAttachmentByFileNameWithHttpInfo
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateContactAttachmentByFileNameWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body)
{
$request = $this->updateContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateContactAttachmentByFileNameAsync
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateContactAttachmentByFileNameAsync($xero_tenant_id, $contact_id, $file_name, $body)
{
return $this->updateContactAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateContactAttachmentByFileNameAsyncWithHttpInfo
*
*
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateContactAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $contact_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateContactAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_id Unique identifier for a Contact (required)
* @param string $file_name Name for the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateContactAttachmentByFileNameRequest($xero_tenant_id, $contact_id, $file_name, $body)
{
// 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 updateContactAttachmentByFileName'
);
}
// verify the required parameter 'contact_id' is set
if ($contact_id === null || (is_array($contact_id) && count($contact_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_id when calling updateContactAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateContactAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateContactAttachmentByFileName'
);
}
$resourcePath = '/Contacts/{ContactID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactID' . '}',
AccountingObjectSerializer::toPathValue($contact_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateContactGroup
*
* Allows you to update a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of Contact groups with Name of specific group to update (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ContactGroups|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateContactGroup($xero_tenant_id, $contact_group_id, $contact_groups)
{
list($response) = $this->updateContactGroupWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_groups);
return $response;
}
/**
* Operation updateContactGroupWithHttpInfo
*
* Allows you to update a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of Contact groups with Name of specific group to update (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ContactGroups|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateContactGroupWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_groups)
{
$request = $this->updateContactGroupRequest($xero_tenant_id, $contact_group_id, $contact_groups);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ContactGroups' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ContactGroups',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateContactGroupAsync
*
* Allows you to update a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of Contact groups with Name of specific group to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateContactGroupAsync($xero_tenant_id, $contact_group_id, $contact_groups)
{
return $this->updateContactGroupAsyncWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_groups)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateContactGroupAsyncWithHttpInfo
*
* Allows you to update a Contract Group
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of Contact groups with Name of specific group to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateContactGroupAsyncWithHttpInfo($xero_tenant_id, $contact_group_id, $contact_groups)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ContactGroups';
$request = $this->updateContactGroupRequest($xero_tenant_id, $contact_group_id, $contact_groups);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateContactGroup'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $contact_group_id Unique identifier for a Contact Group (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ContactGroups $contact_groups an array of Contact groups with Name of specific group to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateContactGroupRequest($xero_tenant_id, $contact_group_id, $contact_groups)
{
// 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 updateContactGroup'
);
}
// verify the required parameter 'contact_group_id' is set
if ($contact_group_id === null || (is_array($contact_group_id) && count($contact_group_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_group_id when calling updateContactGroup'
);
}
// verify the required parameter 'contact_groups' is set
if ($contact_groups === null || (is_array($contact_groups) && count($contact_groups) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $contact_groups when calling updateContactGroup'
);
}
$resourcePath = '/ContactGroups/{ContactGroupID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($contact_group_id !== null) {
$resourcePath = str_replace(
'{' . 'ContactGroupID' . '}',
AccountingObjectSerializer::toPathValue($contact_group_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($contact_groups)) {
$_tempBody = $contact_groups;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateCreditNote
*
* Allows you to update a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes containing credit note details to update (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\CreditNotes|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateCreditNote($xero_tenant_id, $credit_note_id, $credit_notes)
{
list($response) = $this->updateCreditNoteWithHttpInfo($xero_tenant_id, $credit_note_id, $credit_notes);
return $response;
}
/**
* Operation updateCreditNoteWithHttpInfo
*
* Allows you to update a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes containing credit note details to update (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\CreditNotes|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateCreditNoteWithHttpInfo($xero_tenant_id, $credit_note_id, $credit_notes)
{
$request = $this->updateCreditNoteRequest($xero_tenant_id, $credit_note_id, $credit_notes);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\CreditNotes' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\CreditNotes',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateCreditNoteAsync
*
* Allows you to update a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes containing credit note details to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateCreditNoteAsync($xero_tenant_id, $credit_note_id, $credit_notes)
{
return $this->updateCreditNoteAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $credit_notes)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateCreditNoteAsyncWithHttpInfo
*
* Allows you to update a specific credit note
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes containing credit note details to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateCreditNoteAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $credit_notes)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\CreditNotes';
$request = $this->updateCreditNoteRequest($xero_tenant_id, $credit_note_id, $credit_notes);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateCreditNote'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\CreditNotes $credit_notes an array of Credit Notes containing credit note details to update (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateCreditNoteRequest($xero_tenant_id, $credit_note_id, $credit_notes)
{
// 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 updateCreditNote'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling updateCreditNote'
);
}
// verify the required parameter 'credit_notes' is set
if ($credit_notes === null || (is_array($credit_notes) && count($credit_notes) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_notes when calling updateCreditNote'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($credit_notes)) {
$_tempBody = $credit_notes;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateCreditNoteAttachmentByFileName
*
* Allows you to update Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateCreditNoteAttachmentByFileName($xero_tenant_id, $credit_note_id, $file_name, $body)
{
list($response) = $this->updateCreditNoteAttachmentByFileNameWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body);
return $response;
}
/**
* Operation updateCreditNoteAttachmentByFileNameWithHttpInfo
*
* Allows you to update Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateCreditNoteAttachmentByFileNameWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body)
{
$request = $this->updateCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateCreditNoteAttachmentByFileNameAsync
*
* Allows you to update Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateCreditNoteAttachmentByFileNameAsync($xero_tenant_id, $credit_note_id, $file_name, $body)
{
return $this->updateCreditNoteAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateCreditNoteAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to update Attachments on CreditNote by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateCreditNoteAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $credit_note_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateCreditNoteAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $credit_note_id Unique identifier for a Credit Note (required)
* @param string $file_name Name of the file you are attaching to Credit Note (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateCreditNoteAttachmentByFileNameRequest($xero_tenant_id, $credit_note_id, $file_name, $body)
{
// 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 updateCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'credit_note_id' is set
if ($credit_note_id === null || (is_array($credit_note_id) && count($credit_note_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $credit_note_id when calling updateCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateCreditNoteAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateCreditNoteAttachmentByFileName'
);
}
$resourcePath = '/CreditNotes/{CreditNoteID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($credit_note_id !== null) {
$resourcePath = str_replace(
'{' . 'CreditNoteID' . '}',
AccountingObjectSerializer::toPathValue($credit_note_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateEmployee
*
* Allows you to update a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees employees (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Employees|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateEmployee($xero_tenant_id, $employee_id, $employees)
{
list($response) = $this->updateEmployeeWithHttpInfo($xero_tenant_id, $employee_id, $employees);
return $response;
}
/**
* Operation updateEmployeeWithHttpInfo
*
* Allows you to update a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Employees|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateEmployeeWithHttpInfo($xero_tenant_id, $employee_id, $employees)
{
$request = $this->updateEmployeeRequest($xero_tenant_id, $employee_id, $employees);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Employees' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Employees', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Employees',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateEmployeeAsync
*
* Allows you to update a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateEmployeeAsync($xero_tenant_id, $employee_id, $employees)
{
return $this->updateEmployeeAsyncWithHttpInfo($xero_tenant_id, $employee_id, $employees)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateEmployeeAsyncWithHttpInfo
*
* Allows you to update a specific employee used in Xero payrun
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateEmployeeAsyncWithHttpInfo($xero_tenant_id, $employee_id, $employees)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Employees';
$request = $this->updateEmployeeRequest($xero_tenant_id, $employee_id, $employees);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateEmployee'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $employee_id Unique identifier for a Employee (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Employees $employees (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateEmployeeRequest($xero_tenant_id, $employee_id, $employees)
{
// 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 updateEmployee'
);
}
// verify the required parameter 'employee_id' is set
if ($employee_id === null || (is_array($employee_id) && count($employee_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $employee_id when calling updateEmployee'
);
}
// verify the required parameter 'employees' is set
if ($employees === null || (is_array($employees) && count($employees) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $employees when calling updateEmployee'
);
}
$resourcePath = '/Employees/{EmployeeID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($employee_id !== null) {
$resourcePath = str_replace(
'{' . 'EmployeeID' . '}',
AccountingObjectSerializer::toPathValue($employee_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($employees)) {
$_tempBody = $employees;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateExpenseClaim
*
* Allows you to update specified expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims expense_claims (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateExpenseClaim($xero_tenant_id, $expense_claim_id, $expense_claims)
{
list($response) = $this->updateExpenseClaimWithHttpInfo($xero_tenant_id, $expense_claim_id, $expense_claims);
return $response;
}
/**
* Operation updateExpenseClaimWithHttpInfo
*
* Allows you to update specified expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateExpenseClaimWithHttpInfo($xero_tenant_id, $expense_claim_id, $expense_claims)
{
$request = $this->updateExpenseClaimRequest($xero_tenant_id, $expense_claim_id, $expense_claims);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateExpenseClaimAsync
*
* Allows you to update specified expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateExpenseClaimAsync($xero_tenant_id, $expense_claim_id, $expense_claims)
{
return $this->updateExpenseClaimAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id, $expense_claims)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateExpenseClaimAsyncWithHttpInfo
*
* Allows you to update specified expense claims
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateExpenseClaimAsyncWithHttpInfo($xero_tenant_id, $expense_claim_id, $expense_claims)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims';
$request = $this->updateExpenseClaimRequest($xero_tenant_id, $expense_claim_id, $expense_claims);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateExpenseClaim'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $expense_claim_id Unique identifier for a ExpenseClaim (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ExpenseClaims $expense_claims (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateExpenseClaimRequest($xero_tenant_id, $expense_claim_id, $expense_claims)
{
// 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 updateExpenseClaim'
);
}
// verify the required parameter 'expense_claim_id' is set
if ($expense_claim_id === null || (is_array($expense_claim_id) && count($expense_claim_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $expense_claim_id when calling updateExpenseClaim'
);
}
// verify the required parameter 'expense_claims' is set
if ($expense_claims === null || (is_array($expense_claims) && count($expense_claims) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $expense_claims when calling updateExpenseClaim'
);
}
$resourcePath = '/ExpenseClaims/{ExpenseClaimID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($expense_claim_id !== null) {
$resourcePath = str_replace(
'{' . 'ExpenseClaimID' . '}',
AccountingObjectSerializer::toPathValue($expense_claim_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($expense_claims)) {
$_tempBody = $expense_claims;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateInvoice
*
* Allows you to update a specified sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices invoices (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Invoices|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateInvoice($xero_tenant_id, $invoice_id, $invoices)
{
list($response) = $this->updateInvoiceWithHttpInfo($xero_tenant_id, $invoice_id, $invoices);
return $response;
}
/**
* Operation updateInvoiceWithHttpInfo
*
* Allows you to update a specified sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Invoices|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateInvoiceWithHttpInfo($xero_tenant_id, $invoice_id, $invoices)
{
$request = $this->updateInvoiceRequest($xero_tenant_id, $invoice_id, $invoices);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Invoices' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Invoices', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Invoices',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateInvoiceAsync
*
* Allows you to update a specified sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateInvoiceAsync($xero_tenant_id, $invoice_id, $invoices)
{
return $this->updateInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $invoices)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateInvoiceAsyncWithHttpInfo
*
* Allows you to update a specified sales invoices or purchase bills
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateInvoiceAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $invoices)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Invoices';
$request = $this->updateInvoiceRequest($xero_tenant_id, $invoice_id, $invoices);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateInvoice'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Invoices $invoices (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateInvoiceRequest($xero_tenant_id, $invoice_id, $invoices)
{
// 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 updateInvoice'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling updateInvoice'
);
}
// verify the required parameter 'invoices' is set
if ($invoices === null || (is_array($invoices) && count($invoices) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoices when calling updateInvoice'
);
}
$resourcePath = '/Invoices/{InvoiceID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($invoices)) {
$_tempBody = $invoices;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateInvoiceAttachmentByFileName
*
* Allows you to update Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateInvoiceAttachmentByFileName($xero_tenant_id, $invoice_id, $file_name, $body)
{
list($response) = $this->updateInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body);
return $response;
}
/**
* Operation updateInvoiceAttachmentByFileNameWithHttpInfo
*
* Allows you to update Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body)
{
$request = $this->updateInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateInvoiceAttachmentByFileNameAsync
*
* Allows you to update Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateInvoiceAttachmentByFileNameAsync($xero_tenant_id, $invoice_id, $file_name, $body)
{
return $this->updateInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateInvoiceAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to update Attachment on invoices or purchase bills by it's filename
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $invoice_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateInvoiceAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $invoice_id Unique identifier for an Invoice (required)
* @param string $file_name Name of the file you are attaching (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateInvoiceAttachmentByFileNameRequest($xero_tenant_id, $invoice_id, $file_name, $body)
{
// 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 updateInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'invoice_id' is set
if ($invoice_id === null || (is_array($invoice_id) && count($invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $invoice_id when calling updateInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateInvoiceAttachmentByFileName'
);
}
$resourcePath = '/Invoices/{InvoiceID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'InvoiceID' . '}',
AccountingObjectSerializer::toPathValue($invoice_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateItem
*
* Allows you to udpate a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items items (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Items|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateItem($xero_tenant_id, $item_id, $items)
{
list($response) = $this->updateItemWithHttpInfo($xero_tenant_id, $item_id, $items);
return $response;
}
/**
* Operation updateItemWithHttpInfo
*
* Allows you to udpate a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Items|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateItemWithHttpInfo($xero_tenant_id, $item_id, $items)
{
$request = $this->updateItemRequest($xero_tenant_id, $item_id, $items);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Items' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Items', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Items',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateItemAsync
*
* Allows you to udpate a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateItemAsync($xero_tenant_id, $item_id, $items)
{
return $this->updateItemAsyncWithHttpInfo($xero_tenant_id, $item_id, $items)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateItemAsyncWithHttpInfo
*
* Allows you to udpate a specified item
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateItemAsyncWithHttpInfo($xero_tenant_id, $item_id, $items)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Items';
$request = $this->updateItemRequest($xero_tenant_id, $item_id, $items);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateItem'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $item_id Unique identifier for an Item (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Items $items (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateItemRequest($xero_tenant_id, $item_id, $items)
{
// 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 updateItem'
);
}
// verify the required parameter 'item_id' is set
if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $item_id when calling updateItem'
);
}
// verify the required parameter 'items' is set
if ($items === null || (is_array($items) && count($items) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $items when calling updateItem'
);
}
$resourcePath = '/Items/{ItemID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($item_id !== null) {
$resourcePath = str_replace(
'{' . 'ItemID' . '}',
AccountingObjectSerializer::toPathValue($item_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($items)) {
$_tempBody = $items;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateLinkedTransaction
*
* Allows you to update a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions linked_transactions (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateLinkedTransaction($xero_tenant_id, $linked_transaction_id, $linked_transactions)
{
list($response) = $this->updateLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction_id, $linked_transactions);
return $response;
}
/**
* Operation updateLinkedTransactionWithHttpInfo
*
* Allows you to update a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateLinkedTransactionWithHttpInfo($xero_tenant_id, $linked_transaction_id, $linked_transactions)
{
$request = $this->updateLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id, $linked_transactions);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateLinkedTransactionAsync
*
* Allows you to update a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateLinkedTransactionAsync($xero_tenant_id, $linked_transaction_id, $linked_transactions)
{
return $this->updateLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction_id, $linked_transactions)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateLinkedTransactionAsyncWithHttpInfo
*
* Allows you to update a specified linked transactions (billable expenses)
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateLinkedTransactionAsyncWithHttpInfo($xero_tenant_id, $linked_transaction_id, $linked_transactions)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions';
$request = $this->updateLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id, $linked_transactions);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateLinkedTransaction'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $linked_transaction_id Unique identifier for a LinkedTransaction (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\LinkedTransactions $linked_transactions (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateLinkedTransactionRequest($xero_tenant_id, $linked_transaction_id, $linked_transactions)
{
// 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 updateLinkedTransaction'
);
}
// verify the required parameter 'linked_transaction_id' is set
if ($linked_transaction_id === null || (is_array($linked_transaction_id) && count($linked_transaction_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $linked_transaction_id when calling updateLinkedTransaction'
);
}
// verify the required parameter 'linked_transactions' is set
if ($linked_transactions === null || (is_array($linked_transactions) && count($linked_transactions) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $linked_transactions when calling updateLinkedTransaction'
);
}
$resourcePath = '/LinkedTransactions/{LinkedTransactionID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($linked_transaction_id !== null) {
$resourcePath = str_replace(
'{' . 'LinkedTransactionID' . '}',
AccountingObjectSerializer::toPathValue($linked_transaction_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($linked_transactions)) {
$_tempBody = $linked_transactions;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateManualJournal
*
* Allows you to update a specified manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals manual_journals (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\ManualJournals|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateManualJournal($xero_tenant_id, $manual_journal_id, $manual_journals)
{
list($response) = $this->updateManualJournalWithHttpInfo($xero_tenant_id, $manual_journal_id, $manual_journals);
return $response;
}
/**
* Operation updateManualJournalWithHttpInfo
*
* Allows you to update a specified manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\ManualJournals|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateManualJournalWithHttpInfo($xero_tenant_id, $manual_journal_id, $manual_journals)
{
$request = $this->updateManualJournalRequest($xero_tenant_id, $manual_journal_id, $manual_journals);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\ManualJournals' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\ManualJournals',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateManualJournalAsync
*
* Allows you to update a specified manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateManualJournalAsync($xero_tenant_id, $manual_journal_id, $manual_journals)
{
return $this->updateManualJournalAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $manual_journals)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateManualJournalAsyncWithHttpInfo
*
* Allows you to update a specified manual journal
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateManualJournalAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $manual_journals)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\ManualJournals';
$request = $this->updateManualJournalRequest($xero_tenant_id, $manual_journal_id, $manual_journals);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateManualJournal'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\ManualJournals $manual_journals (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateManualJournalRequest($xero_tenant_id, $manual_journal_id, $manual_journals)
{
// 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 updateManualJournal'
);
}
// verify the required parameter 'manual_journal_id' is set
if ($manual_journal_id === null || (is_array($manual_journal_id) && count($manual_journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal_id when calling updateManualJournal'
);
}
// verify the required parameter 'manual_journals' is set
if ($manual_journals === null || (is_array($manual_journals) && count($manual_journals) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journals when calling updateManualJournal'
);
}
$resourcePath = '/ManualJournals/{ManualJournalID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($manual_journal_id !== null) {
$resourcePath = str_replace(
'{' . 'ManualJournalID' . '}',
AccountingObjectSerializer::toPathValue($manual_journal_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($manual_journals)) {
$_tempBody = $manual_journals;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateManualJournalAttachmentByFileName
*
* Allows you to update a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateManualJournalAttachmentByFileName($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
list($response) = $this->updateManualJournalAttachmentByFileNameWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body);
return $response;
}
/**
* Operation updateManualJournalAttachmentByFileNameWithHttpInfo
*
* Allows you to update a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateManualJournalAttachmentByFileNameWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
$request = $this->updateManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateManualJournalAttachmentByFileNameAsync
*
* Allows you to update a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateManualJournalAttachmentByFileNameAsync($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
return $this->updateManualJournalAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateManualJournalAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to update a specified Attachment on ManualJournal by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateManualJournalAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateManualJournalAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $manual_journal_id Unique identifier for a ManualJournal (required)
* @param string $file_name The name of the file being attached to a ManualJournal (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateManualJournalAttachmentByFileNameRequest($xero_tenant_id, $manual_journal_id, $file_name, $body)
{
// 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 updateManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'manual_journal_id' is set
if ($manual_journal_id === null || (is_array($manual_journal_id) && count($manual_journal_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $manual_journal_id when calling updateManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateManualJournalAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateManualJournalAttachmentByFileName'
);
}
$resourcePath = '/ManualJournals/{ManualJournalID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($manual_journal_id !== null) {
$resourcePath = str_replace(
'{' . 'ManualJournalID' . '}',
AccountingObjectSerializer::toPathValue($manual_journal_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updatePurchaseOrder
*
* Allows you to update a specified purchase order
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders purchase_orders (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updatePurchaseOrder($xero_tenant_id, $purchase_order_id, $purchase_orders)
{
list($response) = $this->updatePurchaseOrderWithHttpInfo($xero_tenant_id, $purchase_order_id, $purchase_orders);
return $response;
}
/**
* Operation updatePurchaseOrderWithHttpInfo
*
* Allows you to update a specified purchase order
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updatePurchaseOrderWithHttpInfo($xero_tenant_id, $purchase_order_id, $purchase_orders)
{
$request = $this->updatePurchaseOrderRequest($xero_tenant_id, $purchase_order_id, $purchase_orders);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updatePurchaseOrderAsync
*
* Allows you to update a specified purchase order
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updatePurchaseOrderAsync($xero_tenant_id, $purchase_order_id, $purchase_orders)
{
return $this->updatePurchaseOrderAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id, $purchase_orders)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updatePurchaseOrderAsyncWithHttpInfo
*
* Allows you to update a specified purchase order
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updatePurchaseOrderAsyncWithHttpInfo($xero_tenant_id, $purchase_order_id, $purchase_orders)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders';
$request = $this->updatePurchaseOrderRequest($xero_tenant_id, $purchase_order_id, $purchase_orders);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updatePurchaseOrder'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $purchase_order_id Unique identifier for a PurchaseOrder (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\PurchaseOrders $purchase_orders (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updatePurchaseOrderRequest($xero_tenant_id, $purchase_order_id, $purchase_orders)
{
// 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 updatePurchaseOrder'
);
}
// verify the required parameter 'purchase_order_id' is set
if ($purchase_order_id === null || (is_array($purchase_order_id) && count($purchase_order_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $purchase_order_id when calling updatePurchaseOrder'
);
}
// verify the required parameter 'purchase_orders' is set
if ($purchase_orders === null || (is_array($purchase_orders) && count($purchase_orders) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $purchase_orders when calling updatePurchaseOrder'
);
}
$resourcePath = '/PurchaseOrders/{PurchaseOrderID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($purchase_order_id !== null) {
$resourcePath = str_replace(
'{' . 'PurchaseOrderID' . '}',
AccountingObjectSerializer::toPathValue($purchase_order_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($purchase_orders)) {
$_tempBody = $purchase_orders;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateReceipt
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts receipts (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Receipts|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateReceipt($xero_tenant_id, $receipt_id, $receipts)
{
list($response) = $this->updateReceiptWithHttpInfo($xero_tenant_id, $receipt_id, $receipts);
return $response;
}
/**
* Operation updateReceiptWithHttpInfo
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Receipts|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateReceiptWithHttpInfo($xero_tenant_id, $receipt_id, $receipts)
{
$request = $this->updateReceiptRequest($xero_tenant_id, $receipt_id, $receipts);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Receipts' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Receipts', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Receipts',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateReceiptAsync
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateReceiptAsync($xero_tenant_id, $receipt_id, $receipts)
{
return $this->updateReceiptAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $receipts)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateReceiptAsyncWithHttpInfo
*
* Allows you to retrieve a specified draft expense claim receipts
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateReceiptAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $receipts)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Receipts';
$request = $this->updateReceiptRequest($xero_tenant_id, $receipt_id, $receipts);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateReceipt'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\Receipts $receipts (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateReceiptRequest($xero_tenant_id, $receipt_id, $receipts)
{
// 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 updateReceipt'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling updateReceipt'
);
}
// verify the required parameter 'receipts' is set
if ($receipts === null || (is_array($receipts) && count($receipts) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipts when calling updateReceipt'
);
}
$resourcePath = '/Receipts/{ReceiptID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($receipts)) {
$_tempBody = $receipts;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateReceiptAttachmentByFileName
*
* Allows you to update Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateReceiptAttachmentByFileName($xero_tenant_id, $receipt_id, $file_name, $body)
{
list($response) = $this->updateReceiptAttachmentByFileNameWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body);
return $response;
}
/**
* Operation updateReceiptAttachmentByFileNameWithHttpInfo
*
* Allows you to update Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateReceiptAttachmentByFileNameWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body)
{
$request = $this->updateReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateReceiptAttachmentByFileNameAsync
*
* Allows you to update Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateReceiptAttachmentByFileNameAsync($xero_tenant_id, $receipt_id, $file_name, $body)
{
return $this->updateReceiptAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateReceiptAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to update Attachment on expense claim receipts by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateReceiptAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $receipt_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateReceiptAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $receipt_id Unique identifier for a Receipt (required)
* @param string $file_name The name of the file being attached to the Receipt (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateReceiptAttachmentByFileNameRequest($xero_tenant_id, $receipt_id, $file_name, $body)
{
// 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 updateReceiptAttachmentByFileName'
);
}
// verify the required parameter 'receipt_id' is set
if ($receipt_id === null || (is_array($receipt_id) && count($receipt_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $receipt_id when calling updateReceiptAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateReceiptAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateReceiptAttachmentByFileName'
);
}
$resourcePath = '/Receipts/{ReceiptID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($receipt_id !== null) {
$resourcePath = str_replace(
'{' . 'ReceiptID' . '}',
AccountingObjectSerializer::toPathValue($receipt_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateRepeatingInvoiceAttachmentByFileName
*
* Allows you to update specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateRepeatingInvoiceAttachmentByFileName($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
list($response) = $this->updateRepeatingInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body);
return $response;
}
/**
* Operation updateRepeatingInvoiceAttachmentByFileNameWithHttpInfo
*
* Allows you to update specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\Attachments|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateRepeatingInvoiceAttachmentByFileNameWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
$request = $this->updateRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $body);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\Attachments' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Attachments', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Attachments',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateRepeatingInvoiceAttachmentByFileNameAsync
*
* Allows you to update specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateRepeatingInvoiceAttachmentByFileNameAsync($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
return $this->updateRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo
*
* Allows you to update specified attachment on repeating invoices by file name
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateRepeatingInvoiceAttachmentByFileNameAsyncWithHttpInfo($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\Attachments';
$request = $this->updateRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $body);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateRepeatingInvoiceAttachmentByFileName'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $repeating_invoice_id Unique identifier for a Repeating Invoice (required)
* @param string $file_name The name of the file being attached to a Repeating Invoice (required)
* @param string $body Byte array of file in body of request (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateRepeatingInvoiceAttachmentByFileNameRequest($xero_tenant_id, $repeating_invoice_id, $file_name, $body)
{
// 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 updateRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'repeating_invoice_id' is set
if ($repeating_invoice_id === null || (is_array($repeating_invoice_id) && count($repeating_invoice_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $repeating_invoice_id when calling updateRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'file_name' is set
if ($file_name === null || (is_array($file_name) && count($file_name) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_name when calling updateRepeatingInvoiceAttachmentByFileName'
);
}
// verify the required parameter 'body' is set
if ($body === null || (is_array($body) && count($body) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling updateRepeatingInvoiceAttachmentByFileName'
);
}
$resourcePath = '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{FileName}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($repeating_invoice_id !== null) {
$resourcePath = str_replace(
'{' . 'RepeatingInvoiceID' . '}',
AccountingObjectSerializer::toPathValue($repeating_invoice_id),
$resourcePath
);
}
// path params
if ($file_name !== null) {
$resourcePath = str_replace(
'{' . 'FileName' . '}',
AccountingObjectSerializer::toPathValue($file_name),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/octet-stream']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateTaxRate
*
* Allows you to update Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates tax_rates (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TaxRates|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateTaxRate($xero_tenant_id, $tax_rates)
{
list($response) = $this->updateTaxRateWithHttpInfo($xero_tenant_id, $tax_rates);
return $response;
}
/**
* Operation updateTaxRateWithHttpInfo
*
* Allows you to update Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TaxRates|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateTaxRateWithHttpInfo($xero_tenant_id, $tax_rates)
{
$request = $this->updateTaxRateRequest($xero_tenant_id, $tax_rates);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TaxRates' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TaxRates', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TaxRates',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateTaxRateAsync
*
* Allows you to update Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateTaxRateAsync($xero_tenant_id, $tax_rates)
{
return $this->updateTaxRateAsyncWithHttpInfo($xero_tenant_id, $tax_rates)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateTaxRateAsyncWithHttpInfo
*
* Allows you to update Tax Rates
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateTaxRateAsyncWithHttpInfo($xero_tenant_id, $tax_rates)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TaxRates';
$request = $this->updateTaxRateRequest($xero_tenant_id, $tax_rates);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateTaxRate'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TaxRates $tax_rates (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateTaxRateRequest($xero_tenant_id, $tax_rates)
{
// 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 updateTaxRate'
);
}
// verify the required parameter 'tax_rates' is set
if ($tax_rates === null || (is_array($tax_rates) && count($tax_rates) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tax_rates when calling updateTaxRate'
);
}
$resourcePath = '/TaxRates';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// body params
$_tempBody = null;
if (isset($tax_rates)) {
$_tempBody = $tax_rates;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateTrackingCategory
*
* Allows you to update tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category tracking_category (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateTrackingCategory($xero_tenant_id, $tracking_category_id, $tracking_category)
{
list($response) = $this->updateTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_category);
return $response;
}
/**
* Operation updateTrackingCategoryWithHttpInfo
*
* Allows you to update tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingCategories|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateTrackingCategoryWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_category)
{
$request = $this->updateTrackingCategoryRequest($xero_tenant_id, $tracking_category_id, $tracking_category);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateTrackingCategoryAsync
*
* Allows you to update tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateTrackingCategoryAsync($xero_tenant_id, $tracking_category_id, $tracking_category)
{
return $this->updateTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_category)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateTrackingCategoryAsyncWithHttpInfo
*
* Allows you to update tracking categories
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateTrackingCategoryAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_category)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingCategories';
$request = $this->updateTrackingCategoryRequest($xero_tenant_id, $tracking_category_id, $tracking_category);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateTrackingCategory'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingCategory $tracking_category (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateTrackingCategoryRequest($xero_tenant_id, $tracking_category_id, $tracking_category)
{
// 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 updateTrackingCategory'
);
}
// verify the required parameter 'tracking_category_id' is set
if ($tracking_category_id === null || (is_array($tracking_category_id) && count($tracking_category_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category_id when calling updateTrackingCategory'
);
}
// verify the required parameter 'tracking_category' is set
if ($tracking_category === null || (is_array($tracking_category) && count($tracking_category) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category when calling updateTrackingCategory'
);
}
$resourcePath = '/TrackingCategories/{TrackingCategoryID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($tracking_category_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingCategoryID' . '}',
AccountingObjectSerializer::toPathValue($tracking_category_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($tracking_category)) {
$_tempBody = $tracking_category;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation updateTrackingOptions
*
* Allows you to update options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option tracking_option (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \XeroAPI\XeroPHP\Models\Accounting\TrackingOptions|\XeroAPI\XeroPHP\Models\Accounting\Error
*/
public function updateTrackingOptions($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option)
{
list($response) = $this->updateTrackingOptionsWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option);
return $response;
}
/**
* Operation updateTrackingOptionsWithHttpInfo
*
* Allows you to update options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \XeroAPI\XeroPHP\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \XeroAPI\XeroPHP\Models\Accounting\TrackingOptions|\XeroAPI\XeroPHP\Models\Accounting\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function updateTrackingOptionsWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option)
{
$request = $this->updateTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
switch($statusCode) {
case 200:
if ('\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\XeroAPI\XeroPHP\Models\Accounting\Error' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Accounting\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = AccountingObjectSerializer::deserialize(
$e->getResponseBody(),
'\XeroAPI\XeroPHP\Models\Accounting\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation updateTrackingOptionsAsync
*
* Allows you to update options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateTrackingOptionsAsync($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option)
{
return $this->updateTrackingOptionsAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation updateTrackingOptionsAsyncWithHttpInfo
*
* Allows you to update options for a specified tracking category
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function updateTrackingOptionsAsyncWithHttpInfo($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option)
{
$returnType = '\XeroAPI\XeroPHP\Models\Accounting\TrackingOptions';
$request = $this->updateTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
}
return [
AccountingObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
}
/**
* Create request for operation 'updateTrackingOptions'
*
* @param string $xero_tenant_id Xero identifier for Tenant (required)
* @param string $tracking_category_id Unique identifier for a TrackingCategory (required)
* @param string $tracking_option_id Unique identifier for a Tracking Option (required)
* @param \XeroAPI\XeroPHP\Models\Accounting\TrackingOption $tracking_option (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function updateTrackingOptionsRequest($xero_tenant_id, $tracking_category_id, $tracking_option_id, $tracking_option)
{
// 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 updateTrackingOptions'
);
}
// verify the required parameter 'tracking_category_id' is set
if ($tracking_category_id === null || (is_array($tracking_category_id) && count($tracking_category_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_category_id when calling updateTrackingOptions'
);
}
// verify the required parameter 'tracking_option_id' is set
if ($tracking_option_id === null || (is_array($tracking_option_id) && count($tracking_option_id) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_option_id when calling updateTrackingOptions'
);
}
// verify the required parameter 'tracking_option' is set
if ($tracking_option === null || (is_array($tracking_option) && count($tracking_option) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $tracking_option when calling updateTrackingOptions'
);
}
$resourcePath = '/TrackingCategories/{TrackingCategoryID}/Options/{TrackingOptionID}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($xero_tenant_id !== null) {
$headerParams['Xero-Tenant-Id'] = AccountingObjectSerializer::toHeaderValue($xero_tenant_id);
}
// path params
if ($tracking_category_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingCategoryID' . '}',
AccountingObjectSerializer::toPathValue($tracking_category_id),
$resourcePath
);
}
// path params
if ($tracking_option_id !== null) {
$resourcePath = str_replace(
'{' . 'TrackingOptionID' . '}',
AccountingObjectSerializer::toPathValue($tracking_option_id),
$resourcePath
);
}
// body params
$_tempBody = null;
if (isset($tracking_option)) {
$_tempBody = $tracking_option;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(AccountingObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption()
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
if (!$options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
}
}
return $options;
}
}