apideck-libraries / sdk-php
Requires
- php: ^8.2
- brick/date-time: ^0.7.0
- brick/math: ^0.12.1
- galbar/jsonpath: ^3.0
- guzzlehttp/guzzle: ^7.0
- phpdocumentor/type-resolver: ^1.8
- speakeasy/serializer: ^4.0.0
Requires (Dev)
- laravel/pint: ^1.18.1
- phpstan/phpstan: ^2.1.0
- phpunit/phpunit: ^10
- roave/security-advisories: dev-latest
- dev-main
- v0.4.1
- v0.4.0
- v0.3.1
- v0.3.0
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-speakeasy-sdk-regen-1738747410
- dev-speakeasy-sdk-regen-1738713743
- dev-speakeasy-sdk-regen-1738166096
- dev-speakeasy-sdk-regen-1737545338
- dev-speakeasy-sdk-regen-1737468411
- dev-speakeasy-sdk-regen-1737461366
- dev-speakeasy-sdk-regen-1737099264
- dev-samz/migration-guide
- dev-speakeasy-sdk-regen-1736865339
- dev-speakeasy-sdk-regen-1735817300
- dev-speakeasy-sdk-regen-1735312387
- dev-speakeasy-sdk-regen-1735295055
- dev-samz/add-http-envelop
- dev-speakeasy-sdk-regen-1735225949
- dev-speakeasy-sdk-regen-1734368306
- dev-samz/use-latest-generator
- dev-speakeasy-sdk-regen-1733946806
- dev-speakeasy-sdk-regen-1733922060
- dev-speakeasy-sdk-regen-1733502108
- dev-speakeasy-sdk-regen-1733270547
This package is auto-updated.
Last update: 2025-02-05 09:37:53 UTC
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
- list - List Attachments
- delete - Delete Attachment
- download - Download Attachment
- get - Get Attachment
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
- create - Create Customer
- list - List Customers
- delete - Delete Customer
- get - Get Customer
- update - Update Customer
accounting->departments
- create - Create Department
- list - List Departments
- delete - Delete Department
- get - Get Department
- update - Update Department
accounting->expenses
- create - Create Expense
- list - List Expenses
- delete - Delete Expense
- get - Get Expense
- update - Update Expense
accounting->invoiceItems
- create - Create Invoice Item
- list - List Invoice Items
- delete - Delete Invoice Item
- get - Get Invoice Item
- update - Update Invoice Item
accounting->invoices
- create - Create Invoice
- list - List Invoices
- delete - Delete Invoice
- get - Get Invoice
- update - Update Invoice
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
- create - Create Location
- list - List Locations
- delete - Delete Location
- get - Get Location
- update - Update Location
accounting->payments
- create - Create Payment
- list - List Payments
- delete - Delete Payment
- get - Get Payment
- update - Update Payment
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
- create - Create Supplier
- list - List Suppliers
- delete - Delete Supplier
- get - Get Supplier
- update - Update Supplier
accounting->taxRates
- create - Create Tax Rate
- list - List Tax Rates
- delete - Delete Tax Rate
- get - Get Tax Rate
- update - Update Tax Rate
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
- create - Create Applicant
- list - List Applicants
- delete - Delete Applicant
- get - Get Applicant
- update - Update Applicant
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
crm
crm->activities
- create - Create activity
- list - List activities
- delete - Delete activity
- get - Get activity
- update - Update activity
crm->companies
- create - Create company
- list - List companies
- delete - Delete company
- get - Get company
- update - Update company
crm->contacts
- create - Create contact
- list - List contacts
- delete - Delete contact
- get - Get contact
- update - Update contact
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
ecommerce->orders
ecommerce->products
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
- create - Create Drive
- list - List Drives
- delete - Delete Drive
- get - Get Drive
- update - Update Drive
fileStorage->files
- list - List Files
- delete - Delete File
- download - Download File
- export - Export File
- get - Get File
- search - Search Files
- update - Rename or move File
fileStorage->folders
- create - Create Folder
- copy - Copy Folder
- delete - Delete Folder
- get - Get Folder
- update - Rename or move Folder
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
- create - Create Company
- list - List Companies
- delete - Delete Company
- get - Get Company
- update - Update Company
hris->departments
- create - Create Department
- list - List Departments
- delete - Delete Department
- get - Get Department
- update - Update Department
hris->employeePayrolls
hris->employees
- create - Create Employee
- list - List Employees
- delete - Delete Employee
- get - Get Employee
- update - Update Employee
hris->employeeSchedules
- list - List Employee Schedules
hris->payrolls
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
issueTracking->collectionTags
- list - List Tags
issueTracking->collectionTicketComments
- create - Create Comment
- list - List Comments
- delete - Delete Comment
- get - Get Comment
- update - Update Comment
issueTracking->collectionTickets
- create - Create Ticket
- list - List Tickets
- delete - Delete Ticket
- get - Get Ticket
- update - Update Ticket
issueTracking->collectionUsers
sms
sms->messages
- create - Create Message
- list - List Messages
- delete - Delete Message
- get - Get Message
- update - Update Message
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
vault->consumerRequestCounts
- list - Consumer request counts
vault->consumers
- create - Create consumer
- list - Get all consumers
- delete - Delete consumer
- get - Get consumer
- update - Update consumer
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
- create - Create Session
vault->validateConnection
- state - Validate Connection State
webhook
webhook->webhooks
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.