Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebhookJob

A job that is triggered when a webhook receives a request.

Hierarchy

  • Job
    • WebhookJob

Index

Constructors

constructor

Properties

Protected _responseSent

_responseSent: boolean

Protected e

Protected id

id: string

Protected lifeCycle

lifeCycle: LifeEvent[]

Protected locallyAvailable

locallyAvailable: boolean

Protected name

name: string

Protected nest

nest: Nest

Protected request

request: any

Protected response

response: any

Protected tunnel

tunnel: Tunnel

Accessors

responseSent

  • get responseSent(): boolean
  • set responseSent(sent: boolean): void
  • Get if the response to the webhook was already sent or not.

    Returns boolean

  • Set if the response to the webhook was already sent or not.

    Parameters

    • sent: boolean

    Returns void

Methods

Protected createLifeEvent

  • createLifeEvent(verb: string, start: string, finish: string): void

email

  • Sends an email.

    Parameters

    • emailOptions: EmailOptions

      Email options

      Sending pug template email example

      // my_tunnel.js
      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email from pug template",
               to: "john.smith@example.com",
               template: "./template_files/my_email.pug"
           });
      });
      
      // template_files/my_email.pug
      h1="Example email!"
      p="Got job ID " + job.getId()
      

      Sending plain-text email

      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email with hard-coded plain-text",
               to: "john.smith@example.com",
               text: "My email body!"
           });
      });
      

      Sending html email

      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email with hard-coded html",
               to: "john.smith@example.com",
               html: "<h1>My email body!</h1>"
           });
      });
      

    Returns void

fail

  • fail(reason: string): void
  • Function to call to fail a job while in a tunnel.

    Parameters

    • reason: string

    Returns void

getDataAsString

  • getDataAsString(callback: any): void
  • Get a string from the request body. The given callback is given a string parameter.

    Example

    webhookJob.getDataAsString(function(requestBody){
        console.log(requestBody);
    });
    

    Parameters

    • callback: any

    Returns void

getFormDataFiles

  • getFormDataFiles(): Array<any>

getFormDataValue

  • getFormDataValue(key: string): any

getFormDataValues

  • getFormDataValues(): any

getId

  • getId(): string

getLifeCycle

getName

  • getName(): string

getNameProper

  • getNameProper(): string

getNest

getParameter

  • getParameter(key: string): any
  • Returns a parameter from both the query string and form-data.

    Parameters

    • key: string

    Returns any

getParameters

  • getParameters(): any

getQueryStringValue

  • getQueryStringValue(parameter: string): any
  • Return a specific URL parameter.

    Example

    // Webhook URL: /hooks/my/hook?customer_id=MyCust
    var customer_id = webhookJob.getUrlParameter("customer_id");
    // customer_id => MyCust
    

    Parameters

    • parameter: string

    Returns any

getQueryStringValues

  • getQueryStringValues(): any
  • Return all URl parameters.

    • Example

      // Webhook URL: /hooks/my/hook?customer_id=MyCust&file_name=MyFile.zip
      var query = webhookJob.getUrlParameters();
      // query => {customer_id: "MyCust", file_name: "MyFile.zip"}
      

    Returns any

getRequest

  • getRequest(): any

getResponse

  • getResponse(): any

getTunnel

isLocallyAvailable

  • isLocallyAvailable(): boolean

move

  • move(destinationNest: any, callback: any): void
  • Move function error.

    Parameters

    • destinationNest: any
    • callback: any

    Returns void

setLocallyAvailable

  • setLocallyAvailable(available: boolean): void

setName

  • setName(name: string): void

setNest

  • setNest(nest: Nest): void

setTunnel

  • setTunnel(tunnel: Tunnel): void

toString

  • toString(): string

transfer

  • transfer(tunnel: Tunnel): void

Generated using TypeDoc