@figuredev/business-config-sdk
Advanced tools
Comparing version 0.4.0 to 0.5.0
54
index.ts
import axios from "axios" | ||
import { UserContext } from "./utils" | ||
import { PrinterDTO } from "./printers" | ||
import { AssignmentDTO } from "./assignments" | ||
import { SettingDTO } from "./settings" | ||
@@ -10,5 +12,36 @@ type BusinessConfigClientConfig = { | ||
export type GetAssignmentsQueryParams = { | ||
includeDeleted?: boolean | ||
locationIds?: string[] | ||
} | ||
export type GetSettingsQueryParams = { | ||
locationId?: string | ||
terminalId?: string | ||
keys?: string[] | ||
} | ||
export class BusinessConfigClient { | ||
constructor(private config: BusinessConfigClientConfig) {} | ||
async getAssignments(ctx: UserContext, params: GetAssignmentsQueryParams): Promise<AssignmentDTO[]> { | ||
return await axios | ||
.request({ | ||
baseURL: this.config.baseUrl, | ||
method: "GET", | ||
url: "/assignment", | ||
headers: { | ||
"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), | ||
}, | ||
params: { | ||
includeDeleted: params.includeDeleted, | ||
locationIds: params.locationIds, | ||
}, | ||
}) | ||
.then((r) => r.data) | ||
} | ||
async getPrinters(ctx: UserContext): Promise<PrinterDTO[]> { | ||
@@ -29,2 +62,23 @@ return await axios | ||
} | ||
async getSettings(ctx: UserContext, params: GetSettingsQueryParams): Promise<SettingDTO[]> { | ||
return await axios | ||
.request({ | ||
baseURL: this.config.baseUrl, | ||
method: "GET", | ||
url: "/setting", | ||
headers: { | ||
"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), | ||
}, | ||
params: { | ||
terminalId: params.terminalId, | ||
locationId: params.locationId, | ||
keys: params.keys, | ||
}, | ||
}) | ||
.then((r) => r.data) | ||
} | ||
} |
{ | ||
"name": "@figuredev/business-config-sdk", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
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
3938
6
108