Class: Twitch::EventsubConduitsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/twitch/resources/eventsub_conduits.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(shard_count:) ⇒ Object



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

def create(shard_count:)
  response = post_request("eventsub/conduits", body: { shard_count: shard_count })

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

#delete(id:) ⇒ Object



20
21
22
# File 'lib/twitch/resources/eventsub_conduits.rb', line 20

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

#list(**params) ⇒ Object



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

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

#shards(id:, **params) ⇒ Object



24
25
26
27
# File 'lib/twitch/resources/eventsub_conduits.rb', line 24

def shards(id:, **params)
  response = get_request("eventsub/conduits/shards", params: { conduit_id: id }.merge(params))
  Collection.from_response(response, type: EventsubConduitShard)
end

#update(id:, shard_count:) ⇒ Object



14
15
16
17
18
# File 'lib/twitch/resources/eventsub_conduits.rb', line 14

def update(id:, shard_count:)
  response = patch_request("eventsub/conduits", body: { id: id, shard_count: shard_count })

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

#update_shards(id:, shards:) ⇒ Object



29
30
31
32
# File 'lib/twitch/resources/eventsub_conduits.rb', line 29

def update_shards(id:, shards:)
  response = patch_request("eventsub/conduits/shards", body: { conduit_id: id, shards: shards })
  Collection.from_response(response, type: EventsubConduitShard)
end