UNPKG

2.62 kBTypeScriptView Raw
1import { Environment } from "../environment/environment";
2import { Job } from "./job";
3/**
4 * A job that is triggered when a webhook receives a request.
5 */
6export declare class WebhookJob extends Job {
7 protected request: any;
8 protected response: any;
9 protected _responseSent: boolean;
10 /**
11 * WebhookJob constructor
12 * @param e
13 * @param request
14 * @param response
15 */
16 constructor(e: Environment, request: any, response: any);
17 /**
18 * Get if the response to the webhook was already sent or not.
19 * @returns {boolean}
20 */
21 /**
22 * Set if the response to the webhook was already sent or not.
23 * @param sent
24 */
25 responseSent: boolean;
26 /**
27 * Get the HTTP response object.
28 * @returns {ClientResponse}
29 */
30 getResponse(): any;
31 /**
32 * Get the HTTP request object.
33 * @returns {ClientRequest}
34 */
35 getRequest(): any;
36 /**
37 * Return a specific URL parameter.
38 * #### Example
39 * ```js
40 * // Webhook URL: /hooks/my/hook?customer_id=MyCust
41 * var customer_id = webhookJob.getUrlParameter("customer_id");
42 * // customer_id => MyCust
43 * ```
44 * @param parameter
45 * @returns {any}
46 */
47 getQueryStringValue(parameter: string): any;
48 /**
49 * Return all URl parameters.
50 * * #### Example
51 * ```js
52 * // Webhook URL: /hooks/my/hook?customer_id=MyCust&file_name=MyFile.zip
53 * var query = webhookJob.getUrlParameters();
54 * // query => {customer_id: "MyCust", file_name: "MyFile.zip"}
55 * ```
56 * @returns {any}
57 */
58 getQueryStringValues(): any;
59 /**
60 * Returns FileJobs made from files sent via FormData to the webhook.
61 * @returns {FileJob[]}
62 */
63 getFormDataFiles(): any[];
64 /**
65 * Get all FormData values.
66 * @returns {any}
67 */
68 getFormDataValues(): any;
69 /**
70 * Get a single FormData value.
71 * @param key
72 * @returns {any}
73 */
74 getFormDataValue(key: string): any;
75 /**
76 * Get a string from the request body.
77 * The given callback is given a string parameter.
78 * #### Example
79 * ```js
80 * webhookJob.getDataAsString(function(requestBody){
81 * console.log(requestBody);
82 * });
83 * ```
84 * @param callback
85 */
86 getDataAsString(callback: any): void;
87 /**
88 * Returns an array of parameters from both the query string and form-data.
89 */
90 getParameters(): any;
91 /**
92 * Returns a parameter from both the query string and form-data.
93 * @param key
94 * @returns {any}
95 */
96 getParameter(key: string): any;
97}