Class: FreeAgent::ContactsResource
- Inherits:
-
Resource
- Object
- Resource
- FreeAgent::ContactsResource
show all
- Defined in:
- lib/free_agent/resources/contacts.rb
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#create(**params) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/free_agent/resources/contacts.rb', line 13
def create(**params)
raise "first_name and last_name or organisation_name is required" unless !params[:first_name].nil? || !params[:organisation_name].nil?
response = post_request("contacts", body: params)
Contact.new(response.body["contact"]) if response.success?
end
|
#delete(id:) ⇒ Object
25
26
27
28
|
# File 'lib/free_agent/resources/contacts.rb', line 25
def delete(id:)
response = delete_request("contacts/#{id}")
response.success?
end
|
#list(**params) ⇒ Object
3
4
5
6
|
# File 'lib/free_agent/resources/contacts.rb', line 3
def list(**params)
response = get_request("contacts", params: params)
Collection.from_response(response, type: Contact)
end
|
#retrieve(id:) ⇒ Object
8
9
10
11
|
# File 'lib/free_agent/resources/contacts.rb', line 8
def retrieve(id:)
response = get_request("contacts/#{id}")
Contact.new(response.body["contact"])
end
|
#update(id:, **params) ⇒ Object
20
21
22
23
|
# File 'lib/free_agent/resources/contacts.rb', line 20
def update(id:, **params)
response = put_request("contacts/#{id}", body: params)
Contact.new(response.body["contact"]) if response.success?
end
|