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.



28205
28206
28207
28208
28209
28210
28211
28212
28213
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28205

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.



28203
28204
28205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28203

def attributes
  @attributes
end

#linesObject (readonly)

Returns the value of attribute lines.



28203
28204
28205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28203

def lines
  @lines
end

#refund_idObject (readonly)

Returns the value of attribute refund_id.



28203
28204
28205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28203

def refund_id
  @refund_id
end

#refund_identifierObject (readonly)

Returns the value of attribute refund_identifier.



28203
28204
28205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28203

def refund_identifier
  @refund_identifier
end

#refund_keyObject (readonly)

Returns the value of attribute refund_key.



28203
28204
28205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28203

def refund_key
  @refund_key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28219
28220
28221
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28219

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

#to_hashObject



28223
28224
28225
28226
28227
28228
28229
28230
28231
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28223

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



28215
28216
28217
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28215

def to_json
  JSON.dump(to_hash)
end