Class: FreeAgent::BillsResource
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#create(contact:, dated_on:, due_on:, reference:, bill_items:, **params) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/free_agent/resources/bills.rb', line 23
def create(contact:, dated_on:, due_on:, reference:, bill_items:, **params)
attributes = { contact: contact, dated_on: dated_on, due_on: due_on, reference: reference, bill_items: bill_items }
response = post_request("bills", body: { bill: attributes.merge(params) })
Bill.new(response.body["bill"]) if response.success?
end
|
#delete(id:) ⇒ Object
35
36
37
38
|
# File 'lib/free_agent/resources/bills.rb', line 35
def delete(id:)
response = delete_request("bills/#{id}")
response.success?
end
|
#list(**params) ⇒ Object
3
4
5
6
|
# File 'lib/free_agent/resources/bills.rb', line 3
def list(**params)
response = get_request("bills", params: params)
Collection.from_response(response, type: Bill)
end
|
8
9
10
11
|
# File 'lib/free_agent/resources/bills.rb', line 8
def list_for_contact(contact:, **params)
response = get_request("bills?contact=#{contact}", params: params)
Collection.from_response(response, type: Bill)
end
|
#list_for_project(project:, **params) ⇒ Object
13
14
15
16
|
# File 'lib/free_agent/resources/bills.rb', line 13
def list_for_project(project:, **params)
response = get_request("bills?project=#{project}", params: params)
Collection.from_response(response, type: Bill)
end
|
#retrieve(id:) ⇒ Object
18
19
20
21
|
# File 'lib/free_agent/resources/bills.rb', line 18
def retrieve(id:)
response = get_request("bills/#{id}")
Bill.new(response.body["bill"])
end
|
#update(id:, **params) ⇒ Object
30
31
32
33
|
# File 'lib/free_agent/resources/bills.rb', line 30
def update(id:, **params)
response = put_request("bills/#{id}", body: { bill: params })
Bill.new(response.body["bill"]) if response.success?
end
|