UNPKG

3.24 kBTypeScriptView Raw
1import { Environment } from "../environment/environment";
2import { Nest } from "./nest";
3import { WebhookJob } from "../job/webhookJob";
4import { WebhookInterface } from "../ui/webhookInterface";
5import { InterfaceManager } from "../ui/interfaceManager";
6export declare class WebhookNest extends Nest {
7 protected path: string;
8 protected httpMethod: string;
9 protected handleRequest: any;
10 protected ui: WebhookInterface;
11 protected im: InterfaceManager;
12 protected _holdResponse: boolean;
13 /**
14 * Webhook Nest constructor
15 * @param e
16 * @param path
17 * @param httpMethod
18 * @param handleRequest Custom request handler function.
19 */
20 constructor(e: Environment, path: string | string[], httpMethod: string, handleRequest?: any);
21 /**
22 * Get the holdResponse flag.
23 * @returns {boolean}
24 */
25 /**
26 * Set hold response flag. This allows you to run tunnel logic and send the response after completion.
27 * You must call _releaseResponse_ later if you use this.
28 * @param holdResponse
29 */
30 holdResponse: boolean;
31 /**
32 * Releases the webhook response when tunnel run logic is complete.
33 * @param job {WebhookJob} The webhook job that triggered the webhook nest.
34 * @param message {string} The optional response message, if not using a custom request handler.
35 * #### Example
36 * ```js
37 * var webhook = af.createWebhookNest(["jobs", "submit"], "post");
38 * webhook.holdResponse = true; // Keeps the response from being sent immediately
39 * var tunnel = af.createTunnel("Dwight's test tunnel");
40 * tunnel.watch(webhook);
41 * tunnel.run(function(job, nest){
42 * setTimeout(function(){
43 * nest.releaseResponse(job, "Worked!"); // Sends response
44 * }, 1500); // After 1.5 seconds
45 * });
46 * ```
47 */
48 releaseResponse(job: WebhookJob, message?: string): void;
49 /**
50 * Get the custom handleRequest function.
51 * @returns {any}
52 */
53 getCustomHandleRequest(): any;
54 /**
55 * Set the custom handlerRequest function.
56 * @param handleRequest
57 */
58 protected setCustomHandleRequest(handleRequest: any): void;
59 /**
60 * Set the path as a string or a string array. All parts are URI encoded.
61 * Create directory structures with an array: ["one", "two"] results in "/one/two".
62 * @param path
63 */
64 setPath(path: any): void;
65 /**
66 * Get the path.
67 * @returns {string}
68 */
69 getPath(): string;
70 /**
71 * Get the HTTP method.
72 * @returns {string}
73 */
74 getHttpMethod(): string;
75 /**
76 * Set the HTTP method.
77 * @param httpMethod
78 */
79 protected setHttpMethod(httpMethod: any): void;
80 /**
81 * Get the name.
82 * @returns {string}
83 */
84 getName(): string;
85 /**
86 * On load, do nothing.
87 */
88 load(): void;
89 /**
90 * Add webhook to server watch list.
91 */
92 watch(): void;
93 /**
94 * Creates a new job
95 * @param job
96 */
97 arrive(job: WebhookJob): void;
98 /**
99 * Get the interface manager. Used to manage interface instances for session handling.
100 * @returns {InterfaceManager}
101 */
102 getInterfaceManager(): InterfaceManager;
103}