guesty_api 0.1.0

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: db90ac9f82e97c490061fd47ee316953d3fe43997ee5ffa9f165df18b1259d8d
4
+ data.tar.gz: c5cc6cad1089f44af83e3ca276299d4013662524eb9ac159089d968e1617e8a5
5
+ SHA512:
6
+ metadata.gz: 801e187c99420f7d208c16f65ca30a1558f36a3b8e306d50b3a1779717d9d86a8fc73ae2b66f60f04008866a4f0076f334fb56538aab327f758a573fe301d8c1
7
+ data.tar.gz: c42601333ee2c62a85ed961534ba4203130ebfe3a378da076c258039285a478c418dc46df5f4a13848c41238250c3891ea1054539c41fd3c894ef22d0216bcdf
@@ -0,0 +1,6 @@
1
+ versions:
2
+ - rubocop-performance
3
+ - rubocop-minitest
4
+ - rubocop-rspec
5
+
6
+ rubocop_fail_level: "refactor"
@@ -0,0 +1,45 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ rubocop:
11
+ name: Rubocop
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Rubocop Linter Action
16
+ uses: andrewmcodes/rubocop-linter-action@v3.2.0
17
+ env:
18
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
+ specs:
20
+ name: RSpec
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: 2.6.6
27
+ bundler-cache: true
28
+ - run: bundle install
29
+ - name: Run tests
30
+ run: bundle exec rake
31
+ - name: Release Gem
32
+
33
+ release:
34
+ runs-on: ubuntu-latest
35
+
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+
39
+ - name: Release Gem
40
+ if: contains(github.ref, 'refs/tags/v')
41
+ uses: cadwallion/publish-rubygems-action@master
42
+ env:
43
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
44
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
45
+ RELEASE_COMMAND: rake release
@@ -0,0 +1,48 @@
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
+ ## Documentation cache and generated files:
28
+ /.yardoc/
29
+ /_yardoc/
30
+ /doc/
31
+ /rdoc/
32
+
33
+ ## Environment normalization:
34
+ /.bundle/
35
+ /vendor/bundle
36
+ /lib/bundler/man/
37
+
38
+ # for a library or gem, you might want to ignore these files since the code is
39
+ # intended to run in multiple environments; otherwise, check them in:
40
+ # Gemfile.lock
41
+ # .ruby-version
42
+ # .ruby-gemset
43
+
44
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
45
+ .rvmrc
46
+
47
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
48
+ # .rubocop-https?--*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,14 @@
1
+ example_id | status | run_time |
2
+ ------------------------------------------- | ------ | --------------- |
3
+ ./spec/guesty_api/accounts_spec.rb[1:1:1:1] | passed | 0.01021 seconds |
4
+ ./spec/guesty_api/accounts_spec.rb[1:1:2:1] | passed | 0.00111 seconds |
5
+ ./spec/guesty_api/accounts_spec.rb[1:1:2:2] | passed | 0.00119 seconds |
6
+ ./spec/guesty_api/client_spec.rb[1:1:1:1] | passed | 0.00611 seconds |
7
+ ./spec/guesty_api/client_spec.rb[1:1:2:1] | passed | 0.00019 seconds |
8
+ ./spec/guesty_api/client_spec.rb[1:1:3:1] | passed | 0.00068 seconds |
9
+ ./spec/guesty_api/client_spec.rb[1:1:4:1] | passed | 0.00016 seconds |
10
+ ./spec/guesty_api/client_spec.rb[1:2:1:1] | passed | 0.00021 seconds |
11
+ ./spec/guesty_api/client_spec.rb[1:2:2:1] | passed | 0.0006 seconds |
12
+ ./spec/guesty_api/client_spec.rb[1:2:3:1] | passed | 0.00016 seconds |
13
+ ./spec/guesty_api/client_spec.rb[1:2:4:1] | passed | 0.00016 seconds |
14
+ ./spec/guesty_api_spec.rb[1:1] | passed | 0.00098 seconds |
@@ -0,0 +1,72 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ Exclude:
7
+ - .git/**/*
8
+ - bin/**/*
9
+ - coverage/**/*
10
+ NewCops: enable
11
+
12
+ Layout/FirstArrayElementIndentation:
13
+ EnforcedStyle: consistent
14
+
15
+ Layout/FirstHashElementIndentation:
16
+ EnforcedStyle: consistent
17
+
18
+ Layout/MultilineMethodCallIndentation:
19
+ EnforcedStyle: indented
20
+
21
+ Layout/LineLength:
22
+ Max: 100
23
+
24
+ Lint/AmbiguousBlockAssociation:
25
+ Exclude:
26
+ - spec/**/*
27
+
28
+ Metrics/MethodLength:
29
+ Max: 15
30
+
31
+ Metrics/BlockLength:
32
+ Exclude:
33
+ - guesty_api.gemspec
34
+ - spec/**/*
35
+
36
+ Style/Documentation:
37
+ Enabled: false
38
+
39
+ Style/TrailingCommaInArguments:
40
+ EnforcedStyleForMultiline: comma
41
+
42
+ Style/TrailingCommaInArrayLiteral:
43
+ EnforcedStyleForMultiline: comma
44
+
45
+ Style/TrailingCommaInHashLiteral:
46
+ EnforcedStyleForMultiline: comma
47
+
48
+ # RSpec
49
+ RSpec/ContextWording:
50
+ Prefixes:
51
+ - for
52
+ - when
53
+ - with
54
+ - without
55
+
56
+ RSpec/MessageSpies:
57
+ EnforcedStyle: receive
58
+
59
+ RSpec/DescribeClass:
60
+ Exclude:
61
+ - spec/requests/**/*
62
+
63
+ RSpec/NamedSubject:
64
+ Enabled: false
65
+
66
+ RSpec/RepeatedExample:
67
+ Exclude:
68
+ - spec/policies/**/*
69
+
70
+ RSpec/MultipleExpectations:
71
+ Exclude:
72
+ - spec/mailers/**/*
@@ -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 iamsuperman@ukr.net. 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,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in guesty_api.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
@@ -0,0 +1,89 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guesty_api (0.1.0)
5
+ httparty (~> 0.17.0)
6
+ oj (~> 3.7)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.1)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
16
+ diff-lcs (1.4.4)
17
+ docile (1.3.2)
18
+ hashdiff (1.0.1)
19
+ httparty (0.17.3)
20
+ mime-types (~> 3.0)
21
+ multi_xml (>= 0.5.2)
22
+ mime-types (3.3.1)
23
+ mime-types-data (~> 3.2015)
24
+ mime-types-data (3.2020.0512)
25
+ multi_xml (0.6.0)
26
+ oj (3.10.8)
27
+ parallel (1.19.2)
28
+ parser (2.7.1.4)
29
+ ast (~> 2.4.1)
30
+ public_suffix (4.0.5)
31
+ rainbow (3.0.0)
32
+ rake (12.3.3)
33
+ regexp_parser (1.7.1)
34
+ rexml (3.2.4)
35
+ rspec (3.9.0)
36
+ rspec-core (~> 3.9.0)
37
+ rspec-expectations (~> 3.9.0)
38
+ rspec-mocks (~> 3.9.0)
39
+ rspec-core (3.9.2)
40
+ rspec-support (~> 3.9.3)
41
+ rspec-expectations (3.9.2)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-mocks (3.9.1)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.9.0)
47
+ rspec-support (3.9.3)
48
+ rubocop (0.88.0)
49
+ parallel (~> 1.10)
50
+ parser (>= 2.7.1.1)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 1.7)
53
+ rexml
54
+ rubocop-ast (>= 0.1.0, < 1.0)
55
+ ruby-progressbar (~> 1.7)
56
+ unicode-display_width (>= 1.4.0, < 2.0)
57
+ rubocop-ast (0.2.0)
58
+ parser (>= 2.7.0.1)
59
+ rubocop-performance (1.7.1)
60
+ rubocop (>= 0.82.0)
61
+ rubocop-rspec (1.42.0)
62
+ rubocop (>= 0.87.0)
63
+ ruby-progressbar (1.10.1)
64
+ safe_yaml (1.0.5)
65
+ simplecov (0.18.5)
66
+ docile (~> 1.1)
67
+ simplecov-html (~> 0.11)
68
+ simplecov-html (0.12.2)
69
+ unicode-display_width (1.7.0)
70
+ webmock (3.8.3)
71
+ addressable (>= 2.3.6)
72
+ crack (>= 0.3.2)
73
+ hashdiff (>= 0.4.0, < 2.0.0)
74
+
75
+ PLATFORMS
76
+ ruby
77
+
78
+ DEPENDENCIES
79
+ guesty_api!
80
+ rake (~> 12.0)
81
+ rspec (~> 3.9)
82
+ rubocop (~> 0.88.0)
83
+ rubocop-performance (~> 1.7, >= 1.7.1)
84
+ rubocop-rspec (~> 1.42)
85
+ simplecov (~> 0.18.5)
86
+ webmock (~> 3.8, >= 3.8.3)
87
+
88
+ BUNDLED WITH
89
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Michael Babin
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,43 @@
1
+ # GuestyAPI
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/guesty_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'guesty_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install guesty_api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/guesty_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/guesty_api/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the GuestyAPI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/guesty_api/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "guesty_api"
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,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/guesty_api/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'guesty_api'
7
+ spec.version = GuestyAPI::VERSION
8
+ spec.authors = ['Michael Babin']
9
+ spec.email = ['iamsuperman@ukr.net']
10
+
11
+ spec.summary = 'Guesty API wrapper'
12
+ spec.description = 'Simple abstractions for Guesty API'
13
+ spec.homepage = 'https://github.com/mihilbabin/guesty_api'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/mihilbabin/guesty_api'
21
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
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(__dir__)) 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_development_dependency 'rspec', '~> 3.9'
33
+ spec.add_development_dependency 'rubocop', '~> 0.88.0'
34
+ spec.add_development_dependency 'rubocop-performance', '~> 1.7', '>= 1.7.1'
35
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.42'
36
+ spec.add_development_dependency 'simplecov', '~> 0.18.5'
37
+ spec.add_development_dependency 'webmock', '~> 3.8', '>= 3.8.3'
38
+
39
+ spec.add_dependency 'httparty', '~> 0.17.0'
40
+ spec.add_dependency 'oj', '~> 3.7'
41
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+ require 'oj'
5
+
6
+ require 'guesty_api/resource_base'
7
+ require 'guesty_api/accounts'
8
+ require 'guesty_api/client'
9
+ require 'guesty_api/entities'
10
+ require 'guesty_api/version'
11
+
12
+ module GuestyAPI
13
+ class APIError < StandardError
14
+ attr_accessor :code
15
+
16
+ def initialize(msg, code)
17
+ super(msg)
18
+ @code = code
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuestyAPI
4
+ class Accounts < ResourceBase
5
+ def retrieve
6
+ response = @client.get url: '/accounts/me'
7
+
8
+ throw!(body: response.body, code: response.code) unless response.success?
9
+
10
+ Entities::Account.new(parsed_body(response))
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuestyAPI
4
+ class Client
5
+ include HTTParty
6
+ base_uri 'https://api.guesty.com/api/v2'
7
+
8
+ def initialize(username:, password: nil, auth_mode: :basic)
9
+ @username = username
10
+ @password = password
11
+ @auth_mode = auth_mode
12
+ end
13
+
14
+ def get(url:, data: nil)
15
+ self.class.get(url, query: data, **auth)
16
+ end
17
+
18
+ def post(url:, data:)
19
+ self.class.post(url, body: data, **auth)
20
+ end
21
+
22
+ def put(url:, data:)
23
+ self.class.put(url, body: data, **auth)
24
+ end
25
+
26
+ def delete(url:)
27
+ self.class.delete(url, **auth)
28
+ end
29
+
30
+ private
31
+
32
+ def auth
33
+ if @auth_mode == :basic
34
+ { basic_auth: { username: @username, password: @password } }
35
+ else
36
+ { headers: { 'Authorization' => "Bearer #{@username}" } }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'guesty_api/entities/base'
4
+ require 'guesty_api/entities/account'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuestyAPI
4
+ module Entities
5
+ class Account < Base; end
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuestyAPI
4
+ module Entities
5
+ class Base
6
+ def initialize(payload)
7
+ @raw_data = payload
8
+ @methods = payload.keys.map(&:to_sym)
9
+ end
10
+
11
+ def method_missing(method, *_args)
12
+ super unless @methods.include? method
13
+ @raw_data[method.to_s]
14
+ end
15
+
16
+ def respond_to_missing?(_method_name, _include_private = false)
17
+ true
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuestyAPI
4
+ class ResourceBase
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ private
10
+
11
+ def parsed_body(response)
12
+ JSON.parse response.body
13
+ end
14
+
15
+ def throw!(body:, code:)
16
+ raise APIError.new(body, code)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuestyAPI
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guesty_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Babin
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: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.88.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.88.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-performance
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.7.1
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.7'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.7.1
61
+ - !ruby/object:Gem::Dependency
62
+ name: rubocop-rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.42'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.42'
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.18.5
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.18.5
89
+ - !ruby/object:Gem::Dependency
90
+ name: webmock
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.8'
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 3.8.3
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '3.8'
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 3.8.3
109
+ - !ruby/object:Gem::Dependency
110
+ name: httparty
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: 0.17.0
116
+ type: :runtime
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: 0.17.0
123
+ - !ruby/object:Gem::Dependency
124
+ name: oj
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '3.7'
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: '3.7'
137
+ description: Simple abstractions for Guesty API
138
+ email:
139
+ - iamsuperman@ukr.net
140
+ executables: []
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - ".github/config/rubocop_linter_action.yml"
145
+ - ".github/workflows/ruby-gem.yml"
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".rspec_status"
149
+ - ".rubocop.yml"
150
+ - CODE_OF_CONDUCT.md
151
+ - Gemfile
152
+ - Gemfile.lock
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - bin/console
157
+ - bin/setup
158
+ - guesty_api.gemspec
159
+ - lib/guesty_api.rb
160
+ - lib/guesty_api/accounts.rb
161
+ - lib/guesty_api/client.rb
162
+ - lib/guesty_api/entities.rb
163
+ - lib/guesty_api/entities/account.rb
164
+ - lib/guesty_api/entities/base.rb
165
+ - lib/guesty_api/resource_base.rb
166
+ - lib/guesty_api/version.rb
167
+ homepage: https://github.com/mihilbabin/guesty_api
168
+ licenses:
169
+ - MIT
170
+ metadata:
171
+ allowed_push_host: https://rubygems.org/
172
+ homepage_uri: https://github.com/mihilbabin/guesty_api
173
+ source_code_uri: https://github.com/mihilbabin/guesty_api
174
+ changelog_uri: https://github.com/mihilbabin/guesty_api/CHANGELOG.md
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: 2.3.0
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubygems_version: 3.0.8
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: Guesty API wrapper
194
+ test_files: []