Class: Twitch::Clipr::Client
- Inherits:
-
Object
- Object
- Twitch::Clipr::Client
- Defined in:
- lib/twitch/clipr/client.rb
Instance Method Summary collapse
- #download(download_url, destination_filepath) ⇒ Object
- #get(clip_url) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/twitch/clipr/client.rb', line 7 def initialize @base_url = "https://clipr.xyz" end |
Instance Method Details
#download(download_url, destination_filepath) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/twitch/clipr/client.rb', line 18 def download(download_url, destination_filepath) client = Faraday.new() response = client.get(download_url) File.open(destination_filepath, 'wb') { |fp| fp.write(response.body) } end |
#get(clip_url) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/twitch/clipr/client.rb', line 11 def get(clip_url) clipr = Faraday.new(@base_url) response = clipr.post("/api/grabclip", {clip_url: clip_url}) json = JSON.parse(response.body) json["download_url"] end |