PHP code example of stackone / client-sdk
1. Go to this page and download the library: Download stackone/client-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stackone / client-sdk example snippets
declare(strict_types=1);
StackOne\client\Models\Components;
use StackOne\client\Models\Operations;
use StackOne\client\Utils;
$sdk = client\StackOne::builder()
->setSecurity(
new Components\Security(
username: '',
password: '',
)
)
->build();
$request = new Operations\HrisListEmployeesRequest(
xAccountId: '<id>',
fields: 'id,remote_id,title,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,company,manager_id,remote_manager_id,hire_date,start_date,tenure,work_anniversary,employment_type,employment_contract_type,employment_status,termination_date,company_name,company_id,remote_company_id,preferred_language,citizenships,home_location,work_location,employments,custom_fields,created_at,updated_at,benefits,employee_number,national_identity_number,national_identity_numbers,bank_details,skills,unified_custom_fields',
filter: new Operations\HrisListEmployeesQueryParamFilter(
updatedAfter: Utils\Utils::parseDateTime('2020-01-01T00:00:00.000Z'),
),
expand: 'company,employments,work_location,home_location,groups,skills',
declare(strict_types=1);
StackOne\client\Models\Components;
$sdk = client\StackOne::builder()
->setSecurity(
new Components\Security(
username: '',
password: '',
)
)
->build();
$request = new Components\ConnectSessionCreate(
categories: [
Components\Categories::Ats,
Components\Categories::Hris,
Components\Categories::Ticketing,
Components\Categories::Crm,
Components\Categories::Iam,
Components\Categories::Marketing,
Components\Categories::Lms,
Components\Categories::Iam,
Components\Categories::Documents,
Components\Categories::Ticketing,
Components\Categories::Screening,
Components\Categories::Messaging,
Components\Categories::Accounting,
Components\Categories::Scheduling,
],
originOwnerId: '<id>',
originOwnerName: '<value>',
);
$response = $sdk->connectSessions->createConnectSession(
request: $request
);
if ($response->connectSessionTokenAuthLink !== null) {
// handle response
}
declare(strict_types=1);
StackOne\client\Models\Components;
use StackOne\client\Models\Operations;
$sdk = client\StackOne::builder()->build();
$requestSecurity = new Operations\StackoneMcpGetSecurity(
basic: new Components\SchemeBasic(
username: '',
password: '',
),
);
$response = $sdk->mcp->mcpGet(
security: $requestSecurity,
mcpSessionId: '<id>',
xAccountId: '<id>'
);
if ($response->statusCode === 200) {
// handle response
}
declare(strict_types=1);
StackOne\client\Models\Components;
use StackOne\client\Models\Operations;
$sdk = client\StackOne::builder()
->setSecurity(
new Components\Security(
username: '',
password: '',
)
)
->build();
$request = new Operations\StackoneListActionsMetaRequest(
groupBy: '["connector"]',
filter: new Operations\StackoneListActionsMetaQueryParamFilter(
connectors: 'connector1,connector2',
accountIds: 'account1,account2',
actionKey: 'action1',
),
declare(strict_types=1);
StackOne\client\Models\Components;
use StackOne\client\Utils\Retry;
$sdk = client\StackOne::builder()
->setSecurity(
new Components\Security(
username: '',
password: '',
)
)
->build();
$request = new Components\ConnectSessionCreate(
categories: [
Components\Categories::Ats,
Components\Categories::Hris,
Components\Categories::Ticketing,
Components\Categories::Crm,
Components\Categories::Iam,
Components\Categories::Marketing,
Components\Categories::Lms,
Components\Categories::Iam,
Components\Categories::Documents,
Components\Categories::Ticketing,
Components\Categories::Screening,
Components\Categories::Messaging,
Components\Categories::Accounting,
Components\Categories::Scheduling,
],
originOwnerId: '<id>',
originOwnerName: '<value>',
);
$response = $sdk->connectSessions->createConnectSession(
request: $request,
options: Utils\Options->builder()->setRetryConfig(
new Retry\RetryConfigBackoff(
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
retryConnectionErrors: false,
))->build()
);
if ($response->connectSessionTokenAuthLink !== null) {
// handle response
}
declare(strict_types=1);
StackOne\client\Models\Components;
use StackOne\client\Utils\Retry;
$sdk = client\StackOne::builder()
->setRetryConfig(
new Retry\RetryConfigBackoff(
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
retryConnectionErrors: false,
)
)
->setSecurity(
new Components\Security(
username: '',
password: '',
)
)
->build();
$request = new Components\ConnectSessionCreate(
categories: [
Components\Categories::Ats,
Components\Categories::Hris,
Components\Categories::Ticketing,
Components\Categories::Crm,
Components\Categories::Iam,
Components\Categories::Marketing,
Components\Categories::Lms,
Components\Categories::Iam,
Components\Categories::Documents,
Components\Categories::Ticketing,
Components\Categories::Screening,
Components\Categories::Messaging,
Components\Categories::Accounting,
Components\Categories::Scheduling,
],
originOwnerId: '<id>',
originOwnerName: '<value>',
);
$response = $sdk->connectSessions->createConnectSession(
request: $request
);
if ($response->connectSessionTokenAuthLink !== null) {
// handle response
}
declare(strict_types=1);
StackOne\client\Models\Components;
use StackOne\client\Models\Errors;
$sdk = client\StackOne::builder()
->setSecurity(
new Components\Security(
username: '',
password: '',
)
)
->build();
try {
$request = new Components\ConnectSessionCreate(
categories: [
Components\Categories::Ats,
Components\Categories::Hris,
Components\Categories::Ticketing,
Components\Categories::Crm,
Components\Categories::Iam,
Components\Categories::Marketing,
Components\Categories::Lms,
Components\Categories::Iam,
Components\Categories::Documents,
Components\Categories::Ticketing,
Components\Categories::Screening,
Components\Categories::Messaging,
Components\Categories::Accounting,
Components\Categories::Scheduling,
],
originOwnerId: '<id>',
originOwnerName: '<value>',
);
$response = $sdk->connectSessions->createConnectSession(
request: $request
);
if ($response->connectSessionTokenAuthLink !== 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\ForbiddenResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\NotFoundResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\RequestTimedOutResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\ConflictResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\UnprocessableEntityResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\TooManyRequestsResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\InternalServerErrorResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\NotImplementedResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\BadGatewayResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\SDKException $e) {
// handle default exception
throw $e;
}
declare(strict_types=1);
StackOne\client\Models\Components;
$sdk = client\StackOne::builder()
->setServerURL('https://api.stackone.com')
->setSecurity(
new Components\Security(
username: '',
password: '',
)
)
->build();
$request = new Components\ConnectSessionCreate(
categories: [
Components\Categories::Ats,
Components\Categories::Hris,
Components\Categories::Ticketing,
Components\Categories::Crm,
Components\Categories::Iam,
Components\Categories::Marketing,
Components\Categories::Lms,
Components\Categories::Iam,
Components\Categories::Documents,
Components\Categories::Ticketing,
Components\Categories::Screening,
Components\Categories::Messaging,
Components\Categories::Accounting,
Components\Categories::Scheduling,
],
originOwnerId: '<id>',
originOwnerName: '<value>',
);
$response = $sdk->connectSessions->createConnectSession(
request: $request
);
if ($response->connectSessionTokenAuthLink !== null) {
// handle response
}