Class: Io::Flow::V0::Models::Reversal
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Reversal
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
A reversal is used to clear an authorization (full or partial).
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#authorization ⇒ Object
readonly
Returns the value of attribute authorization.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#requested ⇒ Object
readonly
Returns the value of attribute requested.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Reversal
constructor
A new instance of Reversal.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Reversal
Returns a new instance of Reversal.
25879 25880 25881 25882 25883 25884 25885 25886 25887 25888 25889 25890 25891 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25879 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :key, :authorization, :status, :amount, :currency, :requested, :created_at, :attributes], 'Reversal') @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)) @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::ReversalStatus) ? x : ::Io::Flow::V0::Models::ReversalStatus.apply(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) @requested = (x = opts.delete(:requested); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x)) @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime) @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h } end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def amount @amount end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def attributes @attributes end |
#authorization ⇒ Object (readonly)
Returns the value of attribute authorization.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def @authorization end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def created_at @created_at end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def currency @currency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def key @key end |
#requested ⇒ Object (readonly)
Returns the value of attribute requested.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def requested @requested end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
25877 25878 25879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25877 def status @status end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
25897 25898 25899 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25897 def copy(incoming={}) Reversal.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
25901 25902 25903 25904 25905 25906 25907 25908 25909 25910 25911 25912 25913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25901 def to_hash { :id => id, :key => key, :authorization => .to_hash, :status => status.value, :amount => amount, :currency => currency, :requested => requested.to_hash, :created_at => created_at, :attributes => attributes } end |
#to_json ⇒ Object
25893 25894 25895 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25893 def to_json JSON.dump(to_hash) end |