module AboutYou::SDK::Model::BasketVariantItem

BasketVairantItem is a class representing a basket variant item

Attributes

app_id[RW]

the app id of this variant item

json_object[RW]

the json object from which this instance was created from

product[RW]

the product of this variant item

variant[RW]

the variant of this variant item

variant_id[RW]

the variant id of this variant item

Public Class Methods

new(variant_id, additional_data = nil, app_id = nil) click to toggle source

Constructor for the AboutYou::SDK::Model::BasketVariantItem class

  • Args :

    • variant_id -> the id of the variant item

    • additional_data -> additional data of the variant item

    • app_id -> the app id for the variant item

  • Returns :

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 30
def initialize(variant_id, additional_data = nil, app_id = nil)
  check_variant_id(variant_id)
  check_addition_data(additional_data)
  self.variant_od = variant_id
  self.additional_data = additional_data

  return self unless app_id

  check_app_id(app_id)
  self.app_id = app_id

  self
end

Public Instance Methods

check_app_id(app_id) click to toggle source

This method checks if an app id is valid

  • Fails :

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 150
def check_app_id(app_id)
  fail '\InvalidArgumentException! the app id must be
    an integer' unless app_id.is_a?(Integer)
end
check_variant_id(variant_id) click to toggle source

This method checks if a variant id is valid

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 139
def check_variant_id(variant_id)
  fail '\InvalidArgumentException! the variant id must be
    an integer' unless variant_id.is_a?(Integer)
end
errors?() click to toggle source

This method checks if there are errors in the variant item

  • Returns :

    • Boolean determining whether there are errors or not

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 50
def errors?
  error_code > 0
end
old_price() click to toggle source

Getter for the old price of the variant

  • Returns :

    • an Integer containing the old price of the variant

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 100
def old_price
  variant.old_price
end
tax() click to toggle source

Getter for the tax

  • Returns :

    • an Integer containing the tax

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 70
def tax
  json_object['tax']
end
total_net() click to toggle source

Getter for the total net

  • Returns :

    • an Integer containing the total net

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 90
def total_net
  json_object['total_net']
end
total_price() click to toggle source

Getter for the total price

  • Returns :

    • an Integer containing the total price

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 60
def total_price
  json_object['total_price']
end
total_vat() click to toggle source

Getter for the total vat

  • Returns :

    • an Integer containing the total vat

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 80
def total_vat
  json_object['total_vat']
end
unique_key() click to toggle source

This method is used for creating a unique key for the basket set

  • Returns :

    • a String containing a unique key for the basket set

# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 123
def unique_key
  key = variant_id
  if additionalData
    additionalData.sort!
    key += ':' + additionalData.to_json
  end

  key
end