0.01
No commit activity in last 3 years
No release in over 3 years
BitsOnTheRun.com API implementation in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
>= 2.1.0

Runtime

>= 0.7.0
>= 1.4.0
 Project Readme

BitsOnTheRun

BitsOnTheRun is an implementation of bitsontherun.com API in Ruby.

Install

Just run the following command:

gem install bitsontherun

Then in your Gemfile add the following line:

gem 'bitsontherun'

And finally run:

bundle install

For rails app create the config/initializers/bitsontherun.rb file:

# Bitsonthrun configuration
BitsOnTheRun.key = "your api key"
BitsOnTheRun.secret = "your api secret"

Usage

Basic call:

BitsOnTheRun::call('version') => {:status => "ok", :version => "X.X.X"}
BitsOnTheRun::call('videos/update', :video_key => 'your video key', :title => 'New title for video').ok? => true

Basic store (upload a video):

BitsOnTheRun::store('videos/create', 'video.mp4') => {:status => "ok", ...}

Basic store (create a new video object on the plaform and generate upload url):

BitsOnTheRun::call('videos/create').upload_url => http://upload.bitsontherun.com/v1/videos/upload?api_format=json&key=<key>&token=<token>

Extended call methods:

call = BitsOnTheRun::API.new(:call)
call.method('videos/list')
call.execute

call = BitsOnTheRun::API.new(:call)
call.method('videos/show', :video_key => 'your video key')
call.execute

call = BitsOnTheRun::API.new(:call)
call.method('videos/update', :video_key => 'your video key', :title => 'New title for video')
call.execute

Extended store methods:

call = BitsOnTheRun::API.new(:store)
call.method('videos/create')
call.file('video.mp4')
call.execute

How to navigate through response

Request:

BitsOnTheRun::call('accounts/show')

Response:

{:account => {:cdn => {:name => "Value" }}}

Find methods:

response.account.cdn.name => "Value"
response.account.cdn(:name) => "Value"
response.account(:cdn, :name) => "Value"
response.account([:cdn, :name]) => "Value"
response.find(:account, :cdn, :name) => "Value"
response.find([:account, :cdn, :name]) => "Value"

Request:

BitsOnTheRun::call('videos/list')

Response:

{:videos => [{ video }, { ... }, ...]}

Find methods:

response.videos => [<BitsOnTheRun::Response>, <BitsOnTheRun::Response>, ...]
response.videos.first => <BitsOnTheRun::Response>
repsonse.videos.first.title => "Video title"