Sha256: 5a61f89acf262a24f14d6af0e7f99529fbe662cfd53ad542c1c5c5cdb5d1b72a

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

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

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
  RSqoot::Logger.logger error: e
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rsqoot-0.5.5 lib/rsqoot.rb