@stackone/stackone-client-ts v4.7.2
@stackone/stackone-client-ts
SDK Installation
NPM
npm add @stackone/stackone-client-ts
Yarn
yarn add @stackone/stackone-client-ts
SDK Example Usage
List Employees
import { StackOne } from "@stackone/stackone-client-ts";
const stackOne = new StackOne({
security: {
password: "<YOUR_PASSWORD_HERE>",
},
});
async function run() {
const result = await stackOne.hris.listEmployees({
expand: "company,employments,work_location,home_location,custom_fields,groups",
fields: "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_title,job_description,department,cost_centers,benefits,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",
filterUpdatedAfter: "2020-01-01T00:00:00.000Z",
include: "avatar_url,avatar,custom_fields,job_description,benefits",
updatedAfter: "2020-01-01T00:00:00.000Z",
xAccountId: "<value>",
});
for await (const page of result) {
// handle page
}
}
run();
Available Resources and Operations
accounts
- deleteAccount - Delete Account
- getAccount - Get Account
- getAccountMetaInfo - Get meta information of the account
- listLinkedAccounts - List Accounts
- updateAccount - Update Account
connectSessions
- authenticateConnectSession - Authenticate Connect Session
- createConnectSession - Create Connect Session
connectors
- getConnectorMeta - Get Connector Meta information for the given provider key
- listConnectorsMeta - List Connectors Meta Information for all providers
ats
- createApplication - Create Application
- createCandidate - Create Candidate
- createCandidateNote - Create Candidate Note
- createOffer - Creates an offer
- downloadApplicationDocument - Download Application Document
- getApplication - Get Application
- getApplicationDocument - Get Application Document
- getApplicationOffer - Get Application Offer
- getApplicationScorecard - Get Application Scorecard
- getCandidate - Get Candidate
- getCandidateNote - Get Candidate Note
- getDepartment - Get Department
- getInterview - Get Interview
- getInterviewStage - Get Interview Stage
- getJob - Get Job
- getJobPosting - Get Job Posting
- getLocation - Get Location
- getOffer - Get Offer
- getRejectedReason - Get Rejected Reason
- getUser - Get User
- listApplicationDocuments - List Application Documents
- listApplicationScorecards - List Application Scorecards
- listApplications - List Applications
- listApplicationsOffers - List Application Offers
- listCandidateNotes - List Candidate Notes
- listCandidates - List Candidates
- listDepartments - List Departments
- listInterviewStages - List Interview Stages
- listInterviews - List Interviews
- listJobPostings - List Job Postings
- listJobs - List Jobs
- listLocations - List locations
- listOffers - List Offers
- listRejectedReasons - List Rejected Reasons
- listUsers - List Users
- updateApplication - Update an Application
- updateCandidate - Update Candidate
crm
- createContact - Creates a new Contact
- getAccount - Get Account
- getContact - Get Contact
- getList - Get List
- listAccounts - List Accounts
- listContacts - List Contacts
- listLists - Get all Lists
- updateContact - Update Contact (early access)
hris
- createEmployee - Creates an employee
- createEmployeeTimeOffRequest - Create Employee Time Off Request
- createEmployeeWorkEligibilityRequest - Create Employee Work Eligibility Request
- createTimeOffRequest - Creates a time off request
- downloadEmployeeDocument - Download Employee Document
- getBenefit - Get Benefit
- getCompany - Get Company
- getEmployee - Get Employee
- getEmployeeDocument - Get Employee Document
- getEmployeesTimeOffRequest - Get Employees Time Off Request
- getEmployeesWorkEligibility - Get Employees Work Eligibility
- getEmployment - Get Employment
- getGroup - Get Group
- getLocation - Get Location
- getTimeOffRequest - Get time off request
- listBenefits - List benefits
- listCompanies - List Companies
- listEmployeeDocuments - List Employee Documents
- listEmployeeTimeOffRequests - List Employee Time Off Requests
- listEmployeeWorkEligibility - List Employee Work Eligibility
- listEmployees - List Employees
- listEmployments - List Employments
- listGroups - List Groups
- listLocations - List locations
- listTimeOffRequests - List time off requests
- updateEmployee - Updates an employee
- updateEmployeeWorkEligibilityRequest - Update Employee Work Eligibility Request
- updateTimeOffRequest - Update time off request
- uploadEmployeeDocument - Upload Employee Document
iam
- getGroup - Get Group
- getPolicy - Get Policy
- getRole - Get Role
- getUser - Get User
- listGroups - List Groups
- listPolicies - List Policies
- listRoles - List Roles
- listUsers - List Users
marketing
- createEmailTemplate - Create email template
- createOmniChannelTemplate - Create omni-channel template
- createPushTemplate - Create push template
- getCampaign - Get campaign
- getEmailTemplate - Get email template
- getOmniChannelTemplate - Get omni-channel template
- getPushTemplate - Get push template
- listCampaigns - List campaigns
- listEmailTemplates - List email templates
- listOmniChannelTemplates - List omni-channel templates
- listPushTemplates - List push templates
- updateEmailTemplate - Update email template
- updateOmniChannelTemplate - Update omni-channel template
- updatePushTemplate - Update push template
proxy
- proxyRequest - Proxy Request
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you
make your SDK calls as usual, but the returned response object will also be an
async iterable that can be consumed using the for await...of
syntax.
Here's an example of one such pagination call:
import { StackOne } from "@stackone/stackone-client-ts";
const stackOne = new StackOne({
security: {
password: "<YOUR_PASSWORD_HERE>",
},
});
async function run() {
const result = await stackOne.hris.listEmployees({
expand: "company,employments,work_location,home_location,custom_fields,groups",
fields: "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_title,job_description,department,cost_centers,benefits,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",
filterUpdatedAfter: "2020-01-01T00:00:00.000Z",
include: "avatar_url,avatar,custom_fields,job_description,benefits",
updatedAfter: "2020-01-01T00:00:00.000Z",
xAccountId: "<value>",
});
for await (const page of result) {
// handle page
}
}
run();
Error Handling
All SDK methods return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type.
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The SDKValidationError
that is thrown as a result will capture the raw value that failed validation in an attribute called rawValue
. Additionally, a pretty()
method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging.
import { StackOne } from "@stackone/stackone-client-ts";
import * as errors from "@stackone/stackone-client-ts/sdk/models/errors";
const stackOne = new StackOne({
security: {
password: "<YOUR_PASSWORD_HERE>",
},
});
async function run() {
let result;
try {
result = await stackOne.accounts.deleteAccount({
id: "<id>",
});
} catch (err) {
switch (true) {
case err instanceof errors.SDKValidationError: {
// Validation errors can be pretty-printed
console.error(err.pretty());
// Raw value may also be inspected
console.error(err.rawValue);
return;
}
default: {
throw err;
}
}
}
// Handle the result
console.log(result);
}
run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient
that wraps the native
Fetch API. This
client is a thin wrapper around fetch
and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient
constructor takes an optional fetcher
argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest"
hook to to add a
custom header and a timeout to requests and how to use the "requestError"
hook
to log errors:
import { StackOne } from "@stackone/stackone-client-ts";
import { HTTPClient } from "@stackone/stackone-client-ts/lib/http";
const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native `fetch`.
fetcher: (request) => {
return fetch(request);
}
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000);
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new StackOne({ httpClient });
Authentication
Per-Client Security Schemes
This SDK supports the following security schemes globally:
Name | Type | Scheme |
---|---|---|
password | http | HTTP Basic |
username | http | HTTP Basic |
You can set the security parameters through the security
optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
import { StackOne } from "@stackone/stackone-client-ts";
const stackOne = new StackOne({
security: {
password: "<YOUR_PASSWORD_HERE>",
},
});
async function run() {
const result = await stackOne.accounts.deleteAccount({
id: "<id>",
});
// Handle the result
console.log(result);
}
run();
Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
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. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!
SDK Created by Speakeasy
1 day ago
9 days ago
9 days ago
17 days ago
21 days ago
21 days ago
22 days ago
22 days ago
23 days ago
27 days ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago