@meetelise/chat 1.25.0 → 1.25.2

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.
Files changed (136) hide show
  1. package/coverage/lcov-report/base.css +224 -0
  2. package/coverage/lcov-report/block-navigation.js +79 -0
  3. package/coverage/lcov-report/favicon.png +0 -0
  4. package/coverage/lcov-report/index.html +111 -0
  5. package/coverage/lcov-report/index.js.html +17093 -0
  6. package/coverage/lcov-report/prettify.css +1 -0
  7. package/coverage/lcov-report/prettify.js +2 -0
  8. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  9. package/coverage/lcov-report/sorter.js +170 -0
  10. package/coverage/lcov.info +9986 -0
  11. package/dist/index.d.ts +1 -0
  12. package/package.json +1 -1
  13. package/.eslintignore +0 -2
  14. package/.eslintrc.cjs +0 -23
  15. package/.github/pull_request_template.md +0 -61
  16. package/.github/workflows/pull.yml +0 -46
  17. package/.github/workflows/release.yml +0 -23
  18. package/.husky/commit-msg +0 -2
  19. package/.husky/pre-commit +0 -4
  20. package/.idea/codeStyles/Project.xml +0 -57
  21. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  22. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  23. package/.idea/vcs.xml +0 -6
  24. package/.idea/workspace.xml +0 -67
  25. package/.prettierignore +0 -2
  26. package/.prettierrc.json +0 -1
  27. package/.vscode/settings.json +0 -13
  28. package/CONTRIBUTING.md +0 -36
  29. package/public/demo/index.html +0 -347
  30. package/public/demo/secret.html +0 -63
  31. package/src/MyPubnub.ts +0 -792
  32. package/src/WebComponent/FeeCalculator/components/collapsible-fee-section/collapsible-fee-section-styles.ts +0 -86
  33. package/src/WebComponent/FeeCalculator/components/collapsible-fee-section/collapsible-fee-section.ts +0 -94
  34. package/src/WebComponent/FeeCalculator/components/fee-item/fee-item-styles.ts +0 -47
  35. package/src/WebComponent/FeeCalculator/components/fee-item/fee-item.ts +0 -50
  36. package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles.ts +0 -46
  37. package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector.ts +0 -70
  38. package/src/WebComponent/FeeCalculator/components/index.ts +0 -3
  39. package/src/WebComponent/FeeCalculator/components/promo-card/promo-card-styles.ts +0 -39
  40. package/src/WebComponent/FeeCalculator/components/promo-card/promo-card.ts +0 -39
  41. package/src/WebComponent/FeeCalculator/fee-calculator-styles.ts +0 -280
  42. package/src/WebComponent/FeeCalculator/fee-calculator.ts +0 -256
  43. package/src/WebComponent/FeeCalculator/index.ts +0 -4
  44. package/src/WebComponent/FeeCalculator/model/building-fee.ts +0 -83
  45. package/src/WebComponent/FeeCalculator/model/transaction-category.ts +0 -23
  46. package/src/WebComponent/LeadSourceClient.ts +0 -332
  47. package/src/WebComponent/MEChat.css +0 -5
  48. package/src/WebComponent/OfficeHours.ts +0 -73
  49. package/src/WebComponent/Scheduler/date-picker.ts +0 -405
  50. package/src/WebComponent/Scheduler/time-picker.ts +0 -190
  51. package/src/WebComponent/Scheduler/tour-scheduler.ts +0 -1352
  52. package/src/WebComponent/Scheduler/tour-type-option.ts +0 -112
  53. package/src/WebComponent/Scheduler/tourSchedulerStyles.ts +0 -418
  54. package/src/WebComponent/actions/InputStyles.ts +0 -57
  55. package/src/WebComponent/actions/action-confirm-button.ts +0 -125
  56. package/src/WebComponent/actions/call-us-window.ts +0 -445
  57. package/src/WebComponent/actions/collapse-expand-button.ts +0 -65
  58. package/src/WebComponent/actions/details-window.ts +0 -150
  59. package/src/WebComponent/actions/email-us-window.ts +0 -555
  60. package/src/WebComponent/actions/formatPhoneNumber.ts +0 -72
  61. package/src/WebComponent/actions/minimize-expand-button.ts +0 -93
  62. package/src/WebComponent/chat-additional-actions.ts +0 -135
  63. package/src/WebComponent/health-chat.ts +0 -270
  64. package/src/WebComponent/healthchat-styles.ts +0 -119
  65. package/src/WebComponent/icons/ApplyOutlineIcon.ts +0 -22
  66. package/src/WebComponent/icons/BookTourOutlineIcon.ts +0 -13
  67. package/src/WebComponent/icons/CalculatorOutlineIcon.ts +0 -22
  68. package/src/WebComponent/icons/ChatOutlineIcon.ts +0 -10
  69. package/src/WebComponent/icons/ChevronLeftIcon.ts +0 -7
  70. package/src/WebComponent/icons/ChevronRightIcon.ts +0 -7
  71. package/src/WebComponent/icons/ContactResidentIcon.ts +0 -9
  72. package/src/WebComponent/icons/DollarOutlineIcon.ts +0 -18
  73. package/src/WebComponent/icons/EmailOutlineIcon.ts +0 -7
  74. package/src/WebComponent/icons/HeyThereEmojiIcon.ts +0 -12
  75. package/src/WebComponent/icons/PhoneOutlineIcon.ts +0 -7
  76. package/src/WebComponent/icons/SendMessageIcon.ts +0 -17
  77. package/src/WebComponent/icons/TourSelfGuidedIcon.ts +0 -17
  78. package/src/WebComponent/icons/TourVirtuallyIcon.ts +0 -17
  79. package/src/WebComponent/icons/TourWithAgentIcon.ts +0 -17
  80. package/src/WebComponent/icons/XOutlineIcon.ts +0 -8
  81. package/src/WebComponent/index.ts +0 -2
  82. package/src/WebComponent/launcher/Launcher.ts +0 -1193
  83. package/src/WebComponent/launcher/launcherStyles.ts +0 -500
  84. package/src/WebComponent/launcher/mobile-launcher.ts +0 -159
  85. package/src/WebComponent/launcher/typeEmojiStyles.ts +0 -161
  86. package/src/WebComponent/launcher/typeMiniStyles.ts +0 -60
  87. package/src/WebComponent/launcher/typeMobileStyles.ts +0 -50
  88. package/src/WebComponent/leasing-chat-styles.ts +0 -114
  89. package/src/WebComponent/me-chat.ts +0 -1257
  90. package/src/WebComponent/me-select.ts +0 -322
  91. package/src/WebComponent/mini-loader.ts +0 -28
  92. package/src/WebComponent/pubnub-chat-styles.ts +0 -204
  93. package/src/WebComponent/pubnub-chat.ts +0 -928
  94. package/src/WebComponent/pubnub-media.ts +0 -208
  95. package/src/WebComponent/pubnub-message-styles.ts +0 -54
  96. package/src/WebComponent/pubnub-message.ts +0 -431
  97. package/src/WebComponent/simple-launcher/simple-launcher-styles.ts +0 -34
  98. package/src/WebComponent/simple-launcher/simple-launcher.ts +0 -100
  99. package/src/WebComponent/utilities-chat.ts +0 -270
  100. package/src/WebComponent/utilities-styles.ts +0 -110
  101. package/src/WebComponent/utils.ts +0 -82
  102. package/src/analytics.ts +0 -217
  103. package/src/assetUrls.ts +0 -6
  104. package/src/disclaimers.ts +0 -58
  105. package/src/fetchBuildingABTestType.ts +0 -21
  106. package/src/fetchBuildingInfo.ts +0 -87
  107. package/src/fetchBuildingWebchatView.ts +0 -154
  108. package/src/fetchFeatureFlag.ts +0 -250
  109. package/src/fetchLeadSources.ts +0 -98
  110. package/src/fetchPhoneNumberFromSource.ts +0 -31
  111. package/src/fetchWebchatPreferences.ts +0 -54
  112. package/src/getAvailabilities.ts +0 -174
  113. package/src/getBuildingPhoneNumber.ts +0 -26
  114. package/src/getShouldAllowScheduling.ts +0 -16
  115. package/src/getShouldShowWebchat.ts +0 -114
  116. package/src/getTimezoneString.ts +0 -39
  117. package/src/globals.ts +0 -1
  118. package/src/gtm.ts +0 -17
  119. package/src/handleChatId.ts +0 -101
  120. package/src/insertDNIIntoWebsite.ts +0 -146
  121. package/src/insertLeadSourceIntoSchedulerLinks.ts +0 -71
  122. package/src/main/MEChat.test.ts +0 -110
  123. package/src/main/MEChat.ts +0 -404
  124. package/src/main/utils.ts +0 -70
  125. package/src/postLeadSources.ts +0 -44
  126. package/src/rentgrata.ts +0 -74
  127. package/src/replaceSelectButtonsWithNewLink.ts +0 -68
  128. package/src/services/fees/fetchBuildingFees.ts +0 -28
  129. package/src/svgIcons.ts +0 -14
  130. package/src/themes.ts +0 -65
  131. package/src/types/rest-sdk.types.ts +0 -13
  132. package/src/types/webchat-no-show-reason.ts +0 -6
  133. package/src/utils.ts +0 -121
  134. package/tsconfig.json +0 -84
  135. package/web-test-runner.config.js +0 -10
  136. package/webpack.config.cjs +0 -48
