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 MoneyValue = require('./MoneyValue.js').MoneyValue;
|
22 | const Category = require('./Category.js').Category;
|
23 | const Asset = require('./Asset.js').Asset;
|
24 | const Attribute = require('./Attribute.js').Attribute;
|
25 | const ProductVariant = require('./ProductVariant.js').ProductVariant;
|
26 |
|
27 | class Product {
|
28 |
|
29 | /**
|
30 | * Constructs a Product based on its enclosed builder.
|
31 | * @constructor
|
32 | * @param {Builder} builder the Product builder
|
33 | */
|
34 | constructor(builder) {
|
35 |
|
36 | /**
|
37 | * The assets for this product.
|
38 | * @type {Asset[]}
|
39 | */
|
40 | this.assets = undefined;
|
41 |
|
42 | /**
|
43 | * The attributes for this product.
|
44 | * @type {Attribute[]}
|
45 | */
|
46 | this.attributes = undefined;
|
47 |
|
48 | /**
|
49 | * The categories for this product.
|
50 | * @type {Category[]}
|
51 | */
|
52 | this.categories = undefined;
|
53 |
|
54 | /**
|
55 | * The date-time when this object was created. The JSON representation must be in RFC339 / ISO8601 format
|
56 | * @type {string}
|
57 | */
|
58 | this.createdAt = undefined;
|
59 |
|
60 | /**
|
61 | * The description of the product.
|
62 | * @type {string}
|
63 | */
|
64 | this.description = undefined;
|
65 |
|
66 | /**
|
67 | * The internal unique ID of the product in the commerce backend system.
|
68 | * @type {string}
|
69 | */
|
70 | this.id = builder.id;
|
71 |
|
72 | /**
|
73 | * The date-time when this object was last modified. The JSON representation must be in RFC339 / ISO8601 format
|
74 | * @type {string}
|
75 | */
|
76 | this.lastModifiedAt = undefined;
|
77 |
|
78 | /**
|
79 | * The id of the master variant
|
80 | * @type {string}
|
81 | */
|
82 | this.masterVariantId = builder.masterVariantId;
|
83 |
|
84 | /**
|
85 | * The name of the product.
|
86 | * @type {string}
|
87 | */
|
88 | this.name = builder.name;
|
89 |
|
90 | /**
|
91 | * The prices for this product.
|
92 | * @type {MoneyValue[]}
|
93 | */
|
94 | this.prices = builder.prices;
|
95 |
|
96 | /**
|
97 | * The unique SKU of the product assigned by the vendor or manufacturer.
|
98 | * @type {string}
|
99 | */
|
100 | this.sku = undefined;
|
101 |
|
102 | /**
|
103 | * The variants for this product.
|
104 | * @type {ProductVariant[]}
|
105 | */
|
106 | this.variants = builder.variants;
|
107 | }
|
108 |
|
109 | /**
|
110 | * Builds a Product based on API required properties.
|
111 | */
|
112 | static get Builder() {
|
113 | class Builder {
|
114 |
|
115 | withId(id) {
|
116 | this.id = id;
|
117 | return this;
|
118 | }
|
119 |
|
120 | withMasterVariantId(masterVariantId) {
|
121 | this.masterVariantId = masterVariantId;
|
122 | return this;
|
123 | }
|
124 |
|
125 | withName(name) {
|
126 | this.name = name;
|
127 | return this;
|
128 | }
|
129 |
|
130 | withPrices(prices) {
|
131 | this.prices = prices;
|
132 | return this;
|
133 | }
|
134 |
|
135 | withVariants(variants) {
|
136 | this.variants = variants;
|
137 | return this;
|
138 | }
|
139 |
|
140 | build() {
|
141 | return new Product(this);
|
142 | }
|
143 | }
|
144 | return Builder;
|
145 | }
|
146 | }
|
147 | module.exports.Product = Product;
|