Class: Io::Flow::V0::Models::B2bCreditMemo

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

The b2b credit memo represents a refund transaction between Flow and one of our clients

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ B2bCreditMemo

Returns a new instance of B2bCreditMemo.



29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29571

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :number, :buyer, :seller, :status, :date, :key, :invoice, :lines, :documents, :attributes], 'B2bCreditMemo')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @buyer = (x = opts.delete(:buyer); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecordEntity) ? x : ::Io::Flow::V0::Models::MerchantOfRecordEntity.new(x))
  @seller = (x = opts.delete(:seller); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecordEntity) ? x : ::Io::Flow::V0::Models::MerchantOfRecordEntity.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceStatus) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceStatus.apply(x))
  @date = HttpClient::Preconditions.assert_class('date', HttpClient::Helper.to_date_time_iso8601(opts.delete(:date)), DateTime)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @invoice = (x = opts.delete(:invoice); x.is_a?(::Io::Flow::V0::Models::B2bInvoiceReference) ? x : ::Io::Flow::V0::Models::B2bInvoiceReference.new(x))
  @lines = HttpClient::Preconditions.assert_class('lines', opts.delete(:lines), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLine) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLine.from_json(x)) }
  @documents = HttpClient::Preconditions.assert_class('documents', opts.delete(:documents), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceDocument) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceDocument.new(x)) }
  @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 }
  @b2b_invoice_type = (x = (x = opts.delete(:b2b_invoice_type); x.nil? ? "self_bill_invoice" : x); x.is_a?(::Io::Flow::V0::Models::B2bInvoiceType) ? x : ::Io::Flow::V0::Models::B2bInvoiceType.apply(x))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def attributes
  @attributes
end

#b2b_invoice_typeObject (readonly)

Returns the value of attribute b2b_invoice_type.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def b2b_invoice_type
  @b2b_invoice_type
end

#buyerObject (readonly)

Returns the value of attribute buyer.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def buyer
  @buyer
end

#dateObject (readonly)

Returns the value of attribute date.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def date
  @date
end

#documentsObject (readonly)

Returns the value of attribute documents.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def documents
  @documents
end

#idObject (readonly)

Returns the value of attribute id.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def id
  @id
end

#invoiceObject (readonly)

Returns the value of attribute invoice.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def invoice
  @invoice
end

#keyObject (readonly)

Returns the value of attribute key.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def key
  @key
end

#linesObject (readonly)

Returns the value of attribute lines.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def lines
  @lines
end

#numberObject (readonly)

Returns the value of attribute number.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def number
  @number
end

#sellerObject (readonly)

Returns the value of attribute seller.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def seller
  @seller
end

#statusObject (readonly)

Returns the value of attribute status.



29569
29570
29571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29569

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



29592
29593
29594
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29592

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

#to_hashObject



29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29596

def to_hash
  {
    :id => id,
    :number => number,
    :buyer => buyer.to_hash,
    :seller => seller.to_hash,
    :status => status.value,
    :date => date,
    :key => key,
    :invoice => invoice.to_hash,
    :lines => lines.map { |o| o.to_hash },
    :documents => documents.map { |o| o.to_hash },
    :attributes => attributes,
    :b2b_invoice_type => b2b_invoice_type.value
  }
end

#to_jsonObject



29588
29589
29590
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29588

def to_json
  JSON.dump(to_hash)
end