class GpWebpay::Ws::WsResponse

Public Class Methods

from_fault_error(hash, exception, merchant_number) click to toggle source
# File lib/gp_webpay/ws/ws_response.rb, line 18
def self.from_fault_error(hash, exception, merchant_number)
  validation_response = hash.dig(:fault, :detail, exception)
  new(
    original_response: hash,
    params: validation_response,
    status: :error,
    pr_code: validation_response[:primary_return_code],
    sr_code: validation_response[:secondary_return_code],
    result_text: hash.dig(:fault, :faultstring),
    merchant_number: merchant_number
  )
end
from_http_error(hash, merchant_number) click to toggle source
# File lib/gp_webpay/ws/ws_response.rb, line 31
def self.from_http_error(hash, merchant_number)
  new(
    original_response: hash,
    params: {},
    status: :error,
    pr_code: nil,
    sr_code: nil,
    result_text: "Internal HTTP request error: '#{hash[:code]}'",
    merchant_number: merchant_number
  )
end
from_success(hash, response_name, response_entity_name, merchant_number) click to toggle source
# File lib/gp_webpay/ws/ws_response.rb, line 4
def self.from_success(hash, response_name, response_entity_name, merchant_number)
  validation_response = hash.dig(response_name, response_entity_name)
  new(
    original_response: hash,
    params: validation_response,
    status: validation_response[:status],
    token: validation_response[:token_data],
    pr_code: validation_response[:primary_return_code],
    sr_code: validation_response[:secondary_return_code],
    merchant_number: merchant_number,
    result_text: 'OK'
  )
end

Public Instance Methods

success?() click to toggle source
# File lib/gp_webpay/ws/ws_response.rb, line 47
def success?
  @success ||= (status != :error)
end
valid?() click to toggle source
# File lib/gp_webpay/ws/ws_response.rb, line 43
def valid?
  @valid ||= GpWebpay::Ws::ValidateResult.call(params, config)
end