/stackone-ts

A typescript SDK for accessing the stackone-ts API.

Primary LanguageTypeScriptMIT LicenseMIT

Typescript SDK

Two-way Integrations, Effortlessly.

SDK Installation

NPM

npm add https://github.com/speakeasy-sdks/stackone-ts

Yarn

yarn add https://github.com/speakeasy-sdks/stackone-ts

SDK Example Usage

Example

import { StackOne } from "StackOne";
import { AtsCandidatePostRequest } from "StackOne/dist/sdk/models/operations";
import { AtsCreateCandidateRequestDto, CandidateEmail } from "StackOne/dist/sdk/models/shared";

(async () => {
    const sdk = new StackOne({
        security: {
            password: "BASE_64_ENCODED(API_KEY)",
            username: "YOUR_USERNAME",
        },
    });
    const atsCreateCandidateRequestDto: AtsCreateCandidateRequestDto = {
        applicationIds: ["string"],
        emails: [
            {
                type: "string",
                value: "string",
            },
        ],
        firstName: "Jed",
        lastName: "Kuhn",
        name: "string",
        title: "string",
    };
    const xAccountId: string = "string";

    const res = await sdk.ats.candidates.create(atsCreateCandidateRequestDto, xAccountId);

    if (res.statusCode == 200) {
        // handle response
    }
})();

Available Resources and Operations

  • create - Post Application (early access)
  • get - Get Application
  • getOffers - Get Application Offer
  • list - List Applications
  • listOffers - List Application Offers
  • update - Patch Application (early access)
  • create - Post Candidate (early access)
  • get - Get Candidate
  • list - List Candidates
  • update - Patch Candidate (early access)
  • get - Get Department
  • list - List Departments
  • get - Get Interview Stage
  • list - List Interview Stages
  • get - Get Interview
  • list - List Interviews
  • get - Get Location
  • list - List locations
  • get - Get Rejected Reason
  • list - List Rejected Reasons
  • get - Get Account
  • list - List Accounts
  • create - Post Contact (early access)
  • get - Get Contact
  • list - List Contacts
  • update - Patch Contact (early access)
  • get - Get Company
  • list - List Companies
  • create - Creates an employee
  • get - Get Employee
  • list - List Employees
  • get - Get Employment
  • list - List Employments
  • get - Get location
  • list - List locations
  • get - Get campaign
  • list - List campaigns

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 have a next method that can be called to pull down the next group of results. If the return value of next is null, then there are no more pages to be fetched.

Here's an example of one such pagination call:

Error Handling

Handling errors in this SDK should largely match your expectations. All operations 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 400-600 /

Example

import { StackOne } from "StackOne";
import { AccountsDeleteRequest } from "StackOne/dist/sdk/models/operations";

(async () => {
    const sdk = new StackOne({
        security: {
            password: "BASE_64_ENCODED(API_KEY)",
            username: "YOUR_USERNAME",
        },
    });
    const id: string = "string";

    let res;
    try {
        res = await sdk.accounts.delete(id);
    } catch (e) {}

    if (res.statusCode == 200) {
        // handle response
    }
})();

Server Selection

Select Server by Index

You can override the default server globally by passing a server index to the serverIdx: number optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

# Server Variables
0 https://api.stackone.com None

Example

import { StackOne } from "StackOne";
import { AccountsDeleteRequest } from "StackOne/dist/sdk/models/operations";

(async () => {
    const sdk = new StackOne({
        serverIdx: 0,
        security: {
            password: "BASE_64_ENCODED(API_KEY)",
            username: "YOUR_USERNAME",
        },
    });
    const id: string = "string";

    const res = await sdk.accounts.delete(id);

    if (res.statusCode == 200) {
        // handle response
    }
})();

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the serverURL: str optional parameter when initializing the SDK client instance. For example:

import { StackOne } from "StackOne";
import { AccountsDeleteRequest } from "StackOne/dist/sdk/models/operations";

(async () => {
    const sdk = new StackOne({
        serverURL: "https://api.stackone.com",
        security: {
            password: "BASE_64_ENCODED(API_KEY)",
            username: "YOUR_USERNAME",
        },
    });
    const id: string = "string";

    const res = await sdk.accounts.delete(id);

    if (res.statusCode == 200) {
        // handle response
    }
})();

Custom HTTP Client

The Typescript SDK makes API calls using the (axios)[https://axios-http.com/docs/intro] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom AxiosInstance object.

For example, you could specify a header for every request that your sdk makes as follows:

from StackOne import StackOne;
import axios;

const httpClient = axios.create({
    headers: {'x-custom-header': 'someValue'}
})

const sdk = new StackOne({defaultClient: httpClient});

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 a retryConfig object to the call:

import { StackOne } from "StackOne";
import { AccountsDeleteRequest } from "StackOne/dist/sdk/models/operations";

(async () => {
    const sdk = new StackOne({
        security: {
            password: "BASE_64_ENCODED(API_KEY)",
            username: "YOUR_USERNAME",
        },
    });
    const id: string = "string";

    const res = await sdk.accounts.delete(id, {
        strategy: "backoff",
        backoff: {
            initialInterval: 1,
            maxInterval: 50,
            exponent: 1.1,
            maxElapsedTime: 100,
        },
        retryConnectionErrors: false,
    });

    if (res.statusCode == 200) {
        // handle response
    }
})();

If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:

import { StackOne } from "StackOne";
import { AccountsDeleteRequest } from "StackOne/dist/sdk/models/operations";

(async () => {
    const sdk = new StackOne({
        retry_config: {
            strategy: "backoff",
            backoff: {
                initialInterval: 1,
                maxInterval: 50,
                exponent: 1.1,
                maxElapsedTime: 100,
            },
            retryConnectionErrors: false,
        },
        security: {
            password: "BASE_64_ENCODED(API_KEY)",
            username: "YOUR_USERNAME",
        },
    });
    const id: string = "string";

    const res = await sdk.accounts.delete(id);

    if (res.statusCode == 200) {
        // handle response
    }
})();

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";
import { AccountsDeleteRequest } from "StackOne/dist/sdk/models/operations";

(async () => {
    const sdk = new StackOne({
        security: {
            password: "BASE_64_ENCODED(API_KEY)",
            username: "YOUR_USERNAME",
        },
    });
    const id: string = "string";

    const res = await sdk.accounts.delete(id);

    if (res.statusCode == 200) {
        // handle response
    }
})();

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