class StarkBank::Webhook

# Webhook subscription object

A Webhook is used to subscribe to notification events on a user-selected endpoint. Currently available services for subscription are transfer, invoice, deposit, brcode-payment, boleto, boleto-payment and utility-payment

## Parameters (required):

## Attributes:

Attributes

id[R]
subscriptions[R]
url[R]

Public Class Methods

create(url:, subscriptions:, id: nil, user: nil) click to toggle source

# Create Webhook subscription

Send a single Webhook subscription for creation in the Stark Bank API

## Parameters (required):

## Parameters (optional):

## Return:

  • Webhook object with updated attributes

# File lib/webhook/webhook.rb, line 41
def self.create(url:, subscriptions:, id: nil, user: nil)
  StarkBank::Utils::Rest.post_single(entity: Webhook.new(url: url, subscriptions: subscriptions), user: user, **resource)
end
delete(id, user: nil) click to toggle source

# Delete a Webhook entity

Delete a Webhook entity previously created in the Stark Bank API

## Parameters (required):

  • id [string]: Webhook unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

# File lib/webhook/webhook.rb, line 108
def self.delete(id, user: nil)
  StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource)
end
get(id, user: nil) click to toggle source

# Retrieve a specific Webhook subscription

Receive a single Webhook subscription object previously created in the Stark Bank API by passing its id

## Parameters (required):

  • id [string]: object unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

  • Webhook object with updated attributes

# File lib/webhook/webhook.rb, line 57
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new(url:, subscriptions:, id: nil) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/webhook/webhook.rb, line 22
def initialize(url:, subscriptions:, id: nil)
  super(id)
  @url = url
  @subscriptions = subscriptions
end
page(cursor: nil, limit: nil, user: nil) click to toggle source

# Retrieve paged Webhooks

Receive a list of up to 100 Webhook objects previously created in the Stark Bank API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.

## Parameters (optional):

  • cursor [string, default nil]: cursor returned on the previous page function call

  • limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

  • list of Webhook objects with updated attributes and cursor to retrieve the next page of Webhook objects

# File lib/webhook/webhook.rb, line 87
def self.page(cursor: nil, limit: nil, user: nil)
  return StarkBank::Utils::Rest.get_page(
    cursor: cursor,
    limit: limit,
    user: user,
    **resource
  )
end
query(limit: nil, user: nil) click to toggle source

# Retrieve Webhook subcriptions

Receive a generator of Webhook subcription objects previously created in the Stark Bank API

## Parameters (optional):

  • limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

  • generator of Webhook objects with updated attributes

# File lib/webhook/webhook.rb, line 71
def self.query(limit: nil, user: nil)
  StarkBank::Utils::Rest.get_stream(user: user, limit: limit, **resource)
end
resource() click to toggle source
# File lib/webhook/webhook.rb, line 112
def self.resource
  {
    resource_name: 'Webhook',
    resource_maker: proc { |json|
      Webhook.new(
        id: json['id'],
        url: json['url'],
        subscriptions: json['subscriptions']
      )
    }
  }
end