go_to_webinar 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/go_to_webinar.gemspec +4 -4
- data/lib/go_to_webinar.rb +1 -1
- data/lib/go_to_webinar/auth.rb +24 -0
- data/lib/go_to_webinar/auth/client.rb +88 -0
- data/lib/go_to_webinar/auth/configuration.rb +38 -0
- data/lib/go_to_webinar/client.rb +1 -1
- data/lib/go_to_webinar/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d43d6f762ca5220ad5433530c4aa522145d01b2b3b2ba344e05cbbad8f287632
|
4
|
+
data.tar.gz: a2ceb56bf221130d0281c7228f75a513dd05e1e02962b8aed8042445ee4ce586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e025f554558571f5789341ff885474d523dd375ae3c98bdfee85df040d54639406e00393377d392f1775f4bc7a7527839ac2667ec5317c84ce480f78297259
|
7
|
+
data.tar.gz: c68ad45122be7467ecd51271cb9393a54ace0727ce17fb7c338b4b9d23c2bfe4c44bb9bb45e4a6dacc7d59c66160b9c2d775ad1d1803d81794a6d946bda4a674
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# GoToWebinar
|
2
2
|
|
3
|
-
|
3
|
+
A ruby client to connect GoToWebinar API.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,15 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
### Rails
|
24
|
+
|
25
|
+
config/initializers/go_to_webinar.rb
|
26
|
+
```ruby
|
27
|
+
GoToWebinar.setup do |g2w|
|
28
|
+
g2w.organizer_key = ENV['G2W_ORGANIZER_KEY']
|
29
|
+
g2w.access_token = ENV['G2W_ACCESS_TOKEN']
|
30
|
+
end
|
31
|
+
```
|
24
32
|
|
25
33
|
## Development
|
26
34
|
|
@@ -30,7 +38,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
38
|
|
31
39
|
## Contributing
|
32
40
|
|
33
|
-
|
41
|
+
The repository maintainer only intends to add the functionality necessary for the maintainers need, this will not include all functionality or support all API of GoToWebinar. If you would like to contribute, pull requests are welcome.
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/RecruitiFi/go_to_webinar.
|
34
44
|
|
35
45
|
## License
|
36
46
|
|
data/go_to_webinar.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ['Danilo Jeremias da Silva', 'Michael Bennett']
|
11
11
|
spec.email = ['daniloj.dasilva@gmail.com', 'michael@michaelbennett.nyc']
|
12
12
|
|
13
|
-
spec.summary = '
|
14
|
-
spec.description = '
|
13
|
+
spec.summary = 'Ruby SDK for GoToWebinar'
|
14
|
+
spec.description = 'Full client including authentication for GoToWebinar API V1'
|
15
15
|
spec.homepage = 'https://github.com/RecruitiFi/go_to_webinar'.freeze
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
@@ -23,10 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_dependency 'rest-client','~> 2.0'
|
26
|
-
spec.add_dependency 'oauth2', '~> 1.4.4'
|
26
|
+
spec.add_dependency 'oauth2', '~> 1.4', '>= 1.4.4'
|
27
27
|
spec.add_dependency 'redis', '~> 4.0'
|
28
28
|
|
29
|
-
spec.add_development_dependency 'bundler', '~> 2.1.4'
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
30
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
31
31
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
32
32
|
spec.add_development_dependency 'webmock', '~> 3.0'
|
data/lib/go_to_webinar.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
require 'go_to_webinar/attendee'
|
4
4
|
require 'go_to_webinar/client'
|
5
5
|
require 'go_to_webinar/configuration'
|
6
|
-
require 'go_to_webinar/
|
6
|
+
require 'go_to_webinar/auth'
|
7
7
|
require 'go_to_webinar/registrant'
|
8
8
|
require 'go_to_webinar/session'
|
9
9
|
require 'go_to_webinar/version'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'oauth2'
|
2
|
+
require_relative 'auth/client'
|
3
|
+
require_relative 'auth/configuration'
|
4
|
+
|
5
|
+
module GoToWebinar
|
6
|
+
class Auth
|
7
|
+
class << self
|
8
|
+
attr_accessor :client, :configuration
|
9
|
+
|
10
|
+
def client
|
11
|
+
@client ||= GoToWebinar::Auth::Client.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
@configuration ||= GoToWebinar::Auth::Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
yield(configuration)
|
20
|
+
@client = nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'oauth2'
|
2
|
+
require 'redis'
|
3
|
+
|
4
|
+
module GoToWebinar::Auth
|
5
|
+
class Client
|
6
|
+
attr_accessor :basic_auth_username, :basic_auth_password, :consumer_key, :secret_key
|
7
|
+
|
8
|
+
def initialize(basic_auth_username:, basic_auth_password:, consumer_key:, secret_key:)
|
9
|
+
config = GoToWebinar::Auth.configuration
|
10
|
+
@redis = Redis.new(url: config.redis_url)
|
11
|
+
@basic_auth_username = basic_auth_username || config.basic_auth_username
|
12
|
+
@basic_auth_password = basic_auth_password || config.basic_auth_password
|
13
|
+
@consumer_key = consumer_key || config.consumer_key
|
14
|
+
@secret_key = secret_key || config.secret_key
|
15
|
+
@site = config.site
|
16
|
+
@authorize_url = config.authorize_url
|
17
|
+
@token_url = config.token_url
|
18
|
+
@auth_scheme = config.auth_scheme
|
19
|
+
@oauth2_client = new_oauth2_client
|
20
|
+
end
|
21
|
+
|
22
|
+
def new_oauth2_client
|
23
|
+
oauth2_client = OAuth2::Client.new(
|
24
|
+
consumer_key,
|
25
|
+
secret_key,
|
26
|
+
site: site,
|
27
|
+
authorize_url: authorize_url,
|
28
|
+
token_url: token_url,
|
29
|
+
auth_scheme: auth_scheme
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def access_token
|
34
|
+
@access_token || get_access_token_from_redis || get_new_access_token
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_new_access_token
|
38
|
+
token = oauth2_client.password.get_token(basic_auth_username, basic_auth_password)
|
39
|
+
save_to_redis(token)
|
40
|
+
@access_token = token
|
41
|
+
end
|
42
|
+
|
43
|
+
def refresh_access_token
|
44
|
+
@access_token = access_token&.refresh!
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
attr_accessor :redis, :site, :authorize_url, :authorize_url_optional_params
|
50
|
+
attr_accessor :token_url, :auth_scheme, :oauth2_client
|
51
|
+
|
52
|
+
def get_access_token_from_redis(redis_key: 'g2w_access_token')
|
53
|
+
# retrieve from redis
|
54
|
+
token_json = @redis.get(redis_key)
|
55
|
+
token_hash = JSON.parse(token_json)&.[]("token") if token_json
|
56
|
+
@access_token = OAuth2::AccessToken.from_hash(oauth2_client, token_hash) if token_hash
|
57
|
+
|
58
|
+
# if we found it redis, let's return it
|
59
|
+
return @access_token if @access_token
|
60
|
+
|
61
|
+
# if it doesn't currently exist in redis, return nil
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def save_to_redis(token, redis_key: 'g2w_access_token')
|
66
|
+
@redis.set(redis_key, token.to_hash.to_json)
|
67
|
+
end
|
68
|
+
|
69
|
+
def oauth2_client
|
70
|
+
OAuth2::Client.new(
|
71
|
+
consumer_key,
|
72
|
+
secret_key,
|
73
|
+
site: site,
|
74
|
+
authorize_url: authorize_url,
|
75
|
+
token_url: token_url,
|
76
|
+
auth_scheme: auth_scheme
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def authorize_url
|
81
|
+
authorize_url + '?' + authorize_url_params
|
82
|
+
end
|
83
|
+
|
84
|
+
def authorize_url_params
|
85
|
+
URI.encode_www_form({client_id: consumer_key}.merge(authorize_url_optional_params))
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module GoToWebinar::Auth
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :redis_url, :consumer_key, :secret_key, :site
|
4
|
+
attr_accessor :authorize_url, :token_url, :auth_scheme
|
5
|
+
attr_accessor :basic_auth_username, :basic_auth_password
|
6
|
+
attr_accessor :authorize_optional_params
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@site = GoToWebinar::Auth::Configuration.site
|
10
|
+
@authorize_url = GoToWebinar::Auth::Configuration.authorize_url
|
11
|
+
@authorize_optional_params = GoToWebinar::Auth::Configuration.authorize_optional_params
|
12
|
+
@token_url = GoToWebinar::Auth::Configuration.token_url
|
13
|
+
@auth_scheme = GoToWebinar::Auth::Configuration.auth_scheme
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.site
|
17
|
+
'https://api.getgo.com'
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.authorize_url
|
21
|
+
'/oauth/v2/authorize'
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.authorize_optional_params
|
25
|
+
{ response_type: "code" }
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.token_url
|
29
|
+
'/oauth/v2/token'
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.auth_scheme
|
33
|
+
'basic_auth'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
redis = Redis.new(url: ENV['REDISCLOUD_URL'] )
|
data/lib/go_to_webinar/client.rb
CHANGED
@@ -6,7 +6,7 @@ module GoToWebinar
|
|
6
6
|
config = GoToWebinar.configuration
|
7
7
|
@url = url || config.url
|
8
8
|
@organizer_key = organizer_key || config.organizer_key
|
9
|
-
@g2w_oauth2_client = GoToWebinar::
|
9
|
+
@g2w_oauth2_client = GoToWebinar::Auth::Client.new
|
10
10
|
@access_token = @g2w_oauth2_client.access_token&.token || config.access_token
|
11
11
|
end
|
12
12
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_to_webinar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Jeremias da Silva
|
@@ -30,6 +30,9 @@ dependencies:
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.4'
|
35
|
+
- - ">="
|
33
36
|
- !ruby/object:Gem::Version
|
34
37
|
version: 1.4.4
|
35
38
|
type: :runtime
|
@@ -37,6 +40,9 @@ dependencies:
|
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
38
41
|
requirements:
|
39
42
|
- - "~>"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '1.4'
|
45
|
+
- - ">="
|
40
46
|
- !ruby/object:Gem::Version
|
41
47
|
version: 1.4.4
|
42
48
|
- !ruby/object:Gem::Dependency
|
@@ -58,6 +64,9 @@ dependencies:
|
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
59
65
|
requirements:
|
60
66
|
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
69
|
+
- - ">="
|
61
70
|
- !ruby/object:Gem::Version
|
62
71
|
version: 2.1.4
|
63
72
|
type: :development
|
@@ -65,6 +74,9 @@ dependencies:
|
|
65
74
|
version_requirements: !ruby/object:Gem::Requirement
|
66
75
|
requirements:
|
67
76
|
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '2.1'
|
79
|
+
- - ">="
|
68
80
|
- !ruby/object:Gem::Version
|
69
81
|
version: 2.1.4
|
70
82
|
- !ruby/object:Gem::Dependency
|
@@ -109,7 +121,7 @@ dependencies:
|
|
109
121
|
- - "~>"
|
110
122
|
- !ruby/object:Gem::Version
|
111
123
|
version: '3.0'
|
112
|
-
description:
|
124
|
+
description: Full client including authentication for GoToWebinar API V1
|
113
125
|
email:
|
114
126
|
- daniloj.dasilva@gmail.com
|
115
127
|
- michael@michaelbennett.nyc
|
@@ -129,6 +141,9 @@ files:
|
|
129
141
|
- go_to_webinar.gemspec
|
130
142
|
- lib/go_to_webinar.rb
|
131
143
|
- lib/go_to_webinar/attendee.rb
|
144
|
+
- lib/go_to_webinar/auth.rb
|
145
|
+
- lib/go_to_webinar/auth/client.rb
|
146
|
+
- lib/go_to_webinar/auth/configuration.rb
|
132
147
|
- lib/go_to_webinar/client.rb
|
133
148
|
- lib/go_to_webinar/configuration.rb
|
134
149
|
- lib/go_to_webinar/registrant.rb
|
@@ -158,5 +173,5 @@ rubyforge_project:
|
|
158
173
|
rubygems_version: 2.7.9
|
159
174
|
signing_key:
|
160
175
|
specification_version: 4
|
161
|
-
summary:
|
176
|
+
summary: Ruby SDK for GoToWebinar
|
162
177
|
test_files: []
|