v0.1.0 2024-12-13 10:43 UTC

README

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.

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;

$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',
);

$response = $sdk->accounting->taxRates->list(
    request: $request
);

if ($response->getTaxRatesResponse !== null) {
    // handle response
}

Available Resources and Operations

Available methods

accounting

accounting->agedCreditors

  • get - Get Aged Creditors

accounting->agedDebtors

  • get - Get Aged Debtors

accounting->attachments

accounting->balanceSheet

  • get - Get BalanceSheet

accounting->billPayments

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

accounting->bills

accounting->companyInfo

  • get - Get company info

accounting->creditNotes

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

accounting->customers

accounting->departments

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

accounting->expenses

accounting->invoiceItems

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

accounting->invoices

accounting->journalEntries

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

accounting->ledgerAccounts

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

accounting->locations

accounting->payments

accounting->profitAndLoss

  • get - Get Profit and Loss

accounting->purchaseOrders

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

accounting->subsidiaries

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

accounting->suppliers

accounting->taxRates

accounting->trackingCategories

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

ats

ats->applicants

ats->applications

  • list - List Applications
  • create - Create Application
  • get - Get Application
  • update - Update Application
  • delete - Delete 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

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

crm->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

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

fileStorage->drives

fileStorage->files

fileStorage->folders

fileStorage->sharedLinks

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

fileStorage->uploadSessions

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

hris

hris->companies

hris->departments

  • list - List Departments
  • create - Create Department
  • get - Get Department
  • update - Update Department
  • delete - Delete 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

  • list - List Time Off Requests
  • create - Create Time Off Request
  • get - Get Time Off Request
  • update - Update Time Off Request
  • delete - Delete 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
  • get - Get connection
  • update - Update connection
  • delete - Deletes a connection
  • imports - Import connection
  • token - Authorize Access Token

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

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

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 list 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;

$security = '<YOUR_BEARER_TOKEN_HERE>';

$sdk = Unify\Apideck::builder()
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->setSecurity($security)->build();

try {
    $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',
    );

    $response = $sdk->accounting->taxRates->list(
        request: $request
    );

    if ($response->getTaxRatesResponse !== 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;

$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\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',
);

$response = $sdk->accounting->taxRates->list(
    request: $request
);

if ($response->getTaxRatesResponse !== 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;

$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
}

Development

Maturity

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.

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.

SDK Created by Speakeasy