Class: AbsorbApi::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/absorb_api/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApi

Returns a new instance of Api.



5
6
7
8
9
10
11
12
13
14
# File 'lib/absorb_api/api.rb', line 5

def initialize
  @token = AbsorbApi::Authorize.new.token

  @connection ||= Faraday.new(url: AbsorbApi.configuration.url, parallel_manager: Typhoeus::Hydra.new(max_concurrency: 200)) do |faraday|
    faraday.request :json
    faraday.response :json, content_type: /\bjson$/
    faraday.adapter :typhoeus
    faraday.headers = { 'Authorization' => @token }
  end
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



3
4
5
# File 'lib/absorb_api/api.rb', line 3

def connection
  @connection
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/absorb_api/api.rb', line 3

def token
  @token
end