joinme2 0.2.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/joinme2.gemspec +28 -0
- data/lib/joinme2/client.rb +132 -0
- data/lib/joinme2/configuration.rb +40 -0
- data/lib/joinme2/error.rb +5 -0
- data/lib/joinme2/mashed_parser.rb +19 -0
- data/lib/joinme2/version.rb +3 -0
- data/lib/joinme2.rb +20 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 08826b79346324b52a44409961b9414873791dcf
|
4
|
+
data.tar.gz: 124c30db68e0f8a643b1cac8a8cfd4f341c098d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b175560937ca87102a46c1d3810c707178c8f13202013c9bfd58428cf3a08079b870de65ff8f91996dd6ccaa2a317f24b927f670599886a12271d6a9bb1a164
|
7
|
+
data.tar.gz: cab98f8d3c7396b6938c69a5b3eda693dcb569bacc852e64fe6e0d5ac3bc3d7482d0a6f043d844482ee1fddebcef34ae57e4464c184762b251ee4138a5da4d4b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Tomas Koutsky
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Joinme2
|
2
|
+
Simple Ruby wrapper for the JoinMe API
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'joinme2'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install joinme2
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Joinme2.configure do |config|
|
24
|
+
config.client_id = 'CLIENT_ID'
|
25
|
+
config.redirect_uri = 'REDIRECT_URI'
|
26
|
+
end
|
27
|
+
|
28
|
+
joinme = Joinme2.client(oauth_token: 'OAUTH_TOKEN')
|
29
|
+
# => #<Joinme2::Client:0x00000003d96ab8...
|
30
|
+
|
31
|
+
joinme.authorize_url
|
32
|
+
# => "https://secure.join.me/api/public/v1/auth/oauth2?..."
|
33
|
+
|
34
|
+
joinme.start_new_meeting
|
35
|
+
|
36
|
+
joinme.schedule_new_meeting('Test Meeting',
|
37
|
+
['ex1@example.com', 'ex2@example.com'],
|
38
|
+
'2016-06-21T16:00:00+02:00',
|
39
|
+
'2016-06-21T17:00:00+02:00')
|
40
|
+
|
41
|
+
joinme.update_meeting(23, 'Updated Name',
|
42
|
+
['up1@example.com', 'up2@example.com'],
|
43
|
+
'2016-07-21T16:00:00+02:00',
|
44
|
+
'2016-07-21T17:00:00+02:00')
|
45
|
+
|
46
|
+
joinme.delete_meeting(23)
|
47
|
+
|
48
|
+
joinme.get_user
|
49
|
+
```
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/joinme2.
|
60
|
+
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
65
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'joinme2'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require 'pry'
|
11
|
+
Pry.start
|
12
|
+
|
13
|
+
# require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/joinme2.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'joinme2/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'joinme2'
|
8
|
+
spec.version = Joinme2::VERSION
|
9
|
+
spec.authors = ['Tomas Koutsky']
|
10
|
+
spec.email = ['tomas@stepnivlk.net']
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby wrapper for Joinme API.}
|
13
|
+
spec.description = %q{With this gem you can easily manage all your meetings.}
|
14
|
+
spec.homepage = 'https://github.com/stepnivlk/joinme2'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'httparty'
|
23
|
+
spec.add_runtime_dependency 'hashie'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require_relative './mashed_parser'
|
3
|
+
|
4
|
+
module Joinme2
|
5
|
+
class Client
|
6
|
+
attr_accessor :base_uri,
|
7
|
+
:default_scopes,
|
8
|
+
:redirect_uri,
|
9
|
+
:client_id,
|
10
|
+
:auth_uri
|
11
|
+
|
12
|
+
include HTTParty
|
13
|
+
parser Class.new HTTParty::Parser
|
14
|
+
parser.send :include, MashedParser
|
15
|
+
|
16
|
+
def initialize(options = {})
|
17
|
+
oauth_token = options[:oauth_token]
|
18
|
+
|
19
|
+
options = Joinme2.options.merge(options)
|
20
|
+
[:base_uri, :default_scopes, :redirect_uri, :client_id, :auth_uri].each do |accessor|
|
21
|
+
send("#{accessor}=", options[accessor])
|
22
|
+
end
|
23
|
+
|
24
|
+
self.class.base_uri base_uri
|
25
|
+
@options = {
|
26
|
+
headers: {
|
27
|
+
"Authorization" => "Bearer #{oauth_token}",
|
28
|
+
"Content-Type" => "application/json",
|
29
|
+
"User-Agent" => 'X-JOINME-CLIENT'
|
30
|
+
}
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Public: Generates Joinme authorization url based on client_id, auth_uri
|
35
|
+
# redirect_uri and scopes. Redirect URI has to match configured Joinme
|
36
|
+
# Application callback URL.
|
37
|
+
#
|
38
|
+
# Examples:
|
39
|
+
#
|
40
|
+
# authorize_url(redirect_uri: 'http://example.com/',
|
41
|
+
# scope: "user_info scheduler start_meeting",
|
42
|
+
# client_id: "XXXXX")
|
43
|
+
# # =>
|
44
|
+
# "https://secure.join.me/api/public/v1/auth/oauth2..."
|
45
|
+
#
|
46
|
+
# Returns authorization url as a string.
|
47
|
+
def authorize_url(options = {})
|
48
|
+
params = {}
|
49
|
+
params[:scope] = options[:scope] || default_scopes
|
50
|
+
params[:redirect_uri] = options[:redirect_uri] || redirect_uri
|
51
|
+
params[:client_id] = options[:client_id] || client_id
|
52
|
+
URI.parse(auth_uri).tap do |uri|
|
53
|
+
uri.query = URI.encode_www_form params
|
54
|
+
end.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
# Public: Connects to Joinme API and starts new meeting.
|
58
|
+
#
|
59
|
+
# Returns Hashie::Mash representation of API response.
|
60
|
+
def start_new_meeting(body = { "startWithPersonalUrl": false })
|
61
|
+
payload = @options.dup
|
62
|
+
payload[:body] = body.to_json
|
63
|
+
self.class.post('/meetings/start', payload)
|
64
|
+
end
|
65
|
+
|
66
|
+
def start_sheduled_meeting(id)
|
67
|
+
self.class.post("/meetings/#{id}/start", @options)
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_scheduled_meeting(id)
|
71
|
+
self.class.get("/meetings/#{id}", @options)
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_scheduled_meetings(end_date = nil)
|
75
|
+
payload = @options.dup
|
76
|
+
payload[:headers][:endDate] = end_date if end_date
|
77
|
+
self.class.get('/meetings', @options)
|
78
|
+
end
|
79
|
+
|
80
|
+
def schedule_new_meeting(name, participants = [], start_date, end_date)
|
81
|
+
body = {}
|
82
|
+
body[:startWithPersonalUrl] = false
|
83
|
+
body[:meetingStart] = iso_date!(start_date)
|
84
|
+
body[:meetingEnd] = iso_date!(end_date)
|
85
|
+
body[:meetingName] = name
|
86
|
+
body[:participants] = participants
|
87
|
+
payload = @options.dup
|
88
|
+
payload[:body] = body.to_json
|
89
|
+
self.class.post('/meetings', payload)
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_meeting(id, name = nil, participant = nil, start_date = nil, end_date = nil)
|
93
|
+
body = {}
|
94
|
+
body[:meetingStart] = iso_date(start_date)
|
95
|
+
body[:meetingEnd] = iso_date(end_datee)
|
96
|
+
body[:meetingName] = name
|
97
|
+
body[:participants] = participants
|
98
|
+
payload = @options.dup
|
99
|
+
payload[:body] = body.to_json
|
100
|
+
self.class.patch("/meetings/#{id}", payload)
|
101
|
+
end
|
102
|
+
|
103
|
+
def delete_meeting(id)
|
104
|
+
self.class.delete("/meetings/#{id}", @options)
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_user
|
108
|
+
self.class.get('/user', @options)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def iso_date!(date)
|
114
|
+
parse_date(date, true)
|
115
|
+
end
|
116
|
+
|
117
|
+
def iso_date(date)
|
118
|
+
parse_date(date)
|
119
|
+
end
|
120
|
+
|
121
|
+
def parse_date(date, throw_exception = false)
|
122
|
+
case
|
123
|
+
when date.is_a?(String)
|
124
|
+
DateTime.parse(date).iso8601
|
125
|
+
when date.is_a?(DateTime)
|
126
|
+
date.iso8601
|
127
|
+
else
|
128
|
+
throw_exception ? (raise BadInputDate) : nil
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Joinme2
|
2
|
+
module Configuration
|
3
|
+
AUTH_URI = 'https://secure.join.me/api/public/v1/auth/oauth2'.freeze
|
4
|
+
BASE_URI = 'https://api.join.me/v1/'.freeze
|
5
|
+
API_KEY = nil
|
6
|
+
REDIRECT_URI = nil
|
7
|
+
CLIENT_ID = nil
|
8
|
+
DEFAULT_SCOPES = 'user_info scheduler start_meeting'.freeze
|
9
|
+
|
10
|
+
VALID_ACCESSORS = [:base_uri,
|
11
|
+
:default_scopes,
|
12
|
+
:redirect_uri,
|
13
|
+
:client_id,
|
14
|
+
:auth_uri].freeze
|
15
|
+
|
16
|
+
attr_accessor *VALID_ACCESSORS
|
17
|
+
|
18
|
+
def configure
|
19
|
+
yield self
|
20
|
+
end
|
21
|
+
|
22
|
+
def options
|
23
|
+
VALID_ACCESSORS.inject({}) do |accessor, key|
|
24
|
+
accessor.merge!(key => send(key))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.extended(mod)
|
29
|
+
mod.set_defaults
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_defaults
|
33
|
+
self.base_uri = BASE_URI
|
34
|
+
self.default_scopes = DEFAULT_SCOPES
|
35
|
+
self.redirect_uri = REDIRECT_URI
|
36
|
+
self.client_id = CLIENT_ID
|
37
|
+
self.auth_uri = AUTH_URI
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/joinme2.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "joinme2/version"
|
2
|
+
require File.expand_path('../joinme2/configuration', __FILE__)
|
3
|
+
require File.expand_path('../joinme2/client', __FILE__)
|
4
|
+
|
5
|
+
module Joinme2
|
6
|
+
extend Configuration
|
7
|
+
|
8
|
+
def self.client(options = {})
|
9
|
+
Joinme2::Client.new(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.method_missing(method, *args, &block)
|
13
|
+
return super unless client.respond_to?(method)
|
14
|
+
client.send(method, *args, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.respond_to?(method, include_all = false)
|
18
|
+
return client.respond_to?(method, include_all) || super
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: joinme2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomas Koutsky
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: With this gem you can easily manage all your meetings.
|
98
|
+
email:
|
99
|
+
- tomas@stepnivlk.net
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/console
|
111
|
+
- bin/setup
|
112
|
+
- joinme2.gemspec
|
113
|
+
- lib/joinme2.rb
|
114
|
+
- lib/joinme2/client.rb
|
115
|
+
- lib/joinme2/configuration.rb
|
116
|
+
- lib/joinme2/error.rb
|
117
|
+
- lib/joinme2/mashed_parser.rb
|
118
|
+
- lib/joinme2/version.rb
|
119
|
+
homepage: https://github.com/stepnivlk/joinme2
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.6.4
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Ruby wrapper for Joinme API.
|
143
|
+
test_files: []
|
144
|
+
has_rdoc:
|