Class: LockstepSdk::WebhookModel

Inherits:
Object
  • Object
show all
Defined in:
lib/lockstep_sdk/models/webhook_model.rb

Overview

A Webhook is a subscription to receive notifications automatically to the supplied callback url when changes are made to a supported object.

You will need to create at least one Webhook rule to receive notifications when a specific type of object is inserted, deleted, or updated.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ WebhookModel

Initialize the WebhookModel using the provided prototype



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 28

def initialize(params = {})
    @webhook_id = params.dig(:webhook_id)
    @group_key = params.dig(:group_key)
    @name = params.dig(:name)
    @status_code = params.dig(:status_code)
    @status_message = params.dig(:status_message)
    @client_secret = params.dig(:client_secret)
    @request_content_type = params.dig(:request_content_type)
    @callback_http_method = params.dig(:callback_http_method)
    @callback_url = params.dig(:callback_url)
    @expiration_date = params.dig(:expiration_date)
    @retry_count = params.dig(:retry_count)
    @created = params.dig(:created)
    @created_user_id = params.dig(:created_user_id)
    @modified = params.dig(:modified)
    @modified_user_id = params.dig(:modified_user_id)
    @webhook_rules = params.dig(:webhook_rules)
    @partition_key = params.dig(:partition_key)
end

Instance Attribute Details

#callback_http_methodString

Returns The HTTP Method to be used on the callback URL for use in notifications (GET, POST, PATCH, PUT).

Returns:

  • (String)

    The HTTP Method to be used on the callback URL for use in notifications (GET, POST, PATCH, PUT).



78
79
80
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 78

def callback_http_method
  @callback_http_method
end

#callback_urlUri

Returns The URL where the notification will be sent via the method set in CallbackHttpMethod. When creating a webhook, the Lockstep API will make a call to this url via the method set in the CallbackHttpMethod property with a query parameter of “code” set to an encoded string. To successfully create the webhook, the call must return a successful status code with the query parameter’s value as the plain text content.

Returns:

  • (Uri)

    The URL where the notification will be sent via the method set in CallbackHttpMethod. When creating a webhook, the Lockstep API will make a call to this url via the method set in the CallbackHttpMethod property with a query parameter of “code” set to an encoded string. To successfully create the webhook, the call must return a successful status code with the query parameter’s value as the plain text content.



82
83
84
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 82

def callback_url
  @callback_url
end

#client_secretString

Returns An secret set during webhook creation that can be used to verify that the notification is coming from the Lockstep API.

Returns:

  • (String)

    An secret set during webhook creation that can be used to verify that the notification is coming from the Lockstep API.



70
71
72
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 70

def client_secret
  @client_secret
end

#createdDate-time

Returns The date this webhook was created.

Returns:

  • (Date-time)

    The date this webhook was created



94
95
96
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 94

def created
  @created
end

#created_user_idUuid

Returns The ID of the user who created this webhook.

Returns:

  • (Uuid)

    The ID of the user who created this webhook



98
99
100
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 98

def created_user_id
  @created_user_id
end

#expiration_dateDate-time

Returns The expiration date for the given webhook subscription. Once the expiration date passes, notifications will no longer be sent to the callback url.

Returns:

  • (Date-time)

    The expiration date for the given webhook subscription. Once the expiration date passes, notifications will no longer be sent to the callback url.



86
87
88
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 86

def expiration_date
  @expiration_date
end

#group_keyUuid

Returns The GroupKey uniquely identifies a single Lockstep Platform account. All records for this account will share the same GroupKey value. GroupKey values cannot be changed once created. For more information, see [Accounts and GroupKeys](developer.lockstep.io/docs/accounts-and-groupkeys).

Returns:

  • (Uuid)

    The GroupKey uniquely identifies a single Lockstep Platform account. All records for this account will share the same GroupKey value. GroupKey values cannot be changed once created. For more information, see [Accounts and GroupKeys](developer.lockstep.io/docs/accounts-and-groupkeys).



