validators_app_ruby 1.0.0.pre

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c89330eeb681aa1a95f35231cad1864b73f0eb60052edfd56023147e8c17fdae
4
+ data.tar.gz: 93f5c1fe5ed43e7836c0a9c14b9e377f9135899ab96767295784433d7b14c947
5
+ SHA512:
6
+ metadata.gz: 6b94f47e28ce30f70a5a15fbf8a64ee1bc3baebc7ab51dea0c45af7665240c7f7e7a1128d576e91dea7c0dd8ff7d542da585028ac574462398fccea0fdbc958b
7
+ data.tar.gz: 76d99a7e2a1d9f580f6fbef5d1b0cc2f3d5f12f77ee9114eec7b47f63b7c3766accb0e1097c4b7fcb658b85d716296d9886ea7ce29b38a982c8537b1e1405a18
@@ -0,0 +1,30 @@
1
+ name: Test Suite
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-20.04
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby-version: [3.0, 2.7, 2.6]
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby ${{ matrix.ruby-version }}
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby-version }}
18
+ bundler-cache: true
19
+ - name: bundle install
20
+ run: bundle install
21
+ - name: set up dotenv
22
+ env:
23
+ API_TOKEN: ${{ secrets.API_TOKEN }}
24
+ run: |
25
+ echo $API_TOKEN | base64 --decode > .env
26
+ - name: Run tests
27
+ env:
28
+ RAILS_ENV: test
29
+ run: |
30
+ bundle exec rake test
data/.gitignore ADDED
@@ -0,0 +1,56 @@
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
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ Style/StringLiterals:
2
+ Enabled: true
3
+ EnforcedStyle: double_quotes
4
+
5
+ Style/StringLiteralsInInterpolation:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Layout/LineLength:
10
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.5
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at maciej.kocyla@polcode.net. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in validators_app_ruby.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 0.80"
13
+
14
+ gem "httparty", "~> 0.20"
data/Gemfile.lock ADDED
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ validators_app_ruby (1.0.0.pre)
5
+ httparty (~> 0.20)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.2)
13
+ crack (0.4.5)
14
+ rexml
15
+ dotenv (2.7.6)
16
+ hashdiff (1.0.1)
17
+ httparty (0.20.0)
18
+ mime-types (~> 3.0)
19
+ multi_xml (>= 0.5.2)
20
+ mime-types (3.4.1)
21
+ mime-types-data (~> 3.2015)
22
+ mime-types-data (3.2022.0105)
23
+ minispec-metadata (2.0.0)
24
+ minitest
25
+ minitest (5.15.0)
26
+ minitest-vcr (1.4.0)
27
+ minispec-metadata (~> 2.0)
28
+ minitest (>= 4.7.5)
29
+ vcr (>= 2.9)
30
+ multi_xml (0.6.0)
31
+ parallel (1.22.1)
32
+ parser (3.1.1.0)
33
+ ast (~> 2.4.1)
34
+ public_suffix (4.0.6)
35
+ rainbow (3.1.1)
36
+ rake (13.0.6)
37
+ regexp_parser (2.2.1)
38
+ rexml (3.2.5)
39
+ rubocop (0.93.1)
40
+ parallel (~> 1.10)
41
+ parser (>= 2.7.1.5)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8)
44
+ rexml
45
+ rubocop-ast (>= 0.6.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 1.4.0, < 2.0)
48
+ rubocop-ast (1.16.0)
49
+ parser (>= 3.1.1.0)
50
+ ruby-progressbar (1.11.0)
51
+ unicode-display_width (1.8.0)
52
+ vcr (6.1.0)
53
+ webmock (3.14.0)
54
+ addressable (>= 2.8.0)
55
+ crack (>= 0.3.2)
56
+ hashdiff (>= 0.4.0, < 2.0.0)
57
+
58
+ PLATFORMS
59
+ x86_64-darwin-20
60
+ x86_64-linux
61
+
62
+ DEPENDENCIES
63
+ dotenv (~> 2.7.6)
64
+ httparty (~> 0.20)
65
+ minitest (~> 5.0)
66
+ minitest-vcr (~> 1.4.0)
67
+ rake (~> 13.0)
68
+ rubocop (~> 0.80)
69
+ validators_app_ruby!
70
+ webmock (~> 3.14.0)
71
+
72
+ BUNDLED WITH
73
+ 2.3.5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Block Logic
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/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 maciejkocylapc
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.
data/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # ValidatorsAppRuby
2
+
3
+ This gem helps to utilize the validators.app API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'validators-app-ruby'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install validators-app-ruby
20
+
21
+ ## Usage
22
+
23
+ Please note that in order to use this client, you need to obtain the api token from https://validators.app.
24
+
25
+ Full api documentation is available on https://www.validators.app/api-documentation.
26
+
27
+ If you want to use any of the api method just create a new ValidatorsAppRuby object providing your api token as follows:
28
+
29
+ ```ruby
30
+ client = ValidatorsAppRuby.new(token: "your_api_token")
31
+ ```
32
+
33
+ then you can use any endpoint as follows:
34
+
35
+ ```ruby
36
+ client.<post || get>_<endpoint_path>(params)
37
+ ```
38
+
39
+ Example:
40
+
41
+ ```ruby
42
+ client = ValidatorsAppRuby.new(token: "your_api_token")
43
+ client.get_validators(network: "testnet", order: "score")
44
+
45
+ # returns a list of validators from testnet ordered by score
46
+ ```
47
+
48
+ ## List of available endpoints:
49
+
50
+ ```ruby
51
+ client = ValidatorsAppRuby.new(token: "your_api_token")
52
+
53
+ # Server ping
54
+ # The ping endpoint will allow you to test your connection to the server.
55
+
56
+ client.get_ping
57
+
58
+ # Validators List
59
+ # The Validators endpoint will return a list of validators for the requested network.
60
+
61
+ client.get_validators(
62
+ network: "testnet",
63
+ order: "score",
64
+ limit: 100,
65
+ page: 1,
66
+ q: "example"
67
+ )
68
+
69
+ # Validator Detail
70
+ # The Validators endpoint will return a single validator for the requested network and account.
71
+
72
+ client.get_validators(
73
+ network: "testnet",
74
+ id: "validator_account",
75
+ with_history: true
76
+ )
77
+
78
+ # Validator Block Production History
79
+ # The Validator Block History endpoint will return a history of block production stats for the requested network and account.
80
+
81
+ client.get_validator_block_history(
82
+ network: "testnet",
83
+ id: "validator_account"
84
+ )
85
+
86
+ # Epoch Index
87
+ # The Epoch endpoint will return all epoch data.
88
+
89
+ client.get_epochs(
90
+ network: "testnet",
91
+ per: 10,
92
+ page: 2
93
+ )
94
+
95
+ # Commission Change Index
96
+ # The Commission Change endpoint will return all the changes in commission for a given period of time.
97
+
98
+ client.get_commission_changes(
99
+ network: "testnet",
100
+ date_from: DateTime.now - 30.days,
101
+ date_to: DateTime.now,
102
+ per: 100,
103
+ page: 1,
104
+ query: "example"
105
+ )
106
+
107
+ # Stake Pools
108
+ # The Stake Pools endpoint will return all the stake pools.
109
+
110
+ client.get_stake_pools(
111
+ network: "testnet"
112
+ )
113
+
114
+ # Stake Accounts
115
+ # The Stake Accounts endpoint will return all the stake accounts grouped by vote accounts.
116
+
117
+ client.get_stake_accounts(
118
+ network: "testnet",
119
+ filter_account: "example",
120
+ sort_by: "epoch_desc",
121
+ per: 10,
122
+ page: 1
123
+ )
124
+
125
+ # Ping Thing Post
126
+ # The Ping Thing Post endpoint allows you to push information about transaction times.
127
+
128
+ client.post_ping_thing(
129
+ network: "testnet",
130
+ application: "cli",
131
+ commitment_level: "finished",
132
+ signature: "tested_signature",
133
+ reported_at: DateTime.now,
134
+ success: true,
135
+ time: 123,
136
+ transaction_type: "transfer"
137
+ )
138
+
139
+ # Ping Thing Post Batch
140
+ # The Ping Thing Batch endpoint allows you to push multiple transaction informations at once.
141
+
142
+ client.post_ping_thing_batch(
143
+ network: @testnet_network,
144
+ transactions: [
145
+ {
146
+ application: "cli",
147
+ commitment_level: "finished",
148
+ signature: "tested_signature",
149
+ reported_at: DateTime.now,
150
+ success: true,
151
+ time: 123,
152
+ transaction_type: "transfer"
153
+ }
154
+ ]
155
+ )
156
+
157
+ # Ping Thing List
158
+ # This Ping Thing List endpoint will return a list of pings for the requested network.
159
+
160
+ client.get_ping_thing(
161
+ network: "testnet",
162
+ limit: 100,
163
+ page: 1
164
+ )
165
+
166
+ # Sol Prices
167
+ # The Sol Prices endpoind will return prices gathered from multiple exchanges.
168
+
169
+ client.get_sol_prices(
170
+ from: DateTime.now - 30.days,
171
+ to: DateTime.now,
172
+ exchange: "coin_gecko"
173
+ )
174
+ ```
175
+
176
+ ## Development
177
+
178
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
179
+
180
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
181
+
182
+ ## Contributing
183
+
184
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Block-Logic/validators-app-ruby. 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/Block-Logic/validators-app-ruby/blob/master/CODE_OF_CONDUCT.md).
185
+
186
+ ## License
187
+
188
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
189
+
190
+ ## Code of Conduct
191
+
192
+ Everyone interacting in the validators-app-ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Block-Logic/validators-app-ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "validators_app_ruby"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ 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
data/demo.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/validators_app_ruby"
4
+
5
+ client = ValidatorsAppRuby.new("token")
6
+
7
+ puts client.getting_ping
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ValidatorsAppRubyVersion
4
+ VERSION = "1.0.0.pre"
5
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+ require_relative "validators_app_ruby/version"
5
+
6
+ class ValidatorsAppRuby
7
+ class Error < StandardError; end
8
+
9
+ include HTTParty
10
+
11
+ VALIDATORS_PATH = "https://validators.app/api/v1"
12
+ AVAILABLE_NETWORKS = %w(mainnet testnet).freeze
13
+
14
+ def initialize(token:, url: VALIDATORS_PATH)
15
+ @token = token
16
+ @url = url
17
+ end
18
+
19
+ # EXAMPLE: get_validators(network: "mainnet")
20
+ def method_missing(method, **args)
21
+ network = validate_network(network: args[:network])
22
+ path = prepare_path(path: method, network: network, id: args[:id])
23
+ params = args.reject{ |a| [:network, :id].include?(a) }
24
+
25
+ if method.to_s.start_with?("get_")
26
+ response = self.class.get(path, query: params, headers: headers)
27
+ elsif method.to_s.start_with?("post_")
28
+ response = self.class.post(path, body: params.to_json, headers: headers)
29
+ else
30
+ super
31
+ end
32
+
33
+ raise ArgumentError, "Request failed with #{response.code}: #{response.message}" \
34
+ unless response.code < 300
35
+
36
+ response
37
+ end
38
+
39
+ def prepare_path(path:, network: nil, id: nil)
40
+ [@url, path.to_s.split("_")[1..-1].join("-"), network, id].compact.join("/")
41
+ end
42
+
43
+ def validate_network(network: nil)
44
+ return nil unless network
45
+
46
+ raise ArgumentError, "Allowed networks are: #{AVAILABLE_NETWORKS.join(', ')}." \
47
+ unless AVAILABLE_NETWORKS.include?(network)
48
+
49
+ network
50
+ end
51
+
52
+ def headers
53
+ {
54
+ "Content-Type" => "application/json",
55
+ "Token" => @token
56
+ }
57
+ end
58
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/validators_app_ruby/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "validators_app_ruby"
7
+ spec.version = ValidatorsAppRubyVersion::VERSION
8
+ spec.authors = ["BlockLogic team"]
9
+ spec.email = ["maciej.kocyla@polcode.net"]
10
+
11
+ spec.summary = "Ruby wrapper for validators.app API endpoints"
12
+ spec.homepage = "https://github.com/Block-Logic/validators-app-ruby"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/Block-Logic/validators-app-ruby"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "httparty", "~> 0.20"
29
+
30
+ spec.add_development_dependency "dotenv", "~> 2.7.6"
31
+ spec.add_development_dependency "minitest-vcr", "~> 1.4.0"
32
+ spec.add_development_dependency "webmock", "~> 3.14.0"
33
+
34
+ # Uncomment to register a new dependency of your gem
35
+ # spec.add_dependency "example-gem", "~> 1.0"
36
+
37
+ # For more information and examples about making a new gem, checkout our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: validators_app_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - BlockLogic team
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-30 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.20'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.20'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.7.6
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.7.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-vcr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.4.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.4.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.14.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.14.0
69
+ description:
70
+ email:
71
+ - maciej.kocyla@polcode.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".github/workflows/test_suite.yml"
77
+ - ".gitignore"
78
+ - ".rubocop.yml"
79
+ - ".ruby-version"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/console
88
+ - bin/setup
89
+ - demo.rb
90
+ - lib/validators_app_ruby.rb
91
+ - lib/validators_app_ruby/version.rb
92
+ - validators_app_ruby.gemspec
93
+ homepage: https://github.com/Block-Logic/validators-app-ruby
94
+ licenses:
95
+ - MIT
96
+ metadata:
97
+ homepage_uri: https://github.com/Block-Logic/validators-app-ruby
98
+ source_code_uri: https://github.com/Block-Logic/validators-app-ruby
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 2.3.0
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">"
111
+ - !ruby/object:Gem::Version
112
+ version: 1.3.1
113
+ requirements: []
114
+ rubygems_version: 3.0.9
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Ruby wrapper for validators.app API endpoints
118
+ test_files: []