Sha256: 038ec053aec182e11bb6225e2d1747c0118c4f0d5a99d5643d25a709c41e898f
Contents?: true
Size: 795 Bytes
Versions: 2
Compression:
Stored size: 795 Bytes
Contents
module Fastbill module Automatic module Request class Validator attr_reader :info attr_accessor :response def initialize(info) @info = info end def validated_data_for(incoming_response) self.response = incoming_response verify_response_code info.data = JSON.parse(response.body) validate_response_data info.data end protected def verify_response_code raise AuthenticationError if response.code.to_i == 401 raise APIError if response.code.to_i >= 500 end def validate_response_data raise APIError.new(info.data["RESPONSE"]["ERRORS"]) if info.data["RESPONSE"]["ERRORS"] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fastbill-automatic-0.0.4 | lib/fastbill-automatic/request/validator.rb |
fastbill-automatic-0.0.3 | lib/fastbill-automatic/request/validator.rb |