54
55
56
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 54

def group_key
  @group_key
end

#modifiedDate-time

Returns The date this webhook was last modified.

Returns:

  • (Date-time)

    The date this webhook was last modified



102
103
104
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 102

def modified
  @modified
end

#modified_user_idUuid

Returns The ID of the user who last modified this webhook.

Returns:

  • (Uuid)

    The ID of the user who last modified this webhook



106
107
108
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 106

def modified_user_id
  @modified_user_id
end

#nameString

Returns A name for the webhook subscription.

Returns:

  • (String)

    A name for the webhook subscription.



58
59
60
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 58

def name
  @name
end

#partition_keyString

Returns The partition key used for the webhook callback history.

Returns:

  • (String)

    The partition key used for the webhook callback history



114
115
116
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 114

def partition_key
  @partition_key
end

#request_content_typeString

Returns The format of the content to be returned in the webhook notifications. Current options are ‘Full’ or ‘Id’.

Returns:

  • (String)

    The format of the content to be returned in the webhook notifications. Current options are ‘Full’ or ‘Id’.



74
75
76
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 74

def request_content_type
  @request_content_type
end

#retry_countInt32

Returns The amount of consecutive failed notifications, not including the current attempt, before marking the webhook as errored (i.e. if the value is set to 0, the webhook will be marked errored on the first failure, if the value is set to 1 the webhook will be marked errored on the second failure, and so on). The maximum retry attempts is 5.

Returns:

  • (Int32)

    The amount of consecutive failed notifications, not including the current attempt, before marking the webhook as errored (i.e. if the value is set to 0, the webhook will be marked errored on the first failure, if the value is set to 1 the webhook will be marked errored on the second failure, and so on). The maximum retry attempts is 5.



90
91
92
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 90

def retry_count
  @retry_count
end

#status_codeString

Returns The status of the webhook (Active, Inactive, Errored).

Returns:

  • (String)

    The status of the webhook (Active, Inactive, Errored).



62
63
64
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 62

def status_code
  @status_code
end

#status_messageString

Returns When the StatusCode is set to Errored a message is supplied for why it was errored.

Returns:

  • (String)

    When the StatusCode is set to Errored a message is supplied for why it was errored.



66
67
68
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 66

def status_message
  @status_message
end

#webhook_idUuid

Returns The unique ID of this record, automatically assigned by Lockstep when this record is added to the Lockstep platform.

Returns:

  • (Uuid)

    The unique ID of this record, automatically assigned by Lockstep when this record is added to the Lockstep platform.



50
51
52
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 50

def webhook_id
  @webhook_id
end

#webhook_rulesWebhookRuleModel

Returns A list of Webhook Rules associated with this Webhook.

Returns:



110
111
112
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 110

def webhook_rules
  @webhook_rules
end

Instance Method Details

#as_json(options = {}) ⇒ object

Returns This object as a JSON key-value structure.

Returns:

  • (object)

    This object as a JSON key-value structure



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 118

def as_json(options={})
    {
        'webhookId' => @webhook_id,
        'groupKey' => @group_key,
        'name' => @name,
        'statusCode' => @status_code,
        'statusMessage' => @status_message,
        'clientSecret' => @client_secret,
        'requestContentType' => @request_content_type,
        'callbackHttpMethod' => @callback_http_method,
        'callbackUrl' => @callback_url,
        'expirationDate' => @expiration_date,
        'retryCount' => @retry_count,
        'created' => @created,
        'createdUserId' => @created_user_id,
        'modified' => @modified,
        'modifiedUserId' => @modified_user_id,
        'webhookRules' => @webhook_rules,
        'partitionKey' => @partition_key,
    }
end

#to_json(*options) ⇒ String

Returns This object converted to a JSON string.

Returns:

  • (String)

    This object converted to a JSON string



142
143
144
# File 'lib/lockstep_sdk/models/webhook_model.rb', line 142

def to_json(*options)
    "[#{as_json(*options).to_json(*options)}]"
end