class Fastbill::Automatic::Request::Validator
Attributes
info[R]
response[RW]
Public Class Methods
new(info)
click to toggle source
# File lib/fastbill-automatic/request/validator.rb, line 8 def initialize(info) @info = info end
Public Instance Methods
validated_data_for(incoming_response)
click to toggle source
# File lib/fastbill-automatic/request/validator.rb, line 12 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 Instance Methods
validate_response_data()
click to toggle source
# File lib/fastbill-automatic/request/validator.rb, line 27 def validate_response_data raise APIError.new(info.data["RESPONSE"]["ERRORS"]) if info.data["RESPONSE"]["ERRORS"] end
verify_response_code()
click to toggle source
# File lib/fastbill-automatic/request/validator.rb, line 22 def verify_response_code raise AuthenticationError if response.code.to_i == 401 raise APIError if response.code.to_i >= 500 end