Skip to content

Case: createCase(httpClient)(caseType)(event)(payloadFn) #67

@vlaurin

Description

@vlaurin

Extend existing createCase(httpClient)(caseType)(event)(payload) to accept a function as the payload. This function will be called with the data returned by an optional about-to-start callback and will return the payload object, allowing payload to be generated dynamically based on callback data.

Example

import {createCase, httpClient} from '@quickcase/node-toolkit';

// A configured `httpClient` is required to create case
const client = httpClient('http://data-store:4452')(() => Promise.resolve('access-token'));

const payloadFn = (start) => ({
  data: {
    field1: start.field1,
    field2: 'value2',
  },
  summary: 'Short text',
  description: 'Longer description',
});

const aCase = await createCase(client)('CaseType1')('CreateEvent')(payloadFn);
/*
{
  id: '1234123412341238',
  state: 'Created',
  data: {
    field1: 'value1',
    field2: 'value2',
  },
  ...
}
*/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions