Module: Mirakl

Defined in:
lib/mirakl.rb,
lib/mirakl/util.rb,
lib/mirakl/errors.rb,
lib/mirakl/version.rb,
lib/mirakl/requests/s07.rb,
lib/mirakl/requests/s20.rb,
lib/mirakl/mirakl_client.rb,
lib/mirakl/mirakl_object.rb,
lib/mirakl/requests/dr11.rb,
lib/mirakl/requests/dr12.rb,
lib/mirakl/requests/dr74.rb,
lib/mirakl/mirakl_response.rb,
lib/mirakl/api_operations/request.rb

Defined Under Namespace

Modules: ApiOperations, Requests, Util Classes: APIError, AuthenticationError, InvalidRequestError, MiraklClient, MiraklError, MiraklObject, MiraklResponse

Constant Summary collapse

LEVEL_DEBUG =

map to the same values as the standard library’s logger

Logger::DEBUG
LEVEL_ERROR =
Logger::ERROR
LEVEL_INFO =
Logger::INFO
UnauthorizedError =
Class.new(MiraklError)
ForbiddenError =
Class.new(MiraklError)
ApiRequestsQuotaReachedError =
Class.new(MiraklError)
NotFoundError =
Class.new(MiraklError)
MethodNotAllowedError =
Class.new(MiraklError)
NotAcceptableError =
Class.new(MiraklError)
GoneError =
Class.new(MiraklError)
UnsupportedMediaTypeError =
Class.new(MiraklError)
TooManyRequestsError =
Class.new(MiraklError)
VERSION =
"0.0.3".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_baseObject

Returns the value of attribute api_base.



44
45
46
# File 'lib/mirakl.rb', line 44

def api_base
  @api_base
end

.api_keyObject

Returns the value of attribute api_key.



44
45
46
# File 'lib/mirakl.rb', line 44

def api_key
  @api_key
end

.open_timeoutObject

Returns the value of attribute open_timeout.



44
45
46
# File 'lib/mirakl.rb', line 44

def open_timeout
  @open_timeout
end

.read_timeoutObject

Returns the value of attribute read_timeout.



44
45
46
# File 'lib/mirakl.rb', line 44

def read_timeout
  @read_timeout
end

Class Method Details

.log_levelObject

When set prompts the library to log some extra information to $stdout and $stderr about what it’s doing. For example, it’ll produce information about requests, responses, and errors that are received. Valid log levels are ‘debug` and `info`, with `debug` being a little more verbose in places.

Use of this configuration is only useful when ‘.logger` is not set. When it is, the decision what levels to print is entirely deferred to the logger.



59
60
61
# File 'lib/mirakl.rb', line 59

def self.log_level
  @log_level
end

.log_level=(val) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mirakl.rb', line 63

def self.log_level=(val)
  # Backwards compatibility for values that we briefly allowed
  if val == "debug"
    val = LEVEL_DEBUG
  elsif val == "info"
    val = LEVEL_INFO
  end

  if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
    raise ArgumentError,
          "log_level should only be set to `nil`, `debug` or `info`"
  end
  @log_level = val
end

.loggerObject

Sets a logger to which logging output will be sent. The logger should support the same interface as the ‘Logger` class that’s part of Ruby’s standard library (hint, anything in ‘Rails.logger` will likely be suitable).

If ‘.logger` is set, the value of `.log_level` is ignored. The decision on what levels to print is entirely deferred to the logger.



85
86
87
# File 'lib/mirakl.rb', line 85

def self.logger
  @logger
end

.logger=(val) ⇒ Object



89
90
91
# File 'lib/mirakl.rb', line 89

def self.logger=(val)
  @logger = val
end