Class: Io::Flow::V0::Models::CreditMemoForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::CreditMemoForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
A credit memo form defines the information needed to create a credit memo. You must provide a way to identify the refund issued - either by id, key or identifier.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#refund_id ⇒ Object
readonly
Returns the value of attribute refund_id.
-
#refund_identifier ⇒ Object
readonly
Returns the value of attribute refund_identifier.
-
#refund_key ⇒ Object
readonly
Returns the value of attribute refund_key.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ CreditMemoForm
constructor
A new instance of CreditMemoForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ CreditMemoForm
Returns a new instance of CreditMemoForm.
34342 34343 34344 34345 34346 34347 34348 34349 34350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34342 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:lines], 'CreditMemoForm') @refund_id = (x = opts.delete(:refund_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('refund_id', x, String)) @refund_key = (x = opts.delete(:refund_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('refund_key', x, String)) @refund_identifier = (x = opts.delete(:refund_identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('refund_identifier', x, String)) @lines = HttpClient::Preconditions.assert_class('lines', opts.delete(:lines), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLineForm) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLineForm.from_json(x)) } @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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
34340 34341 34342 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34340 def attributes @attributes end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
34340 34341 34342 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34340 def lines @lines end |
#refund_id ⇒ Object (readonly)
Returns the value of attribute refund_id.
34340 34341 34342 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34340 def refund_id @refund_id end |
#refund_identifier ⇒ Object (readonly)
Returns the value of attribute refund_identifier.
34340 34341 34342 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34340 def refund_identifier @refund_identifier end |
#refund_key ⇒ Object (readonly)
Returns the value of attribute refund_key.
34340 34341 34342 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34340 def refund_key @refund_key end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
34356 34357 34358 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34356 def copy(incoming={}) CreditMemoForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
34360 34361 34362 34363 34364 34365 34366 34367 34368 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34360 def to_hash { :refund_id => refund_id, :refund_key => refund_key, :refund_identifier => refund_identifier, :lines => lines.map { |o| o.to_hash }, :attributes => attributes.nil? ? nil : attributes } end |
#to_json ⇒ Object
34352 34353 34354 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34352 def to_json JSON.dump(to_hash) end |