Sha256: 209860d7fa0e956b040981c096396a50e4a013f229103e9aeee79e5c0c85379b
Contents?: true
Size: 774 Bytes
Versions: 2
Compression:
Stored size: 774 Bytes
Contents
module Fulfillment class Response extend Forwardable attr_reader :raw_response, :errors delegate [:body, :status] => :raw_response def initialize(raw_response) @raw_response = raw_response end def success? (200..299).include?(status) end def on_error yield self unless success? self end 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fulfillment-api-1.1.9 | lib/fulfillment/response.rb |
fulfillment-api-1.1.7 | lib/fulfillment/response.rb |