Class: MaxBotApi::Resources::Subscriptions
- Inherits:
-
Object
- Object
- MaxBotApi::Resources::Subscriptions
- Defined in:
- lib/max_bot_api/resources/subscriptions.rb
Overview
Webhook subscription methods.
Instance Method Summary collapse
-
#get_subscriptions ⇒ Object
List active subscriptions.
-
#initialize(client) ⇒ Subscriptions
constructor
A new instance of Subscriptions.
-
#subscribe(url:, update_types: [], secret: nil) ⇒ Object
Create a webhook subscription.
-
#unsubscribe(url:) ⇒ Object
Remove a webhook subscription.
Constructor Details
#initialize(client) ⇒ Subscriptions
Returns a new instance of Subscriptions.
7 8 9 |
# File 'lib/max_bot_api/resources/subscriptions.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#get_subscriptions ⇒ Object
List active subscriptions.
12 13 14 |
# File 'lib/max_bot_api/resources/subscriptions.rb', line 12 def get_subscriptions @client.request(:get, 'subscriptions') end |
#subscribe(url:, update_types: [], secret: nil) ⇒ Object
Create a webhook subscription.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/max_bot_api/resources/subscriptions.rb', line 20 def subscribe(url:, update_types: [], secret: nil) body = { url: url, update_types: update_types, secret: secret, version: @client.version }.compact @client.request(:post, 'subscriptions', body: body) end |
#unsubscribe(url:) ⇒ Object
Remove a webhook subscription.
33 34 35 |
# File 'lib/max_bot_api/resources/subscriptions.rb', line 33 def unsubscribe(url:) @client.request(:delete, 'subscriptions', query: { 'url' => url }) end |