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.



37717
37718
37719
37720
37721
37722
37723
37724
37725
37726
37727
37728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37717

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.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def flow_order_id
  @flow_order_id
end

#incotermObject (readonly)

Returns the value of attribute incoterm.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def incoterm
  @incoterm
end

#itemsObject (readonly)

Returns the value of attribute items.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def items
  @items
end

#merchant_of_recordObject (readonly)

Returns the value of attribute merchant_of_record.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def merchant_of_record
  @merchant_of_record
end

#merchant_of_record_entityObject (readonly)

Returns the value of attribute merchant_of_record_entity.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def merchant_of_record_entity
  @merchant_of_record_entity
end

#pricesObject (readonly)

Returns the value of attribute prices.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def prices
  @prices
end

#tax_registrationObject (readonly)

Returns the value of attribute tax_registration.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def tax_registration
  @tax_registration
end

#totalObject (readonly)

Returns the value of attribute total.



37715
37716
37717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37715

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37734
37735
37736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37734

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

#to_hashObject



37738
37739
37740
37741
37742
37743
37744
37745
37746
37747
37748
37749
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37738

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



37730
37731
37732
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37730

def to_json
  JSON.dump(to_hash)
end