Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add options to editResource for analysis identifier #45

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/modules/Account/Dashboard.Widgets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Data, GenericID, GenericToken } from "../../common/common.types";
import TagoIOModule, { GenericModuleParams } from "../../common/TagoIOModule";
import { EditDataModel, EditDeviceResource, GetDataModel, PostDataModel, WidgetInfo } from "./dashboards.types";
import {
EditDataModel,
EditDeviceResource,
EditResourceOptions,
GetDataModel,
PostDataModel,
WidgetInfo,
} from "./dashboards.types";

class Widgets extends TagoIOModule<GenericModuleParams> {
/**
Expand Down Expand Up @@ -132,18 +139,21 @@ class Widgets extends TagoIOModule<GenericModuleParams> {
* Update value of a resource for the current widget
* @param dashboardID Dashboard identification
* @param widgetID Widget identification
* @param data
* @param bypassBucket
* @param resourceData Updated data for the resource
* @param options Additional options
*/
public async editResource(
dashboardID: GenericID,
widgetID: GenericID,
resourceData: EditDeviceResource | EditDeviceResource[]
resourceData: EditDeviceResource | EditDeviceResource[],
options?: EditResourceOptions
): Promise<object> {
const result = await this.doRequest<object>({
path: `/data/${dashboardID}/${widgetID}/resource`,
method: "PUT",
params: {},
params: {
widget_exec: options?.identifier,
},
body: resourceData,
});

Expand Down
9 changes: 9 additions & 0 deletions src/modules/Account/dashboards.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ interface EditDeviceResource {
*/
[key: string]: string | boolean;
}

interface EditResourceOptions {
/**
* Identifier to send to the Analysis scope in `widget_exec`.
*/
identifier?: string;
}

interface WidgetInfo {
analysis_run?: GenericID;
dashboard?: GenericID;
Expand Down Expand Up @@ -165,5 +173,6 @@ export {
PostDataModel,
EditDataModel,
EditDeviceResource,
EditResourceOptions,
GetDataModel,
};