Class: UploadFuse::Client
- Inherits:
-
Object
- Object
- UploadFuse::Client
- Defined in:
- lib/upload_fuse/client.rb
Constant Summary collapse
- BASE_URL =
"https://uploadfuse.com/api/v1"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
- #connection ⇒ Object
-
#connection_upload ⇒ Object
Uses Faraday Multipart (lostisland/faraday-multipart).
-
#initialize(access_token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #uploads ⇒ Object
Constructor Details
#initialize(access_token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
7 8 9 10 11 12 13 |
# File 'lib/upload_fuse/client.rb', line 7 def initialize(access_token:, adapter: Faraday.default_adapter, stubs: nil) @access_token = access_token @adapter = adapter # Test stubs for requests @stubs = stubs end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/upload_fuse/client.rb', line 5 def access_token @access_token end |
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/upload_fuse/client.rb', line 5 def adapter @adapter end |
Instance Method Details
#connection ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/upload_fuse/client.rb', line 19 def connection @connection ||= Faraday.new(BASE_URL + "?api_token=#{access_token}") do |conn| # conn.request :authorization, :Bearer, access_token conn.headers = { "User-Agent" => "uploadfuse/v#{VERSION} (github.com/deanpcmad/uploadfuse)", "Accept" => "application/json", "Content-Type" => "application/json", } conn.request :json conn.response :json conn.adapter adapter, @stubs end end |
#connection_upload ⇒ Object
Uses Faraday Multipart (lostisland/faraday-multipart)
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/upload_fuse/client.rb', line 37 def connection_upload @connection ||= Faraday.new(BASE_URL + "?api_token=#{access_token}") do |conn| # conn.request :authorization, :Bearer, access_token conn.request :multipart conn.headers = { "User-Agent" => "uploadfuse/v#{VERSION} (github.com/deanpcmad/uploadfuse)" } end end |
#uploads ⇒ Object
15 16 17 |
# File 'lib/upload_fuse/client.rb', line 15 def uploads UploadsResource.new(self) end |