zoomus 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/zoomus.rb +1 -0
- data/lib/zoomus/actions/meeting.rb +6 -4
- data/lib/zoomus/actions/user.rb +10 -2
- data/lib/zoomus/client.rb +4 -4
- data/lib/zoomus/error.rb +3 -0
- data/lib/zoomus/interface.rb +1 -6
- data/lib/zoomus/utils.rb +36 -19
- data/spec/fixtures/user_custcreate.json +10 -0
- data/spec/lib/zoomus/actions/user/create_spec.rb +6 -6
- data/spec/lib/zoomus/actions/user/custcreate_spec.rb +43 -0
- data/spec/lib/zoomus/client_spec.rb +1 -1
- data/spec/lib/zoomus/utils_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -1
- data/zoomus.gemspec +1 -1
- metadata +13 -6
data/lib/zoomus.rb
CHANGED
@@ -3,23 +3,25 @@ module Zoomus
|
|
3
3
|
module Meeting
|
4
4
|
|
5
5
|
def meeting_list(*args)
|
6
|
-
options =
|
6
|
+
options = extract_options!(args)
|
7
7
|
require_params(:host_id, options)
|
8
8
|
parse_response self.class.post("/meeting/list", :query => options)
|
9
9
|
end
|
10
10
|
|
11
11
|
def meeting_create(*args)
|
12
|
-
options =
|
12
|
+
options = extract_options!(args)
|
13
13
|
require_params([:host_id, :topic, :type], options)
|
14
14
|
parse_response self.class.post("/meeting/create", :query => options)
|
15
15
|
end
|
16
16
|
|
17
17
|
def meeting_update(*args)
|
18
|
-
options =
|
18
|
+
options = extract_options!(args)
|
19
19
|
require_params([:id, :host_id, :topic, :type], options)
|
20
20
|
parse_response self.class.post("/meeting/update", :query => options)
|
21
21
|
end
|
22
22
|
|
23
|
+
Utils::define_bang_methods(self)
|
24
|
+
|
23
25
|
end
|
24
26
|
end
|
25
|
-
end
|
27
|
+
end
|
data/lib/zoomus/actions/user.rb
CHANGED
@@ -7,11 +7,19 @@ module Zoomus
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def user_create(*args)
|
10
|
-
options =
|
10
|
+
options = extract_options!(args)
|
11
11
|
require_params([:type, :email], options)
|
12
12
|
parse_response self.class.post("/user/create", :query => options)
|
13
13
|
end
|
14
14
|
|
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)
|
19
|
+
end
|
20
|
+
|
21
|
+
Utils::define_bang_methods(self)
|
22
|
+
|
15
23
|
end
|
16
24
|
end
|
17
|
-
end
|
25
|
+
end
|
data/lib/zoomus/client.rb
CHANGED
@@ -3,9 +3,9 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Zoomus
|
5
5
|
class Client
|
6
|
-
|
6
|
+
|
7
7
|
include HTTParty
|
8
|
-
|
8
|
+
|
9
9
|
include Utils
|
10
10
|
include Actions::User
|
11
11
|
include Actions::Meeting
|
@@ -14,11 +14,11 @@ module Zoomus
|
|
14
14
|
|
15
15
|
def initialize(*args)
|
16
16
|
|
17
|
-
options =
|
17
|
+
options = extract_options!(args)
|
18
18
|
|
19
19
|
raise argument_error("api_key and api_secret") unless options[:api_key] and options[:api_secret]
|
20
20
|
|
21
|
-
self.class.default_params :api_key => options[:api_key],
|
21
|
+
self.class.default_params :api_key => options[:api_key],
|
22
22
|
:api_secret => options[:api_secret]
|
23
23
|
end
|
24
24
|
|
data/lib/zoomus/error.rb
ADDED
data/lib/zoomus/interface.rb
CHANGED
data/lib/zoomus/utils.rb
CHANGED
@@ -1,30 +1,47 @@
|
|
1
1
|
module Zoomus
|
2
2
|
module Utils
|
3
|
+
|
3
4
|
private
|
4
|
-
|
5
|
-
|
5
|
+
|
6
|
+
def argument_error(name)
|
7
|
+
name ? ArgumentError.new("You must provide #{name}") : ArgumentError
|
8
|
+
end
|
9
|
+
|
10
|
+
def raise_if_error!(response)
|
11
|
+
if response["error"]
|
12
|
+
raise Error.new(response["error"]["message"])
|
13
|
+
else
|
14
|
+
response
|
6
15
|
end
|
16
|
+
end
|
17
|
+
|
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
|
7
23
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
12
31
|
end
|
32
|
+
end
|
13
33
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
break
|
20
|
-
end
|
34
|
+
# Dinamically defines bang methods for Actions modules
|
35
|
+
def self.define_bang_methods(klass)
|
36
|
+
klass.instance_methods.each do |m|
|
37
|
+
klass.send(:define_method, "#{m}!") do |*args|
|
38
|
+
raise_if_error! send(m, *args)
|
21
39
|
end
|
22
40
|
end
|
23
|
-
|
24
|
-
end
|
41
|
+
end
|
25
42
|
|
26
|
-
|
27
|
-
|
28
|
-
|
43
|
+
def extract_options!(array)
|
44
|
+
array.last.is_a?(::Hash) ? array.pop : {}
|
45
|
+
end
|
29
46
|
end
|
30
|
-
end
|
47
|
+
end
|
@@ -20,16 +20,16 @@ describe Zoomus::Actions::User do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns a hash" do
|
23
|
-
expect(@zc.user_create(:email => "foo@bar.com",
|
24
|
-
:first_name => "Foo",
|
25
|
-
:last_name => "Bar",
|
23
|
+
expect(@zc.user_create(:email => "foo@bar.com",
|
24
|
+
:first_name => "Foo",
|
25
|
+
:last_name => "Bar",
|
26
26
|
:type => 1)).to be_kind_of(Hash)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns same params" do
|
30
|
-
res = @zc.user_create(:email => "foo@bar.com",
|
31
|
-
:first_name => "Foo",
|
32
|
-
:last_name => "Bar",
|
30
|
+
res = @zc.user_create(:email => "foo@bar.com",
|
31
|
+
:first_name => "Foo",
|
32
|
+
:last_name => "Bar",
|
33
33
|
:type => 1)
|
34
34
|
|
35
35
|
expect(res["email"]).to eq("foo@bar.com")
|
@@ -0,0 +1,43 @@
|
|
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_custcreate action" do
|
10
|
+
before :each do
|
11
|
+
stub_request(:post, zoomus_url("/user/custcreate")).to_return(:body => json_response("user_custcreate"))
|
12
|
+
end
|
13
|
+
|
14
|
+
it "requires email param" do
|
15
|
+
expect{@zc.user_custcreate(:type => 1, :password => "lolcat")}.to raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "requires type param" do
|
19
|
+
expect{@zc.user_custcreate(:email => "foo@bar.com", :password => "lolcat")}.to raise_error(ArgumentError)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns a hash" do
|
23
|
+
expect(@zc.user_custcreate(:email => "foo@bar.com",
|
24
|
+
:first_name => "Foo",
|
25
|
+
:last_name => "Bar",
|
26
|
+
:password => "lolcat",
|
27
|
+
:type => 1)).to be_kind_of(Hash)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns same params" do
|
31
|
+
res = @zc.user_custcreate(:email => "foo@bar.com",
|
32
|
+
:first_name => "Foo",
|
33
|
+
:last_name => "Bar",
|
34
|
+
:password => "lolcat",
|
35
|
+
:type => 1)
|
36
|
+
|
37
|
+
expect(res["email"]).to eq("foo@bar.com")
|
38
|
+
expect(res["first_name"]).to eq("Foo")
|
39
|
+
expect(res["last_name"]).to eq("Bar")
|
40
|
+
expect(res["type"]).to eq(1)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
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: &69721570 !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: *69721570
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &69721110 !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: *69721110
|
36
36
|
description: A Ruby wrapper for zoom.us API v1
|
37
37
|
email:
|
38
38
|
- collsmaxim@gmail.com
|
@@ -49,19 +49,23 @@ files:
|
|
49
49
|
- lib/zoomus/actions/meeting.rb
|
50
50
|
- lib/zoomus/actions/user.rb
|
51
51
|
- lib/zoomus/client.rb
|
52
|
+
- lib/zoomus/error.rb
|
52
53
|
- lib/zoomus/interface.rb
|
53
54
|
- lib/zoomus/utils.rb
|
54
55
|
- spec/fixtures/meeting_create.json
|
55
56
|
- spec/fixtures/meeting_list.json
|
56
57
|
- spec/fixtures/meeting_update.json
|
57
58
|
- spec/fixtures/user_create.json
|
59
|
+
- spec/fixtures/user_custcreate.json
|
58
60
|
- spec/fixtures/user_list.json
|
59
61
|
- spec/lib/zoomus/actions/meeting/create_spec.rb
|
60
62
|
- spec/lib/zoomus/actions/meeting/list_spec.rb
|
61
63
|
- spec/lib/zoomus/actions/meeting/update_spec.rb
|
62
64
|
- spec/lib/zoomus/actions/user/create_spec.rb
|
65
|
+
- spec/lib/zoomus/actions/user/custcreate_spec.rb
|
63
66
|
- spec/lib/zoomus/actions/user/list_spec.rb
|
64
67
|
- spec/lib/zoomus/client_spec.rb
|
68
|
+
- spec/lib/zoomus/utils_spec.rb
|
65
69
|
- spec/spec_helper.rb
|
66
70
|
- zoomus.gemspec
|
67
71
|
homepage: https://github.com/mllocs/zoomus
|
@@ -93,11 +97,14 @@ test_files:
|
|
93
97
|
- spec/fixtures/meeting_list.json
|
94
98
|
- spec/fixtures/meeting_update.json
|
95
99
|
- spec/fixtures/user_create.json
|
100
|
+
- spec/fixtures/user_custcreate.json
|
96
101
|
- spec/fixtures/user_list.json
|
97
102
|
- spec/lib/zoomus/actions/meeting/create_spec.rb
|
98
103
|
- spec/lib/zoomus/actions/meeting/list_spec.rb
|
99
104
|
- spec/lib/zoomus/actions/meeting/update_spec.rb
|
100
105
|
- spec/lib/zoomus/actions/user/create_spec.rb
|
106
|
+
- spec/lib/zoomus/actions/user/custcreate_spec.rb
|
101
107
|
- spec/lib/zoomus/actions/user/list_spec.rb
|
102
108
|
- spec/lib/zoomus/client_spec.rb
|
109
|
+
- spec/lib/zoomus/utils_spec.rb
|
103
110
|
- spec/spec_helper.rb
|