class VzaarApi::Strategy::Subtitle::Create
Attributes
attrs[R]
klass[R]
video_id[R]
Public Class Methods
new(video_id, attrs, klass)
click to toggle source
# File lib/vzaar_api/strategy/subtitle/create.rb, line 7 def initialize(video_id, attrs, klass) @attrs = attrs @video_id = video_id @klass = klass end
Public Instance Methods
execute()
click to toggle source
# File lib/vzaar_api/strategy/subtitle/create.rb, line 13 def execute res = attrs[:file] ? create_from_file : Lib::Api.new.post(url, attrs) klass.new res.data.merge(scope_id: video_id) end
Private Instance Methods
create_from_file()
click to toggle source
# File lib/vzaar_api/strategy/subtitle/create.rb, line 20 def create_from_file File.open(attrs[:file], "r") do |file| Lib::Api.new.post(url, attrs.merge(file: file)) do |body, headers| headers.delete('Content-Type') [body, headers] end end end
url()
click to toggle source
# File lib/vzaar_api/strategy/subtitle/create.rb, line 29 def url path = VzaarApi::Video::Subtitle::ENDPOINT.call(video_id, nil) Lib::Api.resource_url path end