Class: Io::Flow::V0::Models::RefundForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Refund actually transfers funds. You can refund as many times as you’d like up until the total amount of captured funds has been refunded. Note when creating a refund you can specify either an order authorization id, a capture id, or an order number (or all of them as long as they match).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ RefundForm

Returns a new instance of RefundForm.



58445
58446
58447
58448
58449
58450
58451
58452
58453
58454
58455
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58445

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @authorization_id = (x = opts.delete(:authorization_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_id', x, String))
  @capture_id = (x = opts.delete(:capture_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('capture_id', x, String))
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
  @amount = (x = opts.delete(:amount); x.nil? ? nil : HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @currency = (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String))
  @rma_key = (x = opts.delete(:rma_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('rma_key', x, String))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def attributes
  @attributes
end

#authorization_idObject (readonly)

Returns the value of attribute authorization_id.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def authorization_id
  @authorization_id
end

#capture_idObject (readonly)

Returns the value of attribute capture_id.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def capture_id
  @capture_id
end

#currencyObject (readonly)

Returns the value of attribute currency.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def currency
  @currency
end

#keyObject (readonly)

Returns the value of attribute key.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def key
  @key
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def order_number
  @order_number
end

#rma_keyObject (readonly)

Returns the value of attribute rma_key.



58443
58444
58445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58443

def rma_key
  @rma_key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



58461
58462
58463
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58461

def copy(incoming={})
  RefundForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



58465
58466
58467
58468
58469
58470
58471
58472
58473
58474
58475
58476
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58465

def to_hash
  {
    :authorization_id => authorization_id,
    :capture_id => capture_id,
    :order_number => order_number,
    :key => key,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :rma_key => rma_key,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



58457
58458
58459
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58457

def to_json
  JSON.dump(to_hash)
end