Class: FreeAgent::UsersResource
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#create(email:, first_name:, last_name:, role:, opening_mileage: 0, **params) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/free_agent/resources/users.rb', line 19
def create(email:, first_name:, last_name:, role:, opening_mileage: 0, **params)
attributes = {email: email, first_name: first_name, last_name: last_name, role: role, opening_mileage: opening_mileage}
response = post_request("users", body: attributes.merge(params))
User.new(response.body["user"]) if response.success?
end
|
#delete(id:) ⇒ Object
36
37
38
39
|
# File 'lib/free_agent/resources/users.rb', line 36
def delete(id:)
response = delete_request("users/#{id}")
response.success?
end
|
#list(**params) ⇒ Object
9
10
11
12
|
# File 'lib/free_agent/resources/users.rb', line 9
def list(**params)
response = get_request("users", params: params)
Collection.from_response(response, type: User, key: "users")
end
|
4
5
6
7
|
# File 'lib/free_agent/resources/users.rb', line 4
def me
response = get_request("users/me")
User.new(response.body["user"])
end
|
#retrieve(id:) ⇒ Object
14
15
16
17
|
# File 'lib/free_agent/resources/users.rb', line 14
def retrieve(id:)
response = get_request("users/#{id}")
User.new(response.body["user"])
end
|
#update(id:, **params) ⇒ Object
26
27
28
29
|
# File 'lib/free_agent/resources/users.rb', line 26
def update(id:, **params)
response = put_request("users/#{id}", body: params)
User.new(response.body["user"]) if response.success?
end
|
#update_me(**params) ⇒ Object
31
32
33
34
|
# File 'lib/free_agent/resources/users.rb', line 31
def update_me(**params)
response = put_request("users/me", body: {user: params})
User.new(response.body["user"]) if response.success?
end
|