Class: FreeAgent::Client
- Inherits:
-
Object
- Object
- FreeAgent::Client
- Defined in:
- lib/free_agent/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.freeagent.com/v2"
- SANDBOX_BASE_URL =
"https://api.sandbox.freeagent.com/v2"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
Instance Method Summary collapse
- #attachments ⇒ Object
- #bank_accounts ⇒ Object
- #bank_transaction_explanations ⇒ Object
- #bank_transactions ⇒ Object
- #bills ⇒ Object
- #company ⇒ Object
- #connection ⇒ Object
-
#connection_upload ⇒ Object
Uses Faraday Multipart (lostisland/faraday-multipart).
- #contacts ⇒ Object
- #credit_notes ⇒ Object
- #estimate_items ⇒ Object
- #estimates ⇒ Object
-
#initialize(access_token:, sandbox: false, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #invoices ⇒ Object
- #projects ⇒ Object
- #tasks ⇒ Object
- #timeslips ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(access_token:, sandbox: false, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 |
# File 'lib/free_agent/client.rb', line 8 def initialize(access_token:, sandbox: false, adapter: Faraday.default_adapter, stubs: nil) @access_token = access_token @sandbox = sandbox @adapter = adapter # Test stubs for requests @stubs = stubs end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/free_agent/client.rb', line 6 def access_token @access_token end |
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
6 7 8 |
# File 'lib/free_agent/client.rb', line 6 def adapter @adapter end |
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
6 7 8 |
# File 'lib/free_agent/client.rb', line 6 def sandbox @sandbox end |
Instance Method Details
#attachments ⇒ Object
53 54 55 |
# File 'lib/free_agent/client.rb', line 53 def AttachmentsResource.new(self) end |
#bank_accounts ⇒ Object
25 26 27 |
# File 'lib/free_agent/client.rb', line 25 def bank_accounts BankAccountsResource.new(self) end |
#bank_transaction_explanations ⇒ Object
33 34 35 |
# File 'lib/free_agent/client.rb', line 33 def bank_transaction_explanations BankTransactionExplanationsResource.new(self) end |
#bank_transactions ⇒ Object
29 30 31 |
# File 'lib/free_agent/client.rb', line 29 def bank_transactions BankTransactionsResource.new(self) end |
#bills ⇒ Object
73 74 75 |
# File 'lib/free_agent/client.rb', line 73 def bills BillsResource.new(self) end |
#company ⇒ Object
17 18 19 |
# File 'lib/free_agent/client.rb', line 17 def company CompanyResource.new(self) end |
#connection ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/free_agent/client.rb', line 77 def connection url = (sandbox == true ? SANDBOX_BASE_URL : BASE_URL) @connection ||= Faraday.new(url) do |conn| conn.request :authorization, :Bearer, access_token conn.request :json conn.response :dates conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#connection_upload ⇒ Object
Uses Faraday Multipart (lostisland/faraday-multipart)
91 92 93 94 95 96 97 |
# File 'lib/free_agent/client.rb', line 91 def connection_upload url = (sandbox == true ? SANDBOX_BASE_URL : BASE_URL) @connection ||= Faraday.new(url) do |conn| conn.request :authorization, :Bearer, access_token conn.request :multipart end end |
#contacts ⇒ Object
21 22 23 |
# File 'lib/free_agent/client.rb', line 21 def contacts ContactsResource.new(self) end |
#credit_notes ⇒ Object
69 70 71 |
# File 'lib/free_agent/client.rb', line 69 def credit_notes CreditNotesResource.new(self) end |
#estimate_items ⇒ Object
65 66 67 |
# File 'lib/free_agent/client.rb', line 65 def estimate_items EstimateItemsResource.new(self) end |
#estimates ⇒ Object
61 62 63 |
# File 'lib/free_agent/client.rb', line 61 def estimates EstimatesResource.new(self) end |
#invoices ⇒ Object
57 58 59 |
# File 'lib/free_agent/client.rb', line 57 def invoices InvoicesResource.new(self) end |
#projects ⇒ Object
37 38 39 |
# File 'lib/free_agent/client.rb', line 37 def projects ProjectsResource.new(self) end |
#tasks ⇒ Object
41 42 43 |
# File 'lib/free_agent/client.rb', line 41 def tasks TasksResource.new(self) end |
#timeslips ⇒ Object
45 46 47 |
# File 'lib/free_agent/client.rb', line 45 def timeslips TimeslipsResource.new(self) end |
#users ⇒ Object
49 50 51 |
# File 'lib/free_agent/client.rb', line 49 def users UsersResource.new(self) end |