Class: Freefeed::Client
- Inherits:
-
Object
- Object
- Freefeed::Client
- Defined in:
- lib/freefeed/client.rb
Constant Summary collapse
- HOST =
'freefeed.net'.freeze
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#faraday_options ⇒ Object
Returns the value of attribute faraday_options.
-
#resources ⇒ Object
Returns the value of attribute resources.
Instance Method Summary collapse
- #authenticate(username:, password:) ⇒ Object
- #call!(verb, endpoint, params = {}, headers = {}) ⇒ Object
-
#initialize(api_token = nil, faraday_options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_token = nil, faraday_options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/freefeed/client.rb', line 7 def initialize(api_token = nil, = {}) @api_token = api_token @faraday_options = end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
5 6 7 |
# File 'lib/freefeed/client.rb', line 5 def api_token @api_token end |
#faraday_options ⇒ Object
Returns the value of attribute faraday_options.
5 6 7 |
# File 'lib/freefeed/client.rb', line 5 def @faraday_options end |
#resources ⇒ Object
Returns the value of attribute resources.
5 6 7 |
# File 'lib/freefeed/client.rb', line 5 def resources @resources end |
Instance Method Details
#authenticate(username:, password:) ⇒ Object
12 13 14 15 16 |
# File 'lib/freefeed/client.rb', line 12 def authenticate(username:, password:) Session.create(self, username: username, password: password).tap do |re| @api_token = re.fetch('authToken') end end |
#call!(verb, endpoint, params = {}, headers = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/freefeed/client.rb', line 18 def call!(verb, endpoint, params = {}, headers = {}) response = conn.send( verb, endpoint, params, auth_header.merge(headers) ) handle_erros(response) prepare_response(response) end |