/
home
/
desid573
/
public_html
/
angel
/
payment
/
xero
/
lib
/
Api
/
/home/desid573/public_html/angel/payment/xero/lib/Api
mkdir
upload
Name
Size
Mode
Actions
AccountingApi.php
2536697
0644
edit
dl
rm
IdentityApi.php
11235
0644
edit
dl
rm
Edit:
/home/desid573/public_html/angel/payment/xero/lib/Api/IdentityApi.php
(11235B)
<?php /** * IdentityApi * PHP version 5 * * @category Class * @package XeroAPI\XeroPHP Identity * @author OpenAPI Generator team * @link https://openapi-generator.tech */ /** * Xero oAuth 2 identity service * * This specifing endpoints related to managing authentication tokens and identity for Xero API * * OpenAPI spec version: 1.0.0 * Contact: api@xero.com * Generated by: https://openapi-generator.tech * OpenAPI Generator version: 4.0.0 */ /** * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ namespace XeroAPI\XeroPHP\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use XeroAPI\XeroPHP\ApiException; use XeroAPI\XeroPHP\Configuration; use XeroAPI\XeroPHP\HeaderSelector; use XeroAPI\XeroPHP\IdentityObjectSerializer; /** * IdentityApi Class Doc Comment * * @category Class * @package XeroAPI\XeroPHP * @author OpenAPI Generator team * @link https://openapi-generator.tech */ class IdentityApi { /** * @var ClientInterface */ protected $client; /** * @var Configuration */ protected $config; /** * @var HeaderSelector */ protected $headerSelector; /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector */ public function __construct( ClientInterface $client = null, Configuration $config = null, HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); } /** * @return Configuration */ public function getConfig() { return $this->config; } /** * Operation getConnections * * Allows you to retrieve the connections for this users * * * @throws \XeroAPI\XeroPHP\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \XeroAPI\XeroPHP\Models\Identity\Connection[] */ public function getConnections() { list($response) = $this->getConnectionsWithHttpInfo(); return $response; } /** * Operation getConnectionsWithHttpInfo * * Allows you to retrieve the connections for this users * * * @throws \XeroAPI\XeroPHP\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \XeroAPI\XeroPHP\Models\Identity\Connection[], HTTP status code, HTTP response headers (array of strings) */ public function getConnectionsWithHttpInfo() { $request = $this->getConnectionsRequest(); 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\Identity\Connection[]' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = $responseBody->getContents(); } return [ IdentityObjectSerializer::deserialize($content, '\XeroAPI\XeroPHP\Models\Identity\Connection[]', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\XeroAPI\XeroPHP\Models\Identity\Connection[]'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = $responseBody->getContents(); } return [ IdentityObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = IdentityObjectSerializer::deserialize( $e->getResponseBody(), '\XeroAPI\XeroPHP\Models\Identity\Connection[]', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getConnectionsAsync * * Allows you to retrieve the connections for this users * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getConnectionsAsync() { return $this->getConnectionsAsyncWithHttpInfo() ->then( function ($response) { return $response[0]; } ); } /** * Operation getConnectionsAsyncWithHttpInfo * * Allows you to retrieve the connections for this users * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getConnectionsAsyncWithHttpInfo() { $returnType = '\XeroAPI\XeroPHP\Models\Identity\Connection[]'; $request = $this->getConnectionsRequest(); 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 [ IdentityObjectSerializer::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 'getConnections' * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ protected function getConnectionsRequest() { $resourcePath = '/connections'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // 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(IdentityObjectSerializer::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', "https://api.xero.com" . $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; } }
Save
cmd:
run