go_to_webinar 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a55684b970bdb95c9349d4bfb03dee5d77d9aa07c2ab9dd43ffba2a57b4f2717
4
+ data.tar.gz: 1daf0db4b8baf729e5bbd7c948e8bc516c1810741902c23fa2b1d436e4e1da96
5
+ SHA512:
6
+ metadata.gz: 67def2a9ffd291c0f4226d00eb8b0d83765c7764e54ca72f636d44bc799d1f86e686be3e4e87e58eee3f381b257bdd4be4b8ed75b627f5e07a6e68d305b7195a
7
+ data.tar.gz: f65b6d6e6783e678905f6bd046667ebcfde8ba74b4a5d6b629d8a0e644252ecabd4fff2333d4a16f1a514688300874920833c689727b36150acd0b17ceeaca04
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
11
+ *.rbc
12
+ /.config
13
+ /coverage/
14
+ /InstalledFiles
15
+ /pkg/
16
+ /spec/reports/
17
+ /spec/examples.txt
18
+ /test/tmp/
19
+ /test/version_tmp/
20
+ /tmp/
21
+
22
+ # Used by dotenv library to load environment variables.
23
+ # .env
24
+
25
+ ## Specific to RubyMotion:
26
+ .dat*
27
+ .repl_history
28
+ build/
29
+ *.bridgesupport
30
+ build-iPhoneOS/
31
+ build-iPhoneSimulator/
32
+
33
+ ## Specific to RubyMotion (use of CocoaPods):
34
+ #
35
+ # We recommend against adding the Pods directory to your .gitignore. However
36
+ # you should judge for yourself, the pros and cons are mentioned at:
37
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
38
+ #
39
+ # vendor/Pods/
40
+
41
+ ## Documentation cache and generated files:
42
+ /.yardoc/
43
+ /_yardoc/
44
+ /doc/
45
+ /rdoc/
46
+
47
+ ## Environment normalization:
48
+ /.bundle/
49
+ /vendor/bundle
50
+ /lib/bundler/man/
51
+
52
+ # .ruby-version
53
+ # .ruby-gemset
54
+
55
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
56
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ script:
3
+ - bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in go_to_webinar.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Danilo Jeremias da Silva
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # GoToWebinar
2
+
3
+ It is a Rubygem client to GoToWebinar API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'go_to_webinar'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install go_to_webinar
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dannnylo/go_to_webinar.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ end
8
+
9
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "go_to_webinar"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'go_to_webinar/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'go_to_webinar'
9
+ spec.version = GoToWebinar::VERSION
10
+ spec.authors = ['Danilo Jeremias da Silva', 'Michael Bennett']
11
+ spec.email = ['daniloj.dasilva@gmail.com', 'michael@michaelbennett.nyc']
12
+
13
+ spec.summary = 'Client for Go To Webinar API.'
14
+ spec.description = 'Client for Go To Webinar API.'
15
+ spec.homepage = 'https://github.com/RecruitiFi/go_to_webinar'.freeze
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_dependency 'rest-client','~> 2.0'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 2.1.4'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.6'
30
+ spec.add_development_dependency 'webmock', '~> 3.0'
31
+ end
@@ -0,0 +1,44 @@
1
+ module GoToWebinar
2
+ class Client
3
+ attr_accessor :url, :organizer_key, :access_token
4
+
5
+ def initialize(access_token: nil, organizer_key: nil, url: nil)
6
+ config = GoToWebinar.configuration
7
+ @url = url || config.url
8
+ @organizer_key = organizer_key || config.organizer_key
9
+ @access_token = access_token || config.access_token
10
+ end
11
+
12
+ def headers
13
+ {
14
+ 'Accept' => 'application/json',
15
+ 'Authorization' => "OAuth oauth_token=#{access_token}"
16
+ }
17
+ end
18
+
19
+ def get(path, data = {})
20
+ response = RestClient.get(make_path(path), data.merge(headers))
21
+ JSON.parse(response.body)
22
+ end
23
+
24
+ def post(path, data)
25
+ response = RestClient.post(make_path(path), data, headers)
26
+ JSON.parse(response.body)
27
+ end
28
+
29
+ def put(path, data)
30
+ response = RestClient.put(make_path(path), data, headers)
31
+ JSON.parse(response.body)
32
+ end
33
+
34
+ def delete
35
+ response = RestClient.delete(make_path(path), data, headers)
36
+ JSON.parse(response.body)
37
+ end
38
+
39
+ def make_path(path)
40
+ path.gsub!(':organizer_key:', organizer_key)
41
+ "#{url}#{path}"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,14 @@
1
+ module GoToWebinar
2
+ # Configuration class
3
+ class Configuration
4
+ attr_accessor :organizer_key, :access_token, :url, :client
5
+
6
+ def initialize
7
+ @url = Configuration.default_url
8
+ end
9
+
10
+ def self.default_url
11
+ 'https://api.getgo.com/G2W/rest'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,40 @@
1
+ module GoToWebinar
2
+ class Registrant
3
+ def initialize(data)
4
+ @data = data
5
+ end
6
+
7
+ def registrant_key
8
+ @data['registrantKey'].to_s
9
+ end
10
+
11
+ def webinar_key
12
+ @data['webinarKey'].to_s
13
+ end
14
+
15
+ def join_url
16
+ @data['join_url']
17
+ end
18
+
19
+ def destroy
20
+ GoToWebinar.client.delete("/organizers/:organizer_key:/webinars/#{webinar_key}/registrants/#{registrant_key}")
21
+ end
22
+
23
+ def self.create(webinar_key:, data:)
24
+ data = GoToWebinar.client.post("/organizers/:organizer_key:/webinars/#{webinar_key}/registrants", data)
25
+ Registrant.make(data)
26
+ end
27
+
28
+ def self.all(webinar_key:)
29
+ make(GoToWebinar.client.get("/organizers/:organizer_key:/webinars/#{webinar_key}/registrants"))
30
+ end
31
+
32
+ def self.find(webinar_key:, registrant_key:)
33
+ make(GoToWebinar.client.get("/organizers/:organizer_key:/webinars/#{webinar_key}/registrants/#{registrant_key}"))
34
+ end
35
+
36
+ def self.make(data)
37
+ data.map { |registrant| Registrant.new(registrant) }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module GoToWebinar
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,57 @@
1
+ module GoToWebinar
2
+ class Webinar
3
+ def initialize(data)
4
+ @data = data
5
+ end
6
+
7
+ def webinar_key
8
+ @data['webinarKey'].to_s
9
+ end
10
+
11
+ def add_registrant(first_name:, last_name:, email:)
12
+ data = {first_name: first_name, last_name: last_name, email: email}
13
+ Registrant.create(webinar_key: webinar_key, data: data)
14
+ end
15
+
16
+ def self.find(webinar_key:)
17
+ data = GoToWebinar.client.get("/organizers/:organizer_key:/webinars/#{webinar_key}")
18
+ Webinar.new(data)
19
+ end
20
+
21
+ # Retrieves the list of webinars for an account within a given date range.
22
+ # Page and size parameters are optional. Default page is 0 and default
23
+ # size is 20.
24
+ def self.for_account(account_key:, from:, to:, page: nil, page_size: nil)
25
+ options = { fromTime: from, toTime: to }
26
+ options[:page] = page if page.present?
27
+ options[:size] = page_size if page_size.present?
28
+
29
+ GoToWebinar.client.get("/accounts/#{account_key}/webinars", options)
30
+ # TODO: montar retorno
31
+ end
32
+
33
+ # Returns details for completed webinars for the specified organizer and
34
+ # completed webinars of other organizers where the specified organizer is a
35
+ # co-organizer.
36
+ def self.historical(from: nil, to: nil)
37
+ options = { fromTime: from, toTime: to }
38
+ make(GoToWebinar.client.get("/organizers/:organizer_key:/historicalWebinars", options))
39
+ end
40
+
41
+ # Returns webinars scheduled for the future for a specified organizer.
42
+ def self.for_organizer
43
+ make(GoToWebinar.client.get("/organizers/:organizer_key:/webinars"))
44
+ end
45
+
46
+ # Returns webinars scheduled for the future for the specified organizer and
47
+ # webinars of other organizers where the specified organizer is a
48
+ # co-organizer.
49
+ def self.upcoming
50
+ make(GoToWebinar.client.get("/organizers/:organizer_key:/upcomingWebinars"))
51
+ end
52
+
53
+ def self.make(data)
54
+ data.map { |webinar| Webinar.new(webinar) }
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,25 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+ require "go_to_webinar/version"
4
+ require "go_to_webinar/configuration"
5
+ require "go_to_webinar/client"
6
+ require "go_to_webinar/webinar"
7
+
8
+ module GoToWebinar
9
+ class << self
10
+ attr_accessor :client, :configuration
11
+
12
+ def client
13
+ @client ||= GoToWebinar::Client.new
14
+ end
15
+
16
+ def configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def setup
21
+ yield(configuration)
22
+ @client = nil
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: go_to_webinar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Danilo Jeremias da Silva
8
+ - Michael Bennett
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2020-03-17 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 2.1.4
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 2.1.4
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.6'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.6'
70
+ - !ruby/object:Gem::Dependency
71
+ name: webmock
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.0'
84
+ description: Client for Go To Webinar API.
85
+ email:
86
+ - daniloj.dasilva@gmail.com
87
+ - michael@michaelbennett.nyc
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - go_to_webinar.gemspec
102
+ - lib/go_to_webinar.rb
103
+ - lib/go_to_webinar/client.rb
104
+ - lib/go_to_webinar/configuration.rb
105
+ - lib/go_to_webinar/registrant.rb
106
+ - lib/go_to_webinar/version.rb
107
+ - lib/go_to_webinar/webinar.rb
108
+ homepage: https://github.com/RecruitiFi/go_to_webinar
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.7.9
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Client for Go To Webinar API.
132
+ test_files: []