Class: Twitch::EventsubSubscriptionsResource
- Defined in:
- lib/twitch/resources/eventsub_subscriptions.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #create(type:, version:, condition:, transport:, **params) ⇒ Object
- #delete(id:) ⇒ Object
- #list(**params) ⇒ Object
Methods inherited from Resource
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 14 15 16 17 18 19 20 |
# 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? rescue Twitch::Errors::ConflictError => error existing_id = error.response_body.dig("data", 0, "id") if error.response_body.is_a?(Hash) raise Twitch::Errors::EventsubSubscriptionConflictError.new( error.response_body, error.http_status_code, existing_subscription_id: existing_id ) end |
#delete(id:) ⇒ Object
22 23 24 |
# File 'lib/twitch/resources/eventsub_subscriptions.rb', line 22 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 |