import { WorkflowData } from '../models/workflow' import { APIService } from './api' export class WorkflowService { private v1Url: string constructor(private api: APIService, url: string) { this.v1Url = `${url}/v1` } /** * This function returns all workflows * @returns desired workflow */ public getWorkflows(): Promise { return this.api.get(`${this.v1Url}/workflows`) } /** * This function retrieves a workflow. If `locale` is not found, it will try to find 'en' version of it. * By default, will return most recent workflow of a specific `id`. `createdAt` can be used to select older version. * @param id The uuid of the workflow * @param locale (optional) The desired locale of the workflow (default: 'en') * @param createdAt (optional) The creation date of the workflow (also used for versionning) * @returns desired workflow */ public getWorkflow( id: string, locale?: string, createdAt?: string ): Promise { return this.api.get(`${this.v1Url}/workflows/${id}`, { params: { locale, createdAt }, }) } }