Class: EwayRapid::Message::Convert::Request::RefundToDirectRefundReq

Inherits:
Object
  • Object
show all
Defined in:
lib/eway_rapid/message/convert/request/refund_to_direct_refund_req.rb

Instance Method Summary collapse

Instance Method Details

#do_convert(refund) ⇒ DirectRefundRequest

Parameters:

Returns:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/eway_rapid/message/convert/request/refund_to_direct_refund_req.rb', line 9

def do_convert(refund)
  request = DirectRefundRequest.new

  if refund
    shipping_convert = ShippingDetailsToAddress.new
    customer_convert = CustomerToInternalCustomer.new
    request.refund = refund.refund_details
    request.shipping_address = shipping_convert.do_convert(refund.shipping_details)
    request.customer = customer_convert.do_convert(refund.customer)
    request.partner_id = refund.partner_id
    request.device_id = refund.device_id
    request.line_items = refund.line_items

    # @type [Array]
    list_options = refund.options

    if list_options && list_options.length > 0
      list_convert = []
      list_options.each do |value|
        op = InternalModels::Option.new
        op.value = value
        list_convert.push(op)
      end
      request.options = list_convert
    end
  end
  request
end