Sha256: 4278d5abed390c05128dc8df388eb1b38540fe4dc3aa4e418e1599a4974ffa7c

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require "active_support/core_ext"
require "rsqoot/client"

module RSqoot

  class << self
    attr_accessor :public_api_key, :private_api_key, :base_api_url, :authentication_method, :read_timeout, :expired_in

    # Configure default credentials easily
    #
    # @yield [RSqoot]
    def configure
      load_defaults
      yield self
      raise "You must add your own public api key to initializer ." if self.public_api_key.nil?
      raise "You must add your own private api key to initializer ." if self.private_api_key.nil?
      raise "Authentication method must be :header or :parameter ." if !AUTHENTICATION_METHODS.include? self.authentication_method
      SqootClient.reload!
      true
    end

    def load_defaults
      self.base_api_url ||= "https://api.sqoot.com"
      self.authentication_method = :header
      self.read_timeout = 60.seconds
      self.expired_in = 1.hour
    end

    private

    AUTHENTICATION_METHODS = [:header, :parameter]

  end

end

begin
  RSqoot.load_defaults
  SqootClient ||= RSqoot::Client.instance
rescue => e
  raise e
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rsqoot-0.5.4 lib/rsqoot.rb
rsqoot-0.5.3 lib/rsqoot.rb