Class: Twitch::EventsubSubscriptionsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/twitch/resources/eventsub_subscriptions.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Twitch::Resource

Instance Method Details

#create(type:, version:, condition:, transport:, **params) ⇒ Object



8
9
10
11
12
13
# File 'lib/twitch/resources/eventsub_subscriptions.rb', line 8

def create(type:, version:, condition:, transport:, **params)
  attributes = { type: type, version: version, condition: condition, transport: transport }.merge(params)
  response = post_request("eventsub/subscriptions", body: attributes)

  EventsubSubscription.new(response.body.dig("data")[0]) if response.success?
end

#delete(id:) ⇒ Object



15
16
17
# File 'lib/twitch/resources/eventsub_subscriptions.rb', line 15

def delete(id:)
  delete_request("eventsub/subscriptions", params: { id: id })
end

#list(**params) ⇒ Object



3
4
5
6
# File 'lib/twitch/resources/eventsub_subscriptions.rb', line 3

def list(**params)
  response = get_request("eventsub/subscriptions", params: params)
  Collection.from_response(response, type: EventsubSubscription)
end