Sha256: 7ed645c5466cb5d46a24abbdef4f155009da27e339140247e47248a47018a79b

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require 'httparty'
require_relative './bayonet_client/version'
require_relative './bayonet_client/response.rb'
require_relative './bayonet_client/exceptions.rb'
require_relative './bayonet_client/ecommerce.rb'
require_relative './bayonet_client/lending.rb'
require_relative './bayonet_client/device_fingerprint.rb'

module BayonetClient
  DEFAULT_HTTP_TIMEOUT = 10

  def self.configure(api_key, version, timeout = DEFAULT_HTTP_TIMEOUT)
    if version.nil? || version.empty?
      message = 'Please specify Api version'
      raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
    end
    if api_key.nil? || api_key.empty?
      message = 'Please specify Api key'
      raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
    end
    unless timeout.is_a? Numeric
      message = 'Please specify a valid timeout value'
      raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
    end
    unless BayonetClient::SUPPORTED_API_VERSIONS.include?(version)
      message = 'This library does not support the version specified. Please consider updating your dependencies'
      raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
    end

    @api_key = api_key
    @version = version
    @timeout = timeout
  end

  class << self
    attr_reader :api_key
    attr_reader :version
    attr_reader :timeout
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bayonet_client-2.4.0 lib/bayonet_client.rb
bayonet_client-2.3.0 lib/bayonet_client.rb