UNPKG

@pipedream/podio

Version:

Pipedream Podio Components

76 lines (74 loc) 1.64 kB
import common from "../common/common-hook.mjs"; export default { key: "podio-item-updated", name: "New Item Updated Event", description: "Emit new events when an item is updated. [See the documentation](https://developers.podio.com/doc/hooks)", version: "0.0.2", type: "source", dedupe: "unique", ...common, props: { ...common.props, orgId: { propDefinition: [ common.props.app, "orgId", ], }, spaceId: { propDefinition: [ common.props.app, "spaceId", (configuredProps) => ({ orgId: configuredProps.orgId, }), ], }, appId: { propDefinition: [ common.props.app, "appId", (configuredProps) => ({ spaceId: configuredProps.spaceId, }), ], }, }, methods: { ...common.methods, getMeta(event) { return { id: Date.now(), //can't use item_id because there may be multiple updates ts: Date.now(), summary: `Item updated (ID:${event?.body?.item_id})`, }; }, async getData(event) { return this.app.getItem({ itemId: event?.body?.item_id, }); }, getEvent() { return "item.update"; }, getRefType() { return "app"; }, getRefId() { return this.appId; }, async loadHistoricalEvents() { const { items } = await this.app.filterItems({ appId: this.appId, }); for (const item of items) { this.$emit( item, this.getMeta({ body: item, }), ); } }, }, };