Sha256: 77755670da454988043bd41bc46968ef84319da2de70967f0d5ba99fad9aaefe

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 Bytes

Contents

module DesignerNews
  module Connection
    def request(method, path, data, options={})
      @last_response = response = connection.send(method, URI.encode(path.to_s), data, options)
      JSON.parse(response.body)
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dn-0.1.0 lib/designer_news/mixins/connection.rb
dn-0.0.1 lib/designer_news/mixins/connection.rb