Module: AlmaApi

Defined in:
lib/alma_api.rb,
lib/alma_api/client.rb,
lib/alma_api/version.rb,
lib/alma_api/configuration.rb

Defined Under Namespace

Classes: Client, Configuration, Error, GatewayError, LogicalError, ServerError

Constant Summary collapse

DEFAULT_ERROR_CODE =
"UNKNOWN".freeze
DEFAULT_ERROR_MESSAGE =
"Unknown cause".freeze
GATEWAY_ERROR_CODES =
[
  "GENERAL_ERROR",
  "UNAUTHORIZED",
  "INVALID_REQUEST",
  "PER_SECOND_THRESHOLD",
  "DAILY_THRESHOLD",
  "REQUEST_TOO_LARGE",
  "FORBIDDEN",
  "ROUTING_ERROR"
].freeze
VERSION =
"1.0.1".freeze

Class Method Summary collapse

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:

  • (configuration)


41
42
43
44
45
# File 'lib/alma_api.rb', line 41

def configure
  configuration = Configuration.new
  yield(configuration) if block_given?
  Client.new(configuration)
end

.validate_format!(format) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/alma_api.rb', line 47

def validate_format!(format)
  case format = format.presence&.to_s
  when "json", "xml" then format
  when nil then nil
  else
    raise ArgumentError, "Unsupported format '#{format}'. Only 'json' and 'xml' is supported."
  end
end