UNPKG

@basetime/a2w-api-ts

Version:

Client library that communicates with the addtowallet API.

48 lines (47 loc) 1.86 kB
import { CampaignWorkflow, CampaignWorkflowInput } from '../../types/CampaignWorkflow'; import Endpoint from '../Endpoint'; /** * Communicate with the `/campaigns/:campaignId/workflows` sub-endpoints. * * Accessed via `client.campaigns.workflows`. Methods take `campaignId` as their first * argument, matching the unbound style used elsewhere in the SDK. */ export default class CampaignWorkflowsEndpoint extends Endpoint { /** * Constructor. * * @param parent The parent `CampaignsEndpoint` whose `req`, `do`, and `qb` are * reused. */ constructor(parent: Endpoint); /** * Returns the workflows attached to a campaign. * * @param campaignId The ID of the campaign. */ getAll: (campaignId: string) => Promise<CampaignWorkflow[]>; /** * Attaches a workflow to a campaign. * * @param campaignId The ID of the campaign. * @param body The attachment body (workflow ID + runsWhen + optional schedule). */ attach: (campaignId: string, body: CampaignWorkflowInput) => Promise<CampaignWorkflow>; /** * Updates an existing workflow attachment on a campaign. * * @param campaignId The ID of the campaign. * @param workflowId The ID of the campaign workflow attachment to update. * @param body The updated `runsWhen` and optional schedule. */ update: (campaignId: string, workflowId: string, body: Pick<CampaignWorkflowInput, "runsWhen" | "schedule">) => Promise<string>; /** * Detaches a workflow from a campaign. * * Returns the remaining workflow attachments for the campaign. * * @param campaignId The ID of the campaign. * @param workflowId The ID of the campaign workflow attachment to detach. */ detach: (campaignId: string, workflowId: string) => Promise<CampaignWorkflow[]>; }