Method: PureIterator::Base#initialize

Defined in:
lib/pure_iterator/base.rb

#initialize(config) ⇒ Base

Returns a new instance of Base.

Parameters:

  • config (Hash)

Options Hash (config):

  • :host (String)

    Pure host

  • :username (String)

    Username of the Pure host account

  • :password (String)

    Password of the Pure host account

  • :api_key (String)

    API key of the Pure host account

  • :api_version (Integer)

    Pure API version



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pure_iterator/base.rb', line 12

def initialize(config)
  required = [:host, :username, :password, :api_key, :api_version]
  required.each do |r|
    raise ArgumentError, "Pure #{r} not set" unless config[r] && !config[r].to_s.empty?
  end
  http_client = HTTP::Client.new
  http_client = http_client.headers({ 'api-key' => config[:api_key] })
  http_client = http_client.basic_auth({user: config[:username], pass: config[:password]})
  @http_client = http_client
  @host = config[:host]
  @api_version = config[:api_version].to_s
  accept :xml
end