Class: Io::Flow::V0::Models::RefundCapture

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

Overview

Refund captures provide the detailed information on the amount refunded against a specific capture

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ RefundCapture

Returns a new instance of RefundCapture.



46285
46286
46287
46288
46289
46290
46291
46292
46293
46294
46295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46285

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :refund, :capture, :amount, :currency, :base], 'RefundCapture')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @refund = (x = opts.delete(:refund); x.is_a?(::Io::Flow::V0::Models::Refund) ? x : ::Io::Flow::V0::Models::Refund.new(x))
  @capture = (x = opts.delete(:capture); x.is_a?(::Io::Flow::V0::Models::Capture) ? x : ::Io::Flow::V0::Models::Capture.new(x))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @base = (x = opts.delete(:base); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x))
  @status = (x = (x = opts.delete(:status); x.nil? ? "succeeded" : x); x.is_a?(::Io::Flow::V0::Models::RefundStatus) ? x : ::Io::Flow::V0::Models::RefundStatus.apply(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



46283
46284
46285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46283

def amount
  @amount
end

#baseObject (readonly)

Returns the value of attribute base.



46283
46284
46285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46283

def base
  @base
end

#captureObject (readonly)

Returns the value of attribute capture.



46283
46284
46285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46283

def capture
  @capture
end

#currencyObject (readonly)

Returns the value of attribute currency.



46283
46284
46285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46283

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



46283
46284
46285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46283

def id
  @id
end

#refundObject (readonly)

Returns the value of attribute refund.



46283
46284
46285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46283

def refund
  @refund
end

#statusObject (readonly)

Returns the value of attribute status.



46283
46284
46285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46283

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



46301
46302
46303
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46301

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

#to_hashObject



46305
46306
46307
46308
46309
46310
46311
46312
46313
46314
46315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46305

def to_hash
  {
    :id => id,
    :refund => refund.to_hash,
    :capture => capture.to_hash,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :base => base.to_hash,
    :status => status.value
  }
end

#to_jsonObject



46297
46298
46299
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46297

def to_json
  JSON.dump(to_hash)
end