@eventconnectors/ndtrc_model 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +30 -0
- package/package.json +19 -0
- package/src/model/ConvertedEntry.js +22 -0
- package/src/model/FetchedEntry.js +55 -0
- package/src/model/ndtrc/Address.js +70 -0
- package/src/model/ndtrc/Calendar.js +240 -0
- package/src/model/ndtrc/Categories.js +149 -0
- package/src/model/ndtrc/ContactInfo.js +186 -0
- package/src/model/ndtrc/ExtraPriceInformation.js +16 -0
- package/src/model/ndtrc/File.js +155 -0
- package/src/model/ndtrc/GISCoordinate.js +19 -0
- package/src/model/ndtrc/Location.js +22 -0
- package/src/model/ndtrc/Performer.js +9 -0
- package/src/model/ndtrc/PriceElement.js +64 -0
- package/src/model/ndtrc/Promotion.js +51 -0
- package/src/model/ndtrc/RouteInfo.js +34 -0
- package/src/model/ndtrc/SubItemGroup.js +102 -0
- package/src/model/ndtrc/TRCItem.js +133 -0
- package/src/model/ndtrc/TRCItemCategories.js +105 -0
- package/src/model/ndtrc/TRCItemDetail.js +10 -0
- package/src/model/ndtrc/TRCItemGroup.js +74 -0
- package/src/model/ndtrc/TRCItemRelation.js +13 -0
- package/src/model/ndtrc/Translations.js +8 -0
- package/src/model/ndtrc/enums.js +33 -0
- package/src/resources/schema/NDTRC-types-EVENTS.txt +0 -0
- package/src/resources/schema/NDTRC-types-locaties.txt +0 -0
- package/src/util/StringUtils.js +12 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
const StringUtils = require('../../util/StringUtils'); // Import StringUtils voor validaties
|
|
2
|
+
|
|
3
|
+
class Contactinfo {
|
|
4
|
+
constructor({
|
|
5
|
+
label = '',
|
|
6
|
+
mails = [],
|
|
7
|
+
phones = [],
|
|
8
|
+
faxes = [],
|
|
9
|
+
urls = [],
|
|
10
|
+
addresses = [],
|
|
11
|
+
mail = null,
|
|
12
|
+
phone = null,
|
|
13
|
+
fax = null,
|
|
14
|
+
address = null
|
|
15
|
+
} = {}) {
|
|
16
|
+
this.label = label;
|
|
17
|
+
this.mails = mails.map(mail => new Contactinfo.Mail(mail));
|
|
18
|
+
this.phones = phones.map(phone => new Contactinfo.Phone(phone));
|
|
19
|
+
this.faxes = faxes.map(fax => new Contactinfo.Fax(fax));
|
|
20
|
+
this.urls = urls.map(url => new Contactinfo.Url(url));
|
|
21
|
+
this.addresses = addresses.map(address => new Contactinfo.Address(address));
|
|
22
|
+
this.mail = mail ? new Contactinfo.Mail(mail) : null;
|
|
23
|
+
this.phone = phone ? new Contactinfo.Phone(phone) : null;
|
|
24
|
+
this.fax = fax ? new Contactinfo.Fax(fax) : null;
|
|
25
|
+
this.address = address ? new Contactinfo.Address(address) : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Converteert naar V1 formaat.
|
|
30
|
+
*/
|
|
31
|
+
convertToV1() {
|
|
32
|
+
if (this.mails.length && (!this.mail || this.mail.isEmpty())) {
|
|
33
|
+
this.mail = this.mails[0];
|
|
34
|
+
}
|
|
35
|
+
if (this.addresses.length && (!this.address || this.address.isEmpty())) {
|
|
36
|
+
this.address = this.addresses[0];
|
|
37
|
+
}
|
|
38
|
+
if (this.faxes.length && (!this.fax || this.fax.isEmpty())) {
|
|
39
|
+
this.fax = this.faxes[0];
|
|
40
|
+
}
|
|
41
|
+
if (this.phones.length && (!this.phone || this.phone.isEmpty())) {
|
|
42
|
+
this.phone = this.phones[0];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Converteert naar V2 formaat.
|
|
48
|
+
*/
|
|
49
|
+
convertToV2() {
|
|
50
|
+
this.mails = this.mail ? [this.mail] : [];
|
|
51
|
+
this.addresses = this.address ? [this.address] : [];
|
|
52
|
+
this.faxes = this.fax ? [this.fax] : [];
|
|
53
|
+
this.phones = this.phone ? [this.phone] : [];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Subklasse: Mail
|
|
59
|
+
*/
|
|
60
|
+
Contactinfo.Mail = class Mail {
|
|
61
|
+
constructor({
|
|
62
|
+
email = '',
|
|
63
|
+
descriptioncode = '',
|
|
64
|
+
reservations = false,
|
|
65
|
+
descriptionTranslations = []
|
|
66
|
+
} = {}) {
|
|
67
|
+
this.email = email;
|
|
68
|
+
this.descriptioncode = descriptioncode;
|
|
69
|
+
this.reservations = reservations;
|
|
70
|
+
this.descriptionTranslations = descriptionTranslations.map(
|
|
71
|
+
translation => new Contactinfo.DescriptionTranslation(translation)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
isEmpty() {
|
|
76
|
+
return StringUtils.isEmpty(this.email);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Subklasse: Phone
|
|
82
|
+
*/
|
|
83
|
+
Contactinfo.Phone = class Phone {
|
|
84
|
+
constructor({
|
|
85
|
+
number = '',
|
|
86
|
+
descriptioncode = '',
|
|
87
|
+
reservations = false,
|
|
88
|
+
descriptionTranslations = []
|
|
89
|
+
} = {}) {
|
|
90
|
+
this.number = number;
|
|
91
|
+
this.descriptioncode = descriptioncode;
|
|
92
|
+
this.reservations = reservations;
|
|
93
|
+
this.descriptionTranslations = descriptionTranslations.map(
|
|
94
|
+
translation => new Contactinfo.DescriptionTranslation(translation)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
isEmpty() {
|
|
99
|
+
return StringUtils.isEmpty(this.number);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Subklasse: Fax
|
|
105
|
+
*/
|
|
106
|
+
Contactinfo.Fax = class Fax {
|
|
107
|
+
constructor({
|
|
108
|
+
number = '',
|
|
109
|
+
descriptioncode = '',
|
|
110
|
+
reservations = false,
|
|
111
|
+
descriptionTranslations = []
|
|
112
|
+
} = {}) {
|
|
113
|
+
this.number = number;
|
|
114
|
+
this.descriptioncode = descriptioncode;
|
|
115
|
+
this.reservations = reservations;
|
|
116
|
+
this.descriptionTranslations = descriptionTranslations.map(
|
|
117
|
+
translation => new Contactinfo.DescriptionTranslation(translation)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
isEmpty() {
|
|
122
|
+
return StringUtils.isEmpty(this.number);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Subklasse: Url
|
|
128
|
+
*/
|
|
129
|
+
Contactinfo.Url = class Url {
|
|
130
|
+
constructor({
|
|
131
|
+
url = null,
|
|
132
|
+
descriptioncode = '',
|
|
133
|
+
targetLanguage = '',
|
|
134
|
+
reservations = false,
|
|
135
|
+
urlServiceType = null,
|
|
136
|
+
descriptionTranslations = []
|
|
137
|
+
} = {}) {
|
|
138
|
+
this.url = url;
|
|
139
|
+
this.descriptioncode = descriptioncode;
|
|
140
|
+
this.targetLanguage = targetLanguage;
|
|
141
|
+
this.reservations = reservations;
|
|
142
|
+
this.urlServiceType = urlServiceType;
|
|
143
|
+
this.descriptionTranslations = descriptionTranslations.map(
|
|
144
|
+
translation => new Contactinfo.DescriptionTranslation(translation)
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
isEmpty() {
|
|
149
|
+
return this.url === null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static getTypeFromString(type) {
|
|
153
|
+
if (!Contactinfo.Url.URLServiceType[type]) {
|
|
154
|
+
throw new Error(`No enum found with type: ${type}`);
|
|
155
|
+
}
|
|
156
|
+
return Contactinfo.Url.URLServiceType[type];
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Enum: URLServiceType
|
|
162
|
+
*/
|
|
163
|
+
Contactinfo.Url.URLServiceType = {
|
|
164
|
+
general: 'general',
|
|
165
|
+
booking: 'booking',
|
|
166
|
+
review: 'review',
|
|
167
|
+
video: 'video',
|
|
168
|
+
webshop: 'webshop',
|
|
169
|
+
socialmedia: 'socialmedia',
|
|
170
|
+
lastminute: 'lastminute',
|
|
171
|
+
virtualtour: 'virtualtour',
|
|
172
|
+
dmo: 'dmo',
|
|
173
|
+
sustainability: 'sustainability'
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Subklasse: DescriptionTranslation
|
|
178
|
+
*/
|
|
179
|
+
Contactinfo.DescriptionTranslation = class DescriptionTranslation {
|
|
180
|
+
constructor({ lang = '', label = '' } = {}) {
|
|
181
|
+
this.lang = lang;
|
|
182
|
+
this.label = label;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
module.exports = Contactinfo;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class ExtraPriceInformation {
|
|
2
|
+
constructor({ lang = '', text = '' } = {}) {
|
|
3
|
+
this.lang = lang;
|
|
4
|
+
this.text = text;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Controleert of de velden leeg zijn.
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
isEmpty() {
|
|
12
|
+
return !this.lang && !this.text;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = ExtraPriceInformation;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
class File {
|
|
2
|
+
constructor({
|
|
3
|
+
trcid = '',
|
|
4
|
+
main = false,
|
|
5
|
+
copyright = '',
|
|
6
|
+
filename = '',
|
|
7
|
+
hlink = '',
|
|
8
|
+
filetype = null,
|
|
9
|
+
mediatype = null,
|
|
10
|
+
targetLanguage = '',
|
|
11
|
+
title = null
|
|
12
|
+
} = {}) {
|
|
13
|
+
this.trcid = trcid;
|
|
14
|
+
this.main = main;
|
|
15
|
+
this.copyright = copyright;
|
|
16
|
+
this.filename = filename;
|
|
17
|
+
this.hlink = hlink;
|
|
18
|
+
this.filetype = filetype;
|
|
19
|
+
this.mediatype = mediatype;
|
|
20
|
+
this.targetLanguage = targetLanguage;
|
|
21
|
+
this.title = title ? new File.Title(title) : null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Schoont de data van de file op.
|
|
26
|
+
*/
|
|
27
|
+
cleanupData() {
|
|
28
|
+
if (this.filetype && !this.mediatype) {
|
|
29
|
+
if (['vimeo', 'youtube'].includes(this.filetype)) {
|
|
30
|
+
this.mediatype = File.MediaType.video;
|
|
31
|
+
} else if (
|
|
32
|
+
['jpg', 'jpeg', 'gif', 'png', 'bmp', 'jfif', 'tiff', 'webp'].includes(this.filetype)
|
|
33
|
+
) {
|
|
34
|
+
this.mediatype = File.MediaType.photo;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.hlink && this.filetype === File.FileType.youtube) {
|
|
39
|
+
this.hlink = File.normalizeYouTubeURL(this.hlink);
|
|
40
|
+
this.filename = File.youtubeVideoID(this.hlink);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Normaliseert een YouTube-URL naar een standaardformaat.
|
|
46
|
+
* @param {string} url
|
|
47
|
+
* @returns {string} Genormaliseerde YouTube-URL
|
|
48
|
+
*/
|
|
49
|
+
static normalizeYouTubeURL(url) {
|
|
50
|
+
if (!url?.trim()) return url;
|
|
51
|
+
|
|
52
|
+
const standardPattern = /https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/;
|
|
53
|
+
const shortenedPattern = /https:\/\/youtu\.be\/([a-zA-Z0-9_-]+)/;
|
|
54
|
+
const embedPattern = /https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]+)/;
|
|
55
|
+
|
|
56
|
+
let match = url.match(standardPattern);
|
|
57
|
+
if (match) return `https://www.youtube.com/watch?v=${match[1]}`;
|
|
58
|
+
|
|
59
|
+
match = url.match(shortenedPattern);
|
|
60
|
+
if (match) return `https://www.youtube.com/watch?v=${match[1]}`;
|
|
61
|
+
|
|
62
|
+
match = url.match(embedPattern);
|
|
63
|
+
if (match) return `https://www.youtube.com/watch?v=${match[1]}`;
|
|
64
|
+
|
|
65
|
+
return url; // Als geen van de patronen overeenkomt, retourneer de oorspronkelijke URL
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Extraheert de video-ID van een YouTube-URL.
|
|
70
|
+
* @param {string} url
|
|
71
|
+
* @returns {string|null} YouTube-video-ID
|
|
72
|
+
*/
|
|
73
|
+
static youtubeVideoID(url) {
|
|
74
|
+
if (!url?.trim()) return null;
|
|
75
|
+
|
|
76
|
+
const standardPattern = /https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/;
|
|
77
|
+
const shortenedPattern = /https:\/\/youtu\.be\/([a-zA-Z0-9_-]+)/;
|
|
78
|
+
const embedPattern = /https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]+)/;
|
|
79
|
+
|
|
80
|
+
let match = url.match(standardPattern);
|
|
81
|
+
if (match) return match[1];
|
|
82
|
+
|
|
83
|
+
match = url.match(shortenedPattern);
|
|
84
|
+
if (match) return match[1];
|
|
85
|
+
|
|
86
|
+
match = url.match(embedPattern);
|
|
87
|
+
if (match) return match[1];
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Subklasse: Title
|
|
95
|
+
*/
|
|
96
|
+
File.Title = class Title {
|
|
97
|
+
constructor({ label = '', titleTranslations = [] } = {}) {
|
|
98
|
+
this.label = label;
|
|
99
|
+
this.titleTranslations = titleTranslations.map(
|
|
100
|
+
translation => new File.Title.TitleTranslation(translation)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Subklasse: TitleTranslation
|
|
107
|
+
*/
|
|
108
|
+
File.Title.TitleTranslation = class TitleTranslation {
|
|
109
|
+
constructor({ lang = '', label = '' } = {}) {
|
|
110
|
+
this.lang = lang;
|
|
111
|
+
this.label = label;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Enum: FileType
|
|
117
|
+
*/
|
|
118
|
+
File.FileType = {
|
|
119
|
+
jpeg: 'jpeg',
|
|
120
|
+
jpg: 'jpg',
|
|
121
|
+
gif: 'gif',
|
|
122
|
+
png: 'png',
|
|
123
|
+
mp3: 'mp3',
|
|
124
|
+
pdf: 'pdf',
|
|
125
|
+
gpx: 'gpx',
|
|
126
|
+
kml: 'kml',
|
|
127
|
+
youtube: 'youtube',
|
|
128
|
+
kmz: 'kmz',
|
|
129
|
+
vimeo: 'vimeo',
|
|
130
|
+
tif: 'tif',
|
|
131
|
+
bmp: 'bmp',
|
|
132
|
+
jfif: 'jfif',
|
|
133
|
+
tiff: 'tiff',
|
|
134
|
+
webp: 'webp'
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Enum: MediaType
|
|
139
|
+
*/
|
|
140
|
+
File.MediaType = {
|
|
141
|
+
poster: 'poster',
|
|
142
|
+
other: 'other',
|
|
143
|
+
audio: 'audio',
|
|
144
|
+
brochure: 'brochure',
|
|
145
|
+
floorplan: 'floorplan',
|
|
146
|
+
photo: 'photo',
|
|
147
|
+
logo: 'logo',
|
|
148
|
+
video: 'video',
|
|
149
|
+
roadmap: 'roadmap',
|
|
150
|
+
text: 'text',
|
|
151
|
+
attachment: 'attachment',
|
|
152
|
+
qr: 'qr'
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
module.exports = File;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const StringUtils = require('../../util/StringUtils'); // Import StringUtils voor validaties
|
|
2
|
+
|
|
3
|
+
class GISCoordinate {
|
|
4
|
+
constructor({ xcoordinate = '', ycoordinate = '', label = '' } = {}) {
|
|
5
|
+
this.xcoordinate = xcoordinate;
|
|
6
|
+
this.ycoordinate = ycoordinate;
|
|
7
|
+
this.label = label;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Controleert of de GIS-coördinaten leeg zijn.
|
|
12
|
+
* @returns {boolean}
|
|
13
|
+
*/
|
|
14
|
+
isEmpty() {
|
|
15
|
+
return StringUtils.isEmpty(this.xcoordinate) && StringUtils.isEmpty(this.ycoordinate);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = GISCoordinate;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const Address = require('./Address'); // Importeer de Address-klasse
|
|
2
|
+
|
|
3
|
+
class Location {
|
|
4
|
+
constructor({ address = null, label = '', locationItem = null } = {}) {
|
|
5
|
+
this.address = address ? new Address(address) : null;
|
|
6
|
+
this.label = label;
|
|
7
|
+
this.locationItem = locationItem ? new Location.LocationItem(locationItem) : null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Subklasse: LocationItem
|
|
13
|
+
*/
|
|
14
|
+
Location.LocationItem = class LocationItem {
|
|
15
|
+
constructor({ id = '', trcid = '', text = '' } = {}) {
|
|
16
|
+
this.id = id;
|
|
17
|
+
this.trcid = trcid;
|
|
18
|
+
this.text = text;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = Location;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
class PriceElement {
|
|
2
|
+
constructor({
|
|
3
|
+
freeentrance = false,
|
|
4
|
+
priceValue = null,
|
|
5
|
+
description = null,
|
|
6
|
+
comments = [],
|
|
7
|
+
extraPriceInformations = []
|
|
8
|
+
} = {}) {
|
|
9
|
+
this.freeentrance = freeentrance;
|
|
10
|
+
this.priceValue = priceValue ? new PriceElement.PriceValue(priceValue) : null;
|
|
11
|
+
this.description = description ? new PriceElement.Description(description) : null;
|
|
12
|
+
this.comments = comments.map(comment => new PriceElement.Comment(comment));
|
|
13
|
+
this.extraPriceInformations = extraPriceInformations.map(
|
|
14
|
+
info => new PriceElement.ExtraPriceInformation(info)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
PriceElement.Description = class Description {
|
|
20
|
+
constructor({ value = null, descriptionTranslations = [] } = {}) {
|
|
21
|
+
this.value = value;
|
|
22
|
+
this.descriptionTranslations = descriptionTranslations.map(
|
|
23
|
+
translation => new PriceElement.Description.DescriptionTranslation(translation)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
PriceElement.Description.PriceDescriptionValue = {
|
|
29
|
+
Adults: 'Adults',
|
|
30
|
+
Children: 'Children',
|
|
31
|
+
Groups: 'Groups',
|
|
32
|
+
CJP: 'CJP',
|
|
33
|
+
Pasholders: 'Pasholders',
|
|
34
|
+
Lastminute: 'Lastminute'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
PriceElement.Description.DescriptionTranslation = class DescriptionTranslation {
|
|
38
|
+
constructor({ lang = '', text = '' } = {}) {
|
|
39
|
+
this.lang = lang;
|
|
40
|
+
this.text = text;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
PriceElement.ExtraPriceInformation = class ExtraPriceInformation {
|
|
45
|
+
constructor({ lang = '', text = '' } = {}) {
|
|
46
|
+
this.lang = lang;
|
|
47
|
+
this.text = text;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
PriceElement.PriceValue = class PriceValue {
|
|
52
|
+
constructor({ from = null, until = null } = {}) {
|
|
53
|
+
this.from = from;
|
|
54
|
+
this.until = until;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
PriceElement.Comment = class Comment {
|
|
59
|
+
constructor({ text = '' } = {}) {
|
|
60
|
+
this.text = text;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = PriceElement;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const moment = require('moment');
|
|
2
|
+
const Contactinfo = require('./ContactInfo');
|
|
3
|
+
const Calendar = require('./Calendar');
|
|
4
|
+
|
|
5
|
+
class Promotion {
|
|
6
|
+
constructor({
|
|
7
|
+
product = '',
|
|
8
|
+
promotionType = null,
|
|
9
|
+
discount = null,
|
|
10
|
+
translations = [],
|
|
11
|
+
detailsUrls = [],
|
|
12
|
+
startDate = null,
|
|
13
|
+
endDate = null,
|
|
14
|
+
enabled = true,
|
|
15
|
+
opens = []
|
|
16
|
+
} = {}) {
|
|
17
|
+
this.product = product;
|
|
18
|
+
this.promotionType = promotionType;
|
|
19
|
+
this.discount = discount ? new Promotion.Discount(discount) : null;
|
|
20
|
+
this.translations = translations.map(translation => new Promotion.PromotionTranslation(translation));
|
|
21
|
+
this.detailsUrls = detailsUrls.map(url => new Contactinfo.Url(url));
|
|
22
|
+
this.startDate = startDate ? moment(startDate) : null;
|
|
23
|
+
this.endDate = endDate ? moment(endDate) : null;
|
|
24
|
+
this.enabled = enabled;
|
|
25
|
+
this.opens = opens.map(open => new Calendar.PatternDate.Open(open));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Promotion.Discount = class Discount {
|
|
30
|
+
constructor({ free = false, percentage = null, amount = null } = {}) {
|
|
31
|
+
this.free = free;
|
|
32
|
+
this.percentage = percentage;
|
|
33
|
+
this.amount = amount;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Promotion.PromotionTranslation = class PromotionTranslation {
|
|
38
|
+
constructor({ lang = '', description = '' } = {}) {
|
|
39
|
+
this.lang = lang;
|
|
40
|
+
this.description = description;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Promotion.PromotionType = {
|
|
45
|
+
free: 'free',
|
|
46
|
+
discount: 'discount',
|
|
47
|
+
gift: 'gift',
|
|
48
|
+
allowance: 'allowance'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
module.exports = Promotion;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const Address = require('./Address');
|
|
2
|
+
|
|
3
|
+
class RouteInfo {
|
|
4
|
+
constructor({
|
|
5
|
+
type = null,
|
|
6
|
+
url = '',
|
|
7
|
+
distanceInKilometers = null,
|
|
8
|
+
durationInMinutes = null,
|
|
9
|
+
start = null,
|
|
10
|
+
end = null
|
|
11
|
+
} = {}) {
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.url = url;
|
|
14
|
+
this.distanceInKilometers = distanceInKilometers;
|
|
15
|
+
this.durationInMinutes = durationInMinutes;
|
|
16
|
+
this.start = start ? new Address(start) : null;
|
|
17
|
+
this.end = end ? new Address(end) : null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static Type = {
|
|
21
|
+
ROUTE_MAKER: 'route_maker',
|
|
22
|
+
ROUTE_IQ: 'route_iq',
|
|
23
|
+
ODP_ROUTES: 'odp_routes',
|
|
24
|
+
|
|
25
|
+
fromString(type) {
|
|
26
|
+
if (Object.values(RouteInfo.Type).includes(type)) {
|
|
27
|
+
return type;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Invalid Type: ${type}`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = RouteInfo;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
class SubItemGroup {
|
|
2
|
+
constructor({
|
|
3
|
+
trcid = '',
|
|
4
|
+
type = null,
|
|
5
|
+
categories = [],
|
|
6
|
+
subItemTranslations = [],
|
|
7
|
+
media = []
|
|
8
|
+
} = {}) {
|
|
9
|
+
this.trcid = trcid;
|
|
10
|
+
this.type = type ? new SubItemGroup.Type(type) : null;
|
|
11
|
+
this.categories = categories.map(category => new SubItemGroup.Category(category));
|
|
12
|
+
this.subItemTranslations = subItemTranslations.map(
|
|
13
|
+
translation => new SubItemGroup.SubItemTranslation(translation)
|
|
14
|
+
);
|
|
15
|
+
this.media = media.map(file => new File(file));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
cleanEmptyItems() {
|
|
19
|
+
this.categories = this.categories.filter(category => {
|
|
20
|
+
const dataType = category.datatype?.toLowerCase();
|
|
21
|
+
if (dataType === 'freetext' && !category.value) return false;
|
|
22
|
+
if (['multichoice', 'choice'].includes(dataType) && !category.valueid) return false;
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
SubItemGroup.SubItemTranslation = class SubItemTranslation {
|
|
29
|
+
constructor({ lang = '', title = '' } = {}) {
|
|
30
|
+
this.lang = lang;
|
|
31
|
+
this.title = title;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
SubItemGroup.Type = class Type {
|
|
36
|
+
constructor({ catid = '', isDefault = false, categoryTranslations = [] } = {}) {
|
|
37
|
+
this.catid = catid;
|
|
38
|
+
this.isDefault = isDefault;
|
|
39
|
+
this.categoryTranslations = categoryTranslations.map(
|
|
40
|
+
translation => new SubItemGroup.CategoryTranslation(translation)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
SubItemGroup.Category = class Category {
|
|
46
|
+
constructor({
|
|
47
|
+
catid = '',
|
|
48
|
+
valueid = '',
|
|
49
|
+
value = '',
|
|
50
|
+
datatype = '',
|
|
51
|
+
categoryvalues = [],
|
|
52
|
+
categoryTranslations = [],
|
|
53
|
+
parentCategoryTranslations = [],
|
|
54
|
+
valueCategoryTranslations = []
|
|
55
|
+
} = {}) {
|
|
56
|
+
this.catid = catid;
|
|
57
|
+
this.valueid = valueid;
|
|
58
|
+
this.value = value;
|
|
59
|
+
this.datatype = datatype;
|
|
60
|
+
this.categoryvalues = categoryvalues.map(
|
|
61
|
+
value => new SubItemGroup.CategoryValue(value)
|
|
62
|
+
);
|
|
63
|
+
this.categoryTranslations = categoryTranslations.map(
|
|
64
|
+
translation => new SubItemGroup.CategoryTranslation(translation)
|
|
65
|
+
);
|
|
66
|
+
this.parentCategoryTranslations = parentCategoryTranslations.map(
|
|
67
|
+
translation => new SubItemGroup.CategoryTranslation(translation)
|
|
68
|
+
);
|
|
69
|
+
this.valueCategoryTranslations = valueCategoryTranslations.map(
|
|
70
|
+
translation => new SubItemGroup.CategoryTranslation(translation)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
SubItemGroup.CategoryValue = class CategoryValue {
|
|
76
|
+
constructor({ catid = '', categorytranslations = [] } = {}) {
|
|
77
|
+
this.catid = catid;
|
|
78
|
+
this.categorytranslations = categorytranslations.map(
|
|
79
|
+
translation => new SubItemGroup.CategoryTranslation(translation)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
SubItemGroup.CategoryTranslation = class CategoryTranslation {
|
|
85
|
+
constructor({
|
|
86
|
+
catid = '',
|
|
87
|
+
lang = '',
|
|
88
|
+
label = '',
|
|
89
|
+
unit = '',
|
|
90
|
+
value = '',
|
|
91
|
+
explanation = ''
|
|
92
|
+
} = {}) {
|
|
93
|
+
this.catid = catid;
|
|
94
|
+
this.lang = lang;
|
|
95
|
+
this.label = label;
|
|
96
|
+
this.unit = unit;
|
|
97
|
+
this.value = value;
|
|
98
|
+
this.explanation = explanation;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
module.exports = SubItemGroup;
|