-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
32 lines (29 loc) · 985 Bytes
/
index.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
export default class Address {
constructor (config = {}) {
this.name = config.name || null;
this.street = config.street || null;
this.street2 = config.street2 || null;
this.city = config.city || null;
this.state = config.state || null;
this.country = config.country || null;
this.postCode = config.postCode || null;
this.lat = config.lat || null;
this.lng = config.lng || null;
}
get coordinates() {
return {
lat: this.lat,
lng: this.lng,
};
}
get exists() {
return this.street || this.street2 || this.city || this.state || this.country || this.postCode || this.lat || this.lng;
}
toString() {
return `${this.street ? `${this.street}` : ''}${this.street2 ? ` ${this.street2}` : ''}${this.street || this.street2 ? `,` : ''}
${this.city ? ` ${this.city},` : ''}
${this.state ? ` ${this.state},` : ''}
${this.postCode ? ` ${this.postCode}` : ''}
${this.country ? this.country : ''}`;
}
}