README

Developer-friendly & type-safe Php SDK specifically catered to leverage apideck-libraries/sdk-php API.

Summary

Apideck: The Apideck OpenAPI Spec: SDK Optimized

For more information about the API: Apideck Developer Docs

Table of Contents

SDK Installation

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"

SDK Example Usage

Example

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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
    }
}

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

To authenticate with the API the apiKey parameter must be set when initializing the SDK. For example:

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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
}

Available Resources and Operations

Available methods

accounting

accounting->agedDebtors

  • get - Get Aged Debtors

accounting->attachments

accounting->balanceSheet

  • get - Get BalanceSheet

accounting->billPayments

  • create - Create Bill Payment
  • list - List Bill Payments
  • delete - Delete Bill Payment
  • get - Get Bill Payment
  • update - Update Bill Payment

accounting->bills

accounting->companyInfo

  • get - Get company info

accounting->creditNotes

  • create - Create Credit Note
  • list - List Credit Notes
  • delete - Delete Credit Note
  • get - Get Credit Note
  • update - Update Credit Note

accounting->customers

accounting->departments

  • create - Create Department
  • list - List Departments
  • delete - Delete Department
  • get - Get Department
  • update - Update Department

accounting->expenses

accounting->invoiceItems

  • create - Create Invoice Item
  • list - List Invoice Items
  • delete - Delete Invoice Item
  • get - Get Invoice Item
  • update - Update Invoice Item

accounting->invoices

accounting->journalEntries

  • create - Create Journal Entry
  • list - List Journal Entries
  • delete - Delete Journal Entry
  • get - Get Journal Entry
  • update - Update Journal Entry

accounting->ledgerAccounts

  • create - Create Ledger Account
  • list - List Ledger Accounts
  • delete - Delete Ledger Account
  • get - Get Ledger Account
  • update - Update Ledger Account

accounting->locations

accounting->payments

accounting->profitAndLoss

  • get - Get Profit and Loss

accounting->purchaseOrders

  • create - Create Purchase Order
  • list - List Purchase Orders
  • delete - Delete Purchase Order
  • get - Get Purchase Order
  • update - Update Purchase Order

accounting->subsidiaries

  • create - Create Subsidiary
  • list - List Subsidiaries
  • delete - Delete Subsidiary
  • get - Get Subsidiary
  • update - Update Subsidiary

accounting->suppliers

accounting->taxRates

accounting->trackingCategories

  • create - Create Tracking Category
  • list - List Tracking Categories
  • delete - Delete Tracking Category
  • get - Get Tracking Category
  • update - Update Tracking Category

ats

ats->applicants

ats->applications

  • create - Create Application
  • list - List Applications
  • delete - Delete Application
  • get - Get Application
  • update - Update Application

ats->jobs

connector

connector->apiResourceCoverage

  • get - Get API Resource Coverage

connector->apiResources

  • get - Get API Resource

connector->apis

connector->connectorDocs

  • get - Get Connector Doc content

connector->connectorResources

  • get - Get Connector Resource

connector->connectors

  • list - List Connectors
  • get - Get Connector

crm

crm->activities

crm->companies

crm->contacts

crm->leads

crm->notes

crm->opportunities

  • create - Create opportunity
  • list - List opportunities
  • delete - Delete opportunity
  • get - Get opportunity
  • update - Update opportunity

crm->pipelines

  • list - List pipelines

crm->users

ecommerce

ecommerce->customers

  • list - List Customers
  • get - Get Customer

ecommerce->orders

  • list - List Orders
  • get - Get Order

ecommerce->products

  • list - List Products
  • get - Get Product

ecommerce->stores

  • get - Get Store

fileStorage

fileStorage->driveGroups

  • create - Create DriveGroup
  • list - List DriveGroups
  • delete - Delete DriveGroup
  • get - Get DriveGroup
  • update - Update DriveGroup

fileStorage->drives

fileStorage->files

fileStorage->folders

fileStorage->sharedLinks

  • create - Create Shared Link
  • list - List SharedLinks
  • delete - Delete Shared Link
  • get - Get Shared Link
  • update - Update Shared Link

fileStorage->uploadSessions

  • create - Start Upload Session
  • delete - Abort Upload Session
  • finish - Finish Upload Session
  • get - Get Upload Session

hris

hris->companies

hris->departments

  • create - Create Department
  • list - List Departments
  • delete - Delete Department
  • get - Get Department
  • update - Update Department

hris->employeePayrolls

  • list - List Employee Payrolls
  • get - Get Employee Payroll

hris->employees

hris->employeeSchedules

  • list - List Employee Schedules

hris->payrolls

  • list - List Payroll
  • get - Get Payroll

hris->timeOffRequests

  • 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

issueTracking

issueTracking->collections

  • list - List Collections
  • get - Get Collection

issueTracking->collectionTags

issueTracking->collectionTicketComments

issueTracking->collectionTickets

issueTracking->collectionUsers

sms

sms->messages

vault

vault->connectionCustomMappings

  • list - List connection custom mappings

vault->connections

  • list - Get all connections
  • delete - Deletes a connection
  • imports - Import connection
  • get - Get connection
  • token - Authorize Access Token
  • update - Update connection

vault->connectionSettings

  • list - Get resource settings
  • update - Update settings

vault->consumerRequestCounts

  • list - Consumer request counts

vault->consumers

vault->createCallback

  • state - Create Callback State

vault->customFields

  • list - Get resource custom fields

vault->customMappings

  • list - List custom mappings

vault->logs

  • list - Get all consumer request logs

vault->sessions

vault->validateConnection

  • state - Validate Connection State

webhook

webhook->webhooks

  • create - Create webhook subscription
  • list - List webhook subscriptions
  • delete - Delete webhook subscription
  • get - Get webhook subscription
  • update - Update webhook subscription

Pagination

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;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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
    }
}

Retries

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;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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;

$sdk = Unify\Apideck::builder()
    ->setRetryConfig(
        new Retry\RetryConfigBackoff(
            initialInterval: 1,
            maxInterval:     50,
            exponent:        1.1,
            maxElapsedTime:  100,
            retryConnectionErrors: false,
        )
  )
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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
}

Error Handling

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:

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:

Example

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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;
}

Server Selection

Override Server URL Per-Client

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;

$sdk = Unify\Apideck::builder()
    ->setServerURL('https://unify.apideck.com')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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
}

Override Server URL Per-Operation

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;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->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
}

Development

Maturity

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.

Contributions

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.