Method: Itrp::Client#initialize

Defined in:
lib/itrp/client.rb

#initialize(options = {}) ⇒ Client

Create a new ITRP Client

Shared configuration for all ITRP Clients:

Itrp.configure do |config|
  config.api_token = 'd41f5868feb65fc87fa2311a473a8766ea38bc40'
  config.account = 'my-sandbox'
  ...
end

Override configuration per ITRP Client: itrp = Itrp::Client.new(account: ‘trusted-sandbox’)

All options available:

- logger:      The Ruby Logger instance, default: Logger.new(STDOUT)
- host:        The ITRP API host, default: 'https://api.itrp.com'
- api_version: The ITRP API version, default: 'v1'
- api_token:   *required* The ITRP API token
- account:     Specify a different (trusted) account to work with
               @see http://developer.itrp.com/v1/#multiple-accounts
- source:      The Source used when creating new records
               @see http://developer.itrp.com/v1/general/source/

- max_retry_time: maximum nr of seconds to wait for server to respond (default = 5400 = 1.5 hours)
                  the sleep time between retries starts at 2 seconds and doubles after each retry
                  retry times: 2, 6, 18, 54, 162, 486, 1458, 4374, 13122, ... seconds
                  one retry will always be performed unless you set the value to -1
- read_timeout:   HTTP GET read timeout in seconds (default = 25)
- block_at_rate_limit: Set to +true+ to block the request until the rate limit is lifted, default: +false+
                       @see http://developer.itrp.com/v1/#rate-limiting

- proxy_host:     Define in case HTTP traffic needs to go through a proxy
- proxy_port:     Port of the proxy, defaults to 8080
- proxy_user:     Proxy user
- proxy_password: Proxy password


60
61
62
63
64
65
66
67
68
# File 'lib/itrp/client.rb', line 60

def initialize(options = {})
  @options = Itrp.configuration.current.merge(options)
  [:host, :api_version, :api_token].each do |required_option|
    raise ::Itrp::Exception.new("Missing required configuration option #{required_option}") if option(required_option).blank?
  end
  @ssl, @domain, @port = ssl_domain_port_path(option(:host))
  @ssl_verify_none = options[:ssl_verify_none]
  @logger = @options[:logger]
end