zoomus 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -0
- data/lib/zoomus/actions/meeting.rb +16 -10
- data/lib/zoomus/actions/user.rb +8 -8
- data/lib/zoomus/client.rb +7 -8
- data/lib/zoomus/utils.rb +32 -31
- data/spec/fixtures/error.json +6 -0
- data/spec/fixtures/meeting_delete.json +4 -0
- data/spec/lib/zoomus/actions/meeting/create_spec.rb +16 -1
- data/spec/lib/zoomus/actions/meeting/delete_spec.rb +50 -0
- data/spec/lib/zoomus/actions/meeting/list_spec.rb +11 -0
- data/spec/lib/zoomus/actions/meeting/update_spec.rb +15 -0
- data/spec/lib/zoomus/actions/user/create_spec.rb +16 -0
- data/spec/lib/zoomus/actions/user/custcreate_spec.rb +17 -4
- data/spec/lib/zoomus/actions/user/list_spec.rb +11 -0
- data/spec/lib/zoomus/utils_spec.rb +33 -5
- data/zoomus.gemspec +1 -1
- metadata +11 -5
data/README.md
CHANGED
@@ -16,6 +16,17 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install zoomus
|
18
18
|
|
19
|
+
## Available actions
|
20
|
+
|
21
|
+
- user/create
|
22
|
+
- user/custcreate
|
23
|
+
- user/list
|
24
|
+
|
25
|
+
- user/create
|
26
|
+
- user/delete
|
27
|
+
- user/list
|
28
|
+
- user/update
|
29
|
+
|
19
30
|
## Usage
|
20
31
|
|
21
32
|
require 'zoomus'
|
@@ -3,24 +3,30 @@ module Zoomus
|
|
3
3
|
module Meeting
|
4
4
|
|
5
5
|
def meeting_list(*args)
|
6
|
-
options = extract_options!(args)
|
7
|
-
require_params(:host_id, options)
|
8
|
-
parse_response self.class.post("/meeting/list", :query => options)
|
6
|
+
options = Utils.extract_options!(args)
|
7
|
+
Utils.require_params(:host_id, options)
|
8
|
+
Utils.parse_response self.class.post("/meeting/list", :query => options)
|
9
9
|
end
|
10
10
|
|
11
11
|
def meeting_create(*args)
|
12
|
-
options = extract_options!(args)
|
13
|
-
require_params([:host_id, :topic, :type], options)
|
14
|
-
parse_response self.class.post("/meeting/create", :query => options)
|
12
|
+
options = Utils.extract_options!(args)
|
13
|
+
Utils.require_params([:host_id, :topic, :type], options)
|
14
|
+
Utils.parse_response self.class.post("/meeting/create", :query => options)
|
15
15
|
end
|
16
16
|
|
17
17
|
def meeting_update(*args)
|
18
|
-
options = extract_options!(args)
|
19
|
-
require_params([:id, :host_id, :topic, :type], options)
|
20
|
-
parse_response self.class.post("/meeting/update", :query => options)
|
18
|
+
options = Utils.extract_options!(args)
|
19
|
+
Utils.require_params([:id, :host_id, :topic, :type], options)
|
20
|
+
Utils.parse_response self.class.post("/meeting/update", :query => options)
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
def meeting_delete(*args)
|
24
|
+
options = Utils.extract_options!(args)
|
25
|
+
Utils.require_params([:id, :host_id], options)
|
26
|
+
Utils.parse_response self.class.post("/meeting/delete", :query => options)
|
27
|
+
end
|
28
|
+
|
29
|
+
Utils.define_bang_methods(self)
|
24
30
|
|
25
31
|
end
|
26
32
|
end
|
data/lib/zoomus/actions/user.rb
CHANGED
@@ -3,22 +3,22 @@ module Zoomus
|
|
3
3
|
module User
|
4
4
|
|
5
5
|
def user_list
|
6
|
-
parse_response self.class.post("/user/list")
|
6
|
+
Utils.parse_response self.class.post("/user/list")
|
7
7
|
end
|
8
8
|
|
9
9
|
def user_create(*args)
|
10
|
-
options = extract_options!(args)
|
11
|
-
require_params([:type, :email], options)
|
12
|
-
parse_response self.class.post("/user/create", :query => options)
|
10
|
+
options = Utils.extract_options!(args)
|
11
|
+
Utils.require_params([:type, :email], options)
|
12
|
+
Utils.parse_response self.class.post("/user/create", :query => options)
|
13
13
|
end
|
14
14
|
|
15
15
|
def user_custcreate(*args)
|
16
|
-
options = extract_options!(args)
|
17
|
-
require_params([:type, :email], options)
|
18
|
-
parse_response self.class.post("/user/custcreate", :query => options)
|
16
|
+
options = Utils.extract_options!(args)
|
17
|
+
Utils.require_params([:type, :email], options)
|
18
|
+
Utils.parse_response self.class.post("/user/custcreate", :query => options)
|
19
19
|
end
|
20
20
|
|
21
|
-
Utils
|
21
|
+
Utils.define_bang_methods(self)
|
22
22
|
|
23
23
|
end
|
24
24
|
end
|
data/lib/zoomus/client.rb
CHANGED
@@ -5,8 +5,6 @@ module Zoomus
|
|
5
5
|
class Client
|
6
6
|
|
7
7
|
include HTTParty
|
8
|
-
|
9
|
-
include Utils
|
10
8
|
include Actions::User
|
11
9
|
include Actions::Meeting
|
12
10
|
|
@@ -14,13 +12,14 @@ module Zoomus
|
|
14
12
|
|
15
13
|
def initialize(*args)
|
16
14
|
|
17
|
-
options = extract_options!(args)
|
18
|
-
|
19
|
-
raise argument_error("api_key and api_secret") unless options[:api_key] and options[:api_secret]
|
15
|
+
options = Utils.extract_options!(args)
|
20
16
|
|
21
|
-
|
22
|
-
|
17
|
+
raise Utils.argument_error("api_key and api_secret") unless options[:api_key] &&
|
18
|
+
options[:api_secret]
|
19
|
+
self.class.default_params(
|
20
|
+
:api_key => options[:api_key],
|
21
|
+
:api_secret => options[:api_secret]
|
22
|
+
)
|
23
23
|
end
|
24
|
-
|
25
24
|
end
|
26
25
|
end
|
data/lib/zoomus/utils.rb
CHANGED
@@ -1,47 +1,48 @@
|
|
1
1
|
module Zoomus
|
2
|
-
|
2
|
+
class Utils
|
3
3
|
|
4
|
-
|
4
|
+
class << self
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def argument_error(name)
|
7
|
+
name ? ArgumentError.new("You must provide #{name}") : ArgumentError.new
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def raise_if_error!(response)
|
11
|
+
if response["error"]
|
12
|
+
raise Error.new(response["error"]["message"])
|
13
|
+
else
|
14
|
+
response
|
15
|
+
end
|
15
16
|
end
|
16
|
-
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def parse_response(http_response)
|
19
|
+
response = http_response.parsed_response
|
20
|
+
# Mocked response returns a string
|
21
|
+
response.kind_of?(Hash) ? response : JSON.parse(response)
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
def require_params(params, options)
|
25
|
+
params = [params] unless params.is_a? Array
|
26
|
+
params.each do |param|
|
27
|
+
unless options[param]
|
28
|
+
raise argument_error(param.to_s)
|
29
|
+
break
|
30
|
+
end
|
30
31
|
end
|
31
32
|
end
|
32
|
-
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
# Dinamically defines bang methods for Actions modules
|
35
|
+
def define_bang_methods(klass)
|
36
|
+
klass.instance_methods.each do |m|
|
37
|
+
klass.send(:define_method, "#{m}!") do |*args|
|
38
|
+
Utils.raise_if_error! send(m, *args)
|
39
|
+
end
|
39
40
|
end
|
40
41
|
end
|
41
|
-
end
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
def extract_options!(array)
|
44
|
+
array.last.is_a?(::Hash) ? array.pop : {}
|
45
|
+
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -9,7 +9,8 @@ describe Zoomus::Actions::Meeting do
|
|
9
9
|
|
10
10
|
describe "#meeting_create action" do
|
11
11
|
before :each do
|
12
|
-
stub_request(:post, zoomus_url("/meeting/create")).
|
12
|
+
stub_request(:post, zoomus_url("/meeting/create")).
|
13
|
+
to_return(:body => json_response("meeting_create"))
|
13
14
|
end
|
14
15
|
|
15
16
|
it "requires a 'host_id' argument" do
|
@@ -49,4 +50,18 @@ describe Zoomus::Actions::Meeting do
|
|
49
50
|
expect(res["join_url"]).to_not be_nil
|
50
51
|
end
|
51
52
|
end
|
53
|
+
|
54
|
+
describe "#meeting_create! action" do
|
55
|
+
before :each do
|
56
|
+
stub_request(:post, zoomus_url("/meeting/create")).
|
57
|
+
to_return(:body => json_response("error"))
|
58
|
+
end
|
59
|
+
|
60
|
+
it "raises Zoomus::Error exception" do
|
61
|
+
expect{ @zc.meeting_create!(
|
62
|
+
:host_id => @host_id,
|
63
|
+
:type => 1,
|
64
|
+
:topic => "Foo")}.to raise_error(Zoomus::Error)
|
65
|
+
end
|
66
|
+
end
|
52
67
|
end
|
@@ -0,0 +1,50 @@
|
|
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
|
+
@id = "252482092"
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#meeting_delete action" do
|
12
|
+
before :each do
|
13
|
+
stub_request(:post, zoomus_url("/meeting/delete")).to_return(:body => json_response("meeting_delete"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requires a 'host_id' argument" do
|
17
|
+
expect{@zc.meeting_delete(:id => @id)}.to raise_error(ArgumentError)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "requires a 'id' argument" do
|
21
|
+
expect{@zc.meeting_delete(:host_id => @host_id)}.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns a hash" do
|
25
|
+
expect(@zc.meeting_delete(:host_id => @host_id,
|
26
|
+
:id => @id)).to be_kind_of(Hash)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns id and deleted at attributes" do
|
30
|
+
res = @zc.meeting_delete(:host_id => @host_id,
|
31
|
+
:id => @id)
|
32
|
+
|
33
|
+
expect(res["id"]).to eq(@id)
|
34
|
+
expect(res["deleted_at"]).to eq("2013-04-05T15:50:47Z")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#meeting_delete! action" do
|
39
|
+
before :each do
|
40
|
+
stub_request(:post, zoomus_url("/meeting/delete")).
|
41
|
+
to_return(:body => json_response("error"))
|
42
|
+
end
|
43
|
+
|
44
|
+
it "raises Zoomus::Error exception" do
|
45
|
+
expect{ @zc.meeting_delete!(
|
46
|
+
:host_id => @host_id,
|
47
|
+
:id => @id)}.to raise_error(Zoomus::Error)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -28,4 +28,15 @@ describe Zoomus::Actions::Meeting do
|
|
28
28
|
expect(@zc.meeting_list(:host_id => @host_id)["meetings"]).to be_kind_of(Array)
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
describe "#meeting_list! action" do
|
33
|
+
before :each do
|
34
|
+
stub_request(:post, zoomus_url("/meeting/list")).
|
35
|
+
to_return(:body => json_response("error"))
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises Zoomus::Error exception" do
|
39
|
+
expect{ @zc.meeting_list!(:host_id => @host_id)}.to raise_error(Zoomus::Error)
|
40
|
+
end
|
41
|
+
end
|
31
42
|
end
|
@@ -46,4 +46,19 @@ describe Zoomus::Actions::Meeting do
|
|
46
46
|
expect(res["updated_at"]).to eq("2013-02-25T15:52:38Z")
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
describe "#meeting_update! action" do
|
51
|
+
before :each do
|
52
|
+
stub_request(:post, zoomus_url("/meeting/update")).
|
53
|
+
to_return(:body => json_response("error"))
|
54
|
+
end
|
55
|
+
|
56
|
+
it "raises Zoomus::Error exception" do
|
57
|
+
expect{ @zc.meeting_update!(
|
58
|
+
:host_id => @host_id,
|
59
|
+
:id => @id,
|
60
|
+
:type => 1,
|
61
|
+
:topic => "Foo")}.to raise_error(Zoomus::Error)
|
62
|
+
end
|
63
|
+
end
|
49
64
|
end
|
@@ -38,4 +38,20 @@ describe Zoomus::Actions::User do
|
|
38
38
|
expect(res["type"]).to eq(1)
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
describe "#user_create! action" do
|
43
|
+
before :each do
|
44
|
+
stub_request(:post, zoomus_url("/user/create")).
|
45
|
+
to_return(:body => json_response("error"))
|
46
|
+
end
|
47
|
+
|
48
|
+
it "raises Zoomus::Error exception" do
|
49
|
+
expect{ @zc.user_create!(
|
50
|
+
:email => "foo@bar.com",
|
51
|
+
:first_name => "Foo",
|
52
|
+
:last_name => "Bar",
|
53
|
+
:type => 1)}.to raise_error(Zoomus::Error)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
41
57
|
end
|
@@ -12,18 +12,17 @@ describe Zoomus::Actions::User do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "requires email param" do
|
15
|
-
expect{@zc.user_custcreate(:type => 1
|
15
|
+
expect{@zc.user_custcreate(:type => 1)}.to raise_error(ArgumentError)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "requires type param" do
|
19
|
-
expect{@zc.user_custcreate(:email => "foo@bar.com"
|
19
|
+
expect{@zc.user_custcreate(:email => "foo@bar.com")}.to raise_error(ArgumentError)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns a hash" do
|
23
23
|
expect(@zc.user_custcreate(:email => "foo@bar.com",
|
24
24
|
:first_name => "Foo",
|
25
25
|
:last_name => "Bar",
|
26
|
-
:password => "lolcat",
|
27
26
|
:type => 1)).to be_kind_of(Hash)
|
28
27
|
end
|
29
28
|
|
@@ -31,7 +30,6 @@ describe Zoomus::Actions::User do
|
|
31
30
|
res = @zc.user_custcreate(:email => "foo@bar.com",
|
32
31
|
:first_name => "Foo",
|
33
32
|
:last_name => "Bar",
|
34
|
-
:password => "lolcat",
|
35
33
|
:type => 1)
|
36
34
|
|
37
35
|
expect(res["email"]).to eq("foo@bar.com")
|
@@ -40,4 +38,19 @@ describe Zoomus::Actions::User do
|
|
40
38
|
expect(res["type"]).to eq(1)
|
41
39
|
end
|
42
40
|
end
|
41
|
+
|
42
|
+
describe "#user_custcreate! action" do
|
43
|
+
before :each do
|
44
|
+
stub_request(:post, zoomus_url("/user/custcreate")).
|
45
|
+
to_return(:body => json_response("error"))
|
46
|
+
end
|
47
|
+
|
48
|
+
it "raises Zoomus::Error exception" do
|
49
|
+
expect{ @zc.user_custcreate!(
|
50
|
+
:email => "foo@bar.com",
|
51
|
+
:first_name => "Foo",
|
52
|
+
:last_name => "Bar",
|
53
|
+
:type => 1)}.to raise_error(Zoomus::Error)
|
54
|
+
end
|
55
|
+
end
|
43
56
|
end
|
@@ -23,4 +23,15 @@ describe Zoomus::Actions::User do
|
|
23
23
|
expect(@zc.user_list["users"]).to be_kind_of(Array)
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
describe "#user_list! action" do
|
28
|
+
before :each do
|
29
|
+
stub_request(:post, zoomus_url("/user/list")).
|
30
|
+
to_return(:body => json_response("error"))
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises Zoomus::Error exception" do
|
34
|
+
expect{ @zc.user_list! }.to raise_error(Zoomus::Error)
|
35
|
+
end
|
36
|
+
end
|
26
37
|
end
|
@@ -2,14 +2,42 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Zoomus::Utils do
|
4
4
|
|
5
|
-
|
5
|
+
before(:all) do
|
6
|
+
class Utils < Zoomus::Utils; end
|
7
|
+
end
|
6
8
|
|
7
|
-
describe "#
|
9
|
+
describe "#argument_error" do
|
10
|
+
it "raises ArgumentError" do
|
11
|
+
expect(Utils.argument_error("foo")).to be_instance_of(ArgumentError)
|
12
|
+
end
|
13
|
+
end
|
8
14
|
|
9
|
-
describe "#
|
15
|
+
describe "#raise_if_error!" do
|
16
|
+
it "raises Zoomus::Error if error is present" do
|
17
|
+
response = {'error' => { 'message' => 'lol error'}}
|
18
|
+
expect{Utils.raise_if_error!(response)}.to raise_error(Zoomus::Error)
|
19
|
+
end
|
10
20
|
|
11
|
-
|
21
|
+
it "does not raise Zoomus::Error if error is not present" do
|
22
|
+
response = {}
|
23
|
+
expect{Utils.raise_if_error!(response)}.to_not raise_error(Zoomus::Error)
|
24
|
+
end
|
25
|
+
end
|
12
26
|
|
13
|
-
describe "#
|
27
|
+
describe "#require_params" do
|
28
|
+
it "raises ArgumentError if the param is not present" do
|
29
|
+
expect{Utils.require_params(:foo, {:bar => 'bar'})}.to raise_error(ArgumentError)
|
30
|
+
end
|
14
31
|
|
32
|
+
it "does not raise ArgumentError if the param is present" do
|
33
|
+
expect{Utils.require_params(:foo, {:foo => 'foo'})}.to_not raise_error(ArgumentError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#extract_options!" do
|
38
|
+
it "converts array to hash options" do
|
39
|
+
args = [{:foo => 'foo'}, {:bar => 'bar'}, {:zemba => 'zemba'}]
|
40
|
+
expect(Utils.extract_options!(args)).to be_kind_of(Hash)
|
41
|
+
end
|
42
|
+
end
|
15
43
|
end
|
data/zoomus.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoomus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-04-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &78305960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *78305960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &78305650 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *78305650
|
36
36
|
description: A Ruby wrapper for zoom.us API v1
|
37
37
|
email:
|
38
38
|
- collsmaxim@gmail.com
|
@@ -52,13 +52,16 @@ files:
|
|
52
52
|
- lib/zoomus/error.rb
|
53
53
|
- lib/zoomus/interface.rb
|
54
54
|
- lib/zoomus/utils.rb
|
55
|
+
- spec/fixtures/error.json
|
55
56
|
- spec/fixtures/meeting_create.json
|
57
|
+
- spec/fixtures/meeting_delete.json
|
56
58
|
- spec/fixtures/meeting_list.json
|
57
59
|
- spec/fixtures/meeting_update.json
|
58
60
|
- spec/fixtures/user_create.json
|
59
61
|
- spec/fixtures/user_custcreate.json
|
60
62
|
- spec/fixtures/user_list.json
|
61
63
|
- spec/lib/zoomus/actions/meeting/create_spec.rb
|
64
|
+
- spec/lib/zoomus/actions/meeting/delete_spec.rb
|
62
65
|
- spec/lib/zoomus/actions/meeting/list_spec.rb
|
63
66
|
- spec/lib/zoomus/actions/meeting/update_spec.rb
|
64
67
|
- spec/lib/zoomus/actions/user/create_spec.rb
|
@@ -93,13 +96,16 @@ signing_key:
|
|
93
96
|
specification_version: 3
|
94
97
|
summary: zoom.us API wrapper
|
95
98
|
test_files:
|
99
|
+
- spec/fixtures/error.json
|
96
100
|
- spec/fixtures/meeting_create.json
|
101
|
+
- spec/fixtures/meeting_delete.json
|
97
102
|
- spec/fixtures/meeting_list.json
|
98
103
|
- spec/fixtures/meeting_update.json
|
99
104
|
- spec/fixtures/user_create.json
|
100
105
|
- spec/fixtures/user_custcreate.json
|
101
106
|
- spec/fixtures/user_list.json
|
102
107
|
- spec/lib/zoomus/actions/meeting/create_spec.rb
|
108
|
+
- spec/lib/zoomus/actions/meeting/delete_spec.rb
|
103
109
|
- spec/lib/zoomus/actions/meeting/list_spec.rb
|
104
110
|
- spec/lib/zoomus/actions/meeting/update_spec.rb
|
105
111
|
- spec/lib/zoomus/actions/user/create_spec.rb
|