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.



37313
37314
37315
37316
37317
37318
37319
37320
37321
37322
37323
37324
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37313

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.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def flow_order_id
  @flow_order_id
end

#incotermObject (readonly)

Returns the value of attribute incoterm.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def incoterm
  @incoterm
end

#itemsObject (readonly)

Returns the value of attribute items.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def items
  @items
end

#merchant_of_recordObject (readonly)

Returns the value of attribute merchant_of_record.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def merchant_of_record
  @merchant_of_record
end

#merchant_of_record_entityObject (readonly)

Returns the value of attribute merchant_of_record_entity.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def merchant_of_record_entity
  @merchant_of_record_entity
end

#pricesObject (readonly)

Returns the value of attribute prices.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def prices
  @prices
end

#tax_registrationObject (readonly)

Returns the value of attribute tax_registration.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def tax_registration
  @tax_registration
end

#totalObject (readonly)

Returns the value of attribute total.



37311
37312
37313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37311

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37330
37331
37332
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37330

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

#to_hashObject



37334
37335
37336
37337
37338
37339
37340
37341
37342
37343
37344
37345
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37334

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



37326
37327
37328
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37326

def to_json
  JSON.dump(to_hash)
end