Sha256: 61abe5ca91f70b55fe03fa513e4c25eb51c0719895b6d94455798edd6edfd5e3

Contents?: true

Size: 594 Bytes

Versions: 3

Compression:

Stored size: 594 Bytes

Contents

require 'cgi'

module CRP
  class ReviewCallbackResponse
    SUCCESS_STATUS_CODE = 200

    def initialize(response)
      @response = response
    end

    def successful?
      @response.code.to_i == SUCCESS_STATUS_CODE
    end

    def raw_review
      successful? ? CGI::parse(@response.body) : {}
    end

    def external_id
      raw_review["externalId"].first
    end

    def internal_id
      raw_review["internalId"].first
    end

    def result_code
      raw_review["result"].first.to_i
    end

    def result_message
      ResultMapper.to_message(result_code)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crp-0.0.3 lib/crp/review_callback_response.rb
crp-0.0.2 lib/crp/review_callback_response.rb
crp-0.0.1 lib/crp/review_callback_response.rb