Completed
Push — master ( 57c78c...4fcad4 )
by Muhammad Dyas
15s queued 13s
created

src/helpers/response.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 24
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
mnd 0
bc 0
fnc 2
dl 0
loc 24
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
/**
2
 * Creates an action response.
3
 * Action Response is parameter that a Chat app can use to configure how its
4
 * response is posted.
5
 * ref: https://developers.google.com/chat/api/reference/rest/v1/spaces.messages#actionresponse
6
 *
7
 * @param {string} message - Number of votes for this option
8
 * @param {string} status - Status of
9
 * @returns {object} - ActionResponse
10
 */
11
export function buildActionResponse(message: string, status = 'OK') {
12
  return {
13
    actionResponse: {
14
      type: 'DIALOG',
15
      dialogAction: {
16
        actionStatus: {
17
          statusCode: status,
18
          userFacingMessage: message,
19
        },
20
      },
21
    },
22
  };
23
}
24
25