npm add https://github.com/speakeasy-sdks/stackone-ts
yarn add https://github.com/speakeasy-sdks/stackone-ts
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
}
})();
- connectSessionsAuthenticate - Authenticate Session
- connectSessionsCreate - Create Session
- 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)
- create - Post Contact (early access)
- get - Get Contact
- list - List Contacts
- update - Patch Contact (early access)
- createEmail - Creates an email template
- createOmnichannel - Creates an omni-channel template
- createPush - Creates an push template
- getEmail - Get email template
- getOmnichannel - Get omni-channel template
- getPush - Get push template
- list - List templates
- listEmail - List email templates
- listOmnichannel - List omni-channel templates
- listPush - List push templates
- create - Proxy Request
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:
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
}
})();
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 |
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
}
})();
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
}
})();
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});
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
}
})();
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
}
})();
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.
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!