freeagentrb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +4 -0
- data/bin/console +22 -0
- data/bin/setup +8 -0
- data/freeagentrb.gemspec +34 -0
- data/lib/free_agent/client.rb +100 -0
- data/lib/free_agent/collection.rb +27 -0
- data/lib/free_agent/error.rb +4 -0
- data/lib/free_agent/object.rb +25 -0
- data/lib/free_agent/objects/attachment.rb +4 -0
- data/lib/free_agent/objects/bank_account.rb +4 -0
- data/lib/free_agent/objects/bank_transaction.rb +4 -0
- data/lib/free_agent/objects/bank_transaction_explanation.rb +4 -0
- data/lib/free_agent/objects/bill.rb +4 -0
- data/lib/free_agent/objects/company.rb +4 -0
- data/lib/free_agent/objects/contact.rb +4 -0
- data/lib/free_agent/objects/credit_note.rb +4 -0
- data/lib/free_agent/objects/estimate.rb +4 -0
- data/lib/free_agent/objects/estimate_item.rb +4 -0
- data/lib/free_agent/objects/invoice.rb +4 -0
- data/lib/free_agent/objects/project.rb +4 -0
- data/lib/free_agent/objects/task.rb +4 -0
- data/lib/free_agent/objects/timeslip.rb +4 -0
- data/lib/free_agent/objects/user.rb +4 -0
- data/lib/free_agent/resource.rb +60 -0
- data/lib/free_agent/resources/attachments.rb +15 -0
- data/lib/free_agent/resources/bank_accounts.rb +33 -0
- data/lib/free_agent/resources/bank_transaction_explanations.rb +29 -0
- data/lib/free_agent/resources/bank_transactions.rb +37 -0
- data/lib/free_agent/resources/bills.rb +42 -0
- data/lib/free_agent/resources/company.rb +10 -0
- data/lib/free_agent/resources/contacts.rb +32 -0
- data/lib/free_agent/resources/credit_notes.rb +74 -0
- data/lib/free_agent/resources/estimate_items.rb +22 -0
- data/lib/free_agent/resources/estimates.rb +79 -0
- data/lib/free_agent/resources/invoices.rb +89 -0
- data/lib/free_agent/resources/projects.rb +37 -0
- data/lib/free_agent/resources/tasks.rb +37 -0
- data/lib/free_agent/resources/timeslips.rb +47 -0
- data/lib/free_agent/resources/users.rb +42 -0
- data/lib/free_agent/version.rb +3 -0
- data/lib/free_agent.rb +48 -0
- data/lib/freeagentrb.rb +1 -0
- metadata +133 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class BillsResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("bills", params: params)
|
6
|
+
Collection.from_response(response, type: Bill, key: "bills")
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_for_contact(contact:, **params)
|
10
|
+
response = get_request("bills?contact=#{contact}", params: params)
|
11
|
+
Collection.from_response(response, type: Bill, key: "bills")
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_for_project(project:, **params)
|
15
|
+
response = get_request("bills?project=#{project}", params: params)
|
16
|
+
Collection.from_response(response, type: Bill, key: "bills")
|
17
|
+
end
|
18
|
+
|
19
|
+
def retrieve(id:)
|
20
|
+
response = get_request("bills/#{id}")
|
21
|
+
Bill.new(response.body["bill"])
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(contact:, dated_on:, due_on:, reference:, bill_items:, **params)
|
25
|
+
attributes = {contact: contact, dated_on: dated_on, due_on: due_on, reference: reference, bill_items: bill_items}
|
26
|
+
|
27
|
+
response = post_request("bills", body: {bill: attributes.merge(params)})
|
28
|
+
Bill.new(response.body["bill"]) if response.success?
|
29
|
+
end
|
30
|
+
|
31
|
+
def update(id:, **params)
|
32
|
+
response = put_request("bills/#{id}", body: {bill: params})
|
33
|
+
Bill.new(response.body["bill"]) if response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete(id:)
|
37
|
+
response = delete_request("bills/#{id}")
|
38
|
+
response.success?
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class ContactsResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("contacts", params: params)
|
6
|
+
Collection.from_response(response, type: Contact, key: "contacts")
|
7
|
+
end
|
8
|
+
|
9
|
+
def retrieve(id:)
|
10
|
+
response = get_request("contacts/#{id}")
|
11
|
+
Contact.new(response.body["contact"])
|
12
|
+
end
|
13
|
+
|
14
|
+
def create(**params)
|
15
|
+
raise "first_name and last_name or organisation_name is required" unless !params[:first_name].nil? || !params[:organisation_name].nil?
|
16
|
+
|
17
|
+
response = post_request("contacts", body: params)
|
18
|
+
Contact.new(response.body["contact"]) if response.success?
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(id:, **params)
|
22
|
+
response = put_request("contacts/#{id}", body: params)
|
23
|
+
Contact.new(response.body["contact"]) if response.success?
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(id:)
|
27
|
+
response = delete_request("contacts/#{id}")
|
28
|
+
response.success?
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class CreditNotesResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("credit_notes", params: params)
|
6
|
+
Collection.from_response(response, type: CreditNote, key: "credit_notes")
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_for_contact(contact:, **params)
|
10
|
+
response = get_request("credit_notes?contact=#{contact}", params: params)
|
11
|
+
Collection.from_response(response, type: CreditNote, key: "credit_notes")
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_for_project(project:, **params)
|
15
|
+
response = get_request("credit_notes?project=#{project}", params: params)
|
16
|
+
Collection.from_response(response, type: CreditNote, key: "credit_notes")
|
17
|
+
end
|
18
|
+
|
19
|
+
def retrieve(id:)
|
20
|
+
response = get_request("credit_notes/#{id}")
|
21
|
+
CreditNote.new(response.body["credit_note"])
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns a Base64-encoded PDF
|
25
|
+
def retrieve_pdf(id:)
|
26
|
+
response = get_request("credit_notes/#{id}/pdf")
|
27
|
+
response.body["pdf"]["content"] if response.success?
|
28
|
+
end
|
29
|
+
|
30
|
+
def create(contact:, dated_on:, payment_terms_in_days: 0, **params)
|
31
|
+
attributes = {contact: contact, dated_on: dated_on, payment_terms_in_days: payment_terms_in_days}
|
32
|
+
|
33
|
+
response = post_request("credit_notes", body: {credit_note: attributes.merge(params)})
|
34
|
+
CreditNote.new(response.body["credit_note"]) if response.success?
|
35
|
+
end
|
36
|
+
|
37
|
+
# def duplicate(id:)
|
38
|
+
# response = post_request("invoices/#{id}/duplicate", body: {})
|
39
|
+
# Invoice.new(response.body["invoice"]) if response.success?
|
40
|
+
# end
|
41
|
+
|
42
|
+
def update(id:, **params)
|
43
|
+
response = put_request("credit_notes/#{id}", body: {credit_note: params})
|
44
|
+
CreditNote.new(response.body["credit_note"]) if response.success?
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete(id:)
|
48
|
+
response = delete_request("credit_notes/#{id}")
|
49
|
+
response.success?
|
50
|
+
end
|
51
|
+
|
52
|
+
def email(id:, to:, **params)
|
53
|
+
attributes = {to: to}
|
54
|
+
response = post_request("credit_notes/#{id}/send_email", body: {credit_note: {email: attributes.merge(params)}})
|
55
|
+
response.success?
|
56
|
+
end
|
57
|
+
|
58
|
+
def mark_as_sent(id:)
|
59
|
+
response = put_request("credit_notes/#{id}/transitions/mark_as_sent", body: {})
|
60
|
+
response.success?
|
61
|
+
end
|
62
|
+
|
63
|
+
def mark_as_draft(id:)
|
64
|
+
response = put_request("credit_notes/#{id}/transitions/mark_as_draft", body: {})
|
65
|
+
response.success?
|
66
|
+
end
|
67
|
+
|
68
|
+
def mark_as_cancelled(id:)
|
69
|
+
response = put_request("credit_notes/#{id}/transitions/mark_as_cancelled", body: {})
|
70
|
+
response.success?
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class EstimateItemsResource < Resource
|
3
|
+
|
4
|
+
def create(estimate:, **params)
|
5
|
+
attributes = {estimate: estimate}
|
6
|
+
|
7
|
+
response = post_request("estimate_items", body: attributes.merge(params))
|
8
|
+
EstimateItem.new(response.body["estimate_item"]) if response.success?
|
9
|
+
end
|
10
|
+
|
11
|
+
def update(id:, **params)
|
12
|
+
response = put_request("estimate_items/#{id}", body: params)
|
13
|
+
EstimateItem.new(response.body["estimate_item"]) if response.success?
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(id:)
|
17
|
+
response = delete_request("estimate_items/#{id}")
|
18
|
+
response.success?
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class EstimatesResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("estimates", params: params)
|
6
|
+
Collection.from_response(response, type: Estimate, key: "estimates")
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_for_contact(contact:, **params)
|
10
|
+
response = get_request("estimates?contact=#{contact}", params: params)
|
11
|
+
Collection.from_response(response, type: Estimate, key: "estimates")
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_for_project(project:, **params)
|
15
|
+
response = get_request("estimates?project=#{project}", params: params)
|
16
|
+
Collection.from_response(response, type: Estimate, key: "estimates")
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_for_invoice(invoice:, **params)
|
20
|
+
response = get_request("estimates?invoice=#{invoice}", params: params)
|
21
|
+
Collection.from_response(response, type: Estimate, key: "estimates")
|
22
|
+
end
|
23
|
+
|
24
|
+
def retrieve(id:)
|
25
|
+
response = get_request("estimates/#{id}")
|
26
|
+
Estimate.new(response.body["estimate"])
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns a Base64-encoded PDF
|
30
|
+
def retrieve_pdf(id:)
|
31
|
+
response = get_request("estimates/#{id}/pdf")
|
32
|
+
response.body["pdf"]["content"] if response.success?
|
33
|
+
end
|
34
|
+
|
35
|
+
def create(contact:, dated_on:, currency:, reference:, status: "Draft", estimate_type: "Estimate", **params)
|
36
|
+
attributes = {contact: contact, dated_on: dated_on, status: status, estimate_type: estimate_type, currency: currency, reference: reference}
|
37
|
+
|
38
|
+
response = post_request("estimates", body: {estimate: attributes.merge(params)})
|
39
|
+
Estimate.new(response.body["estimate"]) if response.success?
|
40
|
+
end
|
41
|
+
|
42
|
+
def update(id:, **params)
|
43
|
+
response = put_request("estimates/#{id}", body: params)
|
44
|
+
Estimate.new(response.body["estimate"]) if response.success?
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete(id:)
|
48
|
+
response = delete_request("estimates/#{id}")
|
49
|
+
response.success?
|
50
|
+
end
|
51
|
+
|
52
|
+
def email(id:, to:, **params)
|
53
|
+
attributes = {to: to}
|
54
|
+
response = post_request("estimates/#{id}/send_email", body: {estimate: {email: attributes.merge(params)}})
|
55
|
+
response.success?
|
56
|
+
end
|
57
|
+
|
58
|
+
def mark_as_sent(id:)
|
59
|
+
response = put_request("estimaates/#{id}/transitions/mark_as_sent", body: {})
|
60
|
+
response.success?
|
61
|
+
end
|
62
|
+
|
63
|
+
def mark_as_draft(id:)
|
64
|
+
response = put_request("estimaates/#{id}/transitions/mark_as_draft", body: {})
|
65
|
+
response.success?
|
66
|
+
end
|
67
|
+
|
68
|
+
def mark_as_approved(id:)
|
69
|
+
response = put_request("estimates/#{id}/transitions/mark_as_approved", body: {})
|
70
|
+
response.success?
|
71
|
+
end
|
72
|
+
|
73
|
+
def mark_as_rejected(id:)
|
74
|
+
response = put_request("estimates/#{id}/transitions/mark_as_rejected", body: {})
|
75
|
+
response.success?
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class InvoicesResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("invoices", params: params)
|
6
|
+
Collection.from_response(response, type: Invoice, key: "invoices")
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_for_contact(contact:, **params)
|
10
|
+
response = get_request("invoices?contact=#{contact}", params: params)
|
11
|
+
Collection.from_response(response, type: Invoice, key: "invoices")
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_for_project(project:, **params)
|
15
|
+
response = get_request("invoices?project=#{project}", params: params)
|
16
|
+
Collection.from_response(response, type: Invoice, key: "invoices")
|
17
|
+
end
|
18
|
+
|
19
|
+
def retrieve(id:)
|
20
|
+
response = get_request("invoices/#{id}")
|
21
|
+
Invoice.new(response.body["invoice"])
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns a Base64-encoded PDF
|
25
|
+
def retrieve_pdf(id:)
|
26
|
+
response = get_request("invoices/#{id}/pdf")
|
27
|
+
response.body["pdf"]["content"] if response.success?
|
28
|
+
end
|
29
|
+
|
30
|
+
def create(contact:, dated_on:, payment_terms_in_days: 0, **params)
|
31
|
+
attributes = {contact: contact, dated_on: dated_on, payment_terms_in_days: payment_terms_in_days}
|
32
|
+
|
33
|
+
response = post_request("invoices", body: {invoice: attributes.merge(params)})
|
34
|
+
Invoice.new(response.body["invoice"]) if response.success?
|
35
|
+
end
|
36
|
+
|
37
|
+
def duplicate(id:)
|
38
|
+
response = post_request("invoices/#{id}/duplicate", body: {})
|
39
|
+
Invoice.new(response.body["invoice"]) if response.success?
|
40
|
+
end
|
41
|
+
|
42
|
+
def update(id:, **params)
|
43
|
+
response = put_request("invoices/#{id}", body: {invoice: params})
|
44
|
+
Invoice.new(response.body["invoice"]) if response.success?
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete(id:)
|
48
|
+
response = delete_request("invoices/#{id}")
|
49
|
+
response.success?
|
50
|
+
end
|
51
|
+
|
52
|
+
def email(id:, to:, **params)
|
53
|
+
attributes = {to: to}
|
54
|
+
response = post_request("invoices/#{id}/send_email", body: {invoice: {email: attributes.merge(params)}})
|
55
|
+
response.success?
|
56
|
+
end
|
57
|
+
|
58
|
+
def mark_as_sent(id:)
|
59
|
+
response = put_request("invoices/#{id}/transitions/mark_as_sent", body: {})
|
60
|
+
response.success?
|
61
|
+
end
|
62
|
+
|
63
|
+
def mark_as_scheduled(id:)
|
64
|
+
response = put_request("invoices/#{id}/transitions/mark_as_scheduled", body: {})
|
65
|
+
response.success?
|
66
|
+
end
|
67
|
+
|
68
|
+
def mark_as_draft(id:)
|
69
|
+
response = put_request("invoices/#{id}/transitions/mark_as_draft", body: {})
|
70
|
+
response.success?
|
71
|
+
end
|
72
|
+
|
73
|
+
def mark_as_cancelled(id:)
|
74
|
+
response = put_request("invoices/#{id}/transitions/mark_as_cancelled", body: {})
|
75
|
+
response.success?
|
76
|
+
end
|
77
|
+
|
78
|
+
def convert_to_credit_note(id:)
|
79
|
+
response = put_request("invoices/#{id}/transitions/convert_to_credit_note", body: {})
|
80
|
+
response.success?
|
81
|
+
end
|
82
|
+
|
83
|
+
def direct_debit(id:)
|
84
|
+
response = post_request("invoices/#{id}/direct_debit", body: {})
|
85
|
+
response.success?
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class ProjectsResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("projects", params: params)
|
6
|
+
Collection.from_response(response, type: Project, key: "projects")
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_for_contact(contact:, **params)
|
10
|
+
response = get_request("projects?contact=#{contact}", params: params)
|
11
|
+
Collection.from_response(response, type: Project, key: "projects")
|
12
|
+
end
|
13
|
+
|
14
|
+
def retrieve(id:)
|
15
|
+
response = get_request("projects/#{id}")
|
16
|
+
Project.new(response.body["project"])
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(contact:, name:, status:, currency:, budget_units:, **params)
|
20
|
+
attributes = {contact: contact, name: name, status: status, currency: currency, budget_units: budget_units}
|
21
|
+
|
22
|
+
response = post_request("projects", body: attributes.merge(params))
|
23
|
+
Project.new(response.body["project"]) if response.success?
|
24
|
+
end
|
25
|
+
|
26
|
+
def update(id:, **params)
|
27
|
+
response = put_request("projects/#{id}", body: params)
|
28
|
+
Project.new(response.body["project"]) if response.success?
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(id:)
|
32
|
+
response = delete_request("projects/#{id}")
|
33
|
+
response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class TasksResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("tasks", params: params)
|
6
|
+
Collection.from_response(response, type: Task, key: "tasks")
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_for_project(project:, **params)
|
10
|
+
response = get_request("tasks?project=#{project}", params: params)
|
11
|
+
Collection.from_response(response, type: Task, key: "tasks")
|
12
|
+
end
|
13
|
+
|
14
|
+
def retrieve(id:)
|
15
|
+
response = get_request("tasks/#{id}")
|
16
|
+
Task.new(response.body["task"])
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(project:, name:, **params)
|
20
|
+
attributes = {project: project, name: name}
|
21
|
+
|
22
|
+
response = post_request("tasks", body: attributes.merge(params))
|
23
|
+
Task.new(response.body["task"]) if response.success?
|
24
|
+
end
|
25
|
+
|
26
|
+
def update(id:, **params)
|
27
|
+
response = put_request("tasks/#{id}", body: params)
|
28
|
+
Task.new(response.body["task"]) if response.success?
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(id:)
|
32
|
+
response = delete_request("tasks/#{id}")
|
33
|
+
response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class TimeslipsResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("timeslips", params: params)
|
6
|
+
Collection.from_response(response, type: Timeslip, key: "timeslips")
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_for_user(user:, **params)
|
10
|
+
response = get_request("timeslips?user=#{user}", params: params)
|
11
|
+
Collection.from_response(response, type: Timeslip, key: "timeslips")
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_for_task(task:, **params)
|
15
|
+
response = get_request("timeslips?task=#{task}", params: params)
|
16
|
+
Collection.from_response(response, type: Timeslip, key: "timeslips")
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_for_project(project:, **params)
|
20
|
+
response = get_request("timeslips?project=#{project}", params: params)
|
21
|
+
Collection.from_response(response, type: Timeslip, key: "timeslips")
|
22
|
+
end
|
23
|
+
|
24
|
+
def retrieve(id:)
|
25
|
+
response = get_request("timeslips/#{id}")
|
26
|
+
Timeslip.new(response.body["timeslip"])
|
27
|
+
end
|
28
|
+
|
29
|
+
def create(task:, user:, project:, dated_on:, hours:, **params)
|
30
|
+
attributes = {task: task, user: user, project: project, dated_on: dated_on, hours: hours}
|
31
|
+
|
32
|
+
response = post_request("timeslips", body: attributes.merge(params))
|
33
|
+
Timeslip.new(response.body["timeslip"]) if response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
def update(id:, **params)
|
37
|
+
response = put_request("timeslips/#{id}", body: params)
|
38
|
+
Timeslip.new(response.body["timeslip"]) if response.success?
|
39
|
+
end
|
40
|
+
|
41
|
+
def delete(id:)
|
42
|
+
response = delete_request("timeslips/#{id}")
|
43
|
+
response.success?
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module FreeAgent
|
2
|
+
class UsersResource < Resource
|
3
|
+
|
4
|
+
def me
|
5
|
+
response = get_request("users/me")
|
6
|
+
User.new(response.body["user"])
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(**params)
|
10
|
+
response = get_request("users", params: params)
|
11
|
+
Collection.from_response(response, type: User, key: "users")
|
12
|
+
end
|
13
|
+
|
14
|
+
def retrieve(id:)
|
15
|
+
response = get_request("users/#{id}")
|
16
|
+
User.new(response.body["user"])
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(email:, first_name:, last_name:, role:, opening_mileage: 0, **params)
|
20
|
+
attributes = {email: email, first_name: first_name, last_name: last_name, role: role, opening_mileage: opening_mileage}
|
21
|
+
|
22
|
+
response = post_request("users", body: attributes.merge(params))
|
23
|
+
User.new(response.body["user"]) if response.success?
|
24
|
+
end
|
25
|
+
|
26
|
+
def update(id:, **params)
|
27
|
+
response = put_request("users/#{id}", body: params)
|
28
|
+
User.new(response.body["user"]) if response.success?
|
29
|
+
end
|
30
|
+
|
31
|
+
def update_me(**params)
|
32
|
+
response = put_request("users/me", body: {user: params})
|
33
|
+
User.new(response.body["user"]) if response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete(id:)
|
37
|
+
response = delete_request("users/#{id}")
|
38
|
+
response.success?
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/lib/free_agent.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "faraday/multipart"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
require_relative "free_agent/version"
|
7
|
+
|
8
|
+
module FreeAgent
|
9
|
+
|
10
|
+
autoload :Client, "free_agent/client"
|
11
|
+
autoload :Collection, "free_agent/collection"
|
12
|
+
autoload :Error, "free_agent/error"
|
13
|
+
autoload :Resource, "free_agent/resource"
|
14
|
+
autoload :Object, "free_agent/object"
|
15
|
+
|
16
|
+
autoload :CompanyResource, "free_agent/resources/company"
|
17
|
+
autoload :ContactsResource, "free_agent/resources/contacts"
|
18
|
+
autoload :BankAccountsResource, "free_agent/resources/bank_accounts"
|
19
|
+
autoload :BankTransactionsResource, "free_agent/resources/bank_transactions"
|
20
|
+
autoload :BankTransactionExplanationsResource, "free_agent/resources/bank_transaction_explanations"
|
21
|
+
autoload :ProjectsResource, "free_agent/resources/projects"
|
22
|
+
autoload :TasksResource, "free_agent/resources/tasks"
|
23
|
+
autoload :TimeslipsResource, "free_agent/resources/timeslips"
|
24
|
+
autoload :UsersResource, "free_agent/resources/users"
|
25
|
+
autoload :AttachmentsResource, "free_agent/resources/attachments"
|
26
|
+
autoload :InvoicesResource, "free_agent/resources/invoices"
|
27
|
+
autoload :EstimatesResource, "free_agent/resources/estimates"
|
28
|
+
autoload :EstimateItemsResource, "free_agent/resources/estimate_items"
|
29
|
+
autoload :CreditNotesResource, "free_agent/resources/credit_notes"
|
30
|
+
autoload :BillsResource, "free_agent/resources/bills"
|
31
|
+
|
32
|
+
autoload :Company, "free_agent/objects/company"
|
33
|
+
autoload :Contact, "free_agent/objects/contact"
|
34
|
+
autoload :BankAccount, "free_agent/objects/bank_account"
|
35
|
+
autoload :BankTransaction, "free_agent/objects/bank_transaction"
|
36
|
+
autoload :BankTransactionExplanation, "free_agent/objects/bank_transaction_explanation"
|
37
|
+
autoload :Project, "free_agent/objects/project"
|
38
|
+
autoload :Task, "free_agent/objects/task"
|
39
|
+
autoload :Timeslip, "free_agent/objects/timeslip"
|
40
|
+
autoload :User, "free_agent/objects/user"
|
41
|
+
autoload :Attachment, "free_agent/objects/attachment"
|
42
|
+
autoload :Invoice, "free_agent/objects/invoice"
|
43
|
+
autoload :Estimate, "free_agent/objects/estimate"
|
44
|
+
autoload :EstimateItem, "free_agent/objects/estimate_item"
|
45
|
+
autoload :CreditNote, "free_agent/objects/credit_note"
|
46
|
+
autoload :Bill, "free_agent/objects/bill"
|
47
|
+
|
48
|
+
end
|
data/lib/freeagentrb.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "free_agent"
|