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.



8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8487

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :authorization, :amount, :currency, :created_at], '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)
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



8485
8486
8487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8485

def amount
  @amount
end

#authorizationObject (readonly)

Returns the value of attribute authorization.



8485
8486
8487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8485

def authorization
  @authorization
end

#created_atObject (readonly)

Returns the value of attribute created_at.



8485
8486
8487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8485

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



8485
8486
8487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8485

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



8485
8486
8487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8485

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



8485
8486
8487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8485

def key
  @key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



8502
8503
8504
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8502

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

#to_hashObject



8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8506

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

#to_jsonObject



8498
8499
8500
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8498

def to_json
  JSON.dump(to_hash)
end