Class: Envato::Client
- Inherits:
-
Object
- Object
- Envato::Client
- Defined in:
- lib/envato/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.envato.com"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #bookmarks ⇒ Object
- #connection ⇒ Object
-
#initialize(token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #item ⇒ Object
- #market ⇒ Object
- #markets ⇒ Object
- #search ⇒ Object
- #user ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/envato/client.rb', line 9 def initialize(token:, adapter: Faraday.default_adapter, stubs: nil) @token = token @adapter = adapter @stubs = stubs # Test stubs for requests end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/envato/client.rb', line 7 def adapter @adapter end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/envato/client.rb', line 7 def token @token end |
Instance Method Details
#bookmarks ⇒ Object
35 36 37 |
# File 'lib/envato/client.rb', line 35 def bookmarks BookmarksResource.new(self) end |
#connection ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/envato/client.rb', line 43 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :authorization, :Bearer, token conn.request :json conn.request :url_encoded conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#item ⇒ Object
39 40 41 |
# File 'lib/envato/client.rb', line 39 def item ItemResource.new(self) end |
#market ⇒ Object
27 28 29 |
# File 'lib/envato/client.rb', line 27 def market MarketResource.new(self) end |
#markets ⇒ Object
31 32 33 |
# File 'lib/envato/client.rb', line 31 def markets MarketsResource.new(self) end |
#search ⇒ Object
23 24 25 |
# File 'lib/envato/client.rb', line 23 def search SearchResource.new(self) end |
#user ⇒ Object
15 16 17 |
# File 'lib/envato/client.rb', line 15 def user UserResource.new(self) end |
#users ⇒ Object
19 20 21 |
# File 'lib/envato/client.rb', line 19 def users UsersResource.new(self) end |