Source: models/ProductItem.js

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2. /* Copyright (c) 2020 Mobify Research & Development Inc. All rights reserved. */
  3. /* * * * * * * * * * * * * * * * * * * * * * * * * * * */
  4. /**
  5. * Shop API
  6. * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
  7. *
  8. * OpenAPI spec version: 20.4
  9. *
  10. *
  11. * NOTE: This class is auto generated by the swagger code generator program.
  12. * https://github.com/swagger-api/swagger-codegen.git
  13. * Do not edit the class manually.
  14. *
  15. */
  16. import ApiClient from '../ApiClient'
  17. import OptionItem from './OptionItem'
  18. import PriceAdjustment from './PriceAdjustment'
  19. import ProductListItemReference from './ProductListItemReference'
  20. /**
  21. * The ProductItem model module.
  22. * @module models/ProductItem
  23. * @version 20.4
  24. */
  25. export default class ProductItem {
  26. /**
  27. * Constructs a new <code>ProductItem</code>.
  28. * Document representing a product item.
  29. * @alias module:models/ProductItem
  30. * @class
  31. * @param quantity {Number} The quantity of the products represented by this item.
  32. */
  33. constructor(quantity) {
  34. this.quantity = quantity
  35. }
  36. /**
  37. * Constructs a <code>ProductItem</code> from a plain JavaScript object, optionally creating a new instance.
  38. * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
  39. * @param {Object} data The plain JavaScript object bearing properties of interest.
  40. * @param {module:models/ProductItem} obj Optional instance to populate.
  41. * @return {module:models/ProductItem} The populated <code>ProductItem</code> instance.
  42. */
  43. static constructFromObject(data, obj) {
  44. if (data) {
  45. obj = obj || new ProductItem()
  46. if (data.hasOwnProperty('adjusted_tax')) {
  47. obj.adjusted_tax = ApiClient.convertToType(data.adjusted_tax, 'Number')
  48. }
  49. if (data.hasOwnProperty('base_price')) {
  50. obj.base_price = ApiClient.convertToType(data.base_price, 'Number')
  51. }
  52. if (data.hasOwnProperty('bonus_discount_line_item_id')) {
  53. obj.bonus_discount_line_item_id = ApiClient.convertToType(data.bonus_discount_line_item_id, 'String')
  54. }
  55. if (data.hasOwnProperty('bonus_product_line_item')) {
  56. obj.bonus_product_line_item = ApiClient.convertToType(data.bonus_product_line_item, 'Boolean')
  57. }
  58. if (data.hasOwnProperty('bundled_product_items')) {
  59. obj.bundled_product_items = ApiClient.convertToType(data.bundled_product_items, [ProductItem])
  60. }
  61. if (data.hasOwnProperty('c_fromStoreId')) {
  62. obj.c_fromStoreId = ApiClient.convertToType(data.c_fromStoreId, 'String')
  63. }
  64. if (data.hasOwnProperty('gift')) {
  65. obj.gift = ApiClient.convertToType(data.gift, 'Boolean')
  66. }
  67. if (data.hasOwnProperty('gift_message')) {
  68. obj.gift_message = ApiClient.convertToType(data.gift_message, 'String')
  69. }
  70. if (data.hasOwnProperty('inventory_id')) {
  71. obj.inventory_id = ApiClient.convertToType(data.inventory_id, 'String')
  72. }
  73. if (data.hasOwnProperty('item_id')) {
  74. obj.item_id = ApiClient.convertToType(data.item_id, 'String')
  75. }
  76. if (data.hasOwnProperty('item_text')) {
  77. obj.item_text = ApiClient.convertToType(data.item_text, 'String')
  78. }
  79. if (data.hasOwnProperty('option_items')) {
  80. obj.option_items = ApiClient.convertToType(data.option_items, [OptionItem])
  81. }
  82. if (data.hasOwnProperty('price')) {
  83. obj.price = ApiClient.convertToType(data.price, 'Number')
  84. }
  85. if (data.hasOwnProperty('price_adjustments')) {
  86. obj.price_adjustments = ApiClient.convertToType(data.price_adjustments, [PriceAdjustment])
  87. }
  88. if (data.hasOwnProperty('price_after_item_discount')) {
  89. obj.price_after_item_discount = ApiClient.convertToType(data.price_after_item_discount, 'Number')
  90. }
  91. if (data.hasOwnProperty('price_after_order_discount')) {
  92. obj.price_after_order_discount = ApiClient.convertToType(data.price_after_order_discount, 'Number')
  93. }
  94. if (data.hasOwnProperty('product_id')) {
  95. obj.product_id = ApiClient.convertToType(data.product_id, 'String')
  96. }
  97. if (data.hasOwnProperty('product_list_item')) {
  98. obj.product_list_item = ProductListItemReference.constructFromObject(data.product_list_item)
  99. }
  100. if (data.hasOwnProperty('product_name')) {
  101. obj.product_name = ApiClient.convertToType(data.product_name, 'String')
  102. }
  103. if (data.hasOwnProperty('quantity')) {
  104. obj.quantity = ApiClient.convertToType(data.quantity, 'Number')
  105. }
  106. if (data.hasOwnProperty('shipment_id')) {
  107. obj.shipment_id = ApiClient.convertToType(data.shipment_id, 'String')
  108. }
  109. if (data.hasOwnProperty('shipping_item_id')) {
  110. obj.shipping_item_id = ApiClient.convertToType(data.shipping_item_id, 'String')
  111. }
  112. if (data.hasOwnProperty('tax')) {
  113. obj.tax = ApiClient.convertToType(data.tax, 'Number')
  114. }
  115. if (data.hasOwnProperty('tax_basis')) {
  116. obj.tax_basis = ApiClient.convertToType(data.tax_basis, 'Number')
  117. }
  118. if (data.hasOwnProperty('tax_class_id')) {
  119. obj.tax_class_id = ApiClient.convertToType(data.tax_class_id, 'String')
  120. }
  121. if (data.hasOwnProperty('tax_rate')) {
  122. obj.tax_rate = ApiClient.convertToType(data.tax_rate, 'Number')
  123. }
  124. }
  125. return obj
  126. }
  127. /**
  128. * The tax of the product item after adjustments applying.
  129. * @member {Number} adjusted_tax
  130. */
  131. adjusted_tax = undefined;
  132. /**
  133. * The base price for the line item, which is the price of the unit before applying adjustments, in the purchase currency. The base price may be net or gross of tax depending on the configured taxation policy.
  134. * @member {Number} base_price
  135. */
  136. base_price = undefined;
  137. /**
  138. * The id of the bonus discount line item this bonus product relates to.
  139. * @member {String} bonus_discount_line_item_id
  140. */
  141. bonus_discount_line_item_id = undefined;
  142. /**
  143. * A flag indicating whether the product item is a bonus.
  144. * @member {Boolean} bonus_product_line_item
  145. */
  146. bonus_product_line_item = undefined;
  147. /**
  148. * The array of bundled product items. Can be empty.
  149. * @member {Array.<module:models/ProductItem>} bundled_product_items
  150. */
  151. bundled_product_items = undefined;
  152. /**
  153. * Links the store to the product line item for grouping shipments in the checkout process.
  154. * @member {String} c_fromStoreId
  155. */
  156. c_fromStoreId = undefined;
  157. /**
  158. * Returns true if the item is a gift.
  159. * @member {Boolean} gift
  160. */
  161. gift = undefined;
  162. /**
  163. * The gift message.
  164. * @member {String} gift_message
  165. */
  166. gift_message = undefined;
  167. /**
  168. * The inventory list id associated with this item.
  169. * @member {String} inventory_id
  170. */
  171. inventory_id = undefined;
  172. /**
  173. * The item identifier. Use this to identify an item when updating the item quantity or creating a custom price adjustment for an item.
  174. * @member {String} item_id
  175. */
  176. item_id = undefined;
  177. /**
  178. * The text describing the item in more detail.
  179. * @member {String} item_text
  180. */
  181. item_text = undefined;
  182. /**
  183. * The array of option items. This array can be empty.
  184. * @member {Array.<module:models/OptionItem>} option_items
  185. */
  186. option_items = undefined;
  187. /**
  188. * The price of the line item before applying any adjustments. If the line item is based on net pricing then the net price is returned. If the line item is based on gross pricing then the gross price is returned.
  189. * @member {Number} price
  190. */
  191. price = undefined;
  192. /**
  193. * Array of price adjustments. Can be empty.
  194. * @member {Array.<module:models/PriceAdjustment>} price_adjustments
  195. */
  196. price_adjustments = undefined;
  197. /**
  198. * The price of the product line item after applying all product-level adjustments. For net pricing the adjusted net price is returned. For gross pricing, the adjusted gross price is returned.
  199. * @member {Number} price_after_item_discount
  200. */
  201. price_after_item_discount = undefined;
  202. /**
  203. * The price of this product line item after considering all dependent price adjustments and prorating all order-level price adjustments. For net pricing the net price is returned. For gross pricing, the gross price is returned.
  204. * @member {Number} price_after_order_discount
  205. */
  206. price_after_order_discount = undefined;
  207. /**
  208. *
  209. * @member {String} product_id
  210. */
  211. product_id = undefined;
  212. /**
  213. *
  214. * @member {module:models/ProductListItemReference} product_list_item
  215. */
  216. product_list_item = undefined;
  217. /**
  218. * The name of the product.
  219. * @member {String} product_name
  220. */
  221. product_name = undefined;
  222. /**
  223. * The quantity of the products represented by this item.
  224. * @member {Number} quantity
  225. */
  226. quantity = undefined;
  227. /**
  228. * The id of the shipment which includes the product item.
  229. * @member {String} shipment_id
  230. */
  231. shipment_id = undefined;
  232. /**
  233. * The reference to the related shipping item if it exists. This is the case if for example when a surcharge is defined for individual products using a particular a shipping method.
  234. * @member {String} shipping_item_id
  235. */
  236. shipping_item_id = undefined;
  237. /**
  238. * The tax of the product item before adjustments applying.
  239. * @member {Number} tax
  240. */
  241. tax = undefined;
  242. /**
  243. * The price used to calculate the tax for this product item.
  244. * @member {Number} tax_basis
  245. */
  246. tax_basis = undefined;
  247. /**
  248. * The tax class ID for the product item or null if no tax class ID is associated with the product item.
  249. * @member {String} tax_class_id
  250. */
  251. tax_class_id = undefined;
  252. /**
  253. * The tax rate, which is the decimal tax rate to be applied to the product represented by this item.
  254. * @member {Number} tax_rate
  255. */
  256. tax_rate = undefined;
  257. }