Class: GpWebpay::Ws::BaseSignedRequest

Inherits:
Service
  • Object
show all
Defined in:
lib/gp_webpay/ws/base_signed_request.rb

Constant Summary collapse

OPERATION_NAME =
'override_me'.freeze
REQUEST_NAME =
'override_me'.freeze
RESPONSE_NAME =
'override_me'.freeze
RESPONSE_ENTITY_NAME =
'override_me'.freeze
SERVICE_EXCEPTION =
:service_exception
DEFAULT_ATTRIBUTES =
{}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, merchant_number: :default) ⇒ BaseSignedRequest

Returns a new instance of BaseSignedRequest.



28
29
30
31
32
33
# File 'lib/gp_webpay/ws/base_signed_request.rb', line 28

def initialize(attributes, merchant_number: :default)
  @attributes = attributes
  @merchant_number = merchant_number
  @config = GpWebpay.config[@merchant_number] || GpWebpay.config.default
  super()
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



19
20
21
# File 'lib/gp_webpay/ws/base_signed_request.rb', line 19

def attributes
  @attributes
end

#configObject (readonly)

Returns the value of attribute config.



19
20
21
# File 'lib/gp_webpay/ws/base_signed_request.rb', line 19

def config
  @config
end

Instance Method Details

#callObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gp_webpay/ws/base_signed_request.rb', line 35

def call
  attrs = WsRequest.new(final_attributes).to_gpwebpay

  Rails.logger.debug([self.class::OPERATION_NAME, { message: { self.class::REQUEST_NAME => attributes_with_signature(attrs) } }])
  res = client.call(self.class::OPERATION_NAME, { message: { self.class::REQUEST_NAME => attributes_with_signature(attrs) } })
  WsResponse.from_success(res.body, self.class::RESPONSE_NAME, self.class::RESPONSE_ENTITY_NAME, config.merchant_number)
rescue Savon::HTTPError => e
  rescue_from_http(e)
rescue Savon::SOAPFault => e
  rescue_from_soap(e)
end