@medipass/web-sdk 11.38.0 → 11.38.1-feature-typescript-claudia.1
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/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 +3 -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-f19eb168.js → staff-96febcd8.js} +188 -581
- 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/types/globals.d.ts +7 -0
- package/types/index.d.ts +1 -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 -97
- 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
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import doesParamExist from '../utils/does-param-exist';
|
|
4
|
-
import request from '../utils/request';
|
|
5
|
-
import type { PaginatedQuery } from '../_types';
|
|
6
|
-
import type { MedipassRequestOpts } from '../_types';
|
|
7
|
-
|
|
8
|
-
export const pathHealthFundRNAs = (healthFundId: string) => `/healthfunds/${healthFundId}/rnas`;
|
|
9
|
-
export const pathHealthFundRNA = (healthFundId: string, rnaId: string) => `/healthfunds/${healthFundId}/rnas/${rnaId}`;
|
|
10
|
-
export const pathHealthFundRNAAppointments = (healthFundId: string, rnaId: string) =>
|
|
11
|
-
`/healthfunds/${healthFundId}/rnas/${rnaId}/rnaappointments`;
|
|
12
|
-
export const pathHealthFundRNAAppointment = (healthFundId: string, rnaId: string, rnaAppointmentId: string) =>
|
|
13
|
-
`/healthfunds/${healthFundId}/rnas/${rnaId}/rnaappointments/${rnaAppointmentId}`;
|
|
14
|
-
export const pathBusinessesRNAs = (businessId: string) => `/businesses/${businessId}/rnas`;
|
|
15
|
-
export const pathBusinessRNA = (businessId: string, rnaId: string) => `/businesses/${businessId}/rnas/${rnaId}`;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Get businesses Requests and Appointments
|
|
19
|
-
* @param {String} businessId - Business ID
|
|
20
|
-
* @param {Object} query - Query parameters
|
|
21
|
-
* @param {Object} opts - Additional options
|
|
22
|
-
*/
|
|
23
|
-
export const getBusinessRNAs = (
|
|
24
|
-
businessId: string,
|
|
25
|
-
query?: ?{ ...PaginatedQuery, searchText?: string },
|
|
26
|
-
opts?: MedipassRequestOpts = {}
|
|
27
|
-
): Promise<Object> => {
|
|
28
|
-
doesParamExist({ businessId }, opts.hyperMediaEndpoint);
|
|
29
|
-
return request({ ...opts, path: pathBusinessesRNAs(businessId) }, { method: 'get', params: query });
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get business Requests and Appointments
|
|
34
|
-
* @param {String} businessId - Business ID
|
|
35
|
-
* @param {String} rnaId - RNA ID
|
|
36
|
-
* @param {Object} opts - Additional options
|
|
37
|
-
*/
|
|
38
|
-
export const getBusinessRNA = (businessId: string, rnaId: string, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
39
|
-
doesParamExist({ businessId, rnaId }, opts.hyperMediaEndpoint);
|
|
40
|
-
return request({ ...opts, path: `${pathBusinessRNA(businessId, rnaId)}` }, { method: 'get' });
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Check if dan and epId is valid
|
|
45
|
-
* @param {String} businessId - Business ID
|
|
46
|
-
* @param {Object} query - Query parameters
|
|
47
|
-
* @param {Object} opts - Additional options
|
|
48
|
-
*/
|
|
49
|
-
export const checkRNAExists = (
|
|
50
|
-
businessId: string,
|
|
51
|
-
query: { dan: string, epId: string },
|
|
52
|
-
opts?: MedipassRequestOpts = {}
|
|
53
|
-
): Promise<Object> => {
|
|
54
|
-
doesParamExist({ businessId }, opts.hyperMediaEndpoint);
|
|
55
|
-
return request({ ...opts, path: `${pathBusinessesRNAs(businessId)}/exists` }, { method: 'get', params: query });
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const createHealthFundRNA = (
|
|
59
|
-
healthFundId: string,
|
|
60
|
-
body: Object,
|
|
61
|
-
opts?: MedipassRequestOpts = {}
|
|
62
|
-
): Promise<Object> => {
|
|
63
|
-
doesParamExist({ healthFundId }, opts.hyperMediaEndpoint);
|
|
64
|
-
return request({ ...opts, path: pathHealthFundRNAs(healthFundId) }, { method: 'post', data: body });
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const createAppointmentForHealthFundRNA = (
|
|
68
|
-
healthFundId: string,
|
|
69
|
-
rnaId: string,
|
|
70
|
-
body: Object,
|
|
71
|
-
opts?: MedipassRequestOpts = {}
|
|
72
|
-
): Promise<Object> => {
|
|
73
|
-
doesParamExist({ healthFundId, rnaId }, opts.hyperMediaEndpoint);
|
|
74
|
-
return request({ ...opts, path: pathHealthFundRNAAppointments(healthFundId, rnaId) }, { method: 'post', data: body });
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const getHealthFundRNA = (
|
|
78
|
-
healthFundId: string,
|
|
79
|
-
rnaId: string,
|
|
80
|
-
query?: ?{ includeDeleted?: boolean },
|
|
81
|
-
opts?: MedipassRequestOpts = {}
|
|
82
|
-
): Promise<Object> => {
|
|
83
|
-
doesParamExist({ healthFundId, rnaId }, opts.hyperMediaEndpoint);
|
|
84
|
-
return request({ ...opts, path: pathHealthFundRNA(healthFundId, rnaId) }, { method: 'get', params: query });
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const getHealthFundRNAs = (
|
|
88
|
-
healthFundId: string,
|
|
89
|
-
query?: ?{ ...PaginatedQuery, searchText?: string },
|
|
90
|
-
opts?: MedipassRequestOpts = {}
|
|
91
|
-
): Promise<Object> => {
|
|
92
|
-
doesParamExist({ healthFundId }, opts.hyperMediaEndpoint);
|
|
93
|
-
return request({ ...opts, path: pathHealthFundRNAs(healthFundId) }, { method: 'get', params: query });
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const updateAppointmentForHealthFundRNA = (
|
|
97
|
-
healthFundId: string,
|
|
98
|
-
rnaId: string,
|
|
99
|
-
rnaAppointmentId: string,
|
|
100
|
-
body: Object,
|
|
101
|
-
opts?: MedipassRequestOpts = {}
|
|
102
|
-
): Promise<Object> => {
|
|
103
|
-
doesParamExist({ healthFundId, rnaId, rnaAppointmentId }, opts.hyperMediaEndpoint);
|
|
104
|
-
return request(
|
|
105
|
-
{ ...opts, path: pathHealthFundRNAAppointment(healthFundId, rnaId, rnaAppointmentId) },
|
|
106
|
-
{ method: 'put', data: body }
|
|
107
|
-
);
|
|
108
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import request from '../utils/request';
|
|
3
|
-
import { type MedipassRequestOpts } from '../_types';
|
|
4
|
-
|
|
5
|
-
const PATH__ROLES = '/roles';
|
|
6
|
-
/**
|
|
7
|
-
* Get roles
|
|
8
|
-
* @param {Object} opts - Additional options
|
|
9
|
-
*/
|
|
10
|
-
export const getRoles = async (opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
11
|
-
return request({ ...opts, path: PATH__ROLES }, { method: 'get' });
|
|
12
|
-
};
|
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import _get from 'lodash/get';
|
|
3
|
-
import { isMedicare } from '@medipass/utils/funders';
|
|
4
|
-
|
|
5
|
-
import sdk from '../index';
|
|
6
|
-
import request from '../utils/request';
|
|
7
|
-
import doesParamExist from '../utils/does-param-exist';
|
|
8
|
-
import type { MedipassRequestOpts } from '../_types';
|
|
9
|
-
|
|
10
|
-
const PATH__SELF_CHECKOUT_SESSIONS = '/selfcheckoutsessions';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Create a self checkout session
|
|
14
|
-
* @param {Object} body - Request body
|
|
15
|
-
* @param {Object} opts - Additional options
|
|
16
|
-
*/
|
|
17
|
-
export const createSelfCheckoutSession = async (body: Object, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
18
|
-
return request({ ...opts, path: PATH__SELF_CHECKOUT_SESSIONS }, { method: 'post', data: body });
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Approve my self checkout session
|
|
23
|
-
* @param {Object} body - request body
|
|
24
|
-
* @param {Object} opts - Additional options
|
|
25
|
-
*/
|
|
26
|
-
export const approve = async (body?: Object, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
27
|
-
return request(
|
|
28
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/approvals` },
|
|
29
|
-
{ method: 'post', data: body, tokenType: 'session' }
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Cancel my self checkout session
|
|
35
|
-
* @param {Object} body - Request body
|
|
36
|
-
* @param {Object} opts - Additional options
|
|
37
|
-
*/
|
|
38
|
-
export const cancel = async (body?: Object, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
39
|
-
return request(
|
|
40
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/cancellations` },
|
|
41
|
-
{ method: 'post', data: body, tokenType: 'session' }
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Cancel my self checkout session
|
|
47
|
-
* @param {Object} body - Request body
|
|
48
|
-
* @param {Object} opts - Additional options
|
|
49
|
-
*/
|
|
50
|
-
export const cancelSession = async (body?: Object, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
51
|
-
return request(
|
|
52
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/cancels` },
|
|
53
|
-
{ method: 'post', data: body, tokenType: 'session' }
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Create invoice for my self checkout session
|
|
59
|
-
* @param {Object} opts - Additional options
|
|
60
|
-
*/
|
|
61
|
-
export const createMyInvoice = async (opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
62
|
-
return request(
|
|
63
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/invoices` },
|
|
64
|
-
{ method: 'post', tokenType: 'session' }
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Create payment authority for my self checkout session
|
|
70
|
-
* @param {Object} opts - Additional options
|
|
71
|
-
*/
|
|
72
|
-
export const createPaymentAuthority = async (opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
73
|
-
return request(
|
|
74
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentauthorities` },
|
|
75
|
-
{ method: 'post', tokenType: 'session' }
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Create payment method for my self checkout session
|
|
81
|
-
* @param {String} nonce - Nonce
|
|
82
|
-
* @param {String} source - Source of payment
|
|
83
|
-
* @param {Object} opts - Additional options
|
|
84
|
-
*/
|
|
85
|
-
export const createPaymentMethod = async (
|
|
86
|
-
nonce: string,
|
|
87
|
-
source: string,
|
|
88
|
-
opts?: MedipassRequestOpts = {}
|
|
89
|
-
): Promise<Object> => {
|
|
90
|
-
doesParamExist({ nonce, source }, opts.hyperMediaEndpoint);
|
|
91
|
-
return request(
|
|
92
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods` },
|
|
93
|
-
{ method: 'post', data: { nonce, source }, tokenType: 'session' }
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get payment methods for my self checkout session
|
|
99
|
-
* @param {Object} opts - Additional options
|
|
100
|
-
*/
|
|
101
|
-
export const getPaymentMethods = async (opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
102
|
-
return request(
|
|
103
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods` },
|
|
104
|
-
{ method: 'get', tokenType: 'session' }
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Discover member for a self checkout session
|
|
110
|
-
* @param {Object} ids - Find by ids (Accepts: `memberId` and `email`)
|
|
111
|
-
* @param {Object} query - Additional query parameters
|
|
112
|
-
* @param {Object} opts - Additional options
|
|
113
|
-
* @returns {Object} The device data
|
|
114
|
-
*/
|
|
115
|
-
export const discoverMember = async (
|
|
116
|
-
{ email, memberId }: { email?: string, memberId?: string },
|
|
117
|
-
query?: Object = {},
|
|
118
|
-
opts?: MedipassRequestOpts = {}
|
|
119
|
-
): Promise<Object> => {
|
|
120
|
-
doesParamExist({ email, memberId }, opts.hyperMediaEndpoint, { atLeastOneExists: true });
|
|
121
|
-
const params = Object.assign({}, query, { email, memberId });
|
|
122
|
-
return request(
|
|
123
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/discovery/members` },
|
|
124
|
-
{ method: 'get', params, tokenType: 'session' }
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Check for duplicate member
|
|
130
|
-
* @param {Object} body - Additional request body
|
|
131
|
-
* @param {Object} opts - Additional options
|
|
132
|
-
* @returns {Object} The device data
|
|
133
|
-
*/
|
|
134
|
-
export const checkDupe = async (body: Object, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
135
|
-
return request(
|
|
136
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/checkdupe` },
|
|
137
|
-
{ method: 'post', data: body, tokenType: 'session' }
|
|
138
|
-
);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Get my self checkout session
|
|
143
|
-
* @param {Object} opts - Additional options
|
|
144
|
-
*/
|
|
145
|
-
export const getMySelfCheckoutSession = async (opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
146
|
-
return request({ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me` }, { method: 'get', tokenType: 'session' });
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Get transaction for self checkout session
|
|
151
|
-
* @param {Object} opts - Additional options
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
export const getMySelfCheckoutSessionTransaction = async (
|
|
155
|
-
checkoutSessionId: string,
|
|
156
|
-
opts?: MedipassRequestOpts = {}
|
|
157
|
-
): Promise<Object> => {
|
|
158
|
-
return request(
|
|
159
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/${checkoutSessionId}/transaction` },
|
|
160
|
-
{ method: 'get', tokenType: 'session' }
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Remember me
|
|
166
|
-
* @param {Object} opts - Additional options
|
|
167
|
-
*/
|
|
168
|
-
export const rememberMe = async (opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
169
|
-
return request(
|
|
170
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/rememberme` },
|
|
171
|
-
{ method: 'post', tokenType: 'session' }
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Update my self checkout session
|
|
177
|
-
* @param {Object} body - Request body
|
|
178
|
-
* @param {Object} opts - Additional options
|
|
179
|
-
*/
|
|
180
|
-
export const updateMySelfCheckoutSession = async (body: Object, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
181
|
-
return request(
|
|
182
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me` },
|
|
183
|
-
{ method: 'put', data: body, tokenType: 'session' }
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Request OTK for a self checkout session
|
|
189
|
-
* @param {String} accountId - Account ID
|
|
190
|
-
* @param {Object} opts - Additional options
|
|
191
|
-
*/
|
|
192
|
-
export const requestOtk = async (accountId: string, opts?: MedipassRequestOpts = {}): Promise<Object> => {
|
|
193
|
-
doesParamExist({ accountId }, opts.hyperMediaEndpoint);
|
|
194
|
-
return request(
|
|
195
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/otk` },
|
|
196
|
-
{ method: 'post', data: { accountId }, tokenType: 'session' }
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Add a payment method to a self checkout session
|
|
202
|
-
* @param {Object} body - Config for the method.
|
|
203
|
-
* @param {Object} opts - Additional options
|
|
204
|
-
*/
|
|
205
|
-
export const addPaymentMethodToSelfCheckoutSession = async (
|
|
206
|
-
body: { data?: Object, selfCheckoutSession: Object },
|
|
207
|
-
opts?: MedipassRequestOpts = {}
|
|
208
|
-
) => {
|
|
209
|
-
const { data = {}, selfCheckoutSession } = body;
|
|
210
|
-
const isExistingAccount = Boolean(selfCheckoutSession.accountId);
|
|
211
|
-
|
|
212
|
-
let requestBody = {};
|
|
213
|
-
let paymentMethod;
|
|
214
|
-
|
|
215
|
-
// If card data exists, then add the card data to the self checkout session.
|
|
216
|
-
if (data.cardNumber && data.expiry && data.cvc) {
|
|
217
|
-
const { source, nonce } = await sdk.payments.getNonce({
|
|
218
|
-
cardNumber: data.cardNumber,
|
|
219
|
-
expiry: data.expiry,
|
|
220
|
-
cvc: data.cvc,
|
|
221
|
-
isSelfCheckoutSession: true
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
// If there is an existing account, create a new payment method and attach it to the self checkout session.
|
|
225
|
-
if (isExistingAccount) {
|
|
226
|
-
paymentMethod = await sdk.payments.createAccountPaymentMethod(selfCheckoutSession.accountId, nonce, source, opts);
|
|
227
|
-
requestBody = {
|
|
228
|
-
paymentMethod: { _id: paymentMethod._id }
|
|
229
|
-
};
|
|
230
|
-
} else {
|
|
231
|
-
// Otherwise, we want to create a payment method on the self checkout session.
|
|
232
|
-
await createPaymentMethod(nonce, source, opts);
|
|
233
|
-
}
|
|
234
|
-
} else if (data._id) {
|
|
235
|
-
// If a payment method id is specified, attach it to the self checkout session.
|
|
236
|
-
requestBody = {
|
|
237
|
-
paymentMethod: { _id: data._id }
|
|
238
|
-
};
|
|
239
|
-
} else if (isExistingAccount) {
|
|
240
|
-
// If there is an existing account, try get their payment method and attach it to the self checkout session.
|
|
241
|
-
const paymentMethods = await sdk.payments.getAccountPaymentMethods(selfCheckoutSession.accountId, opts);
|
|
242
|
-
paymentMethod = paymentMethods.find(paymentMethod => Boolean(paymentMethod.isDefault));
|
|
243
|
-
if (paymentMethod) {
|
|
244
|
-
requestBody = {
|
|
245
|
-
paymentMethod: { _id: paymentMethod._id }
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);
|
|
251
|
-
|
|
252
|
-
return { paymentMethod, selfCheckoutSession: newSelfCheckoutSession };
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Add a member to a self checkout session
|
|
257
|
-
* @param {Object} body - Config for the method.
|
|
258
|
-
* @param {Object} opts - Additional options
|
|
259
|
-
*/
|
|
260
|
-
export const addMemberToSelfCheckoutSession = async (
|
|
261
|
-
body?: { data?: Object, selfCheckoutSession?: Object } = {},
|
|
262
|
-
opts?: MedipassRequestOpts = {}
|
|
263
|
-
) => {
|
|
264
|
-
const { data = {}, selfCheckoutSession = {} } = body;
|
|
265
|
-
|
|
266
|
-
let requestBody = {};
|
|
267
|
-
|
|
268
|
-
// If a member exists and there isn't already one attached to the self checkout session, then attach the member.
|
|
269
|
-
if (_get(sdk, 'member._id') && !_get(selfCheckoutSession, 'member._id')) {
|
|
270
|
-
requestBody = { member: { _id: _get(sdk, 'member._id') } };
|
|
271
|
-
} else {
|
|
272
|
-
// Otherwise, add member manually to the self checkout session.
|
|
273
|
-
const [day, month, year] = _get(data, 'dob', '').split('/');
|
|
274
|
-
requestBody = {
|
|
275
|
-
patient: {
|
|
276
|
-
firstName: data.firstName,
|
|
277
|
-
lastName: data.lastName,
|
|
278
|
-
email: data.email,
|
|
279
|
-
mobile: data.mobile,
|
|
280
|
-
dobString: day && month && year ? `${year}-${month}-${day}` : undefined
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);
|
|
286
|
-
|
|
287
|
-
return { selfCheckoutSession: newSelfCheckoutSession };
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Add a health fund account to a self checkout session
|
|
292
|
-
* @param {Object} body - Config for the method.
|
|
293
|
-
* @param {Object} opts - Additional options
|
|
294
|
-
*/
|
|
295
|
-
export const addHealthFundAccountToSelfCheckoutSession = async (
|
|
296
|
-
body: { data?: Object, funder: Object, selfCheckoutSession: Object },
|
|
297
|
-
opts?: MedipassRequestOpts = {}
|
|
298
|
-
) => {
|
|
299
|
-
const { data = {}, funder, selfCheckoutSession } = body;
|
|
300
|
-
const isExistingAccount = selfCheckoutSession.accountId;
|
|
301
|
-
const memberId = _get(selfCheckoutSession, 'member._id') || _get(sdk, 'member._id');
|
|
302
|
-
|
|
303
|
-
let healthFund = data.healthFund;
|
|
304
|
-
if (isMedicare(funder.code)) {
|
|
305
|
-
healthFund = await sdk.healthfunds.getMedicareHealthFund({ ...opts, requestConfig: { tokenType: 'session' } });
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// If there is an existing account, we will need to get their existing health fund accounts to use below.
|
|
309
|
-
let healthFundAccounts;
|
|
310
|
-
if (isExistingAccount) {
|
|
311
|
-
healthFundAccounts = await sdk.healthFundAccounts.getMembersHealthFundAccounts(
|
|
312
|
-
memberId,
|
|
313
|
-
{ funderId: _get(funder, '_id') },
|
|
314
|
-
opts
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
const healthFundAccountId = _get(healthFundAccounts, 'items[0]._id');
|
|
318
|
-
|
|
319
|
-
let healthFundAccount;
|
|
320
|
-
let requestBody = {};
|
|
321
|
-
|
|
322
|
-
// If health fund account data exists, then add the data to the self checkout session.
|
|
323
|
-
if (data.membershipNumber || data.cardNumber) {
|
|
324
|
-
const healthFundAccountRequestBody = {
|
|
325
|
-
healthFundId: _get(healthFund, '_id'),
|
|
326
|
-
...(data || {})
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
// If it's an existing account, delete their current health fund account (if any), and add the new one to their account.
|
|
330
|
-
if (isExistingAccount) {
|
|
331
|
-
if (healthFundAccountId) {
|
|
332
|
-
await sdk.healthFundAccounts.deleteMembersHealthFundAccount(memberId, healthFundAccountId, opts);
|
|
333
|
-
}
|
|
334
|
-
healthFundAccount = await sdk.healthFundAccounts.createMembersHealthFundAccount(
|
|
335
|
-
memberId,
|
|
336
|
-
healthFundAccountRequestBody,
|
|
337
|
-
opts
|
|
338
|
-
);
|
|
339
|
-
requestBody = {
|
|
340
|
-
healthFundAccount: { _id: healthFundAccount._id }
|
|
341
|
-
};
|
|
342
|
-
} else {
|
|
343
|
-
// Otherwise, just add the data to the self checkout session.
|
|
344
|
-
requestBody = {
|
|
345
|
-
healthFundAccount: healthFundAccountRequestBody
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
} else if (data._id) {
|
|
349
|
-
// If a health fund account id is specified, attach it to the self checkout session.
|
|
350
|
-
requestBody = {
|
|
351
|
-
healthFundAccount: { _id: data._id }
|
|
352
|
-
};
|
|
353
|
-
} else if (isExistingAccount) {
|
|
354
|
-
// If there is an existing account, try get the health fund account and attach it to the self checkout session.
|
|
355
|
-
if (healthFundAccountId) {
|
|
356
|
-
healthFundAccount = await sdk.healthFundAccounts.getMembersHealthFundAccount(memberId, healthFundAccountId, opts);
|
|
357
|
-
requestBody = {
|
|
358
|
-
healthFundAccount: { _id: healthFundAccount._id }
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);
|
|
364
|
-
|
|
365
|
-
return { healthFundAccount, selfCheckoutSession: newSelfCheckoutSession };
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Delete payment method
|
|
370
|
-
* @param {String} paymentMethodId - Payment method ID
|
|
371
|
-
* @param {Object} opts - Additional options
|
|
372
|
-
*/
|
|
373
|
-
export const deletePaymentMethod = async (
|
|
374
|
-
paymentMethodId: string,
|
|
375
|
-
opts?: MedipassRequestOpts = {}
|
|
376
|
-
): Promise<Object> => {
|
|
377
|
-
doesParamExist({ paymentMethodId }, opts.hyperMediaEndpoint);
|
|
378
|
-
return request(
|
|
379
|
-
{ ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods/${paymentMethodId}` },
|
|
380
|
-
{ method: 'delete', tokenType: 'session' }
|
|
381
|
-
);
|
|
382
|
-
};
|