Class: Io::Flow::V0::Models::ShopifyOrderDeliveryMetafield

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

Overview

Model to represent a delivery metafield

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyOrderDeliveryMetafield

Returns a new instance of ShopifyOrderDeliveryMetafield.



63158
63159
63160
63161
63162
63163
63164
63165
63166
63167
63168
63169
63170
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63158

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:items, :service, :window], 'ShopifyOrderDeliveryMetafield')
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShopifyOrderDeliveryMetafieldItem) ? x : ::Io::Flow::V0::Models::ShopifyOrderDeliveryMetafieldItem.new(x)) }
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::ServiceSummary) ? x : ::Io::Flow::V0::Models::ServiceSummary.new(x))
  @window = (x = opts.delete(:window); x.is_a?(::Io::Flow::V0::Models::DeliveryWindow) ? x : ::Io::Flow::V0::Models::DeliveryWindow.new(x))
  @liability = (x = opts.delete(:liability); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::RatecardOwner) ? x : ::Io::Flow::V0::Models::RatecardOwner.apply(x)))
  @cost = (x = opts.delete(:cost); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::MoneyWithOptionalBase) ? x : ::Io::Flow::V0::Models::MoneyWithOptionalBase.new(x)))
  @prices = (x = opts.delete(:prices); x.nil? ? nil : HttpClient::Preconditions.assert_class('prices', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShopifyPrice) ? x : ::Io::Flow::V0::Models::ShopifyPrice.new(x)) })
  @total = (x = opts.delete(:total); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShopifyPrice) ? x : ::Io::Flow::V0::Models::ShopifyPrice.new(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)))
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def cost
  @cost
end

#itemsObject (readonly)

Returns the value of attribute items.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def key
  @key
end

#liabilityObject (readonly)

Returns the value of attribute liability.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def liability
  @liability
end

#merchant_of_record_entityObject (readonly)

Returns the value of attribute merchant_of_record_entity.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def merchant_of_record_entity
  @merchant_of_record_entity
end

#pricesObject (readonly)

Returns the value of attribute prices.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def prices
  @prices
end

#serviceObject (readonly)

Returns the value of attribute service.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def service
  @service
end

#totalObject (readonly)

Returns the value of attribute total.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def total
  @total
end

#windowObject (readonly)

Returns the value of attribute window.



63156
63157
63158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63156

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



63176
63177
63178
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63176

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

#to_hashObject



63180
63181
63182
63183
63184
63185
63186
63187
63188
63189
63190
63191
63192
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63180

def to_hash
  {
    :key => key,
    :items => items.map { |o| o.to_hash },
    :service => service.to_hash,
    :window => window.to_hash,
    :liability => liability.nil? ? nil : liability.value,
    :cost => cost.nil? ? nil : cost.to_hash,
    :prices => prices.nil? ? nil : prices.map { |o| o.to_hash },
    :total => total.nil? ? nil : total.to_hash,
    :merchant_of_record_entity => merchant_of_record_entity.nil? ? nil : merchant_of_record_entity.to_hash
  }
end

#to_jsonObject



63172
63173
63174
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63172

def to_json
  JSON.dump(to_hash)
end