class Streamable::Streamable

Constants

STREAMABLE_URL

Attributes

streamable[RW]

Public Class Methods

new(username: username, password: password) click to toggle source
# File lib/streamable.rb, line 12
def initialize(username: username, password: password)
  @streamable = Faraday.new(url: "https://api.streamable.com") do |builder|
    builder.request(:multipart)
    builder.adapter(:net_http)

    if username && password
      builder.basic_auth(username, password)
    end
  end
end

Public Instance Methods

upload_video(filename) click to toggle source
# File lib/streamable.rb, line 23
def upload_video(filename)
  params   = { file: Faraday::UploadIO.new(filename, "video/mp4") }
  response = @streamable.post("/upload", params)

  response_json = JSON.parse(response.body)
  shortcode     = response_json["shortcode"]

  response_json.merge("video_link"       => video_link(shortcode),
                      "video_embed_link" => video_embed_link(shortcode))
end