Skip to content

StackOneHQ/stackone-client-ruby

Repository files navigation

stackone_client

Summary

IAM: The documentation for the StackOne Unified API - IAM

Table of Contents

SDK Installation

The SDK can be installed using RubyGems:

gem install stackone_client

SDK Example Usage

List Employees

require 'stackone_client'

s = ::StackOne::StackOne.new(
      security: Models::Shared::Security.new(
        password: "",
        username: "",
      ),
    )

req = Models::Operations::HrisListEmployeesRequest.new(
  expand: "company,employments,work_location,home_location,groups,skills",
  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,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,documents,created_at,updated_at,benefits,employee_number,national_identity_number,national_identity_numbers,skills",
  filter: Models::Operations::HrisListEmployeesQueryParamFilter.new(
    updated_after: "2020-01-01T00:00:00.000Z",
  ),
  include: "avatar_url,avatar,custom_fields,job_description,benefits",
  x_account_id: "<id>",
)

res = s.hris.list_employees(req)

if ! res.employees_paginated.nil?
  # handle response
end

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
username
password
http HTTP Basic

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

require 'stackone_client'

s = ::StackOne::StackOne.new(
      security: Models::Shared::Security.new(
        password: "",
        username: "",
      ),
    )

res = s.accounts.delete_account(id="<id>")

if ! res.linked_account.nil?
  # handle response
end

Available Resources and Operations

Available methods

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:

require 'stackone_client'

s = ::StackOne::StackOne.new(
      security: Models::Shared::Security.new(
        password: "",
        username: "",
      ),
    )

res = s.accounts.delete_account(id="<id>")

if ! res.linked_account.nil?
  # handle response
end

If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:

require 'stackone_client'

s = ::StackOne::StackOne.new(
      retry_config: Utils::RetryConfig.new(
        backoff: Utils::BackoffStrategy.new(
          exponent: 1.1,
          initial_interval: 1,
          max_elapsed_time: 100,
          max_interval: 50
        ),
        retry_connection_errors: false,
        strategy: 'backoff'
      ),
      security: Models::Shared::Security.new(
        password: "",
        username: "",
      ),
    )

res = s.accounts.delete_account(id="<id>")

if ! res.linked_account.nil?
  # handle response
end

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error.

By default an API error will raise a Errors::APIError, which has the following properties:

Property Type Description
message string The error message
status_code int The HTTP status code
raw_response Faraday::Response The raw HTTP response
body string The response content

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 delete_account method throws the following exceptions:

Error Type Status Code Content Type
Models::Errors::BadRequestResponse 400 application/json
Models::Errors::UnauthorizedResponse 401 application/json
Models::Errors::ForbiddenResponse 403 application/json
Models::Errors::NotFoundResponse 404 application/json
Models::Errors::RequestTimedOutResponse 408 application/json
Models::Errors::ConflictResponse 409 application/json
Models::Errors::UnprocessableEntityResponse 422 application/json
Models::Errors::TooManyRequestsResponse 429 application/json
Models::Errors::InternalServerErrorResponse 500 application/json
Models::Errors::NotImplementedResponse 501 application/json
Models::Errors::BadGatewayResponse 502 application/json
Errors::APIError 4XX, 5XX */*

Example

require 'stackone_client'

s = ::StackOne::StackOne.new(
      security: Models::Shared::Security.new(
        password: '',
        username: '',
      ),
    )

begin
    res = s.accounts.delete_account(id='<id>')

    if ! res.linked_account.nil?
      # handle response
    end
rescue Models::Errors::BadRequestResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::UnauthorizedResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::ForbiddenResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::NotFoundResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::RequestTimedOutResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::ConflictResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::UnprocessableEntityResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::TooManyRequestsResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::InternalServerErrorResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::NotImplementedResponse => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::BadGatewayResponse => e
  # handle $e->$container data
  throw $e;
rescue Errors::APIError => e
  # handle default exception
  raise e
end

Server Selection

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the server_url (String) optional parameter when initializing the SDK client instance. For example:

require 'stackone_client'

s = ::StackOne::StackOne.new(
      server_url: "https://api.stackone.com",
      security: Models::Shared::Security.new(
        password: "",
        username: "",
      ),
    )

res = s.accounts.delete_account(id="<id>")

if ! res.linked_account.nil?
  # handle response
end

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. 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

About

StackOne Client Ruby SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6

Languages