vidyard 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +36 -0
- data/lib/vidyard.rb +3 -0
- data/lib/vidyard/client.rb +43 -0
- data/lib/vidyard/player.rb +17 -0
- data/lib/vidyard/util.rb +12 -0
- data/lib/vidyard/version.rb +3 -0
- metadata +83 -0
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Vidyard API
|
2
|
+
|
3
|
+
This gem implements the [Vidyard v1.0 API](http://api.vidyard.com/docs/dashboard/1.0.html) in Ruby. Currently, only GET methods (on non-nested resources) are supported.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
If you're using bundler, include the gem in your Gemfile and run `bundle install`
|
8
|
+
|
9
|
+
You can instantiate a `Vidyard::Client` object with your API token.
|
10
|
+
|
11
|
+
require 'vidyard'
|
12
|
+
vidyard = Vidyard::Client.new(API_TOKEN)
|
13
|
+
|
14
|
+
Get an array of resources like this...
|
15
|
+
|
16
|
+
vidyard.get_videos()
|
17
|
+
|
18
|
+
Get a single resource like this...
|
19
|
+
|
20
|
+
vidyard.get_video(video_id)
|
21
|
+
|
22
|
+
You get the idea.
|
23
|
+
|
24
|
+
## Testing
|
25
|
+
|
26
|
+
This project uses [Rspec](https://rubygems.org/gems/rspec), [VCR](https://rubygems.org/gems/vcr) and [Webmock](https://rubygems.org/gems/webmock) for testing.
|
27
|
+
|
28
|
+
Before you run the test suite, you need to create a new `.env` file and add your API token, like so...
|
29
|
+
|
30
|
+
API_TOKEN=...
|
31
|
+
|
32
|
+
Initial HTTP requests will be saved in `spec/fixtures`.
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
MIT License. Copyright 2014 [Taylor C. MacDonald](http://github.com/tcmacdonald).
|
data/lib/vidyard.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
module Vidyard
|
5
|
+
class Client
|
6
|
+
|
7
|
+
include HTTParty
|
8
|
+
base_uri 'https://api.vidyard.com/dashboard/v1'
|
9
|
+
format :json
|
10
|
+
|
11
|
+
def initialize(auth_token)
|
12
|
+
@options = { :auth_token => auth_token }
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(meth, *args, &block)
|
16
|
+
if meth.to_s =~ /^get_(.+)$/
|
17
|
+
get_resources($1, args)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_resources(resource, args)
|
24
|
+
if Vidyard::Util.singular?(resource)
|
25
|
+
resource = "#{resource.to_s.pluralize}/#{args.shift}"
|
26
|
+
end
|
27
|
+
query = @options.try(:merge, args[0] || {})
|
28
|
+
payload = self.class.get("/#{resource}.json", :query => query)
|
29
|
+
parse_resources(resource, payload)
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse_resources(resource, payload)
|
33
|
+
if resource == 'players'
|
34
|
+
payload.parsed_response.collect { |player| Vidyard::Player.new(player) }
|
35
|
+
else
|
36
|
+
payload.parsed_response
|
37
|
+
end
|
38
|
+
rescue
|
39
|
+
[]
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Vidyard
|
2
|
+
class Player
|
3
|
+
|
4
|
+
attr_accessor :uuid, :name, :url
|
5
|
+
|
6
|
+
def initialize(player)
|
7
|
+
@uuid = player['uuid']
|
8
|
+
@name = player['name']
|
9
|
+
@url = embed_url
|
10
|
+
end
|
11
|
+
|
12
|
+
def embed_url
|
13
|
+
"//embed.vidyard.com/share/#{@uuid}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/vidyard/util.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vidyard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Taylor C. MacDonald
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-12-15 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'
|
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'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activesupport
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
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
|
+
description: This gem contains a handful of methods for interacting with Vidyard API.
|
47
|
+
email: taylor@helloample.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- lib/vidyard/client.rb
|
53
|
+
- lib/vidyard/player.rb
|
54
|
+
- lib/vidyard/util.rb
|
55
|
+
- lib/vidyard/version.rb
|
56
|
+
- lib/vidyard.rb
|
57
|
+
- README.md
|
58
|
+
homepage: http://rubygems.org/gems/vidyard
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.23.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Vidyard API implemented in Ruby
|
83
|
+
test_files: []
|