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 | */
|
21 | const CartEntry = require('./CartEntry.js').CartEntry;
|
22 | const MoneyValue = require('./MoneyValue.js').MoneyValue;
|
23 | const TaxInfo = require('./TaxInfo.js').TaxInfo;
|
24 | const Address = require('./Address.js').Address;
|
25 | const ShippingInfo = require('./ShippingInfo.js').ShippingInfo;
|
26 | const Discount = require('./Discount.js').Discount;
|
27 | const Payment = require('./Payment.js').Payment;
|
28 | const Coupon = require('./Coupon.js').Coupon;
|
29 |
|
30 | class Cart {
|
31 |
|
32 | /**
|
33 | * Constructs a Cart based on its enclosed builder.
|
34 | * @constructor
|
35 | * @param {Builder} builder the Cart builder
|
36 | */
|
37 | constructor(builder) {
|
38 |
|
39 | /**
|
40 | * The billing address for the cart.
|
41 | * @type {Address}
|
42 | */
|
43 | this.billingAddress = undefined;
|
44 |
|
45 | /**
|
46 | * A list of all coupons of the cart.
|
47 | * @type {Coupon[]}
|
48 | */
|
49 | this.coupons = undefined;
|
50 |
|
51 | /**
|
52 | * The date-time when this object was created. The JSON representation must be in RFC339 / ISO8601 format
|
53 | * @type {string}
|
54 | */
|
55 | this.createdAt = undefined;
|
56 |
|
57 | /**
|
58 | * The currency for the cart.
|
59 | * @type {string}
|
60 | */
|
61 | this.currency = builder.currency;
|
62 |
|
63 | /**
|
64 | * If set, this defines the customer owning this cart. If not set, the cart is an anonymous cart.
|
65 | * @type {string}
|
66 | */
|
67 | this.customerId = undefined;
|
68 |
|
69 | /**
|
70 | * A list of all applied discounts.
|
71 | * @type {Discount[]}
|
72 | */
|
73 | this.discounts = undefined;
|
74 |
|
75 | /**
|
76 | * The list of the entries in the cart.
|
77 | * @type {CartEntry[]}
|
78 | */
|
79 | this.entries = builder.entries;
|
80 |
|
81 | /**
|
82 | * The gross total price for the cart, including discounts, shipping, and all taxes. Until a shipping address is set, this field is typically not set.
|
83 | * @type {MoneyValue}
|
84 | */
|
85 | this.grossTotalPrice = undefined;
|
86 |
|
87 | /**
|
88 | * The id for the cart.
|
89 | * @type {string}
|
90 | */
|
91 | this.id = builder.id;
|
92 |
|
93 | /**
|
94 | * The date-time when this object was last modified. The JSON representation must be in RFC339 / ISO8601 format
|
95 | * @type {string}
|
96 | */
|
97 | this.lastModifiedAt = undefined;
|
98 |
|
99 | /**
|
100 | * The net total price for the cart, including discounts, and shipping, but excluding any taxes. Until a shipping address is set, this field is typically not set.
|
101 | * @type {MoneyValue}
|
102 | */
|
103 | this.netTotalPrice = undefined;
|
104 |
|
105 | /**
|
106 | * DEPRECATED. The payment details for the cart.
|
107 | * @type {Payment}
|
108 | */
|
109 | this.payment = undefined;
|
110 |
|
111 | /**
|
112 | * A list of payment details for the cart.
|
113 | * @type {Payment[]}
|
114 | */
|
115 | this.payments = undefined;
|
116 |
|
117 | /**
|
118 | * The product subtotal for the cart, including discounts and with or without taxes depending if the product prices include taxes or not.Until a shipping address is set, this field is typically used as the temporary cart total until it is known if prices include taxes or not.
|
119 | * @type {MoneyValue}
|
120 | */
|
121 | this.productTotalPrice = builder.productTotalPrice;
|
122 |
|
123 | /**
|
124 | * The shipping address for the cart products.
|
125 | * @type {Address}
|
126 | */
|
127 | this.shippingAddress = undefined;
|
128 |
|
129 | /**
|
130 | * The shipping info for the cart.
|
131 | * @type {ShippingInfo}
|
132 | */
|
133 | this.shippingInfo = undefined;
|
134 |
|
135 | /**
|
136 | * Indicates if taxes are included or not in all the prices. Until a shipping address is set, this field is typically not set.
|
137 | * @type {boolean}
|
138 | */
|
139 | this.taxIncludedInPrices = undefined;
|
140 |
|
141 | /**
|
142 | * The cart tax info, including cart entries tax and shipping info tax. Until a shipping address is set, this field is typically not set.
|
143 | * @type {TaxInfo}
|
144 | */
|
145 | this.taxInfo = undefined;
|
146 | }
|
147 |
|
148 | /**
|
149 | * Builds a Cart based on API required properties.
|
150 | */
|
151 | static get Builder() {
|
152 | class Builder {
|
153 |
|
154 | withCurrency(currency) {
|
155 | this.currency = currency;
|
156 | return this;
|
157 | }
|
158 |
|
159 | withEntries(entries) {
|
160 | this.entries = entries;
|
161 | return this;
|
162 | }
|
163 |
|
164 | withId(id) {
|
165 | this.id = id;
|
166 | return this;
|
167 | }
|
168 |
|
169 | withProductTotalPrice(productTotalPrice) {
|
170 | this.productTotalPrice = productTotalPrice;
|
171 | return this;
|
172 | }
|
173 |
|
174 | build() {
|
175 | return new Cart(this);
|
176 | }
|
177 | }
|
178 | return Builder;
|
179 | }
|
180 | }
|
181 | module.exports.Cart = Cart;
|