Class: GreenhouseApi::Resources::Users

Inherits:
BaseClient
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/greenhouse_api/resources/users.rb

Constant Summary collapse

ON_BEHALF_OF =
'On-Behalf-Of'

Constants inherited from BaseClient

BaseClient::API_URL, BaseClient::MAX_PER_PAGE

Instance Method Summary collapse

Methods inherited from BaseClient

#compose_response, #get_one, #headers, #initialize, #list_many, #request

Constructor Details

This class inherits a constructor from GreenhouseApi::BaseClient

Instance Method Details

#create_user(first_name:, last_name:, email:, on_behalf_of_id:, **additional_args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/greenhouse_api/resources/users.rb', line 14

def create_user(first_name:, last_name:, email:, on_behalf_of_id:, **additional_args)
  body = { first_name: first_name, last_name: last_name, email: email }.merge(additional_args).to_json
  response = request(
    http_method: :post,
    headers: headers.merge(ON_BEHALF_OF => on_behalf_of_id),
    endpoint: "users",
    body: body
  )
  compose_response(response)
end

#disable_user(user, on_behalf_of_id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/greenhouse_api/resources/users.rb', line 26

def disable_user(user, on_behalf_of_id)
  body = { user: user }.to_json
  response = request(
    http_method: :patch,
    headers: headers.merge(ON_BEHALF_OF => on_behalf_of_id),
    endpoint: "users/disable",
    body: body,
    api_version: 'v2'
  )
  compose_response(response)
end

#enable_user(user, on_behalf_of_id) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/greenhouse_api/resources/users.rb', line 39

def enable_user(user, on_behalf_of_id)
  body = { user: user }.to_json
  response = request(
    http_method: :patch,
    headers: headers.merge(ON_BEHALF_OF => on_behalf_of_id),
    endpoint: "users/enable",
    body: body,
    api_version: 'v2'
  )
  compose_response(response)
end