Module: AboutYou::SDK::Model::BasketVariantItem

Included in:
BasketItem, BasketSetItem
Defined in:
lib/AboutYou/Model/Basket/basket_variant_item.rb

Overview

BasketVairantItem is a class representing a basket variant item

See Also:

  • \Collins\ShopApi\Model\Variant
  • \Collins\ShopApi\Model\Basket
  • \Collins\ShopApi

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



16
17
18
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 16

def app_id
  @app_id
end

#json_objectObject

Returns the value of attribute json_object.



12
13
14
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 12

def json_object
  @json_object
end

#productObject

Returns the value of attribute product.



13
14
15
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 13

def product
  @product
end

#variantObject

Get the product variant.

Returns:

  • Variant



91
92
93
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 91

def variant
  @variant
end

#variant_idObject

Returns the value of attribute variant_id.



15
16
17
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 15

def variant_id
  @variant_id
end

Instance Method Details

#check_app_id(app_id) ⇒ Object



116
117
118
119
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 116

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) ⇒ Object



111
112
113
114
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 111

def check_variant_id(variant_id)
  fail '\InvalidArgumentException! the variant id must be
    an integer' unless variant_id.is_a?(Integer)
end

#errors?Boolean

Returns boolean.

Returns:

  • (Boolean)

    boolean



39
40
41
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 39

def errors?
  error_code > 0
end

#initialize(variant_id, additional_data = nil, app_id = nil) ⇒ Object

Constructor.

Parameters:

  • integer

    $variant_id

  • array

    $additional_data



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 24

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 unless app_id

  check_app_id(app_id)
  self.app_id = app_id
end

#old_priceObject

Get the variant old price in euro cents.

Returns:

  • integer



82
83
84
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 82

def old_price
  variant.old_price
end

#taxObject

Get the tax.

Returns:

  • integer



57
58
59
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 57

def tax
  json_object['tax']
end

#total_netObject

Returns integer.

Returns:

  • integer



73
74
75
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 73

def total_net
  json_object['total_net']
end

#total_priceObject

Get the total price.

Returns:

  • integer



48
49
50
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 48

def total_price
  json_object['total_price']
end

#total_vatObject

Get the value added tax.

Returns:

  • integer



66
67
68
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 66

def total_vat
  json_object['total_vat']
end

#unique_keyObject

Returns string.

Returns:

  • string



101
102
103
104
105
106
107
108
109
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 101

def unique_key
  key = variant_id
  if additionalData
    additionalData.sort!
    key += ':' + additionalData.to_json
  end

  key
end