Class: Twitch::ClipsResource

Inherits:
Resource show all
Defined in:
lib/twitch/resources/clips.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(broadcaster_id:, **attributes) ⇒ Object

Required scope: clips:edit



15
16
17
18
19
# File 'lib/twitch/resources/clips.rb', line 15

def create(broadcaster_id:, **attributes)
  response = post_request("clips", body: attributes.merge(broadcaster_id: broadcaster_id))

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

#list(**params) ⇒ Object



3
4
5
6
7
8
# File 'lib/twitch/resources/clips.rb', line 3

def list(**params)
  raise "broadcaster_id or game_id is required" unless !params[:broadcaster_id].nil? || !params[:game_id].nil?

  response = get_request("clips", params: params)
  Collection.from_response(response, type: Clip)
end

#retrieve(id:) ⇒ Object



10
11
12
# File 'lib/twitch/resources/clips.rb', line 10

def retrieve(id:)
  Clip.new get_request("clips", params: { id: id }).body.dig("data")[0]
end