@figuredev/business-config-sdk
Advanced tools
Comparing version 0.9.7 to 0.9.8
@@ -7,2 +7,3 @@ import { UserContext } from "./utils"; | ||
import { LocationDTO, LocationPreviewDTO } from "./location"; | ||
import { TerminalDTO, TerminalPreviewDTO } from "./terminal"; | ||
declare type BusinessConfigClientConfig = { | ||
@@ -25,2 +26,5 @@ baseUrl: string; | ||
}; | ||
export declare type GetTerminalPreviewsQueryParams = { | ||
locationIds?: string[]; | ||
}; | ||
export declare type GetPrintersQueryParams = { | ||
@@ -32,5 +36,13 @@ printerType?: PrinterType; | ||
constructor(config: BusinessConfigClientConfig); | ||
prepareHeaders(ctx: UserContext): { | ||
"twbrds-terminal-id": string; | ||
"twbrds-location-id": string; | ||
"twbrds-account-id": string; | ||
"fgr-service-token": string; | ||
}; | ||
getAccount(ctx: UserContext, id: string): Promise<AccountDTO | null>; | ||
getLocation(ctx: UserContext, id: string): Promise<LocationDTO | null>; | ||
getLocationPreviews(ctx: UserContext, params: GetLocationPreviewsQueryParams): Promise<LocationPreviewDTO[]>; | ||
getTerminal(ctx: UserContext, id: string): Promise<TerminalDTO | null>; | ||
getTerminalPreviews(ctx: UserContext, params: GetTerminalPreviewsQueryParams): Promise<TerminalPreviewDTO[]>; | ||
getAssignments(ctx: UserContext, params: GetAssignmentsQueryParams): Promise<AssignmentDTO[]>; | ||
@@ -37,0 +49,0 @@ getPrinters(ctx: UserContext, params?: GetPrintersQueryParams): Promise<PrinterDTO[]>; |
@@ -18,2 +18,5 @@ "use strict"; | ||
} | ||
prepareHeaders(ctx) { | ||
return Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)); | ||
} | ||
getAccount(ctx, id) { | ||
@@ -26,3 +29,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
url: `/account/${id}`, | ||
headers: Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)), | ||
headers: this.prepareHeaders(ctx), | ||
}) | ||
@@ -39,3 +42,3 @@ .then((r) => r.data); | ||
url: `/location/${id}`, | ||
headers: Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)), | ||
headers: this.prepareHeaders(ctx), | ||
}) | ||
@@ -52,3 +55,3 @@ .then((r) => r.data); | ||
url: "/location", | ||
headers: Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)), | ||
headers: this.prepareHeaders(ctx), | ||
params: { | ||
@@ -61,2 +64,29 @@ locationIds: params.locationIds, | ||
} | ||
getTerminal(ctx, id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield axios_1.default | ||
.request({ | ||
baseURL: this.config.baseUrl, | ||
method: "GET", | ||
url: `/terminal/${id}`, | ||
headers: this.prepareHeaders(ctx), | ||
}) | ||
.then((r) => r.data); | ||
}); | ||
} | ||
getTerminalPreviews(ctx, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield axios_1.default | ||
.request({ | ||
baseURL: this.config.baseUrl, | ||
method: "GET", | ||
url: `/terminal`, | ||
headers: this.prepareHeaders(ctx), | ||
params: { | ||
locationIds: params.locationIds, | ||
}, | ||
}) | ||
.then((r) => r.data); | ||
}); | ||
} | ||
getAssignments(ctx, params) { | ||
@@ -69,3 +99,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
url: "/assignment", | ||
headers: Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)), | ||
headers: this.prepareHeaders(ctx), | ||
params: { | ||
@@ -87,3 +117,3 @@ includeDeleted: params.includeDeleted, | ||
url: "/printer", | ||
headers: Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)), | ||
headers: this.prepareHeaders(ctx), | ||
params: { | ||
@@ -103,3 +133,3 @@ printerType: params.printerType | ||
url: "/printer/physical", | ||
headers: Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)), | ||
headers: this.prepareHeaders(ctx), | ||
}) | ||
@@ -116,3 +146,3 @@ .then((r) => r.data); | ||
url: "/setting", | ||
headers: Object.assign(Object.assign(Object.assign({ "fgr-service-token": this.config.secret }, (ctx.accountId ? { "twbrds-account-id": ctx.accountId } : null)), (ctx.locationId ? { "twbrds-location-id": ctx.locationId } : null)), (ctx.terminalId ? { "twbrds-terminal-id": ctx.terminalId } : null)), | ||
headers: this.prepareHeaders(ctx), | ||
params: { | ||
@@ -119,0 +149,0 @@ terminalId: params.terminalId, |
{ | ||
"name": "@figuredev/business-config-sdk", | ||
"version": "0.9.7", | ||
"version": "0.9.8", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19001
26
396
0