@@ -1,250 +0,0 @@
1
- import axios from "axios";
2
-
3
- // V1 reads from the launch darkly flag
4
- // Note, in launch darkly we can define the building_id as the user filter and just need to pass
5
- // the building_slug to the endpoint - we map in the backend
6
- const featureFlagEndpointV1 = (buildingSlug: string): string => {
7
- const host = "https://app.meetelise.com";
8
- return `${host}/platformApi/webchat/${buildingSlug}/chat-ui-feature-flag`;
9
- };
10
-
11
- // V2 reads from conversation flag table (preferred)
12
- const featureFlagEndpointV2 = (buildingSlug: string): string => {
13
- const host = "https://app.meetelise.com";
14
- return `${host}/platformApi/webchat/${buildingSlug}/v2/chat-ui-feature-flag`;
15
- };
16
-
17
- export enum FeatureFlagsShowDropdown {
18
- onAttributionFailure = "on-attribution-failure",
19
- never = "never", // note, the dropdown will NOT show up if there are also no lead sources (list)!
20
- always = "always",
21
- }
22
-
23
- export async function fetchFeatureFlagMaintenanceMode(
24
- buildingSlug: string
25
- ): Promise<boolean> {
26
- if (!buildingSlug) {
27
- return false;
28
- }
29
- try {
30
- const featureFlagResponse = await axios.get(
31
- featureFlagEndpointV1(buildingSlug),
32
- {
33
- params: {
34
- building_slug: buildingSlug,
35
- flag_type: "bool",
36
- feature_flag: "webchat-leasing-in-maintenance-mode",
37
- default_str: null,
38
- default_bool: false,
39
- },
40
- }
41
- );
42
- return featureFlagResponse.data;
43
- } catch (_) {
44
- return false;
45
- }
46
- }
47
-
48
- export async function fetchFeatureFlagShowMarketingSourceDropdown(
49
- buildingSlug: string
50
- ): Promise<FeatureFlagsShowDropdown> {
51
- if (!buildingSlug) {
52
- return FeatureFlagsShowDropdown.always;
53
- }
54
- try {
55
- const featureFlagResponse = await axios.get(
56
- featureFlagEndpointV1(buildingSlug),
57
- {
58
- params: {
59
- building_slug: buildingSlug,
60
- flag_type: "string",
61
- feature_flag: "webchat-marketing-source-dropdown-configuration",
62
- default_str: "always",
63
- default_bool: true,
64
- },
65
- }
66
- );
67
- if (featureFlagResponse.data === "on-attribution-failure") {
68
- return FeatureFlagsShowDropdown.onAttributionFailure;
69
- }
70
- if (featureFlagResponse.data === "never") {
71
- return FeatureFlagsShowDropdown.never;
72
- }
73
- return FeatureFlagsShowDropdown.always;
74
- } catch (_) {
75
- return FeatureFlagsShowDropdown.always;
76
- }
77
- }
78
-
79
- export async function fetchFeatureFlagUsePhoneNumberBySource(
80
- buildingSlug: string
81
- ): Promise<boolean> {
82
- if (!buildingSlug) {
83
- return false;
84
- }
85
- try {
86
- const featureFlagResponse = await axios.get(
87
- featureFlagEndpointV1(buildingSlug),
88
- {
89
- params: {
90
- building_slug: buildingSlug,
91
- flag_type: "bool",
92
- feature_flag: "webchat-use-dni-phone-number-by-source",
93
- default_str: null,
94
- default_bool: false,
95
- },
96
- }
97
- );
98
- return featureFlagResponse.data;
99
- } catch (_) {
100
- return false;
101
- }
102
- }
103
-
104
- export async function fetchFeatureFlagUseOverrideContactUsForm(
105
- buildingSlug: string
106
- ): Promise<boolean> {
107
- if (!buildingSlug) {
108
- return false;
109
- }
110
- try {
111
- const featureFlagResponse = await axios.get(
112
- featureFlagEndpointV1(buildingSlug),
113
- {
114
- params: {
115
- building_slug: buildingSlug,
116
- flag_type: "bool",
117
- feature_flag: "webchat-use-override-contact-us-form",
118
- default_str: null,
119
- default_bool: false,
120
- },
121
- }
122
- );
123
- return featureFlagResponse.data;
124
- } catch (_) {
125
- return false;
126
- }
127
- }
128
- export async function fetchFeatureFlagUsePubnub(
129
- buildingSlug?: string
130
- ): Promise<boolean> {
131
- if (!buildingSlug) {
132
- return false;
133
- }
134
- try {
135
- const featureFlagResponse = await axios.get(
136
- featureFlagEndpointV1(buildingSlug),
137
- {
138
- params: {
139
- building_slug: buildingSlug,
140
- flag_type: "bool",
141
- feature_flag: "use-pubnub-chat-provider",
142
- default_str: null,
143
- default_bool: false,
144
- },
145
- }
146
- );
147
- return featureFlagResponse.data;
148
- } catch (_) {
149
- return false;
150
- }
151
- }
152
-
153
- export async function fetchFeatureFlagInsertDNIWebsite(
154
- buildingSlug?: string
155
- ): Promise<boolean> {
156
- if (!buildingSlug) {
157
- return false;
158
- }
159
- try {
160
- const featureFlagResponse = await axios.get(
161
- featureFlagEndpointV2(buildingSlug),
162
- {
163
- params: {
164
- building_slug: buildingSlug,
165
- feature_flag_name: "insert_dni_into_website",
166
- default_value: false,
167
- },
168
- }
169
- );
170
- return featureFlagResponse.data;
171
- } catch (_) {
172
- return false;
173
- }
174
- }
175
-
176
- export async function fetchFeatureFlagShowUtilities(
177
- orgSlug: string
178
- ): Promise<boolean> {
179
- if (!orgSlug) {
180
- return false;
181
- }
182
- const buildingSlug = "e2e-test-yardi-building";
183
- try {
184
- const featureFlagResponse = await axios.get(
185
- featureFlagEndpointV1(buildingSlug),
186
- {
187
- params: {
188
- building_slug: buildingSlug,
189
- flag_type: "bool",
190
- feature_flag: "enable-show-utilities-webchat",
191
- default_str: null,
192
- default_bool: false,
193
- },
194
- }
195
- );
196
- return featureFlagResponse.data;
197
- } catch (_) {
198
- return false;
199
- }
200
- }
201
-
202
- export async function fetchFeatureFlagReplaceScheduleTourCtaWebsite(
203
- buildingSlug: string
204
- ): Promise<boolean> {
205
- if (!buildingSlug) {
206
- return false;
207
- }
208
- try {
209
- const featureFlagResponse = await axios.get(
210
- featureFlagEndpointV1(buildingSlug),
211
- {
212
- params: {
213
- building_slug: buildingSlug,
214
- flag_type: "bool",
215
- feature_flag: "webchat-replace-any-schedule-tour-cta-website",
216
- default_str: null,
217
- default_bool: false,
218
- },
219
- }
220
- );
221
- return featureFlagResponse.data;
222
- } catch (_) {
223
- return false;
224
- }
225
- }
226
-
227
- export async function fetchFeatureFlagUseApplicationsLinkReplacement(
228
- buildingSlug: string
229
- ): Promise<boolean> {
230
- if (!buildingSlug) {
231
- return false;
232
- }
233
- try {
234
- const featureFlagResponse = await axios.get(
235
- featureFlagEndpointV1(buildingSlug),
236
- {
237
- params: {
238
- building_slug: buildingSlug,
239
- flag_type: "bool",
240
- feature_flag: "webchat-use-applications-link-replacement",
241
- default_str: null,
242
- default_bool: false,
243
- },
244
- }
245
- );
246
- return featureFlagResponse.data;
247
- } catch (_) {
248
- return false;
249
- }
250
- }
@@ -1,98 +0,0 @@
1
- import axios from "axios";
2
- export interface BuildingABType {
3
- abTestType: string;
4
- }
5
- export default async function fetchLeadSources(
6
- orgSlug: string,
7
- buildingSlug: string
8
- ): Promise<string[]> {
9
- const host = "https://app.meetelise.com";
10
- try {
11
- const leadSourcesResponse = await axios.get(
12
- `${host}/platformApi/webchat/${buildingSlug}/lead-sources`
13
- );
14
- if (leadSourcesResponse.data) {
15
- if (orgSlug === "7e352741-1120-4ccf-9929-5dc99193a908") {
16
- const onlyIncludeSources = [
17
- "Zillow",
18
- "Apartments.com",
19
- "Google PPC",
20
- "Google Maps",
21
- "Apple Maps",
22
- "Social Media",
23
- "Print Marketing",
24
- ];
25
- return leadSourcesResponse.data.filter((source: string) =>
26
- onlyIncludeSources.includes(source)
27
- );
28
- }
29
- return filterOutBuildingSpecificLeadSources(
30
- leadSourcesResponse.data,
31
- buildingSlug
32
- );
33
- }
34
- return [];
35
- } catch (_) {
36
- return [];
37
- }
38
- }
39
-
40
- const filterOutBuildingSpecificLeadSources = (
41
- leadSources: string[],
42
- buildingSlug: string
43
- ): string[] => {
44
- // Dinerstien asked to filter out some sources based on their buildings
45
- let removeLeadSources: string[] = [];
46
- switch (buildingSlug) {
47
- case "d41619ec-0f79-11ee-8439-93855926ad58": // Infinity Lofts in the Gulch
48
- removeLeadSources = [
49
- "Forthea - PPC",
50
- "HotPads",
51
- "Forthea",
52
- "Locator",
53
- "Website-apartmentguide.com",
54
- "Forthea - organic search",
55
- "Tdc employee",
56
- "University newspaper",
57
- "Nashville apartment locators",
58
- "Forthea - paid social",
59
- "Apartment list",
60
- "Off campus partners",
61
- "Waze ads",
62
- "Athletic event",
63
- "Website-apartment guide",
64
- ];
65
- break;
66
- case "d4160560-0f79-11ee-8438-fba837bf3a46": // Sawyer on Lincoln
67
- removeLeadSources = [
68
- "Forthea - PPC",
69
- "Rentgrata",
70
- "Website-ApartmentFinder.com",
71
- "Word of Mouth",
72
- "Texas A&M A-Frame on Campus",
73
- "Rent.com",
74
- "Website-craigslist",
75
- "Apartment List",
76
- "Website-apartments.com",
77
- "Forthea - paid social",
78
- "Forthea - organic search",
79
- "Website-apartmentguide.com",
80
- "Forthea",
81
- "Uhomes",
82
- "Phone book",
83
- "Property - website",
84
- ];
85
- break;
86
- default:
87
- removeLeadSources = [];
88
- }
89
- leadSources.sort();
90
- return leadSources.filter((leadSource) => {
91
- const lowerCaseLeadSource = leadSource.toLowerCase();
92
- const lowerCaseRemoveLeadSources = removeLeadSources.map((source) =>
93
- source.toLowerCase()
94
- );
95
-
96
- return !lowerCaseRemoveLeadSources.includes(lowerCaseLeadSource);
97
- });
98
- };
@@ -1,31 +0,0 @@
1
- import axios from "axios";
2
- import { formatPhoneNumber } from "./WebComponent/actions/formatPhoneNumber";
3
-
4
- export interface NumberForSelectedSource {
5
- number: string;
6
- isMatch: boolean;
7
- isPropertyWebsiteCatchall: boolean;
8
- }
9
-
10
- export default async function fetchPhoneNumberFromSource(
11
- buildingSlug: string,
12
- source: string | null
13
- ): Promise<NumberForSelectedSource | null> {
14
- const host = "https://app.meetelise.com";
15
- try {
16
- const phoneNumberResponse = await axios.get(
17
- `${host}/platformApi/webchat/${buildingSlug}/phone-number-by-source?source=${source}`
18
- );
19
- if (phoneNumberResponse.data) {
20
- return {
21
- number: formatPhoneNumber(phoneNumberResponse.data.number),
22
- isMatch: phoneNumberResponse.data.match,
23
- isPropertyWebsiteCatchall:
24
- phoneNumberResponse.data.isPropertyWebsiteCatchall,
25
- };
26
- }
27
- return null;
28
- } catch (_) {
29
- return null;
30
- }
31
- }
@@ -1,54 +0,0 @@
1
- import axios from "axios";
2
- import { camelize } from "./utils";
3
-
4
- /**
5
- * @deprecated Use BuildingWebchatView instead.
6
- */
7
- export interface WebchatSettings {
8
- config: WebchatConfigurationPreferences;
9
- isInheriting: boolean;
10
- isGlobalDefault: boolean;
11
- }
12
- /**
13
- * @deprecated Use BuildingWebchatView instead.
14
- */
15
- export interface WebchatConfigurationPreferences {
16
- autoOpenChat: boolean;
17
- shouldShowChat: boolean;
18
- shouldShowChatDesktop: boolean;
19
- shouldShowChatMobile: boolean;
20
- shouldShowTextDesktop: boolean;
21
- shouldShowTextMobile: boolean;
22
- shouldShowPhoneDesktop: boolean;
23
- shouldShowPhoneMobile: boolean;
24
- shouldShowEmailDesktop: boolean;
25
- shouldShowEmailMobile: boolean;
26
- shouldShowSstDesktop: boolean;
27
- shouldShowSstMobile: boolean;
28
- requiresConsentForChat: boolean;
29
- privacyPolicyUrlForChat: string | null;
30
- collapseMobileFeatures: boolean;
31
- isInheritingFromOrg: boolean;
32
- isGlobalDefault: boolean;
33
- }
34
-
35
- /**
36
- * @deprecated Use BuildingWebchatView instead.
37
- */
38
- export default async function fetchWebchatPreferences(
39
- buildingId: number
40
- ): Promise<WebchatSettings | null> {
41
- const host = "https://app.meetelise.com";
42
- try {
43
- const webchatPreferencesResponse = await axios.get(
44
- `${host}/eliseCrmApi/webchat/config/v2/building/${buildingId}`
45
- );
46
-
47
- if (webchatPreferencesResponse.data) {
48
- return camelize<WebchatSettings>(webchatPreferencesResponse.data);
49
- }
50
- } catch (_) {
51
- return null;
52
- }
53
- return null;
54
- }
@@ -1,174 +0,0 @@
1
- import formatISO from "date-fns/formatISO";
2
- import startOfToday from "date-fns/startOfToday";
3
- import endOfDay from "date-fns/endOfDay";
4
- import addDays from "date-fns/addDays";
5
- import format from "date-fns/format";
6
- import axios from "axios";
7
-
8
- import {
9
- TourAvailabilityResponse,
10
- TourAvailabilityResponseRankOrderedSupportedTourTypesEnum,
11
- } from "./types/rest-sdk.types";
12
- import groupBy from "lodash/groupBy";
13
- import { TourType } from "./WebComponent/Scheduler/tour-scheduler";
14
- import isPast from "date-fns/isPast";
15
- import parseISO from "date-fns/parseISO";
16
- import isValid from "date-fns/isValid";
17
-
18
- const availabilitiesCache: {
19
- buildingId?: number | null;
20
- availabilities: { [buildingId: number]: TourAvailabilityResponse };
21
- } = { buildingId: null, availabilities: {} };
22
-
23
- /**
24
- * Returns the raw availabilities.
25
- *
26
- * If no `buildingId` is provided, it will use a cached buildingId from the previous call.
27
- * If there is none cached, it will throw an error.
28
- */
29
- export const getRawAvailabilities = async (
30
- buildingId?: number
31
- ): Promise<TourAvailabilityResponse> => {
32
- if (buildingId) {
33
- availabilitiesCache.buildingId = buildingId;
34
- }
35
- const buildingIdToUse = availabilitiesCache.buildingId;
36
- if (!buildingIdToUse) {
37
- throw new Error(
38
- "No buildingId was provided to getRawAvailabilities and there is no buildingId cached."
39
- );
40
- }
41
- const availabilities = availabilitiesCache.availabilities;
42
- if (availabilities[buildingIdToUse]) {
43
- return availabilities[buildingIdToUse];
44
- }
45
- const startTime = startOfToday();
46
- const endTime = formatISO(endOfDay(addDays(startTime, 30)));
47
-
48
- // We MUST encode the URI components because a positive timezone offset counts as a space in urls!
49
- const timeParams = `startTime=${encodeURIComponent(
50
- formatISO(startTime)
51
- )}&endTime=${encodeURIComponent(endTime)}`;
52
- const url = `https://app.meetelise.com/api/pub/v1/buildings/${buildingIdToUse}/tour/availabilities?${timeParams}`;
53
-
54
- const result = await axios.get<TourAvailabilityResponse>(url);
55
- availabilitiesCache.availabilities[buildingIdToUse] = result.data;
56
- // The endpoint INCORRECTLY states that these are returned as dates. They are, in fact, strings.
57
- return result.data;
58
- };
59
-
60
- export const getAvailabilitiesForTourType = async (
61
- tourType: TourAvailabilityResponseRankOrderedSupportedTourTypesEnum,
62
- buildingId?: number
63
- ): Promise<{
64
- /**
65
- *
66
- * @type {number}
67
- * @memberof TourTypeAvailability
68
- */
69
- tourDurationInMinutes?: number;
70
- /**
71
- *
72
- * @type {Array<string>}
73
- * @memberof TourTypeAvailability
74
- */
75
- availableTourStartTimes?: Array<string>;
76
- } | null> => {
77
- // The endpoint INCORRECTLY states that these are returned as dates. They are, in fact, strings.
78
- const availabilities = await getRawAvailabilities(buildingId);
79
- const availableTimes = availabilities.availability?.[tourType]
80
- ? (availabilities.availability?.[tourType]
81
- .availableTourStartTimes as unknown as string[])
82
- : [];
83
- return availabilities.availability
84
- ? {
85
- ...availabilities.availability[tourType],
86
- availableTourStartTimes: availableTimes,
87
- }
88
- : null;
89
- };
90
-
91
- export interface DateWithTimeZoneOffset {
92
- datetime: string;
93
- offset: string;
94
- }
95
-
96
- /**
97
- * Returns an object that reveals whether each tour type supported by
98
- * `tour-scheduler` has availabilities (time slots available for scheduling) in
99
- * the time window of interest.
100
- *
101
- * Note that the existence of current availabilities is distinct from the
102
- * question of whether the community supports the tour type at all. The first
103
- * implies the second but not vice versa.
104
- */
105
- export const getExistenceOfAvailabilitiesByTourType = async (): Promise<{
106
- [TourType.Guided]: boolean;
107
- [TourType.Self]: boolean;
108
- [TourType.Virtual]: boolean;
109
- }> => {
110
- return {
111
- [TourType.Guided]: !!(
112
- await getAvailabilitiesForTourType(
113
- TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent
114
- )
115
- )?.availableTourStartTimes?.length,
116
- [TourType.Self]: !!(
117
- await getAvailabilitiesForTourType(
118
- TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided
119
- )
120
- )?.availableTourStartTimes?.length,
121
- [TourType.Virtual]: !!(
122
- await getAvailabilitiesForTourType(
123
- TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing
124
- )
125
- )?.availableTourStartTimes?.length,
126
- };
127
- };
128
-
129
- export const getAvailabilitiesGroupedByDay = async (
130
- tourType: TourAvailabilityResponseRankOrderedSupportedTourTypesEnum,
131
- buildingId?: number
132
- ): Promise<{ [day: string]: DateWithTimeZoneOffset[] }> => {
133
- const availabilitiesForTourTypeRaw = await getAvailabilitiesForTourType(
134
- tourType,
135
- buildingId
136
- );
137
-
138
- if (!availabilitiesForTourTypeRaw) {
139
- return {};
140
- }
141
- // Specify offset for each datetime in case availabilities span a daylight savings boundary, when offset will change.
142
- // Cast availableTourStartTimes to string[], since the Date[] typing of the API is incorrect
143
- const availabilitiesForTourType: {
144
- availableTourStartTimes: DateWithTimeZoneOffset[] | undefined;
145
- } = {
146
- availableTourStartTimes:
147
- (availabilitiesForTourTypeRaw.availableTourStartTimes
148
- ? (
149
- availabilitiesForTourTypeRaw.availableTourStartTimes as unknown as string[]
150
- ).filter((dt) => isValid(parseISO(dt)) && !isPast(parseISO(dt)))
151
- : []
152
- )?.map((dateString) => dateStringToDateWithTimeZoneOffset(dateString)),
153
- };
154
-
155
- return groupBy(
156
- availabilitiesForTourType.availableTourStartTimes ?? [],
157
- (startTime) => format(new Date(startTime.datetime), "yyyy-MM-dd")
158
- );
159
- };
160
-
161
- /**
162
- * Takes an ISO 8601 date string with time zone offset and returns
163
- * an object of our custom type DateWithTimeZoneOffset.
164
- *
165
- * @example
166
- * // returns { datetime: '2022-06-27T09:00:00', offset: '-07:00' }
167
- * dateStringToDateWithTimeZoneOffset('2022-06-27T09:00:00-07:00')
168
- * */
169
- const dateStringToDateWithTimeZoneOffset = (
170
- dateString: string
171
- ): DateWithTimeZoneOffset => ({
172
- datetime: dateString.slice(0, 19),
173
- offset: dateString.slice(19),
174
- });
@@ -1,26 +0,0 @@
1
- import axios from "axios";
2
- import { LogType, sendLoggingEvent } from "./analytics";
3
-
4
- export const getBuildingPhoneNumber = async (
5
- buildingSlug: string
6
- ): Promise<string | null> => {
7
- try {
8
- const host = "https://app.meetelise.com";
9
- const webchatPreferencesResponse = await axios.get(
10
- `${host}/platformApi/webchat/${buildingSlug}/phone-number`
11
- );
12
- if (webchatPreferencesResponse.data) {
13
- return webchatPreferencesResponse.data;
14
- }
15
- } catch (error) {
16
- sendLoggingEvent({
17
- logType: LogType.error,
18
- buildingSlug,
19
- logTitle: "[ERROR_GETTING_PHONE_NUMBERS]",
20
- logData: { error },
21
- });
22
-
23
- return null;
24
- }
25
- return null;
26
- };
@@ -1,16 +0,0 @@
1
- import axios from "axios";
2
-
3
- export const getShouldAllowScheduling = async (
4
- buildingId: number,
5
- isDynamicSchedulingEnabled = false
6
- ): Promise<boolean> => {
7
- const host = "https://app.meetelise.com";
8
- const url = `${host}/eliseCrmApi/building/${buildingId}/scheduling_status?observe_dynamic_scheduling=${isDynamicSchedulingEnabled}`;
9
-
10
- try {
11
- const response = await axios.get(url);
12
- return response.data.is_enabled;
13
- } catch (e) {
14
- return false;
15
- }
16
- };