class Fulfillment::Response

Attributes

errors[R]
raw_response[R]

Public Class Methods

new(raw_response) click to toggle source
# File lib/fulfillment/response.rb, line 9
def initialize(raw_response)
  @raw_response = raw_response
end

Public Instance Methods

on_error() { |self| ... } click to toggle source
# File lib/fulfillment/response.rb, line 17
def on_error
  yield self unless success?
  self
end
raise_errors() click to toggle source
# File lib/fulfillment/response.rb, line 22
def raise_errors
  case status
  when 400
    fail InvalidRequest, body
  when 401
    fail AccessDenied, body
  when 403
    fail InvalidEvent, body
  when 404
    fail ResourceNotFound, body
  when 405
    fail MethodNotAllowed, body
  when (400..499)
    fail ServiceError, body
  when (500..599)
    fail ServerError, body
  end
end
success?() click to toggle source
# File lib/fulfillment/response.rb, line 13
def success?
  (200..299).include?(status)
end