Class: Ravelin::ProxyClient

Inherits:
Client
  • Object
show all
Defined in:
lib/ravelin/proxy_client.rb

Constant Summary

Constants inherited from Client

Client::API_BASE

Instance Method Summary collapse

Methods inherited from Client

#delete_tag, #get_tag, #send_backfill_event, #send_event, #send_tag

Constructor Details

#initialize(base_url:, username:, password:, api_version: 2) ⇒ ProxyClient

Returns a new instance of ProxyClient.

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ravelin/proxy_client.rb', line 3

def initialize(base_url:, username:, password:, api_version: 2)

  raise ArgumentError, "api_version must be 2 or 3" unless [2,3].include? api_version
  @api_version = api_version
  @url_prefix = '/ravelinproxy'

  @connection = Faraday.new(base_url, faraday_proxy_options) do |conn|
    conn.response :json, context_type: /\bjson$/
    conn.adapter Ravelin.faraday_adapter
    conn.basic_auth(username, password)
  end
end

Instance Method Details

#faraday_proxy_optionsObject



16
17
18
19
20
21
22
23
24
# File 'lib/ravelin/proxy_client.rb', line 16

def faraday_proxy_options
  {
    request: { timeout: Ravelin.faraday_timeout },
    headers: {
      'Content-Type'  => 'application/json; charset=utf-8'.freeze,
      'User-Agent'    => "Ravelin Proxy RubyGem/#{Ravelin::VERSION}".freeze
    }
  }
end