stackone/client-sdk


README

Summary

Marketing: The documentation for the StackOne Unified API - MARKETING

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 "stackone/client-sdk"

SDK Example Usage

List Employees

declare(strict_types=1);

require 'vendor/autoload.php';

use StackOne\client;
use StackOne\client\Models\Components;
use StackOne\client\Models\Operations;

$security = new Components\Security(
    username: '',
    password: '',
);

$sdk = client\StackOne::builder()->setSecurity($security)->build();

$request = new Operations\HrisListEmployeesRequest(
    xAccountId: '<id>',
    fields: 'id,remote_id,first_name,last_name,name,display_name,gender,ethnicity,date_of_birth,birthday,marital_status,avatar_url,avatar,personal_email,personal_phone_number,work_email,work_phone_number,job_id,remote_job_id,job_title,job_description,department_id,remote_department_id,department,cost_centers,benefits,manager_id,remote_manager_id,hire_date,start_date,tenure,work_anniversary,employment_type,employment_contract_type,employment_status,termination_date,company_name,preferred_language,citizenships,home_location,work_location,employments,custom_fields,documents,created_at,updated_at,employee_number,national_identity_number',
    filter: new Operations\QueryParamFilter(
        updatedAfter: '2020-01-01T00:00:00.000Z',
    ),
    expand: 'company,employments,work_location,home_location,custom_fields,groups',
    include: 'avatar_url,avatar,custom_fields,job_description,benefits',
);

$response = $sdk->hris->listEmployees(
    request: $request
);

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

Available Resources and Operations

Available methods

accounts

ats

connectors

connectSessions

crm

hris

iam

lms

marketing

proxy

webhooks

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\SDKException 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 createConnectSession method throws the following exceptions:

Example

declare(strict_types=1);

require 'vendor/autoload.php';

use StackOne\client;
use StackOne\client\Models\Components;

$security = new Components\Security(
    username: '',
    password: '',
);

$sdk = client\StackOne::builder()->setSecurity($security)->build();

try {
    $request = new Components\ConnectSessionCreate(
        originOwnerId: '<id>',
        originOwnerName: '<value>',
        categories: [
            Components\Categories::Ats,
            Components\Categories::Hris,
            Components\Categories::Crm,
            Components\Categories::Crm,
            Components\Categories::Iam,
            Components\Categories::Marketing,
            Components\Categories::Lms,
            Components\Categories::Ats,
            Components\Categories::Lms,
        ],
    );

    $response = $sdk->connectSessions->createConnectSession(
        request: $request
    );

    if ($response->connectSessionToken !== null) {
        // handle response
    }
} catch (Errors\SDKException $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 StackOne\client;
use StackOne\client\Models\Components;

$security = new Components\Security(
    username: '',
    password: '',
);

$sdk = client\StackOne::builder()
    ->setServerURL("https://api.stackone.com")
    ->setSecurity($security)->build();

$request = new Components\ConnectSessionCreate(
    originOwnerId: '<id>',
    originOwnerName: '<value>',
    categories: [
        Components\Categories::Ats,
        Components\Categories::Hris,
        Components\Categories::Crm,
        Components\Categories::Crm,
        Components\Categories::Iam,
        Components\Categories::Marketing,
        Components\Categories::Lms,
        Components\Categories::Ats,
        Components\Categories::Lms,
    ],
);

$response = $sdk->connectSessions->createConnectSession(
    request: $request
);

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