zoomus 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem 'httparty'
4
+ gem 'json'
5
+ group :test do
6
+ gem 'rspec'
7
+ gem 'webmock'
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Maxim Colls
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,5 @@
1
+ help:
2
+ @echo "make console"
3
+
4
+ console:
5
+ irb -rubygems -I lib -r zoomus.rb
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Zoomus Gem
2
+
3
+ Ruby wrapper gem for zoom.us API v1.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'zoomus'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install zoomus
18
+
19
+ ## Usage
20
+
21
+ require 'zoomus'
22
+ zoomus_client = Zoomus.new(:api_key => "xxx", :api_secret => "xxx")
23
+ user_list = zoomus_client.user_list
24
+ user_list["users"].each do |user|
25
+ user_id = u["id"]
26
+ puts zoomus_client.meeting_list(:host_id => user_id)
27
+ end
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/lib/zoomus.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'zoomus/utils'
2
+ require 'zoomus/actions/user'
3
+ require 'zoomus/actions/meeting'
4
+ require 'zoomus/client'
5
+
6
+ module Zoomus
7
+ class << self
8
+ def new(*arg)
9
+ Zoomus::Client.new(*arg)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ module Zoomus
2
+ module Actions
3
+ module Meeting
4
+
5
+ def meeting_list(*args)
6
+ options = args.extract_options!
7
+ require_params(:host_id, options)
8
+ parse_response self.class.post("/meeting/list", :query => options)
9
+ end
10
+
11
+ def meeting_create(*args)
12
+ options = args.extract_options!
13
+ require_params([:host_id, :topic, :type], options)
14
+ parse_response self.class.post("/meeting/create", :query => options)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module Zoomus
2
+ module Actions
3
+ module User
4
+
5
+ def user_list
6
+ parse_response self.class.post("/user/list")
7
+ end
8
+
9
+ def user_create(*args)
10
+ options = args.extract_options!
11
+ require_params([:type, :email], options)
12
+ parse_response self.class.post("/user/create", :query => options)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ module Zoomus
5
+ class Client
6
+
7
+ include HTTParty
8
+
9
+ include Utils
10
+ include Actions::User
11
+ include Actions::Meeting
12
+
13
+ base_uri 'https://api.zoom.us/v1'
14
+
15
+ def initialize(*args)
16
+
17
+ options = args.extract_options!
18
+
19
+ raise argument_error("api_key and api_secret") unless options[:api_key] and options[:api_secret]
20
+
21
+ self.class.default_params :api_key => options[:api_key],
22
+ :api_secret => options[:api_secret]
23
+ end
24
+
25
+ end
26
+ end
27
+
@@ -0,0 +1,28 @@
1
+ module Zoomus
2
+ module Utils
3
+ private
4
+ def argument_error(name)
5
+ name ? ArgumentError.new("You must provide #{name}") : ArgumentError
6
+ end
7
+
8
+ def parse_response(http_response)
9
+ JSON.parse(http_response.parsed_response)
10
+ end
11
+
12
+ def require_params(params, options)
13
+ params = [params] unless params.is_a? Array
14
+ params.each do |param|
15
+ unless options[param]
16
+ raise argument_error(param.to_s)
17
+ break
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ class Array
25
+ def extract_options!
26
+ last.is_a?(::Hash) ? pop : {}
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ {
2
+ "uuid": "F48qM18iRqSQunRLbKBpmQ==",
3
+ "id": 494333439,
4
+ "host_id": "ufR93M2pRyy8ePFN92dttq",
5
+ "topic": "Foo",
6
+ "password": "",
7
+ "type": 1,
8
+ "option_jbh": true,
9
+ "start_time": "",
10
+ "duration": 0,
11
+ "timezone": "",
12
+ "start_url": "https://zoom.us/s/494333439?zpk=ZhyyOBOEVXlCSy9BX8KH5viEMwat3OfU9biKujAxrTk.BwUAAAE8qkJADwAAHCAkODRhOTQzMzctOTIwNS00YzI1LTkxNjMtYzJhZDIwZDM4OGI4FnVmUjkzTTJwUnl5OGVQRk45MmR0dFEWdWZSOTNNMnBSeXk4ZVBGTjkyZHR0UQtNYXhpbSBDb2xsc2QAsjRlMDZwQ2pjNmRMYVB5RG9OeGZ2X0VtcXJxajJjRXBlOWF2UFI2VEhiREkuQmdFZ2NFOUhVVXRVTW1KdVZVdFdRMVJTU25kcFp6VjRPVUozUmtwU0wycE9TelpBTlRVeVpUTTRPR013WlRNeU1EazJZMlF4Tmpaa01HSXlZV0ZqTkRBMk5UUXpOMlE1TVdZek1HSm1abVEyTW1aa016WXhZV1U1Wm1FMk5ETm1OR0V5TmcAABZkUGJUUWoxelJuLVJ5R2ZCeW11QndBAAE",
13
+ "join_url": "https://zoom.us/j/494333439",
14
+ "created_at": "2013-02-05T12:08:54Z"
15
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "page_count": 1,
3
+ "page_number": 1,
4
+ "page_size": 30,
5
+ "total_records": 1,
6
+ "meetings": [{
7
+ "topic": "My Meeting",
8
+ "id": 521910404,
9
+ "start_url": "https://zoom.us/s/521910404?zpk=LRTNfaKqk15rJHbOQ5uCo92GP_iNykiboh9q5jqkoXU.BwUAAAE8qaCS4wAAHCAkYTEwNTc5ZDAtZTliNi00NGJjLTliZWQtMzVjMTQ4MDE2NWRkFnVmUjkzTTJwUnl5OGVQRk45MmR0dFEWdWZSOTNNMnBSeXk4ZVBGTjkyZHR0UQtNYXhpbSBDb2xsc2QAsjRlMDZwQ2pjNmRMYVB5RG9OeGZ2X0VtcXJxajJjRXBlOWF2UFI2VEhiREkuQmdFZ2NFOUhVVXRVTW1KdVZVdFdRMVJTU25kcFp6VjRPVUozUmtwU0wycE9TelpBTlRVeVpUTTRPR013WlRNeU1EazJZMlF4Tmpaa01HSXlZV0ZqTkRBMk5UUXpOMlE1TVdZek1HSm1abVEyTW1aa016WXhZV1U1Wm1FMk5ETm1OR0V5TmcAABZkUGJUUWoxelJuLVJ5R2ZCeW11QndBAAE",
10
+ "timezone": "Europe/Brussels",
11
+ "duration": 60,
12
+ "option_jbh": true,
13
+ "host_id": "ufR9342pRyf8ePFN92dttQ",
14
+ "join_url": "https://zoom.us/j/521910404",
15
+ "created_at": "2013-02-05T09:11:48Z",
16
+ "start_time": "2013-02-05T10:00:00Z",
17
+ "uuid": "g0OFRGGARfaTlDxbGjcVKQ==",
18
+ "type": 2
19
+ }]
20
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "eIimBAXqSrWOcB_EOIXTog",
3
+ "email": "foo@bar.com",
4
+ "first_name": "Foo",
5
+ "last_name": "Bar",
6
+ "type": 1,
7
+ "created_at": "2013-02-05T11:23:58Z",
8
+ "token": null
9
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "page_count": 1,
3
+ "page_number": 1,
4
+ "page_size": 30,
5
+ "total_records": 1,
6
+ "users": [{
7
+ "id": "ufR9342pRyf8ePFN92dttQ",
8
+ "first_name": "Bar",
9
+ "email": "foo@bar.com",
10
+ "last_name": "Foo",
11
+ "created_at": "2013-01-30T12:19:17Z",
12
+ "type": 1
13
+ }]
14
+ }
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe Zoomus::Actions::Meeting do
4
+
5
+ before :all do
6
+ @zc = zoomus_client
7
+ @host_id = "ufR93M2pRyy8ePFN92dttq"
8
+ end
9
+
10
+ describe "#meeting_list action" do
11
+ before :each do
12
+ stub_request(:post, zoomus_url("/meeting/list")).to_return(:body => json_response("meeting_list"))
13
+ end
14
+
15
+ it "requires a 'host_id' argument" do
16
+ expect{@zc.meeting_list()}.to raise_error(ArgumentError)
17
+ end
18
+
19
+ it "returns a hash" do
20
+ expect(@zc.meeting_list(:host_id => @host_id)).to be_kind_of(Hash)
21
+ end
22
+
23
+ it "returns 'total_records'" do
24
+ expect(@zc.meeting_list(:host_id => @host_id)["total_records"]).to eq(1)
25
+ end
26
+
27
+ it "returns 'meetings' Array" do
28
+ expect(@zc.meeting_list(:host_id => @host_id)["meetings"]).to be_kind_of(Array)
29
+ end
30
+ end
31
+
32
+ describe "#meeting_list action" do
33
+ before :each do
34
+ stub_request(:post, zoomus_url("/meeting/create")).to_return(:body => json_response("meeting_create"))
35
+ end
36
+
37
+ it "requires a 'host_id' argument" do
38
+ expect{@zc.meeting_create(:type => 1, :topic => "Foo")}.to raise_error(ArgumentError)
39
+ end
40
+
41
+ it "requires a 'topic' argument" do
42
+ expect{@zc.meeting_create(:host_id => 1, :type => "Foo")}.to raise_error(ArgumentError)
43
+ end
44
+
45
+ it "requires a 'type' argument" do
46
+ expect{@zc.meeting_create(:host_id => 1, :topic => "Foo")}.to raise_error(ArgumentError)
47
+ end
48
+
49
+ it "returns a hash" do
50
+ expect(@zc.meeting_create(:host_id => @host_id,
51
+ :type => 1,
52
+ :topic => "Foo")).to be_kind_of(Hash)
53
+ end
54
+
55
+ it "returns the setted params" do
56
+ res = @zc.meeting_create(:host_id => @host_id,
57
+ :type => 1,
58
+ :topic => "Foo")
59
+
60
+ expect(res["host_id"]).to eq(@host_id)
61
+ expect(res["type"]).to eq(1)
62
+ expect(res["topic"]).to eq("Foo")
63
+ end
64
+
65
+ it "returns 'start_url' and 'join_url'" do
66
+ res = @zc.meeting_create(:host_id => @host_id,
67
+ :type => 1,
68
+ :topic => "Foo")
69
+
70
+ expect(res["start_url"]).to_not be_nil
71
+ expect(res["join_url"]).to_not be_nil
72
+ end
73
+ end
74
+ end
75
+
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Zoomus::Actions::User do
4
+
5
+ before :all do
6
+ @zc = zoomus_client
7
+ end
8
+
9
+ describe "#user_list action" do
10
+ before :each do
11
+ stub_request(:post, zoomus_url("/user/list")).to_return(:body => json_response("user_list"))
12
+ end
13
+
14
+ it "returns a hash" do
15
+ expect(@zc.user_list).to be_kind_of(Hash)
16
+ end
17
+
18
+ it "returns 'total_records" do
19
+ expect(@zc.user_list["total_records"]).to eq(1)
20
+ end
21
+
22
+ it "returns 'users' Array" do
23
+ expect(@zc.user_list["users"]).to be_kind_of(Array)
24
+ end
25
+ end
26
+
27
+ describe "#user_create action" do
28
+ before :each do
29
+ stub_request(:post, zoomus_url("/user/create")).to_return(:body => json_response("user_create"))
30
+ end
31
+
32
+ it "requires email param" do
33
+ expect{@zc.user_create(:type => "foo@bar.com")}.to raise_error(ArgumentError)
34
+ end
35
+
36
+ it "requires type param" do
37
+ expect{@zc.user_create(:email => "foo@bar.com")}.to raise_error(ArgumentError)
38
+ end
39
+
40
+ it "returns a hash" do
41
+ expect(@zc.user_create(:email => "foo@bar.com",
42
+ :first_name => "Foo",
43
+ :last_name => "Bar",
44
+ :type => 1)).to be_kind_of(Hash)
45
+ end
46
+
47
+ it "returns same params" do
48
+ res = @zc.user_create(:email => "foo@bar.com",
49
+ :first_name => "Foo",
50
+ :last_name => "Bar",
51
+ :type => 1)
52
+
53
+ expect(res["email"]).to eq("foo@bar.com")
54
+ expect(res["first_name"]).to eq("Foo")
55
+ expect(res["last_name"]).to eq("Bar")
56
+ expect(res["type"]).to eq(1)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Zoomus::Client do
4
+
5
+ describe "default attributes" do
6
+ it "must include httparty methods" do
7
+ expect(Zoomus::Client).to include(HTTParty)
8
+ end
9
+
10
+ it "must have the base url set to Zoomus API endpoint" do
11
+ expect(Zoomus::Client.base_uri).to eq('https://api.zoom.us/v1')
12
+ end
13
+ end
14
+
15
+ describe "constructor" do
16
+ it "requires api_key and api_secret for a new instance" do
17
+ expect{Zoomus::Client.new(:api_key => "xxx")}.to raise_error(ArgumentError)
18
+ end
19
+
20
+ it "creates instance of Zoomus::Client if api_key and api_secret is provided" do
21
+ expect(Zoomus::Client.new(:api_key => "xxx", :api_secret => "xxx")).to be_an_instance_of(Zoomus::Client)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require "zoomus"
4
+ require 'webmock/rspec'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
9
+
10
+ def fixture(filename)
11
+ File.dirname(__FILE__) + '/fixtures/' + filename
12
+ end
13
+
14
+ def json_response(key)
15
+ open(fixture(key + '.json')).read
16
+ end
17
+
18
+ def zoomus_url(url)
19
+ /https:\/\/api.zoom.us\/v1#{url}.*/
20
+ end
21
+
22
+ def zoomus_client
23
+ Zoomus.new(:api_key => "xxx", :api_secret => "xxx")
24
+ end
data/zoomus.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+
5
+ gem.add_dependency 'httparty'
6
+ gem.add_dependency 'json'
7
+
8
+ gem.authors = ['Maxim Colls']
9
+ gem.email = ['collsmaxim@gmail.com']
10
+ gem.description = %q{A Ruby wrapper for zoom.us API v1}
11
+ gem.summary = %q{zoom.us API wrapper}
12
+ gem.homepage = 'https://github.com/mllocs/zoomus'
13
+
14
+ gem.files = `git ls-files`.split($\)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.name = 'zoomus'
18
+ gem.require_paths = ['lib']
19
+ gem.version = '0.0.5'
20
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zoomus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Maxim Colls
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: &76078940 !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: *76078940
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &76076930 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *76076930
36
+ description: A Ruby wrapper for zoom.us API v1
37
+ email:
38
+ - collsmaxim@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - LICENSE
46
+ - Makefile
47
+ - README.md
48
+ - lib/zoomus.rb
49
+ - lib/zoomus/actions/meeting.rb
50
+ - lib/zoomus/actions/user.rb
51
+ - lib/zoomus/client.rb
52
+ - lib/zoomus/utils.rb
53
+ - spec/fixtures/meeting_create.json
54
+ - spec/fixtures/meeting_list.json
55
+ - spec/fixtures/user_create.json
56
+ - spec/fixtures/user_list.json
57
+ - spec/lib/zoomus/actions/meeting_spec.rb
58
+ - spec/lib/zoomus/actions/user_spec.rb
59
+ - spec/lib/zoomus/client_spec.rb
60
+ - spec/spec_helper.rb
61
+ - zoomus.gemspec
62
+ homepage: https://github.com/mllocs/zoomus
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.10
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: zoom.us API wrapper
86
+ test_files:
87
+ - spec/fixtures/meeting_create.json
88
+ - spec/fixtures/meeting_list.json
89
+ - spec/fixtures/user_create.json
90
+ - spec/fixtures/user_list.json
91
+ - spec/lib/zoomus/actions/meeting_spec.rb
92
+ - spec/lib/zoomus/actions/user_spec.rb
93
+ - spec/lib/zoomus/client_spec.rb
94
+ - spec/spec_helper.rb