Class: Twitch::ClipsResource
- Defined in:
- lib/twitch/resources/clips.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#create(broadcaster_id:, **attributes) ⇒ Object
Required scope: clips:edit.
-
#create_from_vod(editor_id:, broadcaster_id:, vod_id:, vod_offset:, **attributes) ⇒ Object
Required scope: editor:manage:clips or channel:manage:clips.
-
#downloads(editor_id:, broadcaster_id:, clip_id: nil, clip_ids: nil) ⇒ Object
Required scope: editor:manage:clips or channel:manage:clips.
- #list(**params) ⇒ Object
- #retrieve(id:) ⇒ Object
Methods inherited from Resource
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(query_path("clips", attributes.merge(broadcaster_id: broadcaster_id)), body: {}) Clip.new(response.body.dig("data")[0]) if response.success? end |
#create_from_vod(editor_id:, broadcaster_id:, vod_id:, vod_offset:, **attributes) ⇒ Object
Required scope: editor:manage:clips or channel:manage:clips
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/twitch/resources/clips.rb', line 22 def create_from_vod(editor_id:, broadcaster_id:, vod_id:, vod_offset:, **attributes) params = attributes.merge( editor_id: editor_id, broadcaster_id: broadcaster_id, vod_id: vod_id, vod_offset: vod_offset ) response = post_request(query_path("videos/clips", params), body: {}) Clip.new(response.body.dig("data")[0]) if response.success? end |
#downloads(editor_id:, broadcaster_id:, clip_id: nil, clip_ids: nil) ⇒ Object
Required scope: editor:manage:clips or channel:manage:clips
36 37 38 39 40 41 |
# File 'lib/twitch/resources/clips.rb', line 36 def downloads(editor_id:, broadcaster_id:, clip_id: nil, clip_ids: nil) ids = clip_ids || Array(clip_id) response = get_request("clips/downloads", params: { editor_id: editor_id, broadcaster_id: broadcaster_id, clip_id: ids }) Collection.from_response(response, type: ClipDownload) 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 |