Class: TypedForm::Webhook

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/typed_form/webhook.rb

Overview

Methods used for handling incoming webhook events with data using the Typeform Webhook JSON schema.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json:) ⇒ Webhook

Creates a new webhook object from an incoming Typeform Data stream.

Parameters:

  • json (String)

    JSON Data from a Typeform Webhook



25
26
27
# File 'lib/typed_form/webhook.rb', line 25

def initialize(json:)
  @raw_json = json
end

Instance Attribute Details

#raw_jsonString (readonly)

Unformatted JSON data from an incoming Typeform Webhook.

Returns:

  • (String)

    the current value of raw_json



9
10
11
# File 'lib/typed_form/webhook.rb', line 9

def raw_json
  @raw_json
end

Instance Method Details

#form_idInteger

Retrieves the Form ID from the Webhook JSON data.

Returns:

  • (Integer)

    Typeform Form ID for the Webhook.



19
# File 'lib/typed_form/webhook.rb', line 19

def_delegators :form_response, :form_id

#form_responseArendelle

Returns An immutable representation of the Webhook JSON form_response field.

Returns:

  • (Arendelle)

    An immutable representation of the Webhook JSON form_response field.



15
# File 'lib/typed_form/webhook.rb', line 15

def_delegators :parsed_json, :form_response

#form_tokenString

Retrieves the Token from the Webhook JSON data.

Returns:

  • (String)

    Unique token for the form submission.



36
37
38
# File 'lib/typed_form/webhook.rb', line 36

def form_token
  form_response.token
end

#jsonObject



29
30
31
# File 'lib/typed_form/webhook.rb', line 29

def json
  @_json ||= Util.normalize_spaces(@raw_json).freeze
end