@nuralogix.ai/dfx-api-client
Version:
DeepAffex API JavaScript Client Library
1,538 lines (1,528 loc) • 112 kB
JavaScript
var version = "1.0.73";
var HTTPMethod = /* @__PURE__ */ ((HTTPMethod2) => {
HTTPMethod2["DELETE"] = "DELETE";
HTTPMethod2["GET"] = "GET";
HTTPMethod2["PATCH"] = "PATCH";
HTTPMethod2["POST"] = "POST";
HTTPMethod2["PUT"] = "PUT";
HTTPMethod2["CONNECT"] = "CONNECT";
return HTTPMethod2;
})(HTTPMethod || {});
var OnBeforeRESTCallErrors = /* @__PURE__ */ ((OnBeforeRESTCallErrors2) => {
OnBeforeRESTCallErrors2["ON_BEFORE_REST_CALL_ERROR"] = "ON_BEFORE_REST_CALL_ERROR";
return OnBeforeRESTCallErrors2;
})(OnBeforeRESTCallErrors || {});
const isModuleWorker = typeof DedicatedWorkerGlobalScope !== "undefined";
const _fetch = async ({ baseUrl, urlFragment, method, headers, data }, onAfterRESTCall) => {
const url = `${baseUrl}/${urlFragment}`;
let responseBody = {
Code: "",
Message: ""
};
try {
const response = await fetch(url, {
method,
cache: "no-store",
credentials: "include",
headers,
...data != null && {
body: JSON.stringify(data)
}
});
const contentType = response.headers.get("content-type");
const status = response.status.toString();
responseBody = {
Code: "UNSUPPORTED_RESPONSE_CONTENT_TYPE" /* UNSUPPORTED_RESPONSE_CONTENT_TYPE */,
Message: "UNSUPPORTED_RESPONSE_CONTENT_TYPE" /* UNSUPPORTED_RESPONSE_CONTENT_TYPE */
};
if (status === "503")
responseBody = {
Code: "SERVICE_UNAVAILABLE",
Message: "Service unavailable"
};
if (status === "429")
responseBody = {
Code: "TOO_MANY_REQUESTS",
Message: "Too many requests"
};
if (contentType != null) {
if (contentType.startsWith("application/json;"))
responseBody = await response.json();
if (contentType.startsWith("text/plain;"))
responseBody = { data: await response.text() };
}
let responseHeaders = response.headers;
if (isModuleWorker) {
const headersObj = {};
response.headers.forEach((value, key) => {
headersObj[key] = value;
});
responseHeaders = headersObj;
}
setTimeout(() => {
onAfterRESTCall(
status,
status === "200" ? void 0 : responseBody
).catch(
(e) => console.error("Error running onAfterRESTCall callback", e)
);
}, 0);
return { status, headers: responseHeaders, body: responseBody };
} catch (e) {
if (e instanceof SyntaxError) {
responseBody = {
Code: "SYNTAX_ERROR" /* SYNTAX_ERROR */,
Message: "SYNTAX_ERROR" /* SYNTAX_ERROR */
};
} else {
responseBody = {
Code: "UNEXPECTED_ERROR" /* UNEXPECTED_ERROR */,
Message: "UNEXPECTED_ERROR" /* UNEXPECTED_ERROR */
};
}
return {
status: "UNKNOWN" /* UNKNOWN */,
headers: isModuleWorker ? {} : new Headers(),
body: responseBody
};
}
};
const getHeader = () => new Headers({
"Content-Type": "application/json"
});
const asciiletters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
function generateReqId(actionId) {
let reqId = actionId;
for (let i = actionId.length; i < 10; i++) {
reqId += asciiletters.charAt(
Math.floor(Math.random() * asciiletters.length)
);
}
return reqId;
}
function bufferToString(arr) {
let str = "";
for (let i = 0; i < arr.length; i++) {
str += String.fromCodePoint(arr[i]);
}
return str;
}
const getBaseUrl = (url, transport) => {
return JSON.parse(url)[transport].slice(0, -1);
};
const getHeaders = () => isModuleWorker ? {} : new Headers();
var AUTHS = /* @__PURE__ */ ((AUTHS2) => {
AUTHS2["SEND_RESET"] = "2300";
return AUTHS2;
})(AUTHS || {});
var DEVICES = /* @__PURE__ */ ((DEVICES2) => {
DEVICES2["TYPES"] = "0900";
return DEVICES2;
})(DEVICES || {});
var GENERAL = /* @__PURE__ */ ((GENERAL2) => {
GENERAL2["STATUS"] = "0100";
GENERAL2["MIME_TYPES"] = "0101";
return GENERAL2;
})(GENERAL || {});
var LICENSES = /* @__PURE__ */ ((LICENSES2) => {
LICENSES2["CREATE_LICENSE_ALLOWED_STUDY"] = "1400";
return LICENSES2;
})(LICENSES || {});
var MEASUREMENTS = /* @__PURE__ */ ((MEASUREMENTS2) => {
MEASUREMENTS2["DATA"] = "0506";
MEASUREMENTS2["SUBSCRIBE_RESULTS"] = "0510";
return MEASUREMENTS2;
})(MEASUREMENTS || {});
var ORGANIZATIONS = /* @__PURE__ */ ((ORGANIZATIONS2) => {
ORGANIZATIONS2["RETRIEVE"] = "0700";
ORGANIZATIONS2["LOGIN_WITH_TOKEN"] = "0718";
return ORGANIZATIONS2;
})(ORGANIZATIONS || {});
var ORGANIZATIONS_PRIVATE = /* @__PURE__ */ ((ORGANIZATIONS_PRIVATE2) => {
ORGANIZATIONS_PRIVATE2["LIST"] = "1200";
return ORGANIZATIONS_PRIVATE2;
})(ORGANIZATIONS_PRIVATE || {});
var PROFILES = /* @__PURE__ */ ((PROFILES2) => {
PROFILES2["CREATE"] = "0400";
return PROFILES2;
})(PROFILES || {});
var REPORTS = /* @__PURE__ */ ((REPORTS2) => {
REPORTS2["REPORT_READY"] = "1300";
return REPORTS2;
})(REPORTS || {});
var STUDIES = /* @__PURE__ */ ((STUDIES2) => {
STUDIES2["TYPES"] = "0800";
return STUDIES2;
})(STUDIES || {});
var TEMPLATES = /* @__PURE__ */ ((TEMPLATES2) => {
TEMPLATES2["LIST_TEMPLATES"] = "1100";
return TEMPLATES2;
})(TEMPLATES || {});
var USERS = /* @__PURE__ */ ((USERS2) => {
USERS2["CREATE"] = "0200";
return USERS2;
})(USERS || {});
const ActionId = {
AUTHS,
DEVICES,
GENERAL,
LICENSES,
MEASUREMENTS,
ORGANIZATIONS,
ORGANIZATIONS_PRIVATE,
PROFILES,
REPORTS,
STUDIES,
TEMPLATES,
USERS
};
var DeviceTypeID = /* @__PURE__ */ ((DeviceTypeID2) => {
DeviceTypeID2["IPHONE"] = "IPHONE";
DeviceTypeID2["IPAD"] = "IPAD";
DeviceTypeID2["DARWIN"] = "DARWIN";
DeviceTypeID2["ANDROID_PHONE"] = "ANDROID_PHONE";
DeviceTypeID2["WINDOWS"] = "WINDOWS";
DeviceTypeID2["WIN32"] = "WIN32";
DeviceTypeID2["WINDOWS_TABLET"] = "WINDOWS_TABLET";
DeviceTypeID2["LINUX"] = "LINUX";
DeviceTypeID2["DEBIAN"] = "DEBIAN";
return DeviceTypeID2;
})(DeviceTypeID || {});
var __defProp$2 = Object.defineProperty;
var __typeError$1 = (msg) => {
throw TypeError(msg);
};
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), member.get(obj));
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
var _token, __socket, __subProtocol;
class WS {
constructor(parent) {
__publicField$2(this, "parent");
__privateAdd$1(this, _token, "");
__privateAdd$1(this, __socket);
__privateAdd$1(this, __subProtocol, "json");
__publicField$2(this, "onmessage");
__publicField$2(this, "onclose");
__publicField$2(this, "onerror");
this.parent = parent;
this.onmessage = () => {
};
this.onclose = () => {
};
this.onerror = () => {
};
this.onSocketOpen = this.onSocketOpen.bind(this);
this.onSocketMessage = this.onSocketMessage.bind(this);
}
/**
* Opens a socket connection
*/
connect(token) {
__privateSet$1(this, _token, token);
__privateSet$1(this, __socket, new WebSocket(
getBaseUrl(this.parent.getUrl(), "wss"),
__privateGet$1(this, __subProtocol)
));
__privateGet$1(this, __socket).binaryType = "arraybuffer";
__privateGet$1(this, __socket).onopen = this.onSocketOpen;
__privateGet$1(this, __socket).onmessage = this.onSocketMessage;
__privateGet$1(this, __socket).onclose = this.onclose;
__privateGet$1(this, __socket).onerror = this.onerror;
}
/**
* Closes the socket connection
*/
disconnect() {
__privateGet$1(this, __socket).close();
}
onSocketOpen(e) {
this.sendMessage(ActionId.ORGANIZATIONS.LOGIN_WITH_TOKEN, { Token: __privateGet$1(this, _token) });
}
onSocketMessage(e) {
if (e.data instanceof ArrayBuffer) {
const result = new Uint8Array(e.data);
const requestId = bufferToString(result.slice(0, 10));
const status = bufferToString(result.slice(10, 13));
const message = JSON.parse(bufferToString(result.slice(13)));
const actionId = requestId.slice(0, 4);
this.onmessage(requestId, status, message, actionId);
}
}
/**
* Sends a message
*
* @param actionId End point action ID
* @param data message body
* @returns message
*/
sendMessage(actionId, data) {
const actionPadded = `${actionId}`.padStart(4, "0");
const requestId = generateReqId(actionPadded);
if (actionId === ActionId.MEASUREMENTS.SUBSCRIBE_RESULTS) data.RequestID = requestId;
const stringifiedDate = JSON.stringify(data);
const message = new Uint8Array(4 + 10 + stringifiedDate.length);
message.set(
Uint8Array.from(actionPadded, (x) => x.codePointAt(0)),
0
);
message.set(
Uint8Array.from(requestId, (x) => x.codePointAt(0)),
4
);
message.set(
Uint8Array.from(stringifiedDate, (x) => x.codePointAt(0)),
4 + 10
);
__privateGet$1(this, __socket).send(message);
}
}
_token = new WeakMap();
__socket = new WeakMap();
__subProtocol = new WeakMap();
var __defProp$1 = Object.defineProperty;
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
class Main {
/** @internal */
constructor(parent) {
__publicField$1(this, "parent");
this.parent = parent;
}
async onBeforeRESTCall() {
try {
await this.parent.onBeforeRESTCall();
return {
Code: "SUCCESS",
Message: "SUCCESS"
};
} catch (e) {
return {
Code: OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR,
Message: OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR
};
}
}
getDefaults(method) {
return {
baseUrl: getBaseUrl(this.parent.getUrl(), "http"),
method: HTTPMethod[method],
headers: getHeader()
};
}
getHeaderWithDeviceToken() {
const headers = getHeader();
headers.set(
"Authorization",
`Bearer ${this.parent.getSession().deviceToken}`
);
return headers;
}
getHeaderWithUserToken() {
const headers = getHeader();
headers.set(
"Authorization",
`Bearer ${this.parent.getSession().userToken}`
);
return headers;
}
getHeaderWithSessionEnabled() {
const headers = getHeader();
headers.set("x-nura-session", "true");
return headers;
}
}
class General extends Main {
/**
* An endpoint that propagates the current API health status and
* other information. This can be used during an apps initial boot
* process to determine the accessibility of the API and propagate
* a general status message to users.
*
* Endpoint Action ID = 100
*/
async status() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
urlFragment: "status"
},
this.parent.onAfterRESTCall
);
}
/**
* Returns a list of system-wide accepted Mime types and their IDs.
*
* Endpoint Action ID = 101
*/
async listAcceptedMimeTypes() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
urlFragment: "mimes"
},
this.parent.onAfterRESTCall
);
}
/**
* Retrieves a list of available User Roles.
*
* Endpoint Action ID = 102
*/
async listAvailableUserRoles() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithDeviceToken(),
urlFragment: "roles"
},
this.parent.onAfterRESTCall
);
}
/**
* Retrieves a list of available status codes that can be used throughout
* the application to update the StatusID field of various resources.
*
* Endpoint Action ID = 104
*/
async listAvailableStatuses() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: "statuses"
},
this.parent.onAfterRESTCall
);
}
/**
* Checks validity of your Token and returns its encoded info.
*
* Endpoint Action ID = 107
*/
async verifyToken(token) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: new Headers({
"Content-Type": "application/json",
Authorization: `Bearer ${token}`
}),
urlFragment: "auth"
},
this.parent.onAfterRESTCall
);
}
/**
* Return the list of regions available for clusters.
*
* Endpoint Action ID = 108
*/
async regions() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
urlFragment: "regions"
},
this.parent.onAfterRESTCall
);
}
/**
* Retrieve consent.
*
* Endpoint Action ID = 109
*/
async retrieveConsent() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: "consents"
},
this.parent.onAfterRESTCall
);
}
/**
* Create consent.
*
* Endpoint Action ID = 110
*/
async createConsent(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: "consents",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Update consent.
*
* Endpoint Action ID = 111
*/
async updateConsent(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.PATCH),
headers: this.getHeaderWithUserToken(),
urlFragment: "consents",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Return the list of regions available for clusters.
*
* Endpoint Action ID = 113
*/
async getRolesInteractionTree() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: "roles-interaction-tree"
},
this.parent.onAfterRESTCall
);
}
/**
* Retrieve a user Prescription
*
* Endpoint Action ID = 114
*/
async getPrescription(prescriptionId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
urlFragment: `prescription/${prescriptionId}`
},
this.parent.onAfterRESTCall
);
}
}
class Users extends Main {
/**
* Creates a new user in the organization, checking for existing user
* details against the user list. Email + Password OR PhoneNumber fields
* are required. If both are provided, Email + Password will be used to
* create User account. The rest of the fields are optional.
* Endpoint Action ID = 200
*/
async create(data, tokenType) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: tokenType === "device" ? this.getHeaderWithDeviceToken() : this.getHeaderWithUserToken(),
urlFragment: "users",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Logs a user into a new session using Email, Password and optionally an MFAToken and responds with a User Token.
* The Token must be passed to every subsequent API call to the server.
*
* Note: you need to obtain a Device Token first to be able to login through this endpoint.
*
* Note: MFAToken token is mandatory when Multi-factor authentication is enabled for this user.
*
* Endpoint Action ID = 201
*/
async login(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
const { status, body, headers } = await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithDeviceToken(),
urlFragment: "users/auth",
data
},
this.parent.onAfterRESTCall
);
if (status === "200") {
this.parent.setSession({
userToken: body.Token,
userRefreshToken: body.RefreshToken
});
}
return { status, body, headers };
}
/**
* Retrieves User account information based on the provided User Token.
*
* Endpoint Action ID = 202
*/
async retrieve() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: "users"
},
this.parent.onAfterRESTCall
);
}
/**
* Removes the entire user account, profiles, and all measurement
* data associated with it. The account to be deleted is derived
* from the User Token.
*
* Endpoint Action ID = 206
*/
async remove() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: "users"
},
this.parent.onAfterRESTCall
);
}
/**
* Updates a user's account information with new details. This
* endpoint will only update fields supplied to it, hence sending
* only First Name or Last Name will exclusively update those values.
*
* Endpoint Action ID = 208
*/
async update(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.PATCH),
headers: this.getHeaderWithUserToken(),
urlFragment: "users",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Password reset, sends email to user
*
* Endpoint Action ID = 209
*/
async sendReset(email, identifier) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.PATCH),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/sendreset",
data: {
Email: email,
Identifier: identifier
}
},
this.parent.onAfterRESTCall
);
}
/**
* Resets User's password
*
* Endpoint Action ID = 210
*/
async resetPassword(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.PATCH),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/reset",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Retrieves User's Role.
*
* Endpoint Action ID = 211
*/
async retrieveUserRole() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/role"
},
this.parent.onAfterRESTCall
);
}
/**
* Verifies User's email address.
*
* Endpoint Action ID = 212
*/
async verifyUserAccount(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/verify",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Sends an account verification code to the user's
* email address. The code is used to verify the account
* through the account verification endpoint.
*
* Endpoint Action ID = 213
*/
async sendAccountActivationCode(userId, orgKey) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/verificationCode/${userId}/${orgKey}`
},
this.parent.onAfterRESTCall
);
}
/**
* Signup
*
* Endpoint Action ID = 215
*/
async signup(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/signup",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Signup
* /users/auth/code/:OrgKey/:PhoneNumber
* Endpoint Action ID = 216
*/
async requestLoginCode(orgKey, phoneNumber) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/auth/code/${orgKey}/${phoneNumber}`
},
this.parent.onAfterRESTCall
);
}
/**
* Use previously requested 6-digit code to login
* into a new session and obtain UserToken.
*
* Endpoint Action ID = 217
*/
async loginWithPhoneCode(data, enableSession) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
const { status, body, headers } = await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
urlFragment: "users/auth/code",
...enableSession && { headers: this.getHeaderWithSessionEnabled() },
data
},
this.parent.onAfterRESTCall
);
if (status === "200") {
this.parent.setSession({
userToken: body.Token,
userRefreshToken: body.RefreshToken
});
}
return { status, body, headers };
}
/**
* Only DFX_ORG_ADMIN has permission to delete all
* measurement of specific user for its own organization.
*
* Endpoint Action ID = 219
*/
async delete(userId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${userId}/measurements`
},
this.parent.onAfterRESTCall
);
}
/**
* This End Point allow user to change password for already verified user.
*
* Endpoint Action ID = 220
*/
async changePassword(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/changepassword",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Creates a base32 secret, url and a QR code (both derived from the secret)
* that are compatible with Google Authenticator or similar two-factor token
* generation application. The secret can be used to enable 2FA for given
* user, and QR code can be used to configure compatible application to
* generate login tokens for it. This is the first of two API calls needed
* to configure 2FA for a user.
*
* Endpoint Action ID = 221
*/
async createTwoFactorAuthSecret() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/mfa/secret"
},
this.parent.onAfterRESTCall
);
}
/**
* Enables 2FA for logged in user using an MFASecret (created
* by /users/mfa/secret endpoint) and MFAToken (derived from
* MFASecret by scanning a QR code by Google Authenticator or
* compatible app).
*
* This is the second of two API calls needed to configure 2FA for
* a user.The complete workflow would be as follows:
* * Logged in user calls /users/mfa/enable and stores
* `secretBase32Encoded` and `qrcode` properties.
* * User scans `qrcode` by 2FA token generation app.
* * User POSTs `secretBase32Encoded` as `MFASecret` and 2FA app
* temporary token as `MFAToken` to `/users/mfa/enable` endpoint.
*
* Endpoint Action ID = 222
*/
async enableTwoFactorAuthForLoggedInUser(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/mfa",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Disables 2FA for logged in user.
*
* Endpoint Action ID = 223
*/
async disableTwoFactorAuthForLoggedInUser() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/mfa"
},
this.parent.onAfterRESTCall
);
}
/**
* Disables 2FA for user by its ID. This is a privileged
* operation that requires ORG_ADMIN permissions.
*
* Endpoint Action ID = 224
*/
async disableTwoFactorAuthForSpecifiedUser(userId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${userId}/mfa`
},
this.parent.onAfterRESTCall
);
}
/**
* Logs user out from all its sessions at once.
*
* Endpoint Action ID = 226
*/
async logout() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/auth"
},
this.parent.onAfterRESTCall
);
}
/**
* Recovery Verification Code
*
* Endpoint Action ID = 228
*/
async recoveryVerificationCode(userId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/recoveryVerificationCode/${userId}`
},
this.parent.onAfterRESTCall
);
}
/**
* User Prescription
*
* Endpoint Action ID = 229
*/
async getUserPrescription(userId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${userId}/prescription`
},
this.parent.onAfterRESTCall
);
}
/**
* Delete Prescription
*
* Endpoint Action ID = 230
*/
async deletePrescription(id) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${id}/prescription`
},
this.parent.onAfterRESTCall
);
}
/**
* Create Prescription
*
* Endpoint Action ID = 231
*/
async createPrescription(userId, data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${userId}/prescription`,
data
},
this.parent.onAfterRESTCall
);
}
/**
* Resend Prescription
*
* Endpoint Action ID = 231
*/
async resendPrescription(userId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${userId}/resend/prescription`
},
this.parent.onAfterRESTCall
);
}
/**
* Update Prescription
*
* Endpoint Action ID = 232
*/
async updatePrescription(userId, data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.PATCH),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${userId}/prescription`,
data
},
this.parent.onAfterRESTCall
);
}
/**
* Get My Prescription
*
* Endpoint Action ID = 233
*/
async getMyPrescription() {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: "users/prescription"
},
this.parent.onAfterRESTCall
);
}
}
class Profiles extends Main {
/**
* Creates a user profile under a main user account.
* User profiles may be used to segment different accounts
* for measurements.
*
* Endpoint Action ID = 400
*/
async create(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithDeviceToken(),
urlFragment: "users/profiles",
data
},
this.parent.onAfterRESTCall
);
}
/**
* Retrieves a single user Profile specified by ID.
*
* Endpoint Action ID = 401
*/
async retrieve(profileId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/profiles/${profileId}`
},
this.parent.onAfterRESTCall
);
}
/**
* Lists specific profiles managed under the current user account.
*
* Endpoint Action ID = 402
*/
async list(data) {
const {
endDate,
date,
ownerUser,
userProfileName,
status,
limit,
offset,
sortBy,
sortOrder
} = data ?? {};
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/profiles?${userProfileName != null ? `UserProfileName=${userProfileName}&` : ""}${status != null ? `Status=${status}&` : ""}${limit != null ? `Limit=${limit}&` : ""}${offset != null ? `Offset=${offset}&` : ""}${endDate != null ? `EndDate=${endDate}&` : ""}${date != null ? `Date=${date}&` : ""}${sortBy != null ? `SortBy=${sortBy}&` : ""}${sortOrder != null ? `SortOrder=${sortOrder}&` : ""}${ownerUser != null ? `OwnerUser=${ownerUser}` : ""}`
},
this.parent.onAfterRESTCall
);
}
/**
* Lists specific profiles managed under a single user account
* specified by the ID in the request parameters.
*
* Endpoint Action ID = 403
*/
async listByUser(userId, data) {
const { userProfileName, status, limit, offset } = data ?? {};
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/${userId}/profiles?${userProfileName != null ? `UserProfileName=${userProfileName}&` : ""}${status != null ? `Status=${status}&` : ""}${limit != null ? `Limit=${limit}&` : ""}${offset != null ? `Offset=${offset}` : ""}`
},
this.parent.onAfterRESTCall
);
}
/**
* Removes the user profile entirely. It also deletes any related
* meta fields associated with the profile.
*
* Endpoint Action ID = 404
*/
async remove(profileId) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/profiles/${profileId}`
},
this.parent.onAfterRESTCall
);
}
/**
* Updates a specific user profile. To update status the valid
* options are: ACTIVE and INACTIVE.
*
* Endpoint Action ID = 405
*/
async update(profileId, data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.PATCH),
headers: this.getHeaderWithUserToken(),
urlFragment: `users/profiles/${profileId}`,
data
},
this.parent.onAfterRESTCall
);
}
}
class Measurements extends Main {
/**
* Returns the results of a measurement request specified by
* the UUID in the endpoint request. This payload will change
* according to the different requested signals.
*
* Endpoint Action ID = 500
*/
async retrieve(id, tokenType) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: tokenType === "device" ? this.getHeaderWithDeviceToken() : this.getHeaderWithUserToken(),
urlFragment: `measurements/${id}`
},
this.parent.onAfterRESTCall
);
}
/**
* Provides a historical list of measurements captured by the API store. The results
* of the measurements are captured and only displayed for the current application
* providers token designator. Each record has a status representing its cycle in the system:
*
* Status Message | Description
* * CAPTURING | A new record was created and results are being received.
* * PROCESSING | Capture is complete and the record is processing.
* * COMPLETE | The analysis is complete and ready for consumption.
* * ERROR | An error occurred during processing.
* * INCOMPLETE | Capturing process returned as incomplete/not enough data.
*
* Endpoint Action ID = 501
*/
async list(data) {
const {
statusId,
userProfileId,
userProfileName,
studyId,
partnerId,
date,
endDate,
limit,
offset,
sortBy,
sortOrder,
deviceID,
mode,
userName
} = data ?? {};
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `measurements?${statusId != null ? `StatusID=${statusId}&` : ""}${userProfileId != null ? `UserProfileID=${userProfileId}&` : ""}${userProfileName != null ? `UserProfileName=${userProfileName}&` : ""}${studyId != null ? `StudyID=${studyId}&` : ""}${partnerId != null ? `PartnerID=${partnerId}&` : ""}${date != null ? `Date=${date}&` : ""}${endDate != null ? `EndDate=${endDate}&` : ""}${limit != null ? `Limit=${limit}&` : ""}${offset != null ? `Offset=${offset}&` : ""}${deviceID != null ? `DeviceID=${deviceID}&` : ""}${mode != null ? `Mode=${mode}&` : ""}${sortBy != null ? `SortBy=${sortBy}&` : ""}${sortOrder != null ? `SortOrder=${sortOrder}&` : ""}${userName != null ? `UserName=${userName}` : ""}`
},
this.parent.onAfterRESTCall
);
}
/**
* Begins a new data capture session and returns a measurement ID
* property, which should be referenced for adding data chunks and
* retreiving results.
*
* Resolution: currently can be either 0 or 100. (default is 100)
*
* * 100 means the result set will have 100% of the original size
*
* * 0 returns 1 value per signal
*
* PartnerID is mandatory or optional (based on License policy).
*
* Endpoint Action ID = 504
*/
async create(data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
const { status, body, headers } = await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: "measurements",
data
},
this.parent.onAfterRESTCall
);
if (status === "200") {
this.parent.setSession({
lastMeasurementId: body.ID
});
}
return { status, body, headers };
}
/**
* Adds collected blood-flow data to a specific measurement. Upon submitting a
* chunk of data, the API will return a MeasurementDataID value representing
* the received chunk. Data must be sent to the server in the order produced by
* the DFX SDK. If a chunk it sent out of order, the server will return an error.
* Please ensure that new chunks are only sent after the server responds with a
* MeasurementDataID.
*
* Submitting measurements has three stages:
*
* a) starting,
*
* b) measurement body,
*
* c) closing a measurement.
*
* Each of these phases have the same payload structure however a different Action
* flag is to be sent with each request and must follow the CHUNK::ACTION format.
*
* Measurement Actions | Description
*
* FIRST::PROCESS | Start a new measurement (drop any existing), Process results
*
* FIRST::IGNORE | Start a new measurement (drop any existing), Do not process
*
* CHUNK::PROCESS | Arbitrary block of TOI data and process results
*
* CHUNK::IGNORE | Arbitrary block of TOI data and do not process results
*
* LAST::PROCESS | Finish a measurement cycle and process results
*
* LAST::IGNORE | Finish a measurement cycle and do not process
*
* `Payload` is binary data that can currently only be obtained by using our SDK.
* The Payload (binary content) field must be `base64-encoded`.
*
* Note: This endpoint is a subject to request throttling, you must not submit more
* data than can be obtained in real time. i.e., do not send more than five seconds
* of chunk data over the course of five seconds of real time.
*
* Response Error Codes Explanation:
*
* * "RATE_LIMIT": You have sent too many chunks in a given time period. See the Note above.
* * "MEASUREMENT_CLOSED": Requested Measurement is already finished. You need to create a new Measurement.
* * "MISALIGNED_CHUNK": Chunk Order was mismatched. i.e., ChunkOrder 2 was sent before ChunkOrder 1.
* * "INVALID_MEASUREMENT": Requested Measurement ID was not found.
* * "UNPACKER_RPC_ERROR": Payload validation has been failed. Reason(s) will be provided in error message.
*
* Endpoint Action ID = 506
*/
async data(id, data) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.POST),
headers: this.getHeaderWithUserToken(),
urlFragment: `measurements/${id}/data`,
data
},
this.parent.onAfterRESTCall
);
}
/**
* Only DFX_ORG_ADMIN has permission to delete a specific measurment by
* measurement ID for its own organization.
*
* Endpoint Action ID = 507
*/
async delete(id) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.DELETE),
headers: this.getHeaderWithUserToken(),
urlFragment: `measurements/${id}`
},
this.parent.onAfterRESTCall
);
}
}
class Organizations extends Main {
/**
* Retrieves information related to the current organization account.
*
* Endpoint Action ID = 700
*/
async retrieve(tokenType) {
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
urlFragment: "organizations",
headers: tokenType === "device" ? this.getHeaderWithDeviceToken() : this.getHeaderWithUserToken()
},
this.parent.onAfterRESTCall
);
}
/**
* Retrieves a list of users in the current organization.
*
* This endpoint can filter by groups and account creation start
* and end dates to make sorting and filtering easier.
*
* Endpoint Action ID = 702
*/
async users(data) {
const { statusId, userName, roleId, gender, date, endDate, limit, offset } = data ?? {};
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...this.getDefaults(HTTPMethod.GET),
headers: this.getHeaderWithUserToken(),
urlFragment: `organizations/users?${statusId != null ? `StatusID=${statusId}&` : ""}${userName != null ? `UserName=${userName}&` : ""}${roleId != null ? `RoleID=${roleId}&` : ""}${gender != null ? `Gender=${gender}&` : ""}${date != null ? `Date=${date}&` : ""}${endDate != null ? `EndDate=${endDate}&` : ""}${limit != null ? `Limit=${limit}&` : ""}${offset != null ? `Offset=${offset}` : ""}`
},
this.parent.onAfterRESTCall
);
}
/**
* Similar to `measurements.list` endpoint but retrieves all
* measurements across an Organization.
*
* Accessible by users with Researcher or Admin role.
*
* Endpoint Action ID = 703
*/
async listMeasurements(data) {
const {
statusId,
userProfileID,
userProfileName,
studyID,
userName,
date,
endDate,
limit,
offset,
deviceID,
partnerId,
mode,
sortBy,
sortOrder,
region
} = data ?? {};
const { Code, Message } = await this.onBeforeRESTCall();
if (Code === OnBeforeRESTCallErrors.ON_BEFORE_REST_CALL_ERROR) {
return { status: Code, body: { Code, Message }, headers: getHeaders() };
}
return await _fetch(
{
...