@mapsindoors/react-native-maps-indoors-mapbox 2.5.3 → 2.6.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/README.md +1 -1
- package/android/build.gradle +2 -2
- package/package.json +1 -1
- package/react-native-maps-indoors-mapbox.podspec +2 -2
- package/src/core/MPAdditionalDetail.ts +102 -0
- package/src/core/MPCategory.ts +10 -1
- package/src/core/MPDailyOpeningHours.ts +67 -0
- package/src/core/MPDetailType.ts +73 -0
- package/src/core/MPLocation.ts +30 -0
- package/src/core/MPOpeningHours.ts +48 -0
- package/src/core/MPPropertyData.ts +10 -0
- package/src/core/MPWeeklyOpeningHours.ts +129 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Documentation
|
|
4
4
|
|
|
5
|
-
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.
|
|
5
|
+
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.6.0/index.html) to get an overview of what the MapsIndoors SDK offers.
|
|
6
6
|
|
|
7
7
|
## Getting started
|
|
8
8
|
|
package/android/build.gradle
CHANGED
|
@@ -92,8 +92,8 @@ dependencies {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
implementation 'com.mapbox.maps:android:11.
|
|
96
|
-
implementation 'com.mapspeople.mapsindoors:mapbox-
|
|
95
|
+
implementation 'com.mapbox.maps:android-ndk27:11.16.1'
|
|
96
|
+
implementation 'com.mapspeople.mapsindoors:mapbox-ndk27:4.15.5'
|
|
97
97
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
98
98
|
implementation 'androidx.core:core-ktx:1.3.2'
|
|
99
99
|
implementation 'com.github.bumptech.glide:glide:4.16.0'
|
package/package.json
CHANGED
|
@@ -24,6 +24,6 @@ Pod::Spec.new do |s|
|
|
|
24
24
|
s.requires_arc = true
|
|
25
25
|
|
|
26
26
|
s.dependency "React"
|
|
27
|
-
s.dependency "MapsIndoorsMapbox11", "4.
|
|
28
|
-
s.dependency "MapsIndoorsCodable", "4.
|
|
27
|
+
s.dependency "MapsIndoorsMapbox11", "4.15.5"
|
|
28
|
+
s.dependency "MapsIndoorsCodable", "4.15.5"
|
|
29
29
|
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { MPDetailType } from './MPDetailType';
|
|
2
|
+
import { MPOpeningHours } from './MPOpeningHours';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents additional details associated with a MapIndoors entity, such as a location or a point of interest.
|
|
6
|
+
* This class contains various fields that provide information about the additional details.
|
|
7
|
+
*/
|
|
8
|
+
export class MPAdditionalDetail {
|
|
9
|
+
/**
|
|
10
|
+
* The type of detail, e.g. "phone", "email", "website", etc.
|
|
11
|
+
*/
|
|
12
|
+
private _detailType: MPDetailType | null = null;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The key for the additional detail, which is typically a string identifier.
|
|
16
|
+
*/
|
|
17
|
+
private _key: string | null = null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The value of the additional detail, which can be a string representing
|
|
21
|
+
*/
|
|
22
|
+
private _value: string | null = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The icon associated with the additional detail, which is a URL.
|
|
26
|
+
*/
|
|
27
|
+
private _icon: string | null = null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The display text for the additional detail, which is a localized user-friendly string.
|
|
31
|
+
*/
|
|
32
|
+
private _displayText: string | null = null;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Indicates whether the additional detail is active or not.
|
|
36
|
+
*/
|
|
37
|
+
private _active: boolean | null = null;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The opening hours associated with the additional detail, represented by an MPOpeningHours object.
|
|
41
|
+
*/
|
|
42
|
+
private _openingHours: MPOpeningHours | null = null;
|
|
43
|
+
|
|
44
|
+
get detailType(): MPDetailType | null {
|
|
45
|
+
return this._detailType;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get key(): string | null {
|
|
49
|
+
return this._key;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get value(): string | null {
|
|
53
|
+
return this._value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get icon(): string | null {
|
|
57
|
+
return this._icon;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get displayText(): string | null {
|
|
61
|
+
return this._displayText;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get active(): boolean | null {
|
|
65
|
+
return this._active;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get openingHours(): MPOpeningHours | null {
|
|
69
|
+
return this._openingHours;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Creates an instance of MPAdditionalDetail from a JSON object.
|
|
74
|
+
*/
|
|
75
|
+
static fromJson(json: any): MPAdditionalDetail {
|
|
76
|
+
const detail = new MPAdditionalDetail();
|
|
77
|
+
detail._detailType = json.detailType || null;
|
|
78
|
+
detail._key = json.key || null;
|
|
79
|
+
detail._value = json.value || null;
|
|
80
|
+
detail._icon = json.icon || null;
|
|
81
|
+
detail._displayText = json.displayText || null;
|
|
82
|
+
detail._active = json.active || null;
|
|
83
|
+
detail._openingHours = json.openingHours || null;
|
|
84
|
+
return detail;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Converts the instance to a JSON object.
|
|
89
|
+
* This is useful for serialization.
|
|
90
|
+
*/
|
|
91
|
+
toJson(): any {
|
|
92
|
+
return {
|
|
93
|
+
detailType: this._detailType,
|
|
94
|
+
key: this._key,
|
|
95
|
+
value: this._value,
|
|
96
|
+
icon: this._icon,
|
|
97
|
+
displayText: this._displayText,
|
|
98
|
+
active: this._active,
|
|
99
|
+
openingHours: this._openingHours,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
package/src/core/MPCategory.ts
CHANGED
|
@@ -16,11 +16,13 @@ export default class MPCategory {
|
|
|
16
16
|
* @param {string} key The ID of the category.
|
|
17
17
|
* @param {string} value The category's readable name.
|
|
18
18
|
* @param {?Map<string, MPDataField>} [fields] The category's data fields.
|
|
19
|
+
* @param {?string[]} [childKeys] The keys of child categories.
|
|
19
20
|
*/
|
|
20
21
|
private constructor(
|
|
21
22
|
public readonly key: string,
|
|
22
23
|
public readonly value: string,
|
|
23
|
-
public readonly fields?: Map<string, MPDataField
|
|
24
|
+
public readonly fields?: Map<string, MPDataField>,
|
|
25
|
+
public readonly childKeys?: string[],
|
|
24
26
|
) { }
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -43,6 +45,7 @@ export default class MPCategory {
|
|
|
43
45
|
object?.key,
|
|
44
46
|
object?.value,
|
|
45
47
|
fields,
|
|
48
|
+
object?.childKeys,
|
|
46
49
|
);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
@@ -73,4 +76,10 @@ export interface MPCategoryParams {
|
|
|
73
76
|
* @type {?Map<string, MPDataField>}
|
|
74
77
|
*/
|
|
75
78
|
fields?: Map<string, MPDataField>,
|
|
79
|
+
/**
|
|
80
|
+
* The keys of child categories.
|
|
81
|
+
*
|
|
82
|
+
* @type {?string[]}
|
|
83
|
+
*/
|
|
84
|
+
childKeys?: string[],
|
|
76
85
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the opening hours for a single day.
|
|
3
|
+
* Contains information about whether the location is closed all day or the specific opening and closing times.
|
|
4
|
+
*/
|
|
5
|
+
export class MPDailyOpeningHours {
|
|
6
|
+
/**
|
|
7
|
+
* Indicates whether the location is closed all day.
|
|
8
|
+
*/
|
|
9
|
+
private _closedAllDay: boolean | null = null;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The start time for the opening hours (e.g., "09:00").
|
|
13
|
+
*/
|
|
14
|
+
private _startTime: string | null = null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The end time for the opening hours (e.g., "17:00").
|
|
18
|
+
*/
|
|
19
|
+
private _endTime: string | null = null;
|
|
20
|
+
|
|
21
|
+
get closedAllDay(): boolean | null {
|
|
22
|
+
return this._closedAllDay;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get startTime(): string | null {
|
|
26
|
+
return this._startTime;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get endTime(): string | null {
|
|
30
|
+
return this._endTime;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates an instance of MPDailyOpeningHours from a JSON object.
|
|
35
|
+
*/
|
|
36
|
+
static fromJson(json: any): MPDailyOpeningHours {
|
|
37
|
+
const dailyHours = new MPDailyOpeningHours();
|
|
38
|
+
dailyHours._closedAllDay = json.closedAllDay !== undefined ? json.closedAllDay : null;
|
|
39
|
+
dailyHours._startTime = json.startTime || null;
|
|
40
|
+
dailyHours._endTime = json.endTime || null;
|
|
41
|
+
return dailyHours;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Converts the instance to a JSON object.
|
|
46
|
+
* This is useful for serialization.
|
|
47
|
+
*/
|
|
48
|
+
toJson(): any {
|
|
49
|
+
return {
|
|
50
|
+
closedAllDay: this._closedAllDay,
|
|
51
|
+
startTime: this._startTime,
|
|
52
|
+
endTime: this._endTime,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns a string representation of the daily opening hours.
|
|
58
|
+
* @returns String representation showing either "Closed all day" or the opening times
|
|
59
|
+
*/
|
|
60
|
+
toString(): string {
|
|
61
|
+
if (this._closedAllDay === true) {
|
|
62
|
+
return "Closed all day";
|
|
63
|
+
} else {
|
|
64
|
+
return `Open from ${this._startTime} to ${this._endTime}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing different types of additional details for MapIndoors entities.
|
|
3
|
+
*/
|
|
4
|
+
export enum MPDetailType {
|
|
5
|
+
Text = "text",
|
|
6
|
+
Phone = "phone",
|
|
7
|
+
URL = "url",
|
|
8
|
+
Email = "email",
|
|
9
|
+
OpeningHours = "openinghours"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Utility functions for MPDetailType enum.
|
|
14
|
+
*/
|
|
15
|
+
export namespace MPDetailType {
|
|
16
|
+
/**
|
|
17
|
+
* Converts a string value to the corresponding MPDetailType enum value.
|
|
18
|
+
* @param value The string value to convert
|
|
19
|
+
* @returns The corresponding MPDetailType or null if no match is found
|
|
20
|
+
*/
|
|
21
|
+
export function fromString(value: string | null | undefined): MPDetailType | null {
|
|
22
|
+
if (!value) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
switch (value.toLowerCase()) {
|
|
27
|
+
case "text":
|
|
28
|
+
return MPDetailType.Text;
|
|
29
|
+
case "phone":
|
|
30
|
+
return MPDetailType.Phone;
|
|
31
|
+
case "url":
|
|
32
|
+
return MPDetailType.URL;
|
|
33
|
+
case "email":
|
|
34
|
+
return MPDetailType.Email;
|
|
35
|
+
case "openinghours":
|
|
36
|
+
return MPDetailType.OpeningHours;
|
|
37
|
+
default:
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Converts an MPDetailType enum value to its string representation.
|
|
44
|
+
* @param detailType The enum value to convert
|
|
45
|
+
* @returns The string representation of the enum value
|
|
46
|
+
*/
|
|
47
|
+
export function toString(detailType: MPDetailType): string {
|
|
48
|
+
return detailType.valueOf();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Gets all possible MPDetailType values.
|
|
53
|
+
* @returns Array of all MPDetailType enum values
|
|
54
|
+
*/
|
|
55
|
+
export function getAllValues(): MPDetailType[] {
|
|
56
|
+
return [
|
|
57
|
+
MPDetailType.Text,
|
|
58
|
+
MPDetailType.Phone,
|
|
59
|
+
MPDetailType.URL,
|
|
60
|
+
MPDetailType.Email,
|
|
61
|
+
MPDetailType.OpeningHours
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Checks if a string value is a valid MPDetailType.
|
|
67
|
+
* @param value The string value to check
|
|
68
|
+
* @returns True if the value corresponds to a valid MPDetailType, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
export function isValid(value: string | null | undefined): boolean {
|
|
71
|
+
return fromString(value) !== null;
|
|
72
|
+
}
|
|
73
|
+
}
|
package/src/core/MPLocation.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { MPGeometry, MPPoint, MPPolygon, MPBuilding, MPVenue, MPMultiPolygon, MP
|
|
|
3
3
|
import MPEntity from "./MPEntity";
|
|
4
4
|
import MPPropertyData from "./MPPropertyData";
|
|
5
5
|
import MPLocationSettings from "./MPLocationSettings";
|
|
6
|
+
import { MPAdditionalDetail } from "./MPAdditionalDetail";
|
|
7
|
+
import { MPDetailType } from "./MPDetailType";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* A MapsIndoors geographical entity. A location can exist anywhere,
|
|
@@ -407,4 +409,32 @@ export default class MPLocation extends MPEntity {
|
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
411
|
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Gets the location's additional details, if any
|
|
415
|
+
* @returns a list of additional details, or null if none were set
|
|
416
|
+
*/
|
|
417
|
+
public getAdditionalDetails(): MPAdditionalDetail[] | null {
|
|
418
|
+
if (this.properties?.additionalDetails) {
|
|
419
|
+
// Return a readonly copy of the array to prevent external modifications
|
|
420
|
+
return [...this.properties.additionalDetails];
|
|
421
|
+
}
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Gets a specific additional detail from the location's additional details
|
|
427
|
+
* @param type the type of the additional detail to get
|
|
428
|
+
* @returns the additional detail of the specified type, or null if it does not exist
|
|
429
|
+
*/
|
|
430
|
+
public getAdditionalDetail(type: MPDetailType): MPAdditionalDetail | null {
|
|
431
|
+
if (this.properties?.additionalDetails) {
|
|
432
|
+
for (const detail of this.properties.additionalDetails) {
|
|
433
|
+
if (detail.detailType.toLowerCase() === type.toLowerCase() ) {
|
|
434
|
+
return detail;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
410
440
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MPWeeklyOpeningHours } from './MPWeeklyOpeningHours';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents the opening hours for a location.
|
|
5
|
+
*/
|
|
6
|
+
export class MPOpeningHours {
|
|
7
|
+
/**
|
|
8
|
+
* The standard opening hours for the location.
|
|
9
|
+
*/
|
|
10
|
+
private _standardOpeningHours: MPWeeklyOpeningHours | null = null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Gets the standard opening hours for the location.
|
|
14
|
+
*/
|
|
15
|
+
get standardOpeningHours(): MPWeeklyOpeningHours | null {
|
|
16
|
+
return this._standardOpeningHours;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instance of MPOpeningHours from a JSON object.
|
|
21
|
+
*/
|
|
22
|
+
static fromJson(json: any): MPOpeningHours {
|
|
23
|
+
const openingHours = new MPOpeningHours();
|
|
24
|
+
openingHours._standardOpeningHours = json.standardOpeningHours || null;
|
|
25
|
+
return openingHours;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Converts the instance to a JSON object.
|
|
30
|
+
* This is useful for serialization.
|
|
31
|
+
*/
|
|
32
|
+
toJson(): any {
|
|
33
|
+
return {
|
|
34
|
+
standardOpeningHours: this._standardOpeningHours,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns a string representation of the opening hours.
|
|
40
|
+
* @returns String representation of the standard opening hours or a default message
|
|
41
|
+
*/
|
|
42
|
+
toString(): string {
|
|
43
|
+
if (this._standardOpeningHours && typeof this._standardOpeningHours.toString === 'function') {
|
|
44
|
+
return this._standardOpeningHours.toString();
|
|
45
|
+
}
|
|
46
|
+
return "No standard opening hours available";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -2,6 +2,7 @@ import { Platform } from "react-native";
|
|
|
2
2
|
import { MPPoint, MPDataField, MPPointParams } from "../../index";
|
|
3
3
|
import { MPEntityInfo } from "./MPEntityInfo";
|
|
4
4
|
import MPLocationSettings from "./MPLocationSettings";
|
|
5
|
+
import { MPAdditionalDetail } from "./MPAdditionalDetail";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal - Documentation will follow.
|
|
@@ -36,6 +37,7 @@ export default class MPPropertyData extends MPEntityInfo {
|
|
|
36
37
|
* @param {?string} [locationType]
|
|
37
38
|
* @param {?boolean} [bookable]
|
|
38
39
|
* @param {?MPPoint} [anchor]
|
|
40
|
+
* @param {?MPAdditionalDetail[]} [additionalDetails]
|
|
39
41
|
*/
|
|
40
42
|
private constructor(
|
|
41
43
|
name: string,
|
|
@@ -57,6 +59,7 @@ export default class MPPropertyData extends MPEntityInfo {
|
|
|
57
59
|
readonly bookable?: boolean,
|
|
58
60
|
readonly anchor?: MPPoint,
|
|
59
61
|
public locationSettings?: MPLocationSettings,
|
|
62
|
+
readonly additionalDetails?: MPAdditionalDetail[],
|
|
60
63
|
) { super(name, aliases, fields, undefined) }
|
|
61
64
|
|
|
62
65
|
/**
|
|
@@ -95,6 +98,7 @@ export default class MPPropertyData extends MPEntityInfo {
|
|
|
95
98
|
object?.bookable,
|
|
96
99
|
MPPoint.create(object?.anchor),
|
|
97
100
|
object?.locationSettings && id ? MPLocationSettings.create(id, object?.locationSettings) : undefined,
|
|
101
|
+
object?.additionalDetails ? object.additionalDetails.map((detail: any) => MPAdditionalDetail.fromJson(detail)) : undefined,
|
|
98
102
|
);
|
|
99
103
|
}
|
|
100
104
|
}
|
|
@@ -221,4 +225,10 @@ export interface MPPropertyDataParams {
|
|
|
221
225
|
* @type {?MPLocationSettings}
|
|
222
226
|
*/
|
|
223
227
|
locationSettings?: MPLocationSettings,
|
|
228
|
+
/**
|
|
229
|
+
* The location's additional details list
|
|
230
|
+
*
|
|
231
|
+
* @type {?any[]}
|
|
232
|
+
*/
|
|
233
|
+
additionalDetails?: any[],
|
|
224
234
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { MPDailyOpeningHours } from './MPDailyOpeningHours';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents the opening hours for a week, with each day having its own set of opening hours.
|
|
5
|
+
* This class is used to define the opening hours for a business or location, detailing the hours for each day of the week.
|
|
6
|
+
* Each day is represented by an instance of MPDailyOpeningHours, which contains the specific opening and closing times for that day.
|
|
7
|
+
*/
|
|
8
|
+
export class MPWeeklyOpeningHours {
|
|
9
|
+
/**
|
|
10
|
+
* Opening hours for Monday.
|
|
11
|
+
*/
|
|
12
|
+
private _monday: MPDailyOpeningHours | null = null;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Opening hours for Tuesday.
|
|
16
|
+
*/
|
|
17
|
+
private _tuesday: MPDailyOpeningHours | null = null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Opening hours for Wednesday.
|
|
21
|
+
*/
|
|
22
|
+
private _wednesday: MPDailyOpeningHours | null = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Opening hours for Thursday.
|
|
26
|
+
*/
|
|
27
|
+
private _thursday: MPDailyOpeningHours | null = null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Opening hours for Friday.
|
|
31
|
+
*/
|
|
32
|
+
private _friday: MPDailyOpeningHours | null = null;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Opening hours for Saturday.
|
|
36
|
+
*/
|
|
37
|
+
private _saturday: MPDailyOpeningHours | null = null;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Opening hours for Sunday.
|
|
41
|
+
*/
|
|
42
|
+
private _sunday: MPDailyOpeningHours | null = null;
|
|
43
|
+
|
|
44
|
+
get monday(): MPDailyOpeningHours | null {
|
|
45
|
+
return this._monday;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get tuesday(): MPDailyOpeningHours | null {
|
|
49
|
+
return this._tuesday;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get wednesday(): MPDailyOpeningHours | null {
|
|
53
|
+
return this._wednesday;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get thursday(): MPDailyOpeningHours | null {
|
|
57
|
+
return this._thursday;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get friday(): MPDailyOpeningHours | null {
|
|
61
|
+
return this._friday;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get saturday(): MPDailyOpeningHours | null {
|
|
65
|
+
return this._saturday;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get sunday(): MPDailyOpeningHours | null {
|
|
69
|
+
return this._sunday;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Creates an instance of MPWeeklyOpeningHours from a JSON object.
|
|
74
|
+
*/
|
|
75
|
+
static fromJson(json: any): MPWeeklyOpeningHours {
|
|
76
|
+
const weeklyHours = new MPWeeklyOpeningHours();
|
|
77
|
+
weeklyHours._monday = json.monday || null;
|
|
78
|
+
weeklyHours._tuesday = json.tuesday || null;
|
|
79
|
+
weeklyHours._wednesday = json.wednesday || null;
|
|
80
|
+
weeklyHours._thursday = json.thursday || null;
|
|
81
|
+
weeklyHours._friday = json.friday || null;
|
|
82
|
+
weeklyHours._saturday = json.saturday || null;
|
|
83
|
+
weeklyHours._sunday = json.sunday || null;
|
|
84
|
+
return weeklyHours;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Converts the instance to a JSON object.
|
|
89
|
+
* This is useful for serialization.
|
|
90
|
+
*/
|
|
91
|
+
toJson(): any {
|
|
92
|
+
return {
|
|
93
|
+
monday: this._monday,
|
|
94
|
+
tuesday: this._tuesday,
|
|
95
|
+
wednesday: this._wednesday,
|
|
96
|
+
thursday: this._thursday,
|
|
97
|
+
friday: this._friday,
|
|
98
|
+
saturday: this._saturday,
|
|
99
|
+
sunday: this._sunday,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Helper method to safely convert a daily opening hours object to string.
|
|
105
|
+
*/
|
|
106
|
+
private dayToString(day: MPDailyOpeningHours | null): string {
|
|
107
|
+
if (day && typeof day.toString === 'function') {
|
|
108
|
+
return day.toString();
|
|
109
|
+
}
|
|
110
|
+
return 'null';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns a string representation of the weekly opening hours.
|
|
115
|
+
* @returns String representation showing all days of the week
|
|
116
|
+
*/
|
|
117
|
+
toString(): string {
|
|
118
|
+
let out = "WeeklyOpeningHours: { ";
|
|
119
|
+
out += `${this.dayToString(this._monday)}, `;
|
|
120
|
+
out += `${this.dayToString(this._tuesday)}, `;
|
|
121
|
+
out += `${this.dayToString(this._wednesday)}, `;
|
|
122
|
+
out += `${this.dayToString(this._thursday)}, `;
|
|
123
|
+
out += `${this.dayToString(this._friday)}, `;
|
|
124
|
+
out += `${this.dayToString(this._saturday)}, `;
|
|
125
|
+
out += `${this.dayToString(this._sunday)} `;
|
|
126
|
+
out += "}";
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
}
|