Sha256: 30a267e00e1536a8c329f975d704726a7fdd3c6d77e15557ae9c6232adbfab7c

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

module Workarea
  module Forter
    class DecisionResponse
      def initialize(body)
        @body = body
      end

      def success?
        @body["status"] == "success"
      end

      def suspected_fraud?
        @body["action"] == "decline"
      end

      def action
        @body["action"]
      end

      def body_message
        @body["message"]
      end

      def reason_code
        @body["reasonCode"]
      end

      def errors
        @body["errors"]
      end

      def status
        @body["status"]
      end

      def mongoize
        @body
      end

      class << self
        def demongoize(object)
          return nil if object.blank?

          DecisionResponse.new(object)
        end

        def mongoize(object)
          case object
          when DecisionResponse then object.mongoize
          else object
          end
        end

        def evolve(object)
          raise 'querying on an Workarea::Forter::DecisionResponse is unsupported at this time'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-forter-1.3.2 lib/workarea/forter/decision_response.rb
workarea-forter-1.3.1 lib/workarea/forter/decision_response.rb
workarea-forter-1.3.0 lib/workarea/forter/decision_response.rb
workarea-forter-1.2.4 lib/workarea/forter/decision_response.rb
workarea-forter-1.2.3 lib/workarea/forter/decision_response.rb
workarea-forter-1.2.2 lib/workarea/forter/decision_response.rb