go_to_webinar 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d43d6f762ca5220ad5433530c4aa522145d01b2b3b2ba344e05cbbad8f287632
4
- data.tar.gz: a2ceb56bf221130d0281c7228f75a513dd05e1e02962b8aed8042445ee4ce586
3
+ metadata.gz: 19769749decf1f85cdef785033508713f861605fe4f774eaef3d1c71f1415e35
4
+ data.tar.gz: dd1861bb0ee155828a73e4a70d97de4c2acb7ce49de6cf19c3d76ee789e3a299
5
5
  SHA512:
6
- metadata.gz: 52e025f554558571f5789341ff885474d523dd375ae3c98bdfee85df040d54639406e00393377d392f1775f4bc7a7527839ac2667ec5317c84ce480f78297259
7
- data.tar.gz: c68ad45122be7467ecd51271cb9393a54ace0727ce17fb7c338b4b9d23c2bfe4c44bb9bb45e4a6dacc7d59c66160b9c2d775ad1d1803d81794a6d946bda4a674
6
+ metadata.gz: 45ae3ffb0b21c2326d60bf37b8daa912d629793b43e2ec2a30be2c434009b28eb80f55fcbc1bada32f69d80986899aad73ffeba1f6979c2c318de15df655d5af
7
+ data.tar.gz: 46b4c88cfff2aaf456754b554b1cf195f4c55e5b5379b8073f00bac5ac8cb099f7cd2efa67d9f1d05101531e227b88061531909b69dfa0854be4edb8fa2c35cf
data/lib/go_to_webinar.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  require 'rest-client'
2
2
  require 'json'
3
- require 'go_to_webinar/attendee'
4
- require 'go_to_webinar/client'
5
- require 'go_to_webinar/configuration'
6
- require 'go_to_webinar/auth'
7
- require 'go_to_webinar/registrant'
8
- require 'go_to_webinar/session'
9
- require 'go_to_webinar/version'
10
- require 'go_to_webinar/webinar'
3
+ require_relative 'go_to_webinar/attendee'
4
+ require_relative 'go_to_webinar/client'
5
+ require_relative 'go_to_webinar/configuration'
6
+ require_relative 'go_to_webinar/auth'
7
+ require_relative 'go_to_webinar/registrant'
8
+ require_relative 'go_to_webinar/session'
9
+ require_relative 'go_to_webinar/version'
10
+ require_relative 'go_to_webinar/webinar'
11
11
 
12
12
  module GoToWebinar
13
13
  class << self
@@ -1,9 +1,9 @@
1
1
  require 'oauth2'
2
- require_relative 'auth/client'
3
- require_relative 'auth/configuration'
2
+ require 'go_to_webinar/auth/client'
3
+ require 'go_to_webinar/auth/configuration'
4
4
 
5
5
  module GoToWebinar
6
- class Auth
6
+ module Auth
7
7
  class << self
8
8
  attr_accessor :client, :configuration
9
9
 
@@ -1,88 +1,90 @@
1
1
  require 'oauth2'
2
2
  require 'redis'
3
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
4
+ module GoToWebinar
5
+ module Auth
6
+ class Client
7
+ attr_accessor :basic_auth_username, :basic_auth_password, :consumer_key, :secret_key
8
+
9
+ def initialize(basic_auth_username:, basic_auth_password:, consumer_key:, secret_key:)
10
+ config = GoToWebinar::Auth.configuration
11
+ @redis = Redis.new(url: config.redis_url)
12
+ @basic_auth_username = basic_auth_username || config.basic_auth_username
13
+ @basic_auth_password = basic_auth_password || config.basic_auth_password
14
+ @consumer_key = consumer_key || config.consumer_key
15
+ @secret_key = secret_key || config.secret_key
16
+ @site = config.site
17
+ @authorize_url = config.authorize_url
18
+ @token_url = config.token_url
19
+ @auth_scheme = config.auth_scheme
20
+ @oauth2_client = new_oauth2_client
21
+ end
21
22
 
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
23
+ def new_oauth2_client
24
+ oauth2_client = OAuth2::Client.new(
25
+ consumer_key,
26
+ secret_key,
27
+ site: site,
28
+ authorize_url: authorize_url,
29
+ token_url: token_url,
30
+ auth_scheme: auth_scheme
31
+ )
32
+ end
32
33
 
33
- def access_token
34
- @access_token || get_access_token_from_redis || get_new_access_token
35
- end
34
+ def access_token
35
+ @access_token || get_access_token_from_redis || get_new_access_token
36
+ end
36
37
 
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
38
+ def get_new_access_token
39
+ token = oauth2_client.password.get_token(basic_auth_username, basic_auth_password)
40
+ save_to_redis(token)
41
+ @access_token = token
42
+ end
42
43
 
