whereby-ruby 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5887875836138da3a3a1ff0f95723d19be1d9466bfd65d649e8f5bb92400afa9
4
+ data.tar.gz: 669170a57c1d7e1283eda72a2d11aae753657b6a8af63ffbd37e366691245e57
5
+ SHA512:
6
+ metadata.gz: 2c23a61d9f53a67b37121a41b0ad665ea773af2a61a8e6d0a96c37c7cd70cf8acd884b6d35127fc164df3187050f7469bb6d53ecd2ae02c9c1dd2b4e6b13228d
7
+ data.tar.gz: d7e47b14b922efcd376e031e218678802eaaea358e2d3e365fa8cd6fefdbe1981959d028a7b67f7ccf5990a9aa1c778897d455ff2606bf6c2c61a75bb4d4e90a
@@ -0,0 +1,40 @@
1
+ name: Push Wrapper to Ruby Gems
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+
7
+ jobs:
8
+ build:
9
+ name: Build + Publish
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby 2.6
15
+ uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.6.x
18
+
19
+ - name: Publish to GPR
20
+ run: |
21
+ mkdir -p $HOME/.gem
22
+ touch $HOME/.gem/credentials
23
+ chmod 0600 $HOME/.gem/credentials
24
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
25
+ gem build *.gemspec
26
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
27
+ env:
28
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
29
+ OWNER: ${{ github.repository_owner }}
30
+
31
+ - name: Publish to RubyGems
32
+ run: |
33
+ mkdir -p $HOME/.gem
34
+ touch $HOME/.gem/credentials
35
+ chmod 0600 $HOME/.gem/credentials
36
+ printf -- "---\n:rubygems_api_key: ${RUBYGEMS_AUTH_TOKEN}\n" > $HOME/.gem/credentials
37
+ gem build *.gemspec
38
+ gem push *.gem
39
+ env:
40
+ RUBYGEMS_AUTH_TOKEN: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,57 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ .idea/
56
+
57
+ .DS_Store
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at danielkhenriksen@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in whereby-ruby.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ whereby-ruby (0.1.0)
5
+ httparty (~> 0.18)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ httparty (0.18.1)
11
+ mime-types (~> 3.0)
12
+ multi_xml (>= 0.5.2)
13
+ mime-types (3.3.1)
14
+ mime-types-data (~> 3.2015)
15
+ mime-types-data (3.2020.0512)
16
+ minitest (5.14.1)
17
+ multi_xml (0.6.0)
18
+ rake (12.3.3)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ minitest (~> 5.0)
25
+ rake (~> 12.0)
26
+ whereby-ruby!
27
+
28
+ BUNDLED WITH
29
+ 2.1.4
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2020 Daniel Kittilsen Henriksen
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Daniel Kittilsen Henriksen
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.
@@ -0,0 +1,55 @@
1
+ # Whereby Ruby HTTP API Wrapper
2
+
3
+ Just a simple Whereby HTTP API wrapper written for Ruby projects.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'whereby-ruby'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install whereby-ruby
20
+
21
+ ## Usage
22
+
23
+ If using Rails put the following into a initializer. If just Ruby, run this before trying to use the API.
24
+
25
+ ```ruby
26
+ Whereby.configure do |config|
27
+ config.api_key = 'YOUR_KEY_HERE'
28
+ end
29
+ ```
30
+
31
+ ### Instantiate an API object.
32
+
33
+ ```ruby
34
+ api = Whereby::Api.new
35
+ ```
36
+
37
+ ### API Requests
38
+
39
+ ```ruby
40
+ api.meeting(id) # GET /v1/meetings/:id
41
+ api.create_meeting(options) # POST /v1/meetings
42
+ api.delete_meeting(id) # DELETE /v1/meetings/:id
43
+ ```
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/poption/whereby-ruby.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Code of Conduct
54
+
55
+ Everyone interacting in the Whereby Ruby HTTP API project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/whereby-ruby/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "whereby"
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__)
@@ -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,25 @@
1
+ require 'whereby/configuration'
2
+ require 'whereby/version'
3
+ require 'whereby/element'
4
+ require 'whereby/meeting'
5
+ require 'whereby/api'
6
+
7
+ module Whereby
8
+ class << self
9
+ attr_accessor :configuration
10
+ end
11
+
12
+ def self.api_key
13
+ configuration.api_key
14
+ end
15
+
16
+ def self.configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def self.configure
21
+ yield(configuration)
22
+ end
23
+
24
+
25
+ end
@@ -0,0 +1,60 @@
1
+ require 'httparty'
2
+ module Whereby
3
+ class WherebyError < StandardError; end
4
+
5
+ class Api
6
+ API_VERSION = 'v1'
7
+ BASE_URL = "https://api.whereby.dev/#{API_VERSION}"
8
+
9
+ # GET /v1/meetings/:id
10
+ def meeting(id)
11
+ Meeting.new(whereby_request(:get, "meetings/#{id.to_s}"))
12
+ end
13
+
14
+ # POST /v1/meetings/
15
+ def create_meeting(options={})
16
+ Meeting.new(whereby_request(:post, "meetings", options))
17
+ end
18
+
19
+ # DELETE /v1/meetings/:id
20
+ def delete_meeting(id)
21
+ whereby_request(:delete, "meetings/#{id.to_s}")
22
+ end
23
+
24
+ private
25
+ def whereby_request(method, url, options={})
26
+ url = "#{BASE_URL}/#{url}"
27
+
28
+ # Convert hash keys into camel case
29
+ options = Hash[options.map { |k,v| [k.to_s.camelize, v]}]
30
+
31
+ http_attrs = {headers: headers}
32
+ http_attrs.merge!(options)
33
+
34
+ # TODO: Create case/when for special cases for options
35
+
36
+ result = HTTParty.send(method, url, http_attrs)
37
+
38
+ if [200, 201].include? result.code
39
+ JSON.parse(result.body) # Create / Get
40
+ elsif result.code == 204
41
+ true # Delete
42
+ else
43
+ raise WherebyError.new error(result.code)
44
+ end
45
+ end
46
+
47
+ def error(code)
48
+ return "Access token is missing or invalid" if code == 401
49
+ return "The requested resource doesn't exist" if code == 404
50
+ "Major fuck-up."
51
+ end
52
+
53
+ def headers
54
+ {
55
+ 'Content-type' => 'application/json',
56
+ 'Bearer' => Whereby.api_key
57
+ }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,9 @@
1
+ module Whereby
2
+ class Configuration
3
+ attr_accessor :api_key
4
+
5
+ def initialize
6
+ @api_key = nil
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ module Whereby
2
+ class Element
3
+ def initialize(attrs = {})
4
+ # Only set attributes if the method exists
5
+ attrs.each{ |k,v| send("#{k.underscore}=", v) if respond_to?("#{k.underscore}") }
6
+ end
7
+
8
+ def to_h
9
+ Hash[
10
+ *instance_variables.map do |variable|
11
+ name = variable[1..-1].to_sym #Removing @
12
+ [name, instance_variable_get(variable)]
13
+ end.flatten
14
+ ]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Whereby
2
+ class Meeting < Element
3
+ attr_accessor :meeting_id, :room_url, :start_date, :end_date, :host_room_url
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Whereby
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'whereby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "whereby-ruby"
8
+ spec.version = Whereby::VERSION
9
+ spec.authors = ["Daniel Kittilsen Henriksen"]
10
+ spec.email = ["tech@poption.com"]
11
+
12
+ spec.summary = "A Ruby Whereby Wrapper"
13
+ spec.description = "Easily use Whereby's HTTP API using this gem"
14
+ spec.homepage = "https://github.com/poption/whereby-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/poption/whereby-ruby"
21
+ spec.metadata["changelog_uri"] = "https://github.com/poption/whereby-ruby"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "httparty", "~> 0.18"
33
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whereby-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Kittilsen Henriksen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-27 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.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
27
+ description: Easily use Whereby's HTTP API using this gem
28
+ email:
29
+ - tech@poption.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/gem-push.yml"
35
+ - ".gitignore"
36
+ - CODE_OF_CONDUCT.md
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.md
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - bin/console
44
+ - bin/setup
45
+ - lib/whereby.rb
46
+ - lib/whereby/api.rb
47
+ - lib/whereby/configuration.rb
48
+ - lib/whereby/element.rb
49
+ - lib/whereby/meeting.rb
50
+ - lib/whereby/version.rb
51
+ - whereby-ruby.gemspec
52
+ homepage: https://github.com/poption/whereby-ruby
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ homepage_uri: https://github.com/poption/whereby-ruby
57
+ source_code_uri: https://github.com/poption/whereby-ruby
58
+ changelog_uri: https://github.com/poption/whereby-ruby
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.3.0
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.0.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: A Ruby Whereby Wrapper
78
+ test_files: []