Class: SmartRecruiters::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/smartrecruiters/client.rb

Constant Summary collapse

SMART_RECRUITERS_TIMEOUT =
128
SMART_RECRUITERS_RETRIES =
3
SMART_RECRUITERS_BASE_PATHS =
{
  'production' => 'https://api.smartrecruiters.com',
  'sandbox' => 'https://api.sandbox.smartrecruiters.com'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil, environment: 'production') ⇒ Client

Returns a new instance of Client.



19
20
21
22
23
24
25
26
27
28
29
30
# 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

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



17
18
19
# File 'lib/smartrecruiters/client.rb', line 17

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



17
18
19
# File 'lib/smartrecruiters/client.rb', line 17

def api_key
  @api_key
end

Instance Method Details

#access_groupsObject



32
33
34
# File 'lib/smartrecruiters/client.rb', line 32

def access_groups
  AccessGroupsResource.new(self)
end

#candidatesObject



36
37
38
# File 'lib/smartrecruiters/client.rb', line 36

def candidates
  CandidatesResource.new(self)
end

#connectionObject



80
81
82
83
84
85
86
87
88
89
90
91
92
# 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_typesObject



40
41
42
# File 'lib/smartrecruiters/client.rb', line 40

def interview_types
  InterviewTypesResource.new(self)
end

#interviewsObject



44
45
46
# File 'lib/smartrecruiters/client.rb', line 44

def interviews
  InterviewsResource.new(self)
end

#jobsObject



48
49
50
# File 'lib/smartrecruiters/client.rb', line 48

def jobs
  JobsResource.new(self)
end

#offersObject



52
53
54
# File 'lib/smartrecruiters/client.rb', line 52

def offers
  OffersResource.new(self)
end

#postingsObject



56
57
58
# File 'lib/smartrecruiters/client.rb', line 56

def postings
  PostingsResource.new(self)
end

#reportsObject



60
61
62
# File 'lib/smartrecruiters/client.rb', line 60

def reports
  ReportsResource.new(self)
end

#reviewsObject



64
65
66
# File 'lib/smartrecruiters/client.rb', line 64

def reviews
  ReviewsResource.new(self)
end

#system_rolesObject



68
69
70
# File 'lib/smartrecruiters/client.rb', line 68

def system_roles
  SystemRolesResource.new(self)
end

#usersObject



72
73
74
# File 'lib/smartrecruiters/client.rb', line 72

def users
  UsersResource.new(self)
end

#webhooksObject



76
77
78
# File 'lib/smartrecruiters/client.rb', line 76

def webhooks
  WebhooksResource.new(self)
end