Class: Io::Flow::V0::Models::Capture

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

Overview

Capture actually transfers funds. You can capture as many times as you’d like up until the total amount of the authorization has been captured or the authorization otherwise becomes unavailable (e.g. expires).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Capture

Returns a new instance of Capture.



6510
6511
6512
6513
6514
6515
6516
6517
6518
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6510

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :authorization, :amount, :currency], 'Capture')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @authorization = (x = opts.delete(:authorization); x.is_a?(::Io::Flow::V0::Models::AuthorizationReference) ? x : ::Io::Flow::V0::Models::AuthorizationReference.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)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



6508
6509
6510
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6508

def amount
  @amount
end

#authorizationObject (readonly)

Returns the value of attribute authorization.



6508
6509
6510
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6508

def authorization
  @authorization
end

#currencyObject (readonly)

Returns the value of attribute currency.



6508
6509
6510
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6508

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



6508
6509
6510
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6508

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



6508
6509
6510
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6508

def key
  @key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



6524
6525
6526
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6524

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

#to_hashObject



6528
6529
6530
6531
6532
6533
6534
6535
6536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6528

def to_hash
  {
    :id => id,
    :key => key,
    :authorization => authorization.to_hash,
    :amount => amount,
    :currency => currency
  }
end

#to_jsonObject



6520
6521
6522
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6520

def to_json
  JSON.dump(to_hash)
end