go_to_webinar 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +6 -0
- data/Rakefile +3 -1
- data/bin/console +4 -3
- data/go_to_webinar.gemspec +4 -4
- data/lib/go_to_webinar/attendee.rb +2 -16
- data/lib/go_to_webinar/auth/client.rb +8 -4
- data/lib/go_to_webinar/auth/configuration.rb +8 -6
- data/lib/go_to_webinar/auth.rb +2 -0
- data/lib/go_to_webinar/client.rb +11 -11
- data/lib/go_to_webinar/configuration.rb +2 -0
- data/lib/go_to_webinar/registrant.rb +2 -0
- data/lib/go_to_webinar/session.rb +3 -1
- data/lib/go_to_webinar/version.rb +3 -1
- data/lib/go_to_webinar/webinar.rb +5 -3
- data/lib/go_to_webinar.rb +5 -8
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20e96ae2144706c7d710cd56359cae66931b419d60e68b2e76d275676a41a202
|
4
|
+
data.tar.gz: d9dff259f71d18c5d781f09e16207c6e81091cf05453745ea8102fea2c80df87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c035b9793528e92f23e121d02751108350d0737c446b26068d5a84dcd929f973d140a45afccd1bfa7d5d979c885eb6a0850d30d0065864e51bf402a4cf7a322f
|
7
|
+
data.tar.gz: 97912f8b38811b63fd06f84825a1cc4865f4b595003f9ce9581ca5bed7946f2ad3a140cc1af684d2c7aba0d790e392f97f69407c782c3d6b938ccc7b4ae95cb3
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in go_to_webinar.gemspec
|
6
8
|
gemspec
|
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
A ruby client to connect GoToWebinar API V1. Will handle the complete OAuth lifecycle as well utilizing Redis and the OAuth2 gems.
|
4
4
|
|
5
|
+
## Caution
|
6
|
+
|
7
|
+
This gem is still under active development and may become unstable version to version with no promises of backward compatibility, the objective is to reach some semblence of reliability by v0.5.x -- in the interim, if you find a version that works for you, strictly specify that version in your gem file.
|
8
|
+
|
9
|
+
During this period of development, documentation and testing will be minimal and or non-existant.
|
10
|
+
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'go_to_webinar'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "go_to_webinar"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/go_to_webinar.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'go_to_webinar/version'
|
6
6
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.summary = 'Ruby SDK for GoToWebinar'
|
14
14
|
spec.description = 'Full client including authentication for GoToWebinar API V1'
|
15
|
-
spec.homepage = 'https://github.com/RecruitiFi/go_to_webinar'
|
15
|
+
spec.homepage = 'https://github.com/RecruitiFi/go_to_webinar'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency 'rest-client','~> 2.0'
|
26
25
|
spec.add_dependency 'oauth2', '~> 1.4', '>= 1.4.4'
|
27
26
|
spec.add_dependency 'redis', '~> 4.0'
|
27
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
30
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GoToWebinar
|
2
4
|
class Attendee
|
3
5
|
def initialize(data)
|
@@ -49,19 +51,3 @@ module GoToWebinar
|
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
52
|
-
|
53
|
-
# invitations = event.invitations
|
54
|
-
# corrupted = []
|
55
|
-
# attendees.each do |attendee|
|
56
|
-
# invitation = invitations.where(g2w_registrant_key: attendee.registrant_key)
|
57
|
-
|
58
|
-
# if invitation
|
59
|
-
# begin
|
60
|
-
# invitation.update(
|
61
|
-
# arrived_at: attendee.attendance.first["joinTime"].to_datetime
|
62
|
-
# )
|
63
|
-
# rescue StandardError => e
|
64
|
-
# corrupted << { invitation: invitation, attendee: attendee, exception: e }
|
65
|
-
# end
|
66
|
-
# end
|
67
|
-
# end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'oauth2'
|
2
4
|
require 'redis'
|
3
5
|
|
@@ -5,7 +7,7 @@ module GoToWebinar
|
|
5
7
|
module Auth
|
6
8
|
class Client
|
7
9
|
attr_accessor :basic_auth_username, :basic_auth_password, :consumer_key, :secret_key
|
8
|
-
|
10
|
+
|
9
11
|
def initialize(basic_auth_username: nil, basic_auth_password: nil, consumer_key: nil, secret_key: nil)
|
10
12
|
config = GoToWebinar::Auth.configuration
|
11
13
|
@redis = Redis.new(url: config.redis_url)
|
@@ -54,8 +56,10 @@ module GoToWebinar
|
|
54
56
|
def get_access_token_from_redis(redis_key: 'g2w_access_token')
|
55
57
|
# retrieve from redis
|
56
58
|
token_json = @redis.get(redis_key)
|
57
|
-
token_hash = JSON.parse(token_json)&.[](
|
58
|
-
|
59
|
+
token_hash = JSON.parse(token_json)&.[]('token') if token_json
|
60
|
+
if token_hash
|
61
|
+
@access_token = OAuth2::AccessToken.from_hash(oauth2_client, token_hash)
|
62
|
+
end
|
59
63
|
|
60
64
|
# if we found it in redis, and it's expired, let's just refresh it
|
61
65
|
@access_token = refresh_access_token if @access_token&.expired?
|
@@ -87,7 +91,7 @@ module GoToWebinar
|
|
87
91
|
end
|
88
92
|
|
89
93
|
def authorize_url_params
|
90
|
-
URI.encode_www_form({client_id: consumer_key}.merge(authorize_optional_params))
|
94
|
+
URI.encode_www_form({ client_id: consumer_key }.merge(authorize_optional_params))
|
91
95
|
end
|
92
96
|
end
|
93
97
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GoToWebinar
|
2
4
|
module Auth
|
3
5
|
class Configuration
|
@@ -7,11 +9,11 @@ module GoToWebinar
|
|
7
9
|
attr_accessor :authorize_optional_params
|
8
10
|
|
9
11
|
def initialize
|
10
|
-
@site =
|
11
|
-
@authorize_url =
|
12
|
-
@authorize_optional_params =
|
13
|
-
@token_url =
|
14
|
-
@auth_scheme =
|
12
|
+
@site = self.class.site
|
13
|
+
@authorize_url = self.class.authorize_url
|
14
|
+
@authorize_optional_params = self.class.authorize_optional_params
|
15
|
+
@token_url = self.class.token_url
|
16
|
+
@auth_scheme = self.class.auth_scheme
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.site
|
@@ -23,7 +25,7 @@ module GoToWebinar
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.authorize_optional_params
|
26
|
-
{ response_type:
|
28
|
+
{ response_type: 'code' }
|
27
29
|
end
|
28
30
|
|
29
31
|
def self.token_url
|
data/lib/go_to_webinar/auth.rb
CHANGED
data/lib/go_to_webinar/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GoToWebinar
|
2
4
|
class Client
|
3
5
|
attr_accessor :url, :organizer_key, :access_token
|
@@ -41,21 +43,19 @@ module GoToWebinar
|
|
41
43
|
private
|
42
44
|
|
43
45
|
def attempt
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
raise unless @access_token&.expired?
|
46
|
+
retries ||= 0
|
47
|
+
yield
|
48
|
+
rescue RestClient::Forbidden => e
|
49
|
+
raise unless (retries += 1) < 2
|
50
|
+
raise unless int_error_code(e) == 'InvalidToken'
|
51
|
+
raise unless @g2w_oauth2_client&.access_token&.expired?
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
end
|
53
|
+
@access_token = @g2w_oauth2_client.refresh_access_token.token
|
54
|
+
retry
|
55
55
|
end
|
56
56
|
|
57
57
|
def int_error_code(exception)
|
58
|
-
JSON.parse(exception&.http_body)&.[](
|
58
|
+
JSON.parse(exception&.http_body)&.[]('int_err_code')
|
59
59
|
end
|
60
60
|
|
61
61
|
def parse(response)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GoToWebinar
|
2
4
|
class Session
|
3
5
|
def initialize(data)
|
@@ -55,7 +57,7 @@ module GoToWebinar
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def self.all
|
58
|
-
make(GoToWebinar.client.get(
|
60
|
+
make(GoToWebinar.client.get('/organizers/:organizer_key:/sessions'))
|
59
61
|
end
|
60
62
|
|
61
63
|
def self.make(data)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GoToWebinar
|
2
4
|
class Webinar
|
3
5
|
def initialize(data)
|
@@ -45,19 +47,19 @@ module GoToWebinar
|
|
45
47
|
# co-organizer.
|
46
48
|
def self.historical(from: nil, to: nil)
|
47
49
|
options = { fromTime: from, toTime: to }
|
48
|
-
make(GoToWebinar.client.get(
|
50
|
+
make(GoToWebinar.client.get('/organizers/:organizer_key:/historicalWebinars', options))
|
49
51
|
end
|
50
52
|
|
51
53
|
# Returns webinars scheduled for the future for a specified organizer.
|
52
54
|
def self.for_organizer
|
53
|
-
make(GoToWebinar.client.get(
|
55
|
+
make(GoToWebinar.client.get('/organizers/:organizer_key:/webinars'))
|
54
56
|
end
|
55
57
|
|
56
58
|
# Returns webinars scheduled for the future for the specified organizer and
|
57
59
|
# webinars of other organizers where the specified organizer is a
|
58
60
|
# co-organizer.
|
59
61
|
def self.upcoming
|
60
|
-
make(GoToWebinar.client.get(
|
62
|
+
make(GoToWebinar.client.get('/organizers/:organizer_key:/upcomingWebinars'))
|
61
63
|
end
|
62
64
|
|
63
65
|
def self.make(data)
|
data/lib/go_to_webinar.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rest-client'
|
2
4
|
require 'json'
|
3
5
|
require 'go_to_webinar/attendee'
|
@@ -10,17 +12,12 @@ require 'go_to_webinar/version'
|
|
10
12
|
require 'go_to_webinar/webinar'
|
11
13
|
|
12
14
|
module GoToWebinar
|
15
|
+
@client ||= GoToWebinar::Client.new
|
16
|
+
@configuration ||= GoToWebinar::Configuration.new
|
17
|
+
|
13
18
|
class << self
|
14
19
|
attr_accessor :client, :configuration
|
15
20
|
|
16
|
-
def client
|
17
|
-
@client ||= GoToWebinar::Client.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def configuration
|
21
|
-
@configuration ||= Configuration.new
|
22
|
-
end
|
23
|
-
|
24
21
|
def setup
|
25
22
|
yield(configuration)
|
26
23
|
@client = nil
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Jeremias da Silva
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-03-
|
12
|
+
date: 2020-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: rest-client
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '2.0'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '2.0'
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: oauth2
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +45,20 @@ dependencies:
|
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '4.0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rest-client
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: bundler
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|