Class: Sydecar::WebhookCalls

Inherits:
Object
  • Object
show all
Defined in:
lib/sydecar/webhook_calls.rb

Constant Summary collapse

URL =
'/v1/configure/webhooks'

Class Method Summary collapse

Class Method Details

.create(body:, idempotency_key:) ⇒ Hash

Note:

Set a webhook callback URL. You can provide any URL for Sydecar webhook callbacks to land. All webhook callbacks for the specified environment will be directed to the URL you provide. For maximum security, make sure to use https endpoints. In addition, webhook calls will be signed with a token.

The method create a webhook callback URL } See on the api-docs.sydecar.io/api/#tag/Configuration/operation/createWebhook

Examples:

Response samples:
{
"id": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
"label": "string",
"token": "string",
"disabled": true

Parameters:

  • HEADER

    PARAMETERS:

    - idempotency-key [String] - Idempotency key header for sensitive operations
    

    REQUEST BODY SCHEMA: application/json

    - url [String]       - The callback url associated the the webhook (required)
    - label [String]     - A label to easily identify your web hook (required)
    - token [String]     - For security reasons every webhook is associated with a token.  (required)
                            This token will be used to sign the incoming payloads.
    - disabled [boolean] - Enable / disable your web hook. (required)
    

Returns:

  • (Hash)
    • Responses: > ‘201’



37
38
39
# File 'lib/sydecar/webhook_calls.rb', line 37

def create(body:, idempotency_key:)
	Connection.instance.post("#{URL}/create", body, { 'idempotency-key': idempotency_key })
end

.find(id:) ⇒ Object

This method Fetch webhook information by id Fetch webhook information by id. This does not include the associate webhook events. Response samples

{
"id": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
"label": "string",
"token": "string",
"disabled": true

} return [Hash] Responses: > ‘200’

See on the api-docs.sydecar.io/api/#tag/Configuration/operation/getWebhook

Parameters:

  • PATH

    PARAMETERS

    • webhook_id [String] (required)



96
97
98
# File 'lib/sydecar/webhook_calls.rb', line 96

def find(id:)
  Connection.instance.get("#{URL}/#{id}")
end

.find_all(query: {}) ⇒ Object

This method fetch all webhooks Retrieve all webhooks created to date (filtered). Pagination is available. RESPONSE DATA (Sample):

{
"data": [
  {
    "id": "string",
    "created_at": "2019-08-24T14:15:22Z",
    "updated_at": "2019-08-24T14:15:22Z",
    "url": "string",
    "label": "string",
    "token": "string",
    "disabled": true
  }
],
"pagination": {
  "limit": 0,
  "offset": 0,
  "total": 0
}

} See on the api-docs.sydecar.io/api/#tag/Configuration/operation/getAllWebhooks

Parameters:

  • Query

    parameters [Hash]

    • ‘sort’ [String] (Enum: ‘asc’, ‘desc’)

    • ‘limit’ [Number] (<=100)

    • ‘offset’ [Number]

    • ‘start_date’ [String]

    • ‘end_date’ [String]

Returns:

  • See example RESPONSES: > ‘200’



73
74
75
76
# File 'lib/sydecar/webhook_calls.rb', line 73

def find_all(query: {})
  query = "?#{URI.encode_www_form(query)}"
  Connection.instance.post("#{URL}#{query}")
end

.find_latest_events(id:, query: {}) ⇒ Object

This method Fetch latest webhook events Fetch the latest events for a webhook. RESPONSE DATA (Sample): {

"data": [
  {
    "id": "string",
    "created_at": "2019-08-24T14:15:22Z",
    "updated_at": "2019-08-24T14:15:22Z",
    "type": "plaid.account.item.expiring",
    "details": {
      "property1": "string",
      "property2": "string"
    }
  }
],
"pagination": {
  "limit": 0,
  "offset": 0,
  "total": 0
}

} See on the api-docs.sydecar.io/api/#tag/Configuration/operation/getAllWebhookEvents

Parameters:

  • PATH

    PARAMETERS

    • webhook_id [String] (required)

    Query parameters [Hash]

    • ‘sort’ [String] (Enum: ‘asc’, ‘desc’)

    • ‘limit’ [Number] (<=100)

    • ‘offset’ [Number]

    • ‘start_date’ [String]

    • ‘end_date’ [String]

Returns:

  • See example RESPONSES: > ‘200’



164
165
166
167
# File 'lib/sydecar/webhook_calls.rb', line 164

def find_latest_events(id:, query: {})
  query = URI.encode_www_form(query)
  Connection.instance.post("#{URL}/#{id}/events?#{query}")
end

.resend_event(event_id:) ⇒ Hash

This method Resend webhook event Resend a webhook event which was previously published. } See on the api-docs.sydecar.io/api/#tag/Configuration/operation/replayWebhookEvent

Examples:

Response samples
{
"id": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"type": "plaid.account.item.expiring",
"details": {
  "property1": "string",
  "property2": "string"
}

Parameters:

  • PATH

    PARAMETERS

    • event_id [String] (required)

Returns:

  • (Hash)

    Responses > ‘200’



189
190
191
# File 'lib/sydecar/webhook_calls.rb', line 189

def resend_event(event_id:)
  Connection.instance.post("#{URL}/event/#{event_id}")
end

.update(id:, body:) ⇒ Hash

This method Update a webhook Update a webhook. You can update the label, url and/or token. } See on the api-docs.sydecar.io/api/#tag/Configuration/operation/updateWebhook

Examples:

Response samples:
{
"id": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
"label": "string",
"token": "string",
"disabled": true

Parameters:

  • PATH

    PARAMETERS

    • webhook_id [String] (required)

    REQUEST BODY SCHEMA: application/json

    - url [String]       - The callback url associated the the webhook (required)
    - label [String]     - A label to easily identify your web hook    (required)
    - token [String]     - For security reasons every webhook is associated with a token.  (required)
                            This token will be used to sign the incoming payloads.
    - disabled [boolean] - Enable / disable your web hook. (required)
    

Returns:

  • (Hash)
    • Responses: > ‘200’



125
126
127
# File 'lib/sydecar/webhook_calls.rb', line 125

def update(id:, body:)
  Connection.instance.patch("#{URL}/#{id}", body)
end