43
- def refresh_access_token
44
- @access_token = access_token&.refresh!
45
- end
44
+ def refresh_access_token
45
+ @access_token = access_token&.refresh!
46
+ end
46
47
 
47
- private
48
+ private
48
49
 
49
- attr_accessor :redis, :site, :authorize_url, :authorize_url_optional_params
50
- attr_accessor :token_url, :auth_scheme, :oauth2_client
50
+ attr_accessor :redis, :site, :authorize_url, :authorize_url_optional_params
51
+ attr_accessor :token_url, :auth_scheme, :oauth2_client
51
52
 
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
53
+ def get_access_token_from_redis(redis_key: 'g2w_access_token')
54
+ # retrieve from redis
55
+ token_json = @redis.get(redis_key)
56
+ token_hash = JSON.parse(token_json)&.[]("token") if token_json
57
+ @access_token = OAuth2::AccessToken.from_hash(oauth2_client, token_hash) if token_hash
57
58
 
58
- # if we found it redis, let's return it
59
- return @access_token if @access_token
59
+ # if we found it redis, let's return it
60
+ return @access_token if @access_token
60
61
 
61
- # if it doesn't currently exist in redis, return nil
62
- nil
63
- end
62
+ # if it doesn't currently exist in redis, return nil
63
+ nil
64
+ end
64
65
 
65
- def save_to_redis(token, redis_key: 'g2w_access_token')
66
- @redis.set(redis_key, token.to_hash.to_json)
67
- end
66
+ def save_to_redis(token, redis_key: 'g2w_access_token')
67
+ @redis.set(redis_key, token.to_hash.to_json)
68
+ end
68
69
 
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
70
+ def oauth2_client
71
+ OAuth2::Client.new(
72
+ consumer_key,
73
+ secret_key,
74
+ site: site,
75
+ authorize_url: authorize_url,
76
+ token_url: token_url,
77
+ auth_scheme: auth_scheme
78
+ )
79
+ end
79
80
 
80
- def authorize_url
81
- authorize_url + '?' + authorize_url_params
82
- end
81
+ def authorize_url
82
+ authorize_url + '?' + authorize_url_params
83
+ end
83
84
 
84
- def authorize_url_params
85
- URI.encode_www_form({client_id: consumer_key}.merge(authorize_url_optional_params))
85
+ def authorize_url_params
86
+ URI.encode_www_form({client_id: consumer_key}.merge(authorize_url_optional_params))
87
+ end
86
88
  end
87
89
  end
88
90
  end
@@ -1,38 +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
1
+ module GoToWebinar
2
+ module Auth
3
+ class Configuration
4
+ attr_accessor :redis_url, :consumer_key, :secret_key, :site
5
+ attr_accessor :authorize_url, :token_url, :auth_scheme
6
+ attr_accessor :basic_auth_username, :basic_auth_password
7
+ attr_accessor :authorize_optional_params
7
8
 
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
9
+ def initialize
10
+ @site = GoToWebinar::Auth::Configuration.site
11
+ @authorize_url = GoToWebinar::Auth::Configuration.authorize_url
12
+ @authorize_optional_params = GoToWebinar::Auth::Configuration.authorize_optional_params
13
+ @token_url = GoToWebinar::Auth::Configuration.token_url
14
+ @auth_scheme = GoToWebinar::Auth::Configuration.auth_scheme
15
+ end
15
16
 
16
- def self.site
17
- 'https://api.getgo.com'
18
- end
17
+ def self.site
18
+ 'https://api.getgo.com'
19
+ end
19
20
 
20
- def self.authorize_url
21
- '/oauth/v2/authorize'
22
- end
21
+ def self.authorize_url
22
+ '/oauth/v2/authorize'
23
+ end
23
24
 
24
- def self.authorize_optional_params
25
- { response_type: "code" }
26
- end
25
+ def self.authorize_optional_params
26
+ { response_type: "code" }
27
+ end
27
28
 
28
- def self.token_url
29
- '/oauth/v2/token'
30
- end
29
+ def self.token_url
30
+ '/oauth/v2/token'
31
+ end
31
32
 
32
- def self.auth_scheme
33
- 'basic_auth'
33
+ def self.auth_scheme
34
+ 'basic_auth'
35
+ end
34
36
  end
35
37
  end
36
38
  end
37
-
38
- redis = Redis.new(url: ENV['REDISCLOUD_URL'] )
@@ -1,3 +1,3 @@
1
1
  module GoToWebinar
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Jeremias da Silva