class SmartRecruiters::Client

Constants

SMART_RECRUITERS_BASE_PATHS
SMART_RECRUITERS_RETRIES
SMART_RECRUITERS_TIMEOUT

Attributes

adapter[R]
api_key[R]

Public Class Methods

new( api_key:, adapter: Faraday.default_adapter, stubs: nil, environment: 'production' ) click to toggle source
# File lib/smartrecruiters/client.rb, line 19
def initialize(
  api_key:,
  adapter: Faraday.default_adapter,
  stubs: nil,
  environment: 'production'
)
  @api_key = api_key
  @environment = environment

  @adapter = adapter
  @stubs = stubs
end

Public Instance Methods

access_groups() click to toggle source
# File lib/smartrecruiters/client.rb, line 32
def access_groups
  AccessGroupsResource.new(self)
end
candidates() click to toggle source
# File lib/smartrecruiters/client.rb, line 36
def candidates
  CandidatesResource.new(self)
end
connection() click to toggle source
# File lib/smartrecruiters/client.rb, line 80
def connection
  @connection ||= Faraday.new do |conn|
    conn.url_prefix = SMART_RECRUITERS_BASE_PATHS[@environment]
    conn.headers['X-SmartToken'] = api_key
    conn.request :json
    conn.request :retry, retry_options

    conn.response :json, content_type: 'application/json'

    conn.options.timeout = SMART_RECRUITERS_TIMEOUT
    conn.adapter adapter, @stubs
  end
end
interview_types() click to toggle source
# File lib/smartrecruiters/client.rb, line 40
def interview_types
  InterviewTypesResource.new(self)
end
interviews() click to toggle source
# File lib/smartrecruiters/client.rb, line 44
def interviews
  InterviewsResource.new(self)
end
jobs() click to toggle source
# File lib/smartrecruiters/client.rb, line 48
def jobs
  JobsResource.new(self)
end
offers() click to toggle source
# File lib/smartrecruiters/client.rb, line 52
def offers
  OffersResource.new(self)
end
postings() click to toggle source
# File lib/smartrecruiters/client.rb, line 56
def postings
  PostingsResource.new(self)
end
reports() click to toggle source
# File lib/smartrecruiters/client.rb, line 60
def reports
  ReportsResource.new(self)
end
reviews() click to toggle source
# File lib/smartrecruiters/client.rb, line 64
def reviews
  ReviewsResource.new(self)
end
system_roles() click to toggle source
# File lib/smartrecruiters/client.rb, line 68
def system_roles
  SystemRolesResource.new(self)
end
users() click to toggle source
# File lib/smartrecruiters/client.rb, line 72
def users
  UsersResource.new(self)
end
webhooks() click to toggle source
# File lib/smartrecruiters/client.rb, line 76
def webhooks
  WebhooksResource.new(self)
end

Private Instance Methods

retry_options() click to toggle source
# File lib/smartrecruiters/client.rb, line 96
def retry_options
  {
    max: SMART_RECRUITERS_RETRIES,
    retry_statuses: [429]
  }
end