Class: Io::Flow::V0::Models::PaymentOrderDetailsLineItem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentOrderDetailsLineItem

Returns a new instance of PaymentOrderDetailsLineItem.



53794
53795
53796
53797
53798
53799
53800
53801
53802
53803
53804
53805
53806
53807
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53794

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :description, :quantity, :amount], 'PaymentOrderDetailsLineItem')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String)
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentTax) ? x : ::Io::Flow::V0::Models::PaymentTax.new(x)))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentDuty) ? x : ::Io::Flow::V0::Models::PaymentDuty.new(x)))
  @product_url = (x = opts.delete(:product_url); x.nil? ? nil : HttpClient::Preconditions.assert_class('product_url', x, String))
  @image_url = (x = opts.delete(:image_url); x.nil? ? nil : HttpClient::Preconditions.assert_class('image_url', x, String))
  @category = (x = opts.delete(:category); x.nil? ? nil : HttpClient::Preconditions.assert_class('category', x, String))
  @discounts = (x = opts.delete(:discounts); x.nil? ? nil : HttpClient::Preconditions.assert_class('discounts', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentDiscount) ? x : ::Io::Flow::V0::Models::PaymentDiscount.new(x)) })
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def amount
  @amount
end

#categoryObject (readonly)

Returns the value of attribute category.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def category
  @category
end

#descriptionObject (readonly)

Returns the value of attribute description.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def description
  @description
end

#discountsObject (readonly)

Returns the value of attribute discounts.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def discounts
  @discounts
end

#dutyObject (readonly)

Returns the value of attribute duty.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def duty
  @duty
end

#idObject (readonly)

Returns the value of attribute id.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def id
  @id
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def image_url
  @image_url
end

#product_urlObject (readonly)

Returns the value of attribute product_url.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def product_url
  @product_url
end

#quantityObject (readonly)

Returns the value of attribute quantity.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def quantity
  @quantity
end

#taxObject (readonly)

Returns the value of attribute tax.



53792
53793
53794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53792

def tax
  @tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



53813
53814
53815
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53813

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

#to_hashObject



53817
53818
53819
53820
53821
53822
53823
53824
53825
53826
53827
53828
53829
53830
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53817

def to_hash
  {
    :id => id,
    :description => description,
    :quantity => quantity,
    :amount => amount.to_f.to_s,
    :tax => tax.nil? ? nil : tax.to_hash,
    :duty => duty.nil? ? nil : duty.to_hash,
    :product_url => product_url,
    :image_url => image_url,
    :category => category,
    :discounts => discounts.nil? ? nil : discounts.map { |o| o.to_hash }
  }
end

#to_jsonObject



53809
53810
53811
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53809

def to_json
  JSON.dump(to_hash)
end