@medipass/web-sdk 11.37.8 → 11.38.1-feature-typescript-claudia.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/.eslintrc.cjs +95 -0
- package/CHANGELOG.md +11 -0
- package/babel.config.js +2 -1
- package/lib/index.d.ts +262 -0
- package/lib/index.js +83 -3
- package/lib/{regions-ed54f163.js → regions-a0a28864.js} +2 -2
- package/lib/resources/accounts.d.ts +215 -0
- package/lib/resources/accounts.js +3 -3
- package/lib/resources/actions.d.ts +13 -0
- package/lib/resources/actions.js +3 -3
- package/lib/resources/api-keys.d.ts +24 -0
- package/lib/resources/api-keys.js +3 -3
- package/lib/resources/applications.d.ts +31 -0
- package/lib/resources/applications.js +3 -3
- package/lib/resources/attachments.d.ts +32 -0
- package/lib/resources/attachments.js +3 -3
- package/lib/resources/auth.d.ts +59 -0
- package/lib/resources/auth.js +3 -3
- package/lib/resources/bulk-submits.d.ts +17 -0
- package/lib/resources/bulk-submits.js +3 -3
- package/lib/resources/bulk-uploads.d.ts +26 -0
- package/lib/resources/bulk-uploads.js +3 -3
- package/lib/resources/business-profiles.d.ts +18 -0
- package/lib/resources/business-profiles.js +3 -3
- package/lib/resources/businesses.d.ts +132 -0
- package/lib/resources/businesses.js +3 -3
- package/lib/resources/claim-items.d.ts +31 -0
- package/lib/resources/claim-items.js +3 -3
- package/lib/resources/devices.d.ts +11 -0
- package/lib/resources/devices.js +3 -3
- package/lib/resources/doc-accounts.d.ts +32 -0
- package/lib/resources/doc-accounts.js +3 -3
- package/lib/resources/documents.d.ts +90 -0
- package/lib/resources/documents.js +3 -3
- package/lib/resources/emails.d.ts +14 -0
- package/lib/resources/emails.js +3 -3
- package/lib/resources/form-application-templates.d.ts +20 -0
- package/lib/resources/form-application-templates.js +3 -3
- package/lib/resources/form-applications.d.ts +27 -0
- package/lib/resources/form-applications.js +3 -3
- package/lib/resources/forms.d.ts +100 -0
- package/lib/resources/forms.js +3 -3
- package/lib/resources/funder-services.d.ts +8 -0
- package/lib/resources/funder-services.js +3 -3
- package/lib/resources/funder-settings.d.ts +8 -0
- package/lib/resources/funder-settings.js +3 -3
- package/lib/resources/funders.d.ts +5 -0
- package/lib/resources/funders.js +3 -3
- package/lib/resources/futures.d.ts +85 -0
- package/lib/resources/futures.js +3 -3
- package/lib/resources/health-fund-accounts.d.ts +78 -0
- package/lib/resources/health-fund-accounts.js +3 -3
- package/lib/resources/health-fund-settings.d.ts +39 -0
- package/lib/resources/health-fund-settings.js +3 -3
- package/lib/resources/healthfunds.d.ts +64 -0
- package/lib/resources/healthfunds.js +3 -3
- package/lib/resources/icditems.d.ts +14 -0
- package/lib/resources/icditems.js +3 -3
- package/lib/resources/invoice-scans.d.ts +26 -0
- package/lib/resources/invoice-scans.js +3 -3
- package/lib/resources/jhcs.d.ts +7 -0
- package/lib/resources/jhcs.js +3 -3
- package/lib/resources/kyc.d.ts +109 -0
- package/lib/resources/kyc.js +3 -3
- package/lib/resources/logs.d.ts +16 -0
- package/lib/resources/logs.js +3 -3
- package/lib/resources/members.d.ts +92 -0
- package/lib/resources/members.js +3 -3
- package/lib/resources/message-mappings.d.ts +9 -0
- package/lib/resources/message-mappings.js +3 -3
- package/lib/resources/minions.d.ts +40 -0
- package/lib/resources/minions.js +3 -3
- package/lib/resources/modalities.d.ts +19 -0
- package/lib/resources/modalities.js +3 -3
- package/lib/resources/notes.d.ts +17 -0
- package/lib/resources/notes.js +3 -3
- package/lib/resources/onboarding-applications.d.ts +52 -0
- package/lib/resources/onboarding-applications.js +3 -3
- package/lib/resources/onboarding-requests.d.ts +39 -0
- package/lib/resources/onboarding-requests.js +3 -3
- package/lib/resources/ops.d.ts +60 -0
- package/lib/resources/ops.js +3 -3
- package/lib/resources/organisations.d.ts +7 -0
- package/lib/resources/organisations.js +3 -3
- package/lib/resources/partners.d.ts +50 -0
- package/lib/resources/partners.js +3 -3
- package/lib/resources/patients.d.ts +44 -0
- package/lib/resources/patients.js +3 -3
- package/lib/resources/payments.d.ts +155 -0
- package/lib/resources/payments.js +3 -3
- package/lib/resources/pms.d.ts +43 -0
- package/lib/resources/pms.js +3 -3
- package/lib/resources/practice-profiles.d.ts +20 -0
- package/lib/resources/practice-profiles.js +3 -3
- package/lib/resources/practice-types.d.ts +6 -0
- package/lib/resources/practice-types.js +3 -3
- package/lib/resources/practices.d.ts +137 -0
- package/lib/resources/practices.js +3 -3
- package/lib/resources/products.d.ts +23 -0
- package/lib/resources/products.js +3 -3
- package/lib/resources/professional-categories.d.ts +23 -0
- package/lib/resources/professional-categories.js +3 -3
- package/lib/resources/provider-number-types.d.ts +16 -0
- package/lib/resources/provider-number-types.js +3 -3
- package/lib/resources/provider-registration-types.d.ts +15 -0
- package/lib/resources/provider-registration-types.js +3 -3
- package/lib/resources/provider-requests.d.ts +17 -0
- package/lib/resources/provider-requests.js +3 -3
- package/lib/resources/provider-types.d.ts +6 -0
- package/lib/resources/provider-types.js +3 -3
- package/lib/resources/ref-sources.d.ts +6 -0
- package/lib/resources/ref-sources.js +3 -3
- package/lib/resources/risk.d.ts +13 -0
- package/lib/resources/risk.js +3 -3
- package/lib/resources/rnas.d.ts +43 -0
- package/lib/resources/rnas.js +3 -3
- package/lib/resources/roles.d.ts +7 -0
- package/lib/resources/roles.js +3 -3
- package/lib/resources/self-checkout-sessions.d.ts +134 -0
- package/lib/resources/self-checkout-sessions.js +3 -3
- package/lib/resources/services.d.ts +88 -0
- package/lib/resources/services.js +3 -3
- package/lib/resources/settlements.d.ts +37 -0
- package/lib/resources/settlements.js +4 -3
- package/lib/resources/sign-up.d.ts +5 -0
- package/lib/resources/sign-up.js +3 -3
- package/lib/resources/specialties.d.ts +23 -0
- package/lib/resources/specialties.js +3 -3
- package/lib/resources/staff-profiles.d.ts +20 -0
- package/lib/resources/staff-profiles.js +3 -3
- package/lib/resources/staff.d.ts +242 -0
- package/lib/resources/staff.js +3 -3
- package/lib/resources/statistics.d.ts +56 -0
- package/lib/resources/statistics.js +3 -3
- package/lib/resources/subscriptions.d.ts +32 -0
- package/lib/resources/subscriptions.js +3 -3
- package/lib/resources/terminals.d.ts +71 -0
- package/lib/resources/terminals.js +3 -3
- package/lib/resources/transaction-export.d.ts +18 -0
- package/lib/resources/transaction-export.js +3 -3
- package/lib/resources/transactions.d.ts +466 -0
- package/lib/resources/transactions.js +3 -3
- package/lib/resources/triggers.d.ts +20 -0
- package/lib/resources/triggers.js +3 -3
- package/lib/resources/vendors.d.ts +9 -0
- package/lib/resources/vendors.js +3 -3
- package/lib/resources/verify.d.ts +9 -0
- package/lib/resources/verify.js +3 -3
- package/lib/resources/workers.d.ts +3 -0
- package/lib/resources/workers.js +3 -3
- package/lib/resources/workflow-exceptions.d.ts +5 -0
- package/lib/resources/workflow-exceptions.js +3 -3
- package/lib/services/aws.d.ts +54 -0
- package/lib/services/aws.js +3 -3
- package/lib/services/storage.d.ts +28 -0
- package/lib/services/storage.js +126 -18
- package/lib/services/version.d.ts +21 -0
- package/lib/services/version.js +3 -3
- package/lib/{staff-df3df93e.js → staff-96febcd8.js} +217 -582
- package/lib/types/documents.d.ts +115 -0
- package/lib/types/documents.js +2 -0
- package/lib/types/forms.d.ts +67 -0
- package/lib/types/forms.js +2 -0
- package/lib/types/index.d.ts +42 -0
- package/lib/types/index.js +2 -0
- package/lib/types/message-mappings.d.ts +18 -0
- package/lib/types/message-mappings.js +2 -0
- package/lib/types/notes.d.ts +5 -0
- package/lib/types/notes.js +2 -0
- package/lib/types/products.d.ts +34 -0
- package/lib/types/products.js +2 -0
- package/lib/types/professional-categories.d.ts +20 -0
- package/lib/types/professional-categories.js +2 -0
- package/lib/types/specialties.d.ts +22 -0
- package/lib/types/specialties.js +2 -0
- package/lib/types/subscriptions.d.ts +52 -0
- package/lib/types/subscriptions.js +2 -0
- package/lib/utils/application.d.ts +1 -0
- package/lib/utils/application.js +3 -3
- package/lib/utils/base-urls/core.d.ts +19 -0
- package/lib/utils/base-urls/index.d.ts +37 -0
- package/lib/utils/base-urls/risk.d.ts +17 -0
- package/lib/utils/does-param-exist.d.ts +2 -0
- package/lib/utils/get-axios-error.d.ts +2 -0
- package/lib/utils/param-error.d.ts +3 -0
- package/lib/utils/professions.d.ts +3 -0
- package/lib/utils/professions.js +3 -3
- package/lib/utils/regions.d.ts +1 -0
- package/lib/utils/regions.js +2 -2
- package/lib/utils/request.d.ts +3 -0
- package/lib/utils/request.js +3 -3
- package/lib/utils/staff.d.ts +8 -0
- package/lib/utils/staff.js +3 -3
- package/package.json +19 -9
- package/tsconfig.json +33 -0
- package/.eslintrc +0 -3
- package/lib/_types/documents.js.flow +0 -118
- package/lib/_types/forms.js.flow +0 -57
- package/lib/_types/index.js.flow +0 -47
- package/lib/_types/message-mappings.js.flow +0 -22
- package/lib/_types/notes.js.flow +0 -7
- package/lib/_types/products.js.flow +0 -40
- package/lib/_types/professional-categories.js.flow +0 -25
- package/lib/_types/specialties.js.flow +0 -27
- package/lib/_types/subscriptions.js.flow +0 -58
- package/lib/index.js.flow +0 -438
- package/lib/resources/accounts.js.flow +0 -445
- package/lib/resources/actions.js.flow +0 -25
- package/lib/resources/api-keys.js.flow +0 -54
- package/lib/resources/applications.js.flow +0 -60
- package/lib/resources/attachments.js.flow +0 -75
- package/lib/resources/auth.js.flow +0 -185
- package/lib/resources/bulk-submits.js.flow +0 -43
- package/lib/resources/bulk-uploads.js.flow +0 -56
- package/lib/resources/business-profiles.js.flow +0 -45
- package/lib/resources/businesses.js.flow +0 -267
- package/lib/resources/claim-items.js.flow +0 -76
- package/lib/resources/devices.js.flow +0 -64
- package/lib/resources/doc-accounts.js.flow +0 -61
- package/lib/resources/documents.js.flow +0 -216
- package/lib/resources/emails.js.flow +0 -96
- package/lib/resources/form-application-templates.js.flow +0 -52
- package/lib/resources/form-applications.js.flow +0 -62
- package/lib/resources/forms.js.flow +0 -222
- package/lib/resources/funder-services.js.flow +0 -17
- package/lib/resources/funder-settings.js.flow +0 -58
- package/lib/resources/funders.js.flow +0 -15
- package/lib/resources/futures.js.flow +0 -154
- package/lib/resources/health-fund-accounts.js.flow +0 -198
- package/lib/resources/health-fund-settings.js.flow +0 -104
- package/lib/resources/healthfunds.js.flow +0 -139
- package/lib/resources/icditems.js.flow +0 -36
- package/lib/resources/invoice-scans.js.flow +0 -56
- package/lib/resources/jhcs.js.flow +0 -20
- package/lib/resources/kyc.js.flow +0 -216
- package/lib/resources/logs.js.flow +0 -32
- package/lib/resources/members.js.flow +0 -196
- package/lib/resources/message-mappings.js.flow +0 -25
- package/lib/resources/minions.js.flow +0 -96
- package/lib/resources/modalities.js.flow +0 -46
- package/lib/resources/notes.js.flow +0 -112
- package/lib/resources/onboarding-applications.js.flow +0 -142
- package/lib/resources/onboarding-requests.js.flow +0 -97
- package/lib/resources/ops.js.flow +0 -116
- package/lib/resources/organisations.js.flow +0 -15
- package/lib/resources/partners.js.flow +0 -118
- package/lib/resources/patients.js.flow +0 -102
- package/lib/resources/payments.js.flow +0 -523
- package/lib/resources/pms.js.flow +0 -102
- package/lib/resources/practice-profiles.js.flow +0 -51
- package/lib/resources/practice-types.js.flow +0 -14
- package/lib/resources/practices.js.flow +0 -314
- package/lib/resources/products.js.flow +0 -48
- package/lib/resources/professional-categories.js.flow +0 -56
- package/lib/resources/provider-number-types.js.flow +0 -32
- package/lib/resources/provider-registration-types.js.flow +0 -32
- package/lib/resources/provider-requests.js.flow +0 -46
- package/lib/resources/provider-types.js.flow +0 -14
- package/lib/resources/ref-sources.js.flow +0 -16
- package/lib/resources/risk.js.flow +0 -29
- package/lib/resources/rnas.js.flow +0 -108
- package/lib/resources/roles.js.flow +0 -12
- package/lib/resources/self-checkout-sessions.js.flow +0 -382
- package/lib/resources/services.js.flow +0 -219
- package/lib/resources/settlements.js.flow +0 -79
- package/lib/resources/sign-up.js.flow +0 -15
- package/lib/resources/specialties.js.flow +0 -46
- package/lib/resources/staff-profiles.js.flow +0 -51
- package/lib/resources/staff.js.flow +0 -583
- package/lib/resources/statistics.js.flow +0 -147
- package/lib/resources/subscriptions.js.flow +0 -81
- package/lib/resources/terminals.js.flow +0 -161
- package/lib/resources/transaction-export.js.flow +0 -48
- package/lib/resources/transactions.js.flow +0 -1097
- package/lib/resources/triggers.js.flow +0 -36
- package/lib/resources/vendors.js.flow +0 -28
- package/lib/resources/verify.js.flow +0 -14
- package/lib/resources/workers.js.flow +0 -10
- package/lib/resources/workflow-exceptions.js.flow +0 -17
- package/lib/services/__mocks__/storage.js.flow +0 -30
- package/lib/services/aws.js.flow +0 -339
- package/lib/services/storage.js.flow +0 -92
- package/lib/services/version.js.flow +0 -73
- package/lib/storage-16fd26f8.js +0 -1268
- package/lib/utils/application.js.flow +0 -23
- package/lib/utils/base-urls/core.js.flow +0 -18
- package/lib/utils/base-urls/index.js.flow +0 -7
- package/lib/utils/base-urls/risk.js.flow +0 -16
- package/lib/utils/does-param-exist.js.flow +0 -23
- package/lib/utils/get-axios-error.js.flow +0 -8
- package/lib/utils/param-error.js.flow +0 -8
- package/lib/utils/professions.js.flow +0 -66
- package/lib/utils/regions.js.flow +0 -21
- package/lib/utils/request.js.flow +0 -36
- package/lib/utils/staff.js.flow +0 -81
package/lib/index.js.flow
DELETED
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
// $FlowFixMe
|
|
5
|
-
import differenceInSeconds from 'date-fns/differenceInSeconds';
|
|
6
|
-
// $FlowFixMe
|
|
7
|
-
import jwtDecode from 'jwt-decode';
|
|
8
|
-
import _forOwn from 'lodash/forOwn';
|
|
9
|
-
import _get from 'lodash/get';
|
|
10
|
-
|
|
11
|
-
import { type SetupOpts } from './_types';
|
|
12
|
-
import * as accounts from './resources/accounts';
|
|
13
|
-
import * as actions from './resources/actions';
|
|
14
|
-
import * as apiKeys from './resources/api-keys';
|
|
15
|
-
import * as attachments from './resources/attachments';
|
|
16
|
-
import * as auth from './resources/auth';
|
|
17
|
-
import * as applications from './resources/applications';
|
|
18
|
-
import * as bulkUploads from './resources/bulk-uploads';
|
|
19
|
-
import * as bulkSubmits from './resources/bulk-submits';
|
|
20
|
-
import * as businessProfiles from './resources/business-profiles';
|
|
21
|
-
import * as businesses from './resources/businesses';
|
|
22
|
-
import * as claimItems from './resources/claim-items';
|
|
23
|
-
import * as devices from './resources/devices';
|
|
24
|
-
import * as docAccounts from './resources/doc-accounts';
|
|
25
|
-
import * as documents from './resources/documents';
|
|
26
|
-
import * as emails from './resources/emails';
|
|
27
|
-
import * as formApplicationTemplates from './resources/form-application-templates';
|
|
28
|
-
import * as formApplications from './resources/form-applications';
|
|
29
|
-
import * as forms from './resources/forms';
|
|
30
|
-
import * as funders from './resources/funders';
|
|
31
|
-
import * as funderServices from './resources/funder-services';
|
|
32
|
-
import * as funderSettings from './resources/funder-settings';
|
|
33
|
-
import * as futures from './resources/futures';
|
|
34
|
-
import * as healthFundAccounts from './resources/health-fund-accounts';
|
|
35
|
-
import * as healthFundSettings from './resources/health-fund-settings';
|
|
36
|
-
import * as healthfunds from './resources/healthfunds';
|
|
37
|
-
import * as icdItems from './resources/icditems';
|
|
38
|
-
import * as invoiceScans from './resources/invoice-scans';
|
|
39
|
-
import * as jhcs from './resources/jhcs';
|
|
40
|
-
import * as kyc from './resources/kyc';
|
|
41
|
-
import * as logs from './resources/logs';
|
|
42
|
-
import * as members from './resources/members';
|
|
43
|
-
import * as messageMappings from './resources/message-mappings';
|
|
44
|
-
import * as minions from './resources/minions';
|
|
45
|
-
import * as modalities from './resources/modalities';
|
|
46
|
-
import * as notes from './resources/notes';
|
|
47
|
-
import * as onboardingApplications from './resources/onboarding-applications';
|
|
48
|
-
import * as onboardingRequests from './resources/onboarding-requests';
|
|
49
|
-
import * as ops from './resources/ops';
|
|
50
|
-
import * as organisations from './resources/organisations';
|
|
51
|
-
import * as partners from './resources/partners';
|
|
52
|
-
import * as patients from './resources/patients';
|
|
53
|
-
import * as payments from './resources/payments';
|
|
54
|
-
import * as pms from './resources/pms';
|
|
55
|
-
import * as practiceProfiles from './resources/practice-profiles';
|
|
56
|
-
import * as practices from './resources/practices';
|
|
57
|
-
import * as practiceTypes from './resources/practice-types';
|
|
58
|
-
import * as products from './resources/products';
|
|
59
|
-
import * as professionalCategories from './resources/professional-categories';
|
|
60
|
-
import * as providerRequests from './resources/provider-requests';
|
|
61
|
-
import * as providerRegistrationTypes from './resources/provider-registration-types';
|
|
62
|
-
import * as providerNumberTypes from './resources/provider-number-types';
|
|
63
|
-
import * as providerTypes from './resources/provider-types';
|
|
64
|
-
import * as refSources from './resources/ref-sources';
|
|
65
|
-
import * as risk from './resources/risk';
|
|
66
|
-
import * as rnas from './resources/rnas';
|
|
67
|
-
import * as roles from './resources/roles';
|
|
68
|
-
import * as selfCheckoutSessions from './resources/self-checkout-sessions';
|
|
69
|
-
import * as services from './resources/services';
|
|
70
|
-
import * as settlements from './resources/settlements';
|
|
71
|
-
import * as signUp from './resources/sign-up';
|
|
72
|
-
import * as specialties from './resources/specialties';
|
|
73
|
-
import * as staffProfiles from './resources/staff-profiles';
|
|
74
|
-
import * as staff from './resources/staff';
|
|
75
|
-
import * as statistics from './resources/statistics';
|
|
76
|
-
import * as subscriptions from './resources/subscriptions';
|
|
77
|
-
import * as terminals from './resources/terminals';
|
|
78
|
-
import * as transactionExport from './resources/transaction-export';
|
|
79
|
-
import * as transactions from './resources/transactions';
|
|
80
|
-
import * as triggers from './resources/triggers';
|
|
81
|
-
import * as vendors from './resources/vendors';
|
|
82
|
-
import * as verify from './resources/verify';
|
|
83
|
-
import * as workers from './resources/workers';
|
|
84
|
-
import * as workflowExceptions from './resources/workflow-exceptions';
|
|
85
|
-
import * as aws from './services/aws';
|
|
86
|
-
import storage from './services/storage';
|
|
87
|
-
import * as versions from './services/version';
|
|
88
|
-
import baseUrls from './utils/base-urls';
|
|
89
|
-
import * as regions from './utils/regions';
|
|
90
|
-
import * as professionsUtils from './utils/professions';
|
|
91
|
-
import * as staffUtils from './utils/staff';
|
|
92
|
-
import * as applicationUtils from './utils/application';
|
|
93
|
-
|
|
94
|
-
export const APP_ID = 'web-application';
|
|
95
|
-
export const API_VER = '0.82.0';
|
|
96
|
-
export const API_VERSIONS = {
|
|
97
|
-
core: 'v3',
|
|
98
|
-
risk: 'v1'
|
|
99
|
-
};
|
|
100
|
-
export const CONTENT_TYPE = 'application/json';
|
|
101
|
-
export const DEFAULT_ENV = 'prod';
|
|
102
|
-
export const DEFAULT_REGION = 'au';
|
|
103
|
-
export const DEFAULT_VERSION = 'v1';
|
|
104
|
-
export const HEADER__APP_ID = 'x-appid';
|
|
105
|
-
export const HEADER__APP_VERSION = 'x-appver';
|
|
106
|
-
export const HEADER__API_VER = 'x-apiver';
|
|
107
|
-
export const HEADER__DEVICE_ID = 'x-deviceid';
|
|
108
|
-
export const HEADER__INTERCOM_HASH = 'x-intercom-hash';
|
|
109
|
-
export const HEADER__SDK_VERSION = 'x-sdkver';
|
|
110
|
-
export const HEADER__TOKEN = 'x-token';
|
|
111
|
-
|
|
112
|
-
export const _isTokenExpired = (token: string) => {
|
|
113
|
-
try {
|
|
114
|
-
const decodedToken = jwtDecode(token);
|
|
115
|
-
return differenceInSeconds(decodedToken.exp * 1000, new Date()) < 0;
|
|
116
|
-
} catch (err) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const _getEnvBaseUrls = (envBaseUrls: Object, { env, region }) =>
|
|
122
|
-
Object.keys(envBaseUrls).reduce(
|
|
123
|
-
(baseUrls, apiName) => ({
|
|
124
|
-
...baseUrls,
|
|
125
|
-
[apiName]: envBaseUrls[apiName][region][env]
|
|
126
|
-
}),
|
|
127
|
-
{}
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const sdk = {
|
|
131
|
-
account: storage.get('account'),
|
|
132
|
-
accountId: storage.get('accountId'),
|
|
133
|
-
apiVersions: API_VERSIONS,
|
|
134
|
-
appId: APP_ID,
|
|
135
|
-
appVersion: storage.get('appVersion'),
|
|
136
|
-
apiVer: API_VER,
|
|
137
|
-
axios: axios.create(),
|
|
138
|
-
baseUrls: undefined,
|
|
139
|
-
defaultVersion: DEFAULT_VERSION,
|
|
140
|
-
device: storage.get('device'),
|
|
141
|
-
env: DEFAULT_ENV,
|
|
142
|
-
hasInit: false,
|
|
143
|
-
intercomHash: storage.get('intercomHash'),
|
|
144
|
-
isSuperAdmin: storage.get('isSuperAdmin'),
|
|
145
|
-
isAnalyticsInitialised: false,
|
|
146
|
-
member: storage.get('member'),
|
|
147
|
-
region: undefined,
|
|
148
|
-
requestInterceptor: undefined,
|
|
149
|
-
requestInterceptorSuccess: undefined,
|
|
150
|
-
sdkVersion: storage.get('sdkVersion'),
|
|
151
|
-
tokens: storage.get('tokens', { storeType: 'session' }) || {
|
|
152
|
-
account: null,
|
|
153
|
-
session: null
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
// Attach resource getters/setters
|
|
157
|
-
accounts,
|
|
158
|
-
actions,
|
|
159
|
-
apiKeys,
|
|
160
|
-
attachments,
|
|
161
|
-
auth,
|
|
162
|
-
applications,
|
|
163
|
-
bulkUploads,
|
|
164
|
-
bulkSubmits,
|
|
165
|
-
businessProfiles,
|
|
166
|
-
businesses,
|
|
167
|
-
claimItems,
|
|
168
|
-
devices,
|
|
169
|
-
docAccounts,
|
|
170
|
-
documents,
|
|
171
|
-
emails,
|
|
172
|
-
formApplicationTemplates,
|
|
173
|
-
formApplications,
|
|
174
|
-
forms,
|
|
175
|
-
funders,
|
|
176
|
-
funderServices,
|
|
177
|
-
funderSettings,
|
|
178
|
-
futures,
|
|
179
|
-
healthFundAccounts,
|
|
180
|
-
healthFundSettings,
|
|
181
|
-
healthfunds,
|
|
182
|
-
icdItems,
|
|
183
|
-
invoiceScans,
|
|
184
|
-
jhcs,
|
|
185
|
-
kyc,
|
|
186
|
-
logs,
|
|
187
|
-
members,
|
|
188
|
-
messageMappings,
|
|
189
|
-
minions,
|
|
190
|
-
modalities,
|
|
191
|
-
notes,
|
|
192
|
-
onboardingApplications,
|
|
193
|
-
onboardingRequests,
|
|
194
|
-
ops,
|
|
195
|
-
organisations,
|
|
196
|
-
partners,
|
|
197
|
-
patients,
|
|
198
|
-
payments,
|
|
199
|
-
pms,
|
|
200
|
-
practiceProfiles,
|
|
201
|
-
practices,
|
|
202
|
-
practiceTypes,
|
|
203
|
-
products,
|
|
204
|
-
professionalCategories,
|
|
205
|
-
providerRequests,
|
|
206
|
-
providerRegistrationTypes,
|
|
207
|
-
providerNumberTypes,
|
|
208
|
-
providerTypes,
|
|
209
|
-
refSources,
|
|
210
|
-
risk,
|
|
211
|
-
rnas,
|
|
212
|
-
roles,
|
|
213
|
-
selfCheckoutSessions,
|
|
214
|
-
settlements,
|
|
215
|
-
services,
|
|
216
|
-
signUp,
|
|
217
|
-
specialties,
|
|
218
|
-
staffProfiles,
|
|
219
|
-
staff,
|
|
220
|
-
statistics,
|
|
221
|
-
subscriptions,
|
|
222
|
-
terminals,
|
|
223
|
-
transactionExport,
|
|
224
|
-
transactions,
|
|
225
|
-
triggers,
|
|
226
|
-
vendors,
|
|
227
|
-
verify,
|
|
228
|
-
workflowExceptions,
|
|
229
|
-
workers,
|
|
230
|
-
// Attach services
|
|
231
|
-
aws,
|
|
232
|
-
versions,
|
|
233
|
-
|
|
234
|
-
// Attach utils
|
|
235
|
-
regions,
|
|
236
|
-
professionsUtils,
|
|
237
|
-
staffUtils,
|
|
238
|
-
applicationUtils,
|
|
239
|
-
storage,
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Setup the Medipass SDK
|
|
243
|
-
* @param {String} env - The environment that the SDK will point to
|
|
244
|
-
* @param {?Object} opts - Additional setup options
|
|
245
|
-
*/
|
|
246
|
-
setup(env?: string, opts?: SetupOpts = {}): void {
|
|
247
|
-
// Setup axios instance
|
|
248
|
-
this.axios = axios.create();
|
|
249
|
-
if (this.axios) {
|
|
250
|
-
this.axios.defaults.headers.post['Content-Type'] = CONTENT_TYPE;
|
|
251
|
-
this.axios.defaults.headers.post.Accept = CONTENT_TYPE;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
this.setConfig({ ...opts, env });
|
|
255
|
-
this.hasInit = true;
|
|
256
|
-
|
|
257
|
-
// Setup request/response interceptors
|
|
258
|
-
this.setRequestInterceptor({});
|
|
259
|
-
this.setResponseInterceptor();
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
setConfig(opts: SetupOpts): void {
|
|
263
|
-
// Setup initial SDK properties
|
|
264
|
-
this.appId = _get(opts, 'appId', this.appId);
|
|
265
|
-
this.appVersion = _get(opts, 'appVersion', this.appVersion);
|
|
266
|
-
this.apiVer = _get(opts, 'apiVer', this.apiVer);
|
|
267
|
-
this.apiVersions = _get(opts, 'apiVersions', this.apiVersions);
|
|
268
|
-
this.defaultVersion = _get(opts, 'defaultVersion', this.defaultVersion);
|
|
269
|
-
this.env = _get(opts, 'env', this.env);
|
|
270
|
-
this.sdkVersion = _get(opts, 'sdkVersion', this.sdkVersion);
|
|
271
|
-
this.baseUrls = _get(opts, 'baseUrls');
|
|
272
|
-
this.setRegion(_get(opts, 'region', this.regions.getUserRegion()));
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
setSDKAppVersion(version: string): void {
|
|
276
|
-
this.sdkVersion = this.appVersion;
|
|
277
|
-
this.appVersion = version;
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Check if the token is valid and the client is logged in
|
|
282
|
-
* @return {Boolean} hasValidSession
|
|
283
|
-
*/
|
|
284
|
-
hasValidSession(tokenType?: string = 'account') {
|
|
285
|
-
return this.tokens[tokenType] && !_isTokenExpired(this.tokens[tokenType]);
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Check if the token has expired
|
|
290
|
-
* @return {Boolean} hasSessionExpired
|
|
291
|
-
*/
|
|
292
|
-
hasSessionExpired(tokenType?: string = 'account') {
|
|
293
|
-
return this.tokens[tokenType] && _isTokenExpired(this.tokens[tokenType]);
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Set the HTTP request interceptor - will intercept every HTTP request that the Medipass SDK uses.
|
|
298
|
-
* @param {Object} headers - Headers to be included in every request
|
|
299
|
-
*/
|
|
300
|
-
setRequestInterceptor(headers: Object) {
|
|
301
|
-
this.requestInterceptor = this.axios.interceptors.request.use(
|
|
302
|
-
async config => {
|
|
303
|
-
const request = Object.assign({}, config);
|
|
304
|
-
_forOwn(headers, (val, key) => {
|
|
305
|
-
request.headers[key] = val;
|
|
306
|
-
});
|
|
307
|
-
request.headers[HEADER__APP_ID] = this.appId;
|
|
308
|
-
request.headers[HEADER__APP_VERSION] = this.appVersion;
|
|
309
|
-
request.headers[HEADER__API_VER] = this.apiVer;
|
|
310
|
-
if (this.sdkVersion) {
|
|
311
|
-
request.headers[HEADER__SDK_VERSION] = this.sdkVersion;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (config.tokenType === 'session' && this.tokens.session) {
|
|
315
|
-
request.headers.Authorization = this.tokens.session;
|
|
316
|
-
} else if (this.tokens.account) {
|
|
317
|
-
request.headers.Authorization = this.tokens.account;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (!config.skipDeviceCheck) {
|
|
321
|
-
const deviceId = await devices.getDeviceId();
|
|
322
|
-
request.headers[HEADER__DEVICE_ID] = deviceId;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (this.requestInterceptorSuccess) {
|
|
326
|
-
this.requestInterceptorSuccess(config);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return request;
|
|
330
|
-
},
|
|
331
|
-
error => Promise.reject(error)
|
|
332
|
-
);
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Set the HTTP response interceptor - will intercept every HTTP response that the Medipass SDK uses.
|
|
337
|
-
*/
|
|
338
|
-
setResponseInterceptor() {
|
|
339
|
-
this.responseInterceptor = this.axios.interceptors.response.use(
|
|
340
|
-
config => {
|
|
341
|
-
const response = Object.assign({}, config);
|
|
342
|
-
if (
|
|
343
|
-
response.headers &&
|
|
344
|
-
response.headers[HEADER__TOKEN] &&
|
|
345
|
-
!_get(response, 'config.url', '').includes('/auth/impersonate')
|
|
346
|
-
) {
|
|
347
|
-
const authToken = response.headers[HEADER__TOKEN];
|
|
348
|
-
this.setToken(authToken);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (response.headers && response.headers[HEADER__INTERCOM_HASH]) {
|
|
352
|
-
this.intercomHash = response.headers[HEADER__INTERCOM_HASH];
|
|
353
|
-
storage.set('intercomHash', this.intercomHash);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (this.responseInterceptorSuccess) {
|
|
357
|
-
this.responseInterceptorSuccess(config);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return response;
|
|
361
|
-
},
|
|
362
|
-
err => {
|
|
363
|
-
if (this.responseInterceptorFailure) {
|
|
364
|
-
this.responseInterceptorFailure(_get(err, 'response', err));
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return Promise.reject(err);
|
|
368
|
-
}
|
|
369
|
-
);
|
|
370
|
-
},
|
|
371
|
-
|
|
372
|
-
clearTokens() {
|
|
373
|
-
this.tokens = { account: null, session: null };
|
|
374
|
-
storage.remove('tokens');
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
isImpersonating() {
|
|
378
|
-
const { imp } = jwtDecode(this.tokens.account);
|
|
379
|
-
return Boolean(imp);
|
|
380
|
-
},
|
|
381
|
-
|
|
382
|
-
getTokenExpiry(tokenType?: string = 'account') {
|
|
383
|
-
return jwtDecode(this.tokens[tokenType]).exp;
|
|
384
|
-
},
|
|
385
|
-
|
|
386
|
-
setToken(token: string, tokenType?: string = 'account') {
|
|
387
|
-
this.tokens[tokenType] = token;
|
|
388
|
-
storage.set('tokens', Object.assign({}, this.tokens, { [tokenType]: token }), { storeType: 'session' });
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
setAccount(account: Object) {
|
|
392
|
-
storage.set('accountId', account._id);
|
|
393
|
-
this.accountId = account._id;
|
|
394
|
-
storage.set('account', account);
|
|
395
|
-
this.account = account;
|
|
396
|
-
},
|
|
397
|
-
|
|
398
|
-
setMember(member: Object) {
|
|
399
|
-
storage.set('member', member);
|
|
400
|
-
this.member = member;
|
|
401
|
-
},
|
|
402
|
-
|
|
403
|
-
setRegion(region: string) {
|
|
404
|
-
if (region) {
|
|
405
|
-
this.region = region;
|
|
406
|
-
}
|
|
407
|
-
if (this.env && this.region) {
|
|
408
|
-
this.baseUrls = this.baseUrls || _getEnvBaseUrls(baseUrls, { env: this.env, region: this.region });
|
|
409
|
-
}
|
|
410
|
-
storage.set('region', region);
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Kill the SDK - stop interceptors, clear class properties, clear local storage
|
|
415
|
-
*/
|
|
416
|
-
stop() {
|
|
417
|
-
this.axios.interceptors.request.eject(this.requestInterceptor);
|
|
418
|
-
this.axios.interceptors.request.eject(this.responseInterceptor);
|
|
419
|
-
|
|
420
|
-
this.removeStorage();
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
removeStorage() {
|
|
424
|
-
this.clearTokens();
|
|
425
|
-
this.account = null;
|
|
426
|
-
this.accountId = null;
|
|
427
|
-
this.intercomHash = null;
|
|
428
|
-
this.isSuperAdmin = null;
|
|
429
|
-
this.member = null;
|
|
430
|
-
storage.clearAll();
|
|
431
|
-
},
|
|
432
|
-
|
|
433
|
-
setIsAnalyticsInitialised(isInitialised: boolean) {
|
|
434
|
-
this.isAnalyticsInitialised = isInitialised;
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
export default sdk;
|