Class: Io::Flow::V0::Models::CreditMemoForm

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#attributesObject (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

#linesObject (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_idObject (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_identifierObject (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_keyObject (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_hashObject



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_jsonObject



34352
34353
34354
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34352

def to_json
  JSON.dump(to_hash)
end