-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcart.js
44 lines (32 loc) · 923 Bytes
/
cart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"use strict";
const Address = require("./address");
const Consumer = require("./consumer");
const Iata = require("./iata");
module.exports = class Cart {
address(type = Address.BOTH) {
let address = Address();
if ((type & Address.BILLING) === Address.BILLING) {
this.billing = address;
}
if ((type & Address.SHIPPING) === Address.SHIPPING) {
this.shipping = [address];
}
return address;
}
addItem(item) {
if (this.items === undefined) {
this.items = [];
}
this.items.push(item);
return this;
}
setConsumer(name, email, cpf) {
this.consumer = new Consumer(name, email, cpf);
return this.consumer;
}
setIata(code, departureTax, flight) {
this.iata = new Iata(code, departureTax);
this.iata.flight = flight;
return this;
}
};