Class: Io::Flow::V0::Models::ShopifyOrderMetafieldValue

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

Overview

Model to represent details available in an order metafield.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyOrderMetafieldValue

Returns a new instance of ShopifyOrderMetafieldValue.



38482
38483
38484
38485
38486
38487
38488
38489
38490
38491
38492
38493
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38482

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:items, :prices, :total], 'ShopifyOrderMetafieldValue')
  @merchant_of_record = (x = (x = opts.delete(:merchant_of_record); x.nil? ? "flow" : x); x.is_a?(::Io::Flow::V0::Models::OrderMerchantOfRecord) ? x : ::Io::Flow::V0::Models::OrderMerchantOfRecord.apply(x))
  @merchant_of_record_entity = (x = opts.delete(:merchant_of_record_entity); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::MerchantOfRecordEntity) ? x : ::Io::Flow::V0::Models::MerchantOfRecordEntity.new(x)))
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LocalizedLineItem) ? x : ::Io::Flow::V0::Models::LocalizedLineItem.new(x)) }
  @prices = HttpClient::Preconditions.assert_class('prices', opts.delete(:prices), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x)) }
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::LocalizedTotal) ? x : ::Io::Flow::V0::Models::LocalizedTotal.new(x))
  @flow_order_id = (x = opts.delete(:flow_order_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('flow_order_id', x, String))
  @incoterm = (x = opts.delete(:incoterm); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Incoterm) ? x : ::Io::Flow::V0::Models::Incoterm.apply(x)))
  @tax_registration = (x = opts.delete(:tax_registration); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::TaxRegistration) ? x : ::Io::Flow::V0::Models::TaxRegistration.new(x)))
end

Instance Attribute Details

#flow_order_idObject (readonly)

Returns the value of attribute flow_order_id.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def flow_order_id
  @flow_order_id
end

#incotermObject (readonly)

Returns the value of attribute incoterm.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def incoterm
  @incoterm
end

#itemsObject (readonly)

Returns the value of attribute items.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def items
  @items
end

#merchant_of_recordObject (readonly)

Returns the value of attribute merchant_of_record.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def merchant_of_record
  @merchant_of_record
end

#merchant_of_record_entityObject (readonly)

Returns the value of attribute merchant_of_record_entity.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def merchant_of_record_entity
  @merchant_of_record_entity
end

#pricesObject (readonly)

Returns the value of attribute prices.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def prices
  @prices
end

#tax_registrationObject (readonly)

Returns the value of attribute tax_registration.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def tax_registration
  @tax_registration
end

#totalObject (readonly)

Returns the value of attribute total.



38480
38481
38482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38480

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



38499
38500
38501
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38499

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

#to_hashObject



38503
38504
38505
38506
38507
38508
38509
38510
38511
38512
38513
38514
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38503

def to_hash
  {
    :merchant_of_record => merchant_of_record.value,
    :merchant_of_record_entity => merchant_of_record_entity.nil? ? nil : merchant_of_record_entity.to_hash,
    :items => items.map { |o| o.to_hash },
    :prices => prices.map { |o| o.to_hash },
    :total => total.to_hash,
    :flow_order_id => flow_order_id,
    :incoterm => incoterm.nil? ? nil : incoterm.value,
    :tax_registration => tax_registration.nil? ? nil : tax_registration.to_hash
  }
end

#to_jsonObject



38495
38496
38497
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38495

def to_json
  JSON.dump(to_hash)
end