vmix 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.document +5 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +73 -0
- data/LICENSE.txt +20 -0
- data/README.md +69 -0
- data/README.rdoc +92 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/lib/vmix.rb +29 -0
- data/lib/vmix/api.rb +96 -0
- data/lib/vmix/client.rb +5 -0
- data/lib/vmix/configuration.rb +179 -0
- data/lib/vmix/error.rb +15 -0
- data/test/helper.rb +18 -0
- data/test/test_vmix.rb +7 -0
- data/vmix.gemspec +84 -0
- metadata +228 -0
data/.DS_Store
ADDED
Binary file
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
#
|
9
|
+
#
|
10
|
+
gem 'httparty', '~> 0.10.0'
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem "shoulda", ">= 0"
|
14
|
+
gem "rdoc", "~> 3.12"
|
15
|
+
gem "bundler", "~> 1.2.3"
|
16
|
+
gem "jeweler", "~> 1.8.4"
|
17
|
+
gem "simplecov", ">= 0"
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.11)
|
5
|
+
i18n (~> 0.6)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
bourne (1.1.2)
|
8
|
+
mocha (= 0.10.5)
|
9
|
+
faraday (0.8.4)
|
10
|
+
multipart-post (~> 1.1)
|
11
|
+
git (1.2.5)
|
12
|
+
github_api (0.8.6)
|
13
|
+
faraday (~> 0.8.1)
|
14
|
+
hashie (~> 1.2.0)
|
15
|
+
multi_json (~> 1.4)
|
16
|
+
nokogiri (~> 1.5.2)
|
17
|
+
oauth2
|
18
|
+
hashie (1.2.0)
|
19
|
+
highline (1.6.15)
|
20
|
+
httparty (0.10.0)
|
21
|
+
multi_json (~> 1.0)
|
22
|
+
multi_xml
|
23
|
+
httpauth (0.2.0)
|
24
|
+
i18n (0.6.1)
|
25
|
+
jeweler (1.8.4)
|
26
|
+
bundler (~> 1.0)
|
27
|
+
git (>= 1.2.5)
|
28
|
+
github_api (>= 0.8.1)
|
29
|
+
highline (>= 1.6.15)
|
30
|
+
rake
|
31
|
+
rdoc
|
32
|
+
json (1.7.6)
|
33
|
+
jwt (0.1.5)
|
34
|
+
multi_json (>= 1.0)
|
35
|
+
metaclass (0.0.1)
|
36
|
+
mocha (0.10.5)
|
37
|
+
metaclass (~> 0.0.1)
|
38
|
+
multi_json (1.5.0)
|
39
|
+
multi_xml (0.5.2)
|
40
|
+
multipart-post (1.1.5)
|
41
|
+
nokogiri (1.5.6)
|
42
|
+
oauth2 (0.8.0)
|
43
|
+
faraday (~> 0.8)
|
44
|
+
httpauth (~> 0.1)
|
45
|
+
jwt (~> 0.1.4)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
rack (~> 1.2)
|
48
|
+
rack (1.4.4)
|
49
|
+
rake (10.0.3)
|
50
|
+
rdoc (3.12)
|
51
|
+
json (~> 1.4)
|
52
|
+
shoulda (3.3.2)
|
53
|
+
shoulda-context (~> 1.0.1)
|
54
|
+
shoulda-matchers (~> 1.4.1)
|
55
|
+
shoulda-context (1.0.2)
|
56
|
+
shoulda-matchers (1.4.2)
|
57
|
+
activesupport (>= 3.0.0)
|
58
|
+
bourne (~> 1.1.2)
|
59
|
+
simplecov (0.7.1)
|
60
|
+
multi_json (~> 1.0)
|
61
|
+
simplecov-html (~> 0.7.1)
|
62
|
+
simplecov-html (0.7.1)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
bundler (~> 1.2.3)
|
69
|
+
httparty (~> 0.10.0)
|
70
|
+
jeweler (~> 1.8.4)
|
71
|
+
rdoc (~> 3.12)
|
72
|
+
shoulda
|
73
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Alan McCann
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# VmixRubyClient
|
2
|
+
|
3
|
+
Ruby wrapper for VMIX REST API
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'vmix'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install vmix_ruby_client
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require "rubygems"
|
22
|
+
require "vmix"
|
23
|
+
|
24
|
+
### All methods require authentication
|
25
|
+
|
26
|
+
Vmix.configure do |config|
|
27
|
+
# Endpoint = 'apis.vmixcore.com/apis'
|
28
|
+
config.endpoint = REST_API_URL
|
29
|
+
# You can choose HTTP Basic Authentication (:http_basic_auth)
|
30
|
+
# or Token Based Authentication (:token_auth)
|
31
|
+
config.authentication = YOUR_AUTHENTICATION_METHOD
|
32
|
+
# For read requests, only token is required for token-based authentication
|
33
|
+
config.token = YOUR_VMIX_API_TOKEN
|
34
|
+
# For read and write requests, HTTP Basic Authentication requires username and password
|
35
|
+
config.account_id = YOUR_ACCOUNT_ID
|
36
|
+
config.api_password = YOUR_API_PASSWORD
|
37
|
+
end
|
38
|
+
|
39
|
+
### Initialize the Client
|
40
|
+
|
41
|
+
v = Vmix::Client.new(:method => :token, :token => 'your-vmix-api-token')
|
42
|
+
|
43
|
+
### List available API method calls
|
44
|
+
|
45
|
+
v.available_methods
|
46
|
+
|
47
|
+
### Access methods with options
|
48
|
+
|
49
|
+
response = v.getCollections
|
50
|
+
|
51
|
+
response = v.getMediaList(:start => 100, :alltime => 1)
|
52
|
+
|
53
|
+
## Current Status
|
54
|
+
|
55
|
+
This currently only implements the token api (not basic auth api) - ie. read only
|
56
|
+
|
57
|
+
## TODO
|
58
|
+
* Implement basic auth api
|
59
|
+
* Write tests
|
60
|
+
* Improve documentation
|
61
|
+
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create new Pull Request
|
data/README.rdoc
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
= vmix
|
2
|
+
|
3
|
+
Ruby wrapper for VMIX REST API.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'vmix'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install vmix
|
17
|
+
|
18
|
+
== Usage
|
19
|
+
|
20
|
+
require "rubygems"
|
21
|
+
require "vmix"
|
22
|
+
|
23
|
+
=== All methods require authentication
|
24
|
+
|
25
|
+
Vmix.configure do |config|
|
26
|
+
# Endpoint = 'apis.vmixcore.com/apis'
|
27
|
+
config.endpoint = REST_API_URL
|
28
|
+
# You can choose HTTP Basic Authentication (:http_basic_auth)
|
29
|
+
# or Token Based Authentication (:token_auth)
|
30
|
+
config.authentication = YOUR_AUTHENTICATION_METHOD
|
31
|
+
# For read requests, only token is required for token-based authentication
|
32
|
+
config.token = YOUR_VMIX_API_TOKEN
|
33
|
+
# For read and write requests, HTTP Basic Authentication requires username and password
|
34
|
+
config.account_id = YOUR_ACCOUNT_ID
|
35
|
+
config.api_password = YOUR_API_PASSWORD
|
36
|
+
end
|
37
|
+
|
38
|
+
=== Initialize the Client
|
39
|
+
|
40
|
+
v = Vmix::Client.new(:method => :token, :token => 'your-vmix-api-token')
|
41
|
+
|
42
|
+
=== List available API method calls
|
43
|
+
|
44
|
+
v.available_methods
|
45
|
+
|
46
|
+
=== Access methods with options
|
47
|
+
|
48
|
+
response = v.getCollections
|
49
|
+
|
50
|
+
response = v.getMediaList(:start => 100, :alltime => 1)
|
51
|
+
|
52
|
+
== Current Status
|
53
|
+
|
54
|
+
This currently only implements the token api (not basic auth api) - ie. read only
|
55
|
+
|
56
|
+
== TODO
|
57
|
+
* Implement basic auth api
|
58
|
+
* Write tests
|
59
|
+
* Improve documentation
|
60
|
+
|
61
|
+
== Contributing to vmix
|
62
|
+
|
63
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
64
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
65
|
+
* Fork the project.
|
66
|
+
* Start a feature/bugfix branch.
|
67
|
+
* Commit and push until you are happy with your contribution.
|
68
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
69
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
70
|
+
|
71
|
+
== Copyright
|
72
|
+
|
73
|
+
Copyright (c) 2013 Alan McCann. See LICENSE.txt for
|
74
|
+
further details.
|
75
|
+
|
76
|
+
|
77
|
+
# VmixRubyClient
|
78
|
+
|
79
|
+
Ruby wrapper for VMIX REST API
|
80
|
+
|
81
|
+
## Installation
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
## Contributing
|
86
|
+
|
87
|
+
1. Fork it
|
88
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
89
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
90
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
91
|
+
5. Create new Pull Request
|
92
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "vmix"
|
18
|
+
gem.homepage = "http://github.com/alanmccann/vmix"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Ruby Client for VMIX REST API}
|
21
|
+
gem.description = %Q{Ruby Client for VMIX REST API}
|
22
|
+
gem.email = "alan@imccann.com"
|
23
|
+
gem.authors = ["Alan McCann"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
gem.add_dependency "httparty", "~> 0.10.0"
|
26
|
+
|
27
|
+
gem.add_development_dependency "rake", "~> 0.9.2.2"
|
28
|
+
gem.add_development_dependency "rspec", "~> 2.12"
|
29
|
+
gem.add_development_dependency "webmock", "~> 1.9.0"
|
30
|
+
end
|
31
|
+
|
32
|
+
Jeweler::RubygemsDotOrgTasks.new
|
33
|
+
|
34
|
+
require 'rake/testtask'
|
35
|
+
Rake::TestTask.new(:test) do |test|
|
36
|
+
test.libs << 'lib' << 'test'
|
37
|
+
test.pattern = 'test/**/test_*.rb'
|
38
|
+
test.verbose = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# require 'rcov/rcovtask'
|
42
|
+
# Rcov::RcovTask.new do |test|
|
43
|
+
# test.libs << 'test'
|
44
|
+
# test.pattern = 'test/**/test_*.rb'
|
45
|
+
# test.verbose = true
|
46
|
+
# test.rcov_opts << '--exclude "gems/*"'
|
47
|
+
# end
|
48
|
+
|
49
|
+
task :default => :test
|
50
|
+
|
51
|
+
require 'rdoc/task'
|
52
|
+
Rake::RDocTask.new do |rdoc|
|
53
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
54
|
+
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "vmix #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/vmix.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'vmix/error'
|
2
|
+
require 'vmix/configuration'
|
3
|
+
require 'vmix/api'
|
4
|
+
require 'vmix/client'
|
5
|
+
|
6
|
+
|
7
|
+
module Vmix
|
8
|
+
extend Configuration
|
9
|
+
|
10
|
+
#Alias for Vmix::Client.new
|
11
|
+
#
|
12
|
+
# @return [Vmix::Client]
|
13
|
+
|
14
|
+
def self.client(options={})
|
15
|
+
Vmix.new(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Delegate to Vmix::Client
|
19
|
+
def self.method_missing(method, *args, &block)
|
20
|
+
return super unless client.respond_to?(method)
|
21
|
+
client.send(method, *args, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.respond_to?(method, include_private = false)
|
25
|
+
client.respond_to?(method, include_private) || super(method, include_private)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
data/lib/vmix/api.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'openssl'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
|
6
|
+
module Vmix
|
7
|
+
class Api
|
8
|
+
include HTTParty
|
9
|
+
debug_output $stderr
|
10
|
+
attr_accessor *Configuration::VALID_OPTIONS_KEYS
|
11
|
+
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
options = Vmix.options.merge(options)
|
15
|
+
@valid_methods = Vmix::Configuration::VMIX_METHODS
|
16
|
+
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
17
|
+
send("#{key}=", options[key])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def download_url(download_token, &block)
|
22
|
+
# TODO - raise error if no api_password has been set in configuration
|
23
|
+
expires = block.nil? ? (Time.now + 6 * 24 * 60 * 60).to_i : block.call.to_i
|
24
|
+
digest = OpenSSL::Digest::Digest.new('sha1')
|
25
|
+
enc_string = "#{expires}\n#{self.api_password}\n/vmixcore/download?token=#{download_token}"
|
26
|
+
hmac = OpenSSL::HMAC.digest(digest,self.api_password,enc_string)
|
27
|
+
signature = URI.escape(Base64.encode64(hmac).strip)
|
28
|
+
download_url = "http://#{self.download_endpoint}?token=#{download_token}&expires=#{expires}&signature=#{signature}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def available_api_methods
|
32
|
+
@valid_methods
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid_method?(method)
|
36
|
+
method = method.to_s
|
37
|
+
if respond_to?(method)
|
38
|
+
return true
|
39
|
+
else
|
40
|
+
return !@valid_methods.select {|k,v| v.include? method}.empty?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
# response = v.getMediaList(:start=>3000,:status_id=>'all',:alltime=>1)
|
49
|
+
|
50
|
+
# Handle all methods from vmix
|
51
|
+
# TODO: Better error handling
|
52
|
+
|
53
|
+
def method_missing(method, *args,&block)
|
54
|
+
puts "method: #{method}"
|
55
|
+
if valid_method?(method.to_s)
|
56
|
+
get(method.to_sym, *args)
|
57
|
+
else
|
58
|
+
raise NoMethodError, 'Invalid Vmix API Call'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def get(method, query = {})
|
63
|
+
|
64
|
+
# Set :output format - default is json, alternatives are xml and jsonp
|
65
|
+
if query[:output].nil?
|
66
|
+
query.merge(:output => 'json')
|
67
|
+
else
|
68
|
+
query[:output] = query[:output].to_sym
|
69
|
+
end
|
70
|
+
output_format = query[:output] || 'json'
|
71
|
+
|
72
|
+
# merge in method and authentication token
|
73
|
+
# TODO - do not require token for HTTP Basic Authentication
|
74
|
+
query.merge!(:action => method.to_s, :atoken => @token)
|
75
|
+
|
76
|
+
# determine url for method calls
|
77
|
+
puts @valid_methods.select {|k,v| v.include? method.to_s}.keys.first.to_s
|
78
|
+
url_segment_for_method = "http://" + api_endpoint + "/" + @valid_methods.select {|k,v| v.include? method.to_s}.keys.first.to_s + ".php"
|
79
|
+
puts url_segment_for_method
|
80
|
+
|
81
|
+
# execute request and return response
|
82
|
+
@response = self.class.get(url_segment_for_method,:query => query)
|
83
|
+
|
84
|
+
# Format return according to output type
|
85
|
+
if output_format == 'json' || output_format == 'jsonp'
|
86
|
+
return JSON.parse(@response.body)
|
87
|
+
else
|
88
|
+
return @response.body
|
89
|
+
end
|
90
|
+
end
|
91
|
+
# TODO - Create this
|
92
|
+
# def verify_errors(response)
|
93
|
+
# end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
data/lib/vmix/client.rb
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
module Vmix
|
2
|
+
module Configuration
|
3
|
+
# An array of valid keys in the options hash when configuring a {Oas::Client}
|
4
|
+
VALID_OPTIONS_KEYS = [
|
5
|
+
:api_endpoint,
|
6
|
+
:download_endpoint,
|
7
|
+
:authentication,
|
8
|
+
:token,
|
9
|
+
:partner_id,
|
10
|
+
:api_password].freeze
|
11
|
+
|
12
|
+
# The endpoint that will be used to connect if none is set
|
13
|
+
DEFAULT_API_ENDPOINT = "api.vmixcore.com/apis".freeze
|
14
|
+
|
15
|
+
# The download endpoint that will be used to download media if none is set
|
16
|
+
DEFAULT_DOWNLOAD_ENDPOINT = "media.vmixcore.com/vmixcore/download".freeze
|
17
|
+
|
18
|
+
# The account that will be used to connect if none is set
|
19
|
+
DEFAULT_AUTHENTICATION = 'token'.freeze
|
20
|
+
|
21
|
+
# By default, don't set a token
|
22
|
+
DEFAULT_TOKEN = nil
|
23
|
+
|
24
|
+
# By default, don't set a username
|
25
|
+
DEFAULT_PARTNERID = nil
|
26
|
+
|
27
|
+
# By default, don't set a password
|
28
|
+
DEFAULT_API_PASSWORD = nil
|
29
|
+
|
30
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
31
|
+
|
32
|
+
def self.extended(base)
|
33
|
+
base.reset
|
34
|
+
end
|
35
|
+
|
36
|
+
def configure
|
37
|
+
yield self if block_given?
|
38
|
+
end
|
39
|
+
|
40
|
+
def options
|
41
|
+
options = {}
|
42
|
+
VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }
|
43
|
+
options
|
44
|
+
end
|
45
|
+
|
46
|
+
def reset
|
47
|
+
self.api_endpoint = DEFAULT_API_ENDPOINT
|
48
|
+
self.download_endpoint = DEFAULT_DOWNLOAD_ENDPOINT
|
49
|
+
self.authentication = DEFAULT_AUTHENTICATION
|
50
|
+
self.token = DEFAULT_TOKEN
|
51
|
+
self.partner_id = DEFAULT_PARTNERID
|
52
|
+
self.api_password = DEFAULT_API_PASSWORD
|
53
|
+
end
|
54
|
+
|
55
|
+
VMIX_METHODS =
|
56
|
+
{
|
57
|
+
# collection.php
|
58
|
+
"collection" =>
|
59
|
+
["addCollectionToGroup",
|
60
|
+
"addCollectionToGroup",
|
61
|
+
"addMediaToCollection",
|
62
|
+
"addNetworkMediaToAssets",
|
63
|
+
"createCollection",
|
64
|
+
"deleteCollection",
|
65
|
+
"editCollection",
|
66
|
+
"editCollectionMediaPosition",
|
67
|
+
"editCollectionPrefs",
|
68
|
+
"getCollectionMedias",
|
69
|
+
"getCollectionPrefs",
|
70
|
+
"getCollections",
|
71
|
+
"getMediaCollections",
|
72
|
+
"removeCollectionFromGroup",
|
73
|
+
"removeMediaFromCollection",
|
74
|
+
"removeNetworkMediaFromAssets"],
|
75
|
+
|
76
|
+
# crypt.php
|
77
|
+
"crypt" =>
|
78
|
+
["decrypt",
|
79
|
+
"encrypt",
|
80
|
+
"getKey"],
|
81
|
+
|
82
|
+
# media.php
|
83
|
+
|
84
|
+
"media" =>
|
85
|
+
["addToEncodeQueue",
|
86
|
+
"createMetadataAttribute",
|
87
|
+
"createSource",
|
88
|
+
"genUploadToken",
|
89
|
+
"getApprovalQueuedMediaCount",
|
90
|
+
"getApprovalQueuedMedias",
|
91
|
+
"getMedia",
|
92
|
+
"getMediaCount",
|
93
|
+
"getMediaFiles",
|
94
|
+
"getMediaList",
|
95
|
+
"getMediaMetadata",
|
96
|
+
"getMediaUrl",
|
97
|
+
"getMetadataAttributes",
|
98
|
+
"getSource",
|
99
|
+
"getStatusMap",
|
100
|
+
"insertApprovalQueue",
|
101
|
+
"removeFromApprovalQueue",
|
102
|
+
"searchMedia",
|
103
|
+
"setDefaultThumbnail",
|
104
|
+
"updateMediaData"],
|
105
|
+
|
106
|
+
# ReportedPost.php
|
107
|
+
|
108
|
+
"ReportedPost" =>
|
109
|
+
["getReports",
|
110
|
+
"editReportStatus",
|
111
|
+
"createReport"],
|
112
|
+
|
113
|
+
# stats.php
|
114
|
+
|
115
|
+
"stats" =>
|
116
|
+
["getTopRankedMedia",
|
117
|
+
"getRatingRankedMedia"],
|
118
|
+
|
119
|
+
# comments.php
|
120
|
+
"comments" =>
|
121
|
+
["addComment",
|
122
|
+
"editComment",
|
123
|
+
"editCommentStatus",
|
124
|
+
"getComment",
|
125
|
+
"getComments",
|
126
|
+
"getCount"],
|
127
|
+
|
128
|
+
# genre.php
|
129
|
+
"genre" =>
|
130
|
+
["createGenre",
|
131
|
+
"deleteGenre",
|
132
|
+
"editGenre",
|
133
|
+
"getGenres"],
|
134
|
+
|
135
|
+
|
136
|
+
# ratings.php
|
137
|
+
|
138
|
+
"ratings" =>
|
139
|
+
["createRatingGroup",
|
140
|
+
"createRatingSystem",
|
141
|
+
"deleteRatingSystemGroup",
|
142
|
+
"createRatingSystemGroup",
|
143
|
+
"getRatingGroups",
|
144
|
+
"getRatings",
|
145
|
+
"getRatingSummaries",
|
146
|
+
"getRatingSummary",
|
147
|
+
"getRatingSystems",
|
148
|
+
"getRatingSystemsByGroup",
|
149
|
+
"saveRatings",
|
150
|
+
"updateRating",
|
151
|
+
"updateRatingGroup",
|
152
|
+
"updateRatingSystem"],
|
153
|
+
|
154
|
+
|
155
|
+
# reports.php
|
156
|
+
|
157
|
+
"reports" =>
|
158
|
+
["getTopApplications",
|
159
|
+
"getTopCollections",
|
160
|
+
"getTopDomains",
|
161
|
+
"getTopGenres",
|
162
|
+
"getTopMedia",
|
163
|
+
"getTopPartners",
|
164
|
+
"getExposure"],
|
165
|
+
|
166
|
+
|
167
|
+
# tags.php
|
168
|
+
|
169
|
+
"tags" =>
|
170
|
+
["createTags",
|
171
|
+
"deleteTags",
|
172
|
+
"fetchTagCloud",
|
173
|
+
"fetchTags",
|
174
|
+
"fetchTagsByTargetIds",
|
175
|
+
"fetchTargetsByTag",
|
176
|
+
"replaceTags"],
|
177
|
+
}
|
178
|
+
end
|
179
|
+
end
|
data/lib/vmix/error.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Vmix
|
2
|
+
# Custom error class for rescuing from all Oas errors
|
3
|
+
class Error < StandardError
|
4
|
+
attr_reader :error_code
|
5
|
+
|
6
|
+
def initialize(message, error_code)
|
7
|
+
@error_code = error_code
|
8
|
+
super message
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Raised when the method call is not a valid Vmix API Method
|
13
|
+
class InvalidMethod < Error; end
|
14
|
+
|
15
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'vmix'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_vmix.rb
ADDED
data/vmix.gemspec
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "vmix"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alan McCann"]
|
12
|
+
s.date = "2013-01-14"
|
13
|
+
s.description = "Ruby Client for VMIX REST API"
|
14
|
+
s.email = "alan@imccann.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".DS_Store",
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.md",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"lib/vmix.rb",
|
31
|
+
"lib/vmix/api.rb",
|
32
|
+
"lib/vmix/client.rb",
|
33
|
+
"lib/vmix/configuration.rb",
|
34
|
+
"lib/vmix/error.rb",
|
35
|
+
"test/helper.rb",
|
36
|
+
"test/test_vmix.rb",
|
37
|
+
"vmix.gemspec"
|
38
|
+
]
|
39
|
+
s.homepage = "http://github.com/alanmccann/vmix"
|
40
|
+
s.licenses = ["MIT"]
|
41
|
+
s.require_paths = ["lib"]
|
42
|
+
s.rubygems_version = "1.8.24"
|
43
|
+
s.summary = "Ruby Client for VMIX REST API"
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.10.0"])
|
50
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.2.3"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
54
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.10.0"])
|
56
|
+
s.add_development_dependency(%q<rake>, ["~> 0.9.2.2"])
|
57
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.12"])
|
58
|
+
s.add_development_dependency(%q<webmock>, ["~> 1.9.0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<httparty>, ["~> 0.10.0"])
|
61
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
62
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.3"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
65
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
66
|
+
s.add_dependency(%q<httparty>, ["~> 0.10.0"])
|
67
|
+
s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
|
68
|
+
s.add_dependency(%q<rspec>, ["~> 2.12"])
|
69
|
+
s.add_dependency(%q<webmock>, ["~> 1.9.0"])
|
70
|
+
end
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<httparty>, ["~> 0.10.0"])
|
73
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
74
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
75
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.3"])
|
76
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
77
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
78
|
+
s.add_dependency(%q<httparty>, ["~> 0.10.0"])
|
79
|
+
s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
|
80
|
+
s.add_dependency(%q<rspec>, ["~> 2.12"])
|
81
|
+
s.add_dependency(%q<webmock>, ["~> 1.9.0"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vmix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alan McCann
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.10.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.10.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: shoulda
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.2.3
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.2.3
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.8.4
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.8.4
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: httparty
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.10.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.10.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rake
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.9.2.2
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.9.2.2
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rspec
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '2.12'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ~>
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '2.12'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: webmock
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 1.9.0
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 1.9.0
|
174
|
+
description: Ruby Client for VMIX REST API
|
175
|
+
email: alan@imccann.com
|
176
|
+
executables: []
|
177
|
+
extensions: []
|
178
|
+
extra_rdoc_files:
|
179
|
+
- LICENSE.txt
|
180
|
+
- README.md
|
181
|
+
- README.rdoc
|
182
|
+
files:
|
183
|
+
- .DS_Store
|
184
|
+
- .document
|
185
|
+
- Gemfile
|
186
|
+
- Gemfile.lock
|
187
|
+
- LICENSE.txt
|
188
|
+
- README.md
|
189
|
+
- README.rdoc
|
190
|
+
- Rakefile
|
191
|
+
- VERSION
|
192
|
+
- lib/vmix.rb
|
193
|
+
- lib/vmix/api.rb
|
194
|
+
- lib/vmix/client.rb
|
195
|
+
- lib/vmix/configuration.rb
|
196
|
+
- lib/vmix/error.rb
|
197
|
+
- test/helper.rb
|
198
|
+
- test/test_vmix.rb
|
199
|
+
- vmix.gemspec
|
200
|
+
homepage: http://github.com/alanmccann/vmix
|
201
|
+
licenses:
|
202
|
+
- MIT
|
203
|
+
post_install_message:
|
204
|
+
rdoc_options: []
|
205
|
+
require_paths:
|
206
|
+
- lib
|
207
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
208
|
+
none: false
|
209
|
+
requirements:
|
210
|
+
- - ! '>='
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
segments:
|
214
|
+
- 0
|
215
|
+
hash: -2700820936572026164
|
216
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
requirements: []
|
223
|
+
rubyforge_project:
|
224
|
+
rubygems_version: 1.8.24
|
225
|
+
signing_key:
|
226
|
+
specification_version: 3
|
227
|
+
summary: Ruby Client for VMIX REST API
|
228
|
+
test_files: []
|