Module: DesignerNews::Connection
- Included in:
- Client
- Defined in:
- lib/designer_news/mixins/connection.rb
Instance Method Summary collapse
Instance Method Details
#connection ⇒ Object
8 9 10 11 12 13 |
# File 'lib/designer_news/mixins/connection.rb', line 8 def connection @connection ||= Faraday.new(url: @api_endpoint, builder: @middleware) do |conn| conn.headers[:user_agent] = user_agent conn.headers[:Authorization] = "Bearer #{access_token}" end end |
#request(method, path, data, options = {}) ⇒ Object
3 4 5 6 |
# File 'lib/designer_news/mixins/connection.rb', line 3 def request(method, path, data, ={}) @last_response = response = connection.send(method, URI.encode(path.to_s), data, ) JSON.parse(response.body) end |