Developer-friendly & type-safe Php SDK specifically catered to leverage apideck-libraries/sdk-php API.
Important
This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Apideck: The Apideck OpenAPI Spec: SDK Optimized
For more information about the API: Apideck Developer Docs
The SDK relies on Composer to manage its dependencies.
To install the SDK and add it as a dependency to an existing composer.json
file:
composer require "apideck-libraries/sdk-php"
declare(strict_types=1);
require 'vendor/autoload.php';
use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Unify\Apideck::builder()
->setConsumerId('test-consumer')
->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
->setSecurity($security)->build();
$request = new Operations\AccountingTaxRatesAllRequest(
serviceId: 'salesforce',
filter: new Components\TaxRatesFilter(
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
),
passThrough: [
'search' => 'San Francisco',
],
fields: 'id,updated_at',
);
$responses = $sdk->accounting->taxRates->list(
request: $request
);
foreach ($responses as $response) {
if ($response->httpMeta->response->getStatusCode() === 200) {
// handle response
}
}
Available methods
- get - Get Aged Debtors
- list - List Attachments
- delete - Delete Attachment
- download - Download Attachment
- get - Get Attachment
- get - Get BalanceSheet
- create - Create Bill Payment
- list - List Bill Payments
- delete - Delete Bill Payment
- get - Get Bill Payment
- update - Update Bill Payment
- get - Get company info
- create - Create Credit Note
- list - List Credit Notes
- delete - Delete Credit Note
- get - Get Credit Note
- update - Update Credit Note
- create - Create Customer
- list - List Customers
- delete - Delete Customer
- get - Get Customer
- update - Update Customer
- create - Create Department
- list - List Departments
- delete - Delete Department
- get - Get Department
- update - Update Department
- create - Create Expense
- list - List Expenses
- delete - Delete Expense
- get - Get Expense
- update - Update Expense
- create - Create Invoice Item
- list - List Invoice Items
- delete - Delete Invoice Item
- get - Get Invoice Item
- update - Update Invoice Item
- create - Create Invoice
- list - List Invoices
- delete - Delete Invoice
- get - Get Invoice
- update - Update Invoice
- create - Create Journal Entry
- list - List Journal Entries
- delete - Delete Journal Entry
- get - Get Journal Entry
- update - Update Journal Entry
- create - Create Ledger Account
- list - List Ledger Accounts
- delete - Delete Ledger Account
- get - Get Ledger Account
- update - Update Ledger Account
- create - Create Location
- list - List Locations
- delete - Delete Location
- get - Get Location
- update - Update Location
- create - Create Payment
- list - List Payments
- delete - Delete Payment
- get - Get Payment
- update - Update Payment
- get - Get Profit and Loss
- create - Create Purchase Order
- list - List Purchase Orders
- delete - Delete Purchase Order
- get - Get Purchase Order
- update - Update Purchase Order
- create - Create Subsidiary
- list - List Subsidiaries
- delete - Delete Subsidiary
- get - Get Subsidiary
- update - Update Subsidiary
- create - Create Supplier
- list - List Suppliers
- delete - Delete Supplier
- get - Get Supplier
- update - Update Supplier
- create - Create Tax Rate
- list - List Tax Rates
- delete - Delete Tax Rate
- get - Get Tax Rate
- update - Update Tax Rate
- create - Create Tracking Category
- list - List Tracking Categories
- delete - Delete Tracking Category
- get - Get Tracking Category
- update - Update Tracking Category
- create - Create Applicant
- list - List Applicants
- delete - Delete Applicant
- get - Get Applicant
- update - Update Applicant
- create - Create Application
- list - List Applications
- delete - Delete Application
- get - Get Application
- update - Update Application
- get - Get API Resource Coverage
- get - Get API Resource
- get - Get Connector Doc content
- get - Get Connector Resource
- create - Create activity
- list - List activities
- delete - Delete activity
- get - Get activity
- update - Update activity
- create - Create company
- list - List companies
- delete - Delete company
- get - Get company
- update - Update company
- create - Create contact
- list - List contacts
- delete - Delete contact
- get - Get contact
- update - Update contact
- create - Create opportunity
- list - List opportunities
- delete - Delete opportunity
- get - Get opportunity
- update - Update opportunity
- list - List pipelines
- get - Get Store
- create - Create DriveGroup
- list - List DriveGroups
- delete - Delete DriveGroup
- get - Get DriveGroup
- update - Update DriveGroup
- create - Create Drive
- list - List Drives
- delete - Delete Drive
- get - Get Drive
- update - Update Drive
- list - List Files
- delete - Delete File
- download - Download File
- export - Export File
- get - Get File
- search - Search Files
- update - Rename or move File
- create - Create Folder
- copy - Copy Folder
- delete - Delete Folder
- get - Get Folder
- update - Rename or move Folder
- create - Create Shared Link
- list - List SharedLinks
- delete - Delete Shared Link
- get - Get Shared Link
- update - Update Shared Link
- create - Start Upload Session
- delete - Abort Upload Session
- finish - Finish Upload Session
- get - Get Upload Session
- create - Create Company
- list - List Companies
- delete - Delete Company
- get - Get Company
- update - Update Company
- create - Create Department
- list - List Departments
- delete - Delete Department
- get - Get Department
- update - Update Department
- create - Create Employee
- list - List Employees
- delete - Delete Employee
- get - Get Employee
- update - Update Employee
- list - List Employee Schedules
- create - Create Time Off Request
- list - List Time Off Requests
- delete - Delete Time Off Request
- get - Get Time Off Request
- update - Update Time Off Request
- list - List Tags
- create - Create Comment
- list - List Comments
- delete - Delete Comment
- get - Get Comment
- update - Update Comment
- create - Create Ticket
- list - List Tickets
- delete - Delete Ticket
- get - Get Ticket
- update - Update Ticket
- create - Create Message
- list - List Messages
- delete - Delete Message
- get - Get Message
- update - Update Message
- list - List connection custom mappings
- list - Get all connections
- delete - Deletes a connection
- imports - Import connection
- get - Get connection
- token - Authorize Access Token
- update - Update connection
- list - Consumer request counts
- create - Create consumer
- list - Get all consumers
- delete - Delete consumer
- get - Get consumer
- update - Update consumer
- state - Create Callback State
- list - Get resource custom fields
- list - List custom mappings
- list - Get all consumer request logs
- create - Create Session
- state - Validate Connection State
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned object will be a Generator
instead of an individual response.
Working with generators is as simple as iterating over the responses in a foreach
loop, and you can see an example below:
declare(strict_types=1);
require 'vendor/autoload.php';
use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Unify\Apideck::builder()
->setConsumerId('test-consumer')
->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
->setSecurity($security)->build();
$request = new Operations\AccountingTaxRatesAllRequest(
serviceId: 'salesforce',
filter: new Components\TaxRatesFilter(
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
),
passThrough: [
'search' => 'San Francisco',
],
fields: 'id,updated_at',
);
$responses = $sdk->accounting->taxRates->list(
request: $request
);
foreach ($responses as $response) {
if ($response->httpMeta->response->getStatusCode() === 200) {
// handle response
}
}
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide an Options
object built with a RetryConfig
object to the call:
declare(strict_types=1);
require 'vendor/autoload.php';
use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
use Apideck\Unify\Utils\Retry;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Unify\Apideck::builder()
->setConsumerId('test-consumer')
->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
->setSecurity($security)->build();
$request = new Operations\AccountingTaxRatesAddRequest(
taxRate: new Components\TaxRateInput(
name: 'GST on Purchases',
passThrough: [
new Components\PassThroughBody(
serviceId: '<id>',
extendPaths: [
new Components\ExtendPaths(
path: '$.nested.property',
value: [
'TaxClassificationRef' => [
'value' => 'EUC-99990201-V1-00020000',
],
],
),
],
),
],
customFields: [
new Components\CustomField(
id: '2389328923893298',
name: 'employee_level',
description: 'Employee Level',
value: true,
),
],
id: '1234',
code: 'ABN',
description: 'Reduced rate GST Purchases',
effectiveTaxRate: 10,
totalTaxRate: 10,
taxPayableAccountId: '123456',
taxRemittedAccountId: '123456',
components: [
new Components\Components(
name: 'GST',
id: '10',
rate: 10,
compound: true,
),
],
type: 'NONE',
reportTaxType: 'NONE',
originalTaxRateId: '12345',
status: Components\TaxRateStatus::Active,
rowVersion: '1-12345',
),
serviceId: 'salesforce',
);
$response = $sdk->accounting->taxRates->create(
request: $request,
options: Utils\Options->builder()->setRetryConfig(
new Retry\RetryConfigBackoff(
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
retryConnectionErrors: false,
))->build()
);
if ($response->createTaxRateResponse !== null) {
// handle response
}
If you'd like to override the default retry strategy for all operations that support retries, you can pass a RetryConfig
object to the SDKBuilder->setRetryConfig
function when initializing the SDK:
declare(strict_types=1);
require 'vendor/autoload.php';
use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
use Apideck\Unify\Utils\Retry;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Unify\Apideck::builder()
->setRetryConfig(
new Retry\RetryConfigBackoff(
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
retryConnectionErrors: false,
)
)
->setConsumerId('test-consumer')
->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
->setSecurity($security)->build();
$request = new Operations\AccountingTaxRatesAddRequest(
taxRate: new Components\TaxRateInput(
name: 'GST on Purchases',
passThrough: [
new Components\PassThroughBody(
serviceId: '<id>',
extendPaths: [
new Components\ExtendPaths(
path: '$.nested.property',
value: [
'TaxClassificationRef' => [
'value' => 'EUC-99990201-V1-00020000',
],
],
),
],
),
],
customFields: [
new Components\CustomField(
id: '2389328923893298',
name: 'employee_level',
description: 'Employee Level',
value: true,
),
],
id: '1234',
code: 'ABN',
description: 'Reduced rate GST Purchases',
effectiveTaxRate: 10,
totalTaxRate: 10,
taxPayableAccountId: '123456',
taxRemittedAccountId: '123456',
components: [
new Components\Components(
name: 'GST',
id: '10',
rate: 10,
compound: true,
),
],
type: 'NONE',
reportTaxType: 'NONE',
originalTaxRateId: '12345',
status: Components\TaxRateStatus::Active,
rowVersion: '1-12345',
),
serviceId: 'salesforce',
);
$response = $sdk->accounting->taxRates->create(
request: $request
);
if ($response->createTaxRateResponse !== null) {
// handle response
}
Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.
By default an API error will raise a Errors\APIException
exception, which has the following properties:
Property | Type | Description |
---|---|---|
$message |
string | The error message |
$request |
?\Psr\Http\Message\RequestInterface | The HTTP request |
$response |
*?\Psr\Http\Message\ResponseInterface * | The HTTP response |
When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the create
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
Errors\BadRequestResponse | 400 | application/json |
Errors\UnauthorizedResponse | 401 | application/json |
Errors\PaymentRequiredResponse | 402 | application/json |
Errors\NotFoundResponse | 404 | application/json |
Errors\UnprocessableResponse | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
declare(strict_types=1);
require 'vendor/autoload.php';
use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Unify\Apideck::builder()
->setConsumerId('test-consumer')
->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
->setSecurity($security)->build();
try {
$request = new Operations\AccountingTaxRatesAddRequest(
taxRate: new Components\TaxRateInput(
name: 'GST on Purchases',
passThrough: [
new Components\PassThroughBody(
serviceId: '<id>',
extendPaths: [
new Components\ExtendPaths(
path: '$.nested.property',
value: [
'TaxClassificationRef' => [
'value' => 'EUC-99990201-V1-00020000',
],
],
),
],
),
],
customFields: [
new Components\CustomField(
id: '2389328923893298',
name: 'employee_level',
description: 'Employee Level',
value: true,
),
],
id: '1234',
code: 'ABN',
description: 'Reduced rate GST Purchases',
effectiveTaxRate: 10,
totalTaxRate: 10,
taxPayableAccountId: '123456',
taxRemittedAccountId: '123456',
components: [
new Components\Components(
name: 'GST',
id: '10',
rate: 10,
compound: true,
),
],
type: 'NONE',
reportTaxType: 'NONE',
originalTaxRateId: '12345',
status: Components\TaxRateStatus::Active,
rowVersion: '1-12345',
),
serviceId: 'salesforce',
);
$response = $sdk->accounting->taxRates->create(
request: $request
);
if ($response->createTaxRateResponse !== null) {
// handle response
}
} catch (Errors\BadRequestResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\UnauthorizedResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\PaymentRequiredResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\NotFoundResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\UnprocessableResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\APIException $e) {
// handle default exception
throw $e;
}
The default server can also be overridden globally using the setServerUrl(string $serverUrl)
builder method when initializing the SDK client instance. For example:
declare(strict_types=1);
require 'vendor/autoload.php';
use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Unify\Apideck::builder()
->setServerURL('https://unify.apideck.com')
->setConsumerId('test-consumer')
->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
->setSecurity($security)->build();
$request = new Operations\AccountingTaxRatesAddRequest(
taxRate: new Components\TaxRateInput(
name: 'GST on Purchases',
passThrough: [
new Components\PassThroughBody(
serviceId: '<id>',
extendPaths: [
new Components\ExtendPaths(
path: '$.nested.property',
value: [
'TaxClassificationRef' => [
'value' => 'EUC-99990201-V1-00020000',
],
],
),
],
),
],
customFields: [
new Components\CustomField(
id: '2389328923893298',
name: 'employee_level',
description: 'Employee Level',
value: true,
),
],
id: '1234',
code: 'ABN',
description: 'Reduced rate GST Purchases',
effectiveTaxRate: 10,
totalTaxRate: 10,
taxPayableAccountId: '123456',
taxRemittedAccountId: '123456',
components: [
new Components\Components(
name: 'GST',
id: '10',
rate: 10,
compound: true,
),
],
type: 'NONE',
reportTaxType: 'NONE',
originalTaxRateId: '12345',
status: Components\TaxRateStatus::Active,
rowVersion: '1-12345',
),
serviceId: 'salesforce',
);
$response = $sdk->accounting->taxRates->create(
request: $request
);
if ($response->createTaxRateResponse !== null) {
// handle response
}
The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:
declare(strict_types=1);
require 'vendor/autoload.php';
use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Unify\Apideck::builder()
->setConsumerId('test-consumer')
->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
->setSecurity($security)->build();
$request = new Operations\FileStorageUploadSessionsAddRequest(
createUploadSessionRequest: new Components\CreateUploadSessionRequest(
name: 'Documents',
parentFolderId: '1234',
driveId: '1234',
size: 1810673,
passThrough: [
new Components\PassThroughBody(
serviceId: '<id>',
extendPaths: [
new Components\ExtendPaths(
path: '$.nested.property',
value: [
'TaxClassificationRef' => [
'value' => 'EUC-99990201-V1-00020000',
],
],
),
],
),
],
),
serviceId: 'salesforce',
);
$response = $sdk->fileStorage->uploadSessions->create(
request: $request,
'https://upload.apideck.com'
);
if ($response->createUploadSessionResponse !== null) {
// handle response
}
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.