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.



37484
37485
37486
37487
37488
37489
37490
37491
37492
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37484

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.



37482
37483
37484
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37482

def attributes
  @attributes
end

#linesObject (readonly)

Returns the value of attribute lines.



37482
37483
37484
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37482

def lines
  @lines
end

#refund_idObject (readonly)

Returns the value of attribute refund_id.



37482
37483
37484
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37482

def refund_id
  @refund_id
end

#refund_identifierObject (readonly)

Returns the value of attribute refund_identifier.



37482
37483
37484
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37482

def refund_identifier
  @refund_identifier
end

#refund_keyObject (readonly)

Returns the value of attribute refund_key.



37482
37483
37484
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37482

def refund_key
  @refund_key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37498
37499
37500
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37498

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

#to_hashObject



37502
37503
37504
37505
37506
37507
37508
37509
37510
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37502

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



37494
37495
37496
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37494

def to_json
  JSON.dump(to_hash)
end