Sha256: 40c662023011c3f4880b446d5edbfe61f7f089ae7a00d9cc34e9f7eb0f834390

Contents?: true

Size: 951 Bytes

Versions: 3

Compression:

Stored size: 951 Bytes

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
      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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rsqoot-0.5.2 lib/rsqoot.rb
rsqoot-0.5.1 lib/rsqoot.rb
rsqoot-0.5.0 lib/rsqoot.rb