UNPKG

3.73 kBJavaScriptView Raw
1/*******************************************************************************
2 *
3 * Copyright 2018 Adobe. All rights reserved.
4 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. You may obtain a copy
6 * of the License at http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software distributed under
9 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10 * OF ANY KIND, either express or implied. See the License for the specific language
11 * governing permissions and limitations under the License.
12 *
13 ******************************************************************************/
14
15/**
16 * Auto generated code based on Swagger definition.
17 * Dot not edit manually. Manual changes will be overridden.
18 *
19 * @version 1.1.2
20 */
21const ProductVariant = require('./ProductVariant.js').ProductVariant;
22const MoneyValue = require('./MoneyValue.js').MoneyValue;
23const Discount = require('./Discount.js').Discount;
24const TaxInfo = require('./TaxInfo.js').TaxInfo;
25
26class CartEntry {
27
28 /**
29 * Constructs a CartEntry based on its enclosed builder.
30 * @constructor
31 * @param {Builder} builder the CartEntry builder
32 */
33 constructor(builder) {
34
35 /**
36 * The cart entry price after all discounts have been applied.
37 * @type {MoneyValue}
38 */
39 this.discountedPrice = undefined;
40
41 /**
42 * A list of all applied discounts.
43 * @type {Discount[]}
44 */
45 this.discounts = undefined;
46
47 /**
48 * The id for the entry.
49 * @type {string}
50 */
51 this.id = builder.id;
52
53 /**
54 * The calculated cart entry price. May or may not include taxes, depending on the tax policy.
55 * @type {MoneyValue}
56 */
57 this.price = builder.price;
58
59 /**
60 * The ProductVariant for the entry.
61 * @type {ProductVariant}
62 */
63 this.productVariant = builder.productVariant;
64
65 /**
66 * The quantity for the entry.
67 * @type {integer}
68 */
69 this.quantity = builder.quantity;
70
71 /**
72 * The cart entry tax info. Until a shipping address is set, this field is typically not set.
73 * @type {TaxInfo}
74 */
75 this.taxInfo = undefined;
76
77 /**
78 * Cart entry type.
79 * @type {string}
80 */
81 this.type = builder.type;
82
83 /**
84 * The product variant item price.
85 * @type {MoneyValue}
86 */
87 this.unitPrice = builder.unitPrice;
88 }
89
90 /**
91 * Builds a CartEntry based on API required properties.
92 */
93 static get Builder() {
94 class Builder {
95
96 withId(id) {
97 this.id = id;
98 return this;
99 }
100
101 withPrice(price) {
102 this.price = price;
103 return this;
104 }
105
106 withProductVariant(productVariant) {
107 this.productVariant = productVariant;
108 return this;
109 }
110
111 withQuantity(quantity) {
112 this.quantity = quantity;
113 return this;
114 }
115
116 withType(type) {
117 this.type = type;
118 return this;
119 }
120
121 withUnitPrice(unitPrice) {
122 this.unitPrice = unitPrice;
123 return this;
124 }
125
126 build() {
127 return new CartEntry(this);
128 }
129 }
130 return Builder;
131 }
132}
133module.exports.CartEntry = CartEntry;