joinme-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ *.sw[^f]
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@joinme-api --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ joinme-api (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ addressable (2.3.2)
10
+ coderay (1.0.8)
11
+ columnize (0.3.6)
12
+ crack (0.3.1)
13
+ debugger (1.2.1)
14
+ columnize (>= 0.3.1)
15
+ debugger-linecache (~> 1.1.1)
16
+ debugger-ruby_core_source (~> 1.1.4)
17
+ debugger-linecache (1.1.2)
18
+ debugger-ruby_core_source (>= 1.1.1)
19
+ debugger-ruby_core_source (1.1.4)
20
+ diff-lcs (1.1.3)
21
+ growl (1.0.3)
22
+ guard (1.5.2)
23
+ listen (>= 0.4.2)
24
+ lumberjack (>= 1.0.2)
25
+ pry (>= 0.9.10)
26
+ thor (>= 0.14.6)
27
+ guard-bundler (1.0.0)
28
+ bundler (~> 1.0)
29
+ guard (~> 1.1)
30
+ guard-rspec (2.1.0)
31
+ guard (>= 1.1)
32
+ rspec (~> 2.11)
33
+ listen (0.5.3)
34
+ lumberjack (1.0.2)
35
+ method_source (0.8.1)
36
+ pry (0.9.10)
37
+ coderay (~> 1.0.5)
38
+ method_source (~> 0.8)
39
+ slop (~> 3.3.1)
40
+ rb-fsevent (0.9.2)
41
+ rspec (2.11.0)
42
+ rspec-core (~> 2.11.0)
43
+ rspec-expectations (~> 2.11.0)
44
+ rspec-mocks (~> 2.11.0)
45
+ rspec-core (2.11.1)
46
+ rspec-expectations (2.11.3)
47
+ diff-lcs (~> 1.1.3)
48
+ rspec-mocks (2.11.3)
49
+ slop (3.3.3)
50
+ thor (0.16.0)
51
+ webmock (1.8.11)
52
+ addressable (>= 2.2.7)
53
+ crack (>= 0.1.7)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ debugger
60
+ growl (~> 1.0.3)
61
+ guard (~> 1.5.2)
62
+ guard-bundler (~> 1.0.0)
63
+ guard-rspec (~> 2.1.0)
64
+ joinme-api!
65
+ rb-fsevent (~> 0.9.2)
66
+ rspec (~> 2.11.0)
67
+ webmock (~> 1.8.11)
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ group 'backend' do
2
+ guard 'bundler' do
3
+ watch('Gemfile')
4
+ watch('Gemfile.lock')
5
+ end
6
+
7
+ guard 'rspec', rvm: '1.9.3', cli: "--color -d --format nested --color --profile", :bundle => false do
8
+ watch(%r{^spec/.+_spec\.rb$})
9
+ watch(%r{spec/(.*)_spec.rb})
10
+ watch(%r{lib/(.*)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+ end
13
+ end
14
+
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ joinme-api
2
+ ==========
3
+
4
+ A ruby gem that is a simple wrapper for the join.me API
5
+
6
+ ## How to use ##
7
+
8
+ ### Create an Instance ###
9
+
10
+ session = JoinmeApi.new('myemail@gmail.com', 'mypassword')
11
+
12
+ ### Login ###
13
+
14
+ session.login
15
+
16
+ ### Request an Auth Code ###
17
+
18
+ session.request_auth_code
19
+
20
+ ### Request an Meeting Code ###
21
+
22
+ session.request_code
23
+
24
+
25
+ ### Generate a Download URL for a Meeting ###
26
+
27
+ session.download
28
+ session.download_url
29
+
30
+ ## Official Join.Me Documentation ##
31
+
32
+ https://secure.join.me/welcome/webhelp/joinme/join.me/c_joinme_API.html
33
+
34
+ ## Contributing
35
+
36
+ This is a very simple gem and I am sure you could think of something you could
37
+ add to it, please create a pull request.
38
+
39
+ ## Author
40
+
41
+ Paul Hepworth (http://peppyheppy.com)
42
+
43
+ ## License
44
+
45
+ The MIT License (MIT)
46
+ Copyright (c) 2011 Paul Hepworth
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
49
+
50
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require "rspec/core/rake_task"
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ task :default => [:spec]
13
+
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'joinme-api'
3
+ s.author = 'Paul Hepworth'
4
+ s.email = 'paul<dot>hepworth<at>peppyheppy<dot>com'
5
+ s.version = '0.0.1'
6
+ s.homepage = 'https://github.com/peppyheppy/joinme-api'
7
+ s.date = '2012-10-29'
8
+ s.summary = "A gem that provides a basic wrapper for the join.me API"
9
+ s.description = "A gem that provides a basic wrapper for the join.me API (https://secure.join.me/welcome/webhelp/joinme/join.me/c_joinme_API.html)"
10
+ s.files = s.files = `git ls-files`.split("\n")
11
+ s.add_development_dependency 'rspec', '~>2.11.0'
12
+ s.add_development_dependency 'debugger'
13
+ s.add_development_dependency 'rb-fsevent', '~>0.9.2'
14
+ s.add_development_dependency 'guard', '~>1.5.2'
15
+ s.add_development_dependency 'guard-bundler', '~>1.0.0'
16
+ s.add_development_dependency 'guard-rspec', '~>2.1.0'
17
+ s.add_development_dependency 'growl', '~>1.0.3'
18
+ s.add_development_dependency 'webmock', '~>1.8.11'
19
+ end
20
+
data/lib/joinme-api.rb ADDED
@@ -0,0 +1,67 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
4
+ class JoinmeApi
5
+ attr_accessor :email, :password
6
+
7
+ def initialize(email, password)
8
+ @email = email
9
+ @password = password
10
+ end
11
+
12
+ def login
13
+ api_call('login', 'email' => email, 'password' => password) == 'OK'
14
+ end
15
+
16
+ def request_auth_code
17
+ parts = api_call('requestAuthCode', 'email' => email, 'password' => password).split("\n")
18
+ if parts.first == 'OK'
19
+ parts.last.split(': ').last
20
+ end
21
+ end
22
+
23
+ def request_code(auth_code = request_auth_code)
24
+ codes = code_and_ticket(auth_code)
25
+ codes['code']
26
+ end
27
+
28
+ def download(code=nil, ticket=nil)
29
+ codes = {}
30
+ if code and ticket
31
+ codes['code'] = code
32
+ codes['ticket'] = ticket
33
+ else
34
+ codes = code_and_ticket
35
+ end
36
+
37
+ if codes['code'] and codes['ticket']
38
+ "https://secure.join.me/download.aspx?code=%s&ticket=%s" % [codes['code'], codes['ticket']]
39
+ end
40
+ end
41
+ alias :download_url :download
42
+
43
+ private
44
+
45
+ def code_and_ticket(auth_code = request_auth_code)
46
+ parts = api_call('requestCode', 'authcode' => auth_code).split("\n")
47
+ params = {}
48
+ if parts.first == 'OK'
49
+ parts.each do |param|
50
+ key, value = param.split(': ')
51
+ params[key.downcase] = value
52
+ end
53
+ end
54
+ params
55
+ end
56
+
57
+ def api_call(call, params)
58
+ uri = URI("https://secure.join.me/API/#{call}.aspx")
59
+ req = Net::HTTP::Post.new(uri.path)
60
+ req.set_form_data(params)
61
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
62
+ http.request(req)
63
+ end
64
+ res.body.to_s
65
+ end
66
+
67
+ end
@@ -0,0 +1,140 @@
1
+ require 'spec_helper'
2
+
3
+ describe JoinmeApi do
4
+ before :each do
5
+ @api = JoinmeApi.new('p@z.com','qawsed')
6
+ end
7
+
8
+ describe "#new" do
9
+ it "should require email and password" do
10
+ expect {
11
+ JoinmeApi.new
12
+ }.to raise_error(ArgumentError)
13
+ end
14
+ end
15
+
16
+ describe "#login" do
17
+ it "should hit the login api" do
18
+ stub_request(:post, "http://secure.join.me:443/API/login.aspx")
19
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
20
+ .to_return(:status => 200, :body => "OK")
21
+
22
+ @api.login.should be_true
23
+ end
24
+
25
+ it "should handle errors" do
26
+ stub_request(:post, "http://secure.join.me:443/API/login.aspx")
27
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
28
+ .to_return(:status => 200, :body => "ERROR: 4; Invalid email or password")
29
+
30
+ @api.login.should be_false
31
+ end
32
+ end
33
+
34
+ describe "#request_auth_code" do
35
+ it "should return an auth code" do
36
+ stub_request(:post, "http://secure.join.me:443/API/requestAuthCode.aspx")
37
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
38
+ .to_return(:status => 200, :body => "OK\nAUTHCODE: usbzlurwujpw2xbfy1xc2cjiuovaankw")
39
+
40
+ @api.request_auth_code.should == 'usbzlurwujpw2xbfy1xc2cjiuovaankw'
41
+ end
42
+
43
+ it "should handle errors" do
44
+ stub_request(:post, "http://secure.join.me:443/API/requestAuthCode.aspx")
45
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
46
+ .to_return(:status => 200, :body => "ERROR: 4; Invalid email or password")
47
+
48
+ @api.request_auth_code.should be_nil
49
+ end
50
+ end
51
+
52
+ describe "#request_code" do
53
+ it "should return an meeting and ticket codes" do
54
+ # stub the request auth code call
55
+ stub_request(:post, "http://secure.join.me:443/API/requestAuthCode.aspx")
56
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
57
+ .to_return(:status => 200, :body => "OK\nAUTHCODE: usbzlurwujpw2xbfy1xc2cjiuovaankw")
58
+
59
+ # stub the request meeting code
60
+ stub_request(:post, "http://secure.join.me:443/API/requestCode.aspx")
61
+ .with(:body => {"authcode"=>"usbzlurwujpw2xbfy1xc2cjiuovaankw"})
62
+ .to_return(:status => 200, :body => "OK\nCODE: 101494581\nTICKET: 432412671")
63
+
64
+ @api.request_code.should == '101494581'
65
+ end
66
+
67
+ it "should handle errors" do
68
+ # stub the request auth code call
69
+ stub_request(:post, "http://secure.join.me:443/API/requestAuthCode.aspx")
70
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
71
+ .to_return(:status => 200, :body => "OK\nAUTHCODE: usbzlurwujpw2xbfy1xc2cjiuovaankw")
72
+
73
+ stub_request(:post, "http://secure.join.me:443/API/requestCode.aspx")
74
+ .with(:body => {"authcode"=>"usbzlurwujpw2xbfy1xc2cjiuovaankw"})
75
+ .to_return(:status => 200, :body => "ERROR: 4; Invalid email or password")
76
+
77
+ @api.request_code.should be_nil
78
+ end
79
+
80
+ it "should accept the request code as a parameter" do
81
+ stub_request(:post, "http://secure.join.me:443/API/requestCode.aspx")
82
+ .with(:body => {"authcode"=>"usbzlurwujpw2xbfy1xc2cjiuovaankw"})
83
+ .to_return(:status => 200, :body => "ERROR: 4; Invalid email or password")
84
+
85
+ @api.request_code('usbzlurwujpw2xbfy1xc2cjiuovaankw').should be_nil
86
+ end
87
+ end
88
+
89
+ describe "#download and #download_url" do
90
+ it "should return the download url" do
91
+ # stub the request meeting code
92
+ stub_request(:post, "http://secure.join.me:443/API/requestCode.aspx")
93
+ .with(:body => {"authcode"=>"usbzlurwujpw2xbfy1xc2cjiuovaankw"})
94
+ .to_return(:status => 200, :body => "OK\nCODE: 101494581\nTICKET: 432412671")
95
+
96
+ url = "https://secure.join.me/download.aspx?code=101494588&ticket=432412675"
97
+ @api.download('101494588','432412675').should == url
98
+ @api.download_url('101494588','432412675').should == url
99
+ end
100
+
101
+ it "should return the download url" do
102
+ # stub the request meeting code
103
+ stub_request(:post, "http://secure.join.me:443/API/requestCode.aspx")
104
+ .with(:body => {"authcode"=>"usbzlurwujpw2xbfy1xc2cjiuovaankw"})
105
+ .to_return(:status => 200, :body => "OK\nCODE: 101494581\nTICKET: 432412671")
106
+
107
+ url = "https://secure.join.me/download.aspx?code=101494588&ticket=432412675"
108
+ @api.download('101494588','432412675').should == url
109
+ end
110
+
111
+ it "should return the download url" do
112
+ # stub the request auth code call
113
+ stub_request(:post, "http://secure.join.me:443/API/requestAuthCode.aspx")
114
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
115
+ .to_return(:status => 200, :body => "OK\nAUTHCODE: usbzlurwujpw2xbfy1xc2cjiuovaankw")
116
+
117
+ # stub the request meeting code
118
+ stub_request(:post, "http://secure.join.me:443/API/requestCode.aspx")
119
+ .with(:body => {"authcode"=>"usbzlurwujpw2xbfy1xc2cjiuovaankw"})
120
+ .to_return(:status => 200, :body => "OK\nCODE: 101494588\nTICKET: 432412675")
121
+
122
+ url = "https://secure.join.me/download.aspx?code=101494588&ticket=432412675"
123
+ @api.download.should == url
124
+ end
125
+
126
+ it "should handle errors" do
127
+ # stub the request auth code call
128
+ stub_request(:post, "http://secure.join.me:443/API/requestAuthCode.aspx")
129
+ .with(:body => {"email"=>"p@z.com", "password"=>"qawsed"})
130
+ .to_return(:status => 200, :body => "OK\nAUTHCODE: usbzlurwujpw2xbfy1xc2cjiuovaankw")
131
+
132
+ # stub the request meeting code
133
+ stub_request(:post, "http://secure.join.me:443/API/requestCode.aspx")
134
+ .with(:body => {"authcode"=>"usbzlurwujpw2xbfy1xc2cjiuovaankw"})
135
+ .to_return(:status => 200, :body => "ERROR: 4; Invalid email or password")
136
+
137
+ @api.download_url.should be_nil
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,11 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "joinme-api"
4
+ require 'webmock/rspec'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+ config.order = 'random'
11
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: joinme-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paul Hepworth
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70193753743180 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.11.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70193753743180
25
+ - !ruby/object:Gem::Dependency
26
+ name: debugger
27
+ requirement: &70193753742580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70193753742580
36
+ - !ruby/object:Gem::Dependency
37
+ name: rb-fsevent
38
+ requirement: &70193753741680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.2
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70193753741680
47
+ - !ruby/object:Gem::Dependency
48
+ name: guard
49
+ requirement: &70193753740860 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.2
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70193753740860
58
+ - !ruby/object:Gem::Dependency
59
+ name: guard-bundler
60
+ requirement: &70193753740240 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.0.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70193753740240
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: &70193753739520 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 2.1.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70193753739520
80
+ - !ruby/object:Gem::Dependency
81
+ name: growl
82
+ requirement: &70193753738960 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 1.0.3
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70193753738960
91
+ - !ruby/object:Gem::Dependency
92
+ name: webmock
93
+ requirement: &70193753738320 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.8.11
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70193753738320
102
+ description: A gem that provides a basic wrapper for the join.me API (https://secure.join.me/welcome/webhelp/joinme/join.me/c_joinme_API.html)
103
+ email: paul<dot>hepworth<at>peppyheppy<dot>com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - .gitignore
109
+ - .rspec
110
+ - .rvmrc
111
+ - Gemfile
112
+ - Gemfile.lock
113
+ - Guardfile
114
+ - README.md
115
+ - Rakefile
116
+ - joinme-api.gemspec
117
+ - lib/joinme-api.rb
118
+ - spec/lib/joinme_api_spec.rb
119
+ - spec/spec_helper.rb
120
+ homepage: https://github.com/peppyheppy/joinme-api
121
+ licenses: []
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 1.8.17
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: A gem that provides a basic wrapper for the join.me API
144
+ test_files: []