beeceptor_ruby 0.2.0

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: 8e9e3123b36ab28fe28bfa3af99de2946153ae5c8a0881bb6eeb9c84902f3832
4
+ data.tar.gz: 84de13f378c7da98c4966d5a19107ac53a10fa36cce0b88dd206279a5ab67e6b
5
+ SHA512:
6
+ metadata.gz: 6cde750ced5a59cdd1f4057d278260f2314d6dd0ca91569722975300af78a48a6a99963182a96847874b1d0e640c70e3fb370659583f5fd22747c2f28a564b46
7
+ data.tar.gz: 97548adb9ec831fae51fea5b6f79bcca4206b28e20c719b9436c467ec9a3ee9062c8407f0365891ca2d7ddf3c8828e712c3301e1152f9b2f0edb2fabc1374634
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.2.0] - 2022-12-15
4
+
5
+ - Initial release
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 beeceptor_ruby.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Chris Davis
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,47 @@
1
+ # BeeceptorRuby
2
+
3
+ ## Installation
4
+
5
+ Install the gem and add to the application's Gemfile by executing:
6
+
7
+ $ bundle add beeceptor_ruby
8
+
9
+ If bundler is not being used to manage dependencies, install the gem by executing:
10
+
11
+ $ gem install beeceptor_ruby
12
+
13
+ ## Usage
14
+
15
+ This gem provides access to the Beeceptor REST API.
16
+
17
+ ```ruby
18
+ require 'beeceptor_ruby'
19
+
20
+ options = {
21
+ :api_key => 'YOUR_API_KEY',
22
+ :endpoint => 'YOUR_ENDPOINT'
23
+ }
24
+
25
+ client = BeeceptorRuby::Client.new(options)
26
+
27
+ puts client.list_rules
28
+ ```
29
+
30
+ ## Beeceptor REST API Documentation
31
+ - [Overview](https://docs.beeceptor.com/docs/api-overview/)
32
+ - [Rules](https://docs.beeceptor.com/docs/features-mocking-rules/)
33
+ - [History](https://docs.beeceptor.com/docs/api-request-history/)
34
+
35
+ ## Development
36
+
37
+ 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.
38
+
39
+ 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).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/beeceptor_ruby.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: %i[]
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource/history'
4
+ require_relative 'resource/rules'
5
+ require 'faraday'
6
+ require 'json'
7
+
8
+ module BeeceptorRuby
9
+ # Client provides methods for interacting with all beeceptor
10
+ # features i.e. mocking rules and api request
11
+ class Client
12
+ include BeeceptorRuby::Client::Resource::History
13
+ include BeeceptorRuby::Client::Resource::Rules
14
+
15
+ def initialize(options)
16
+ @base_url = "https://api.beeceptor.com/api/v1/endpoints/#{options[:endpoint]}"
17
+ @api_key = options[:api_key]
18
+ @client = Faraday.new(@base_url, builder: build_middleware) do |http|
19
+ http.headers[:content_type] = 'application/json'
20
+ http.headers[:authorization] = @api_key
21
+ end
22
+ end
23
+
24
+ attr_reader :base_url
25
+
26
+ def request(method, path, params = {}, headers = {})
27
+ path = URI.parse("#{@base_url}#{path}").normalize.to_s
28
+ @client.send(method, path, params, headers)
29
+ end
30
+
31
+ def build_middleware
32
+ Faraday::RackBuilder.new do |builder|
33
+ builder.response :json
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeeceptorRuby
4
+ class Client
5
+ module Resource
6
+ # The History API can be used to retrieve and manage request history
7
+ module History
8
+ def get_request(request_id)
9
+ request :get, "/requests/#{request_id}"
10
+ end
11
+
12
+ def list_requests
13
+ request :get, '/requests'
14
+ end
15
+
16
+ def purge_request(request_id)
17
+ request :delete, "/requests/#{request_id}"
18
+ end
19
+
20
+ def purge_requests
21
+ request :delete, '/requests'
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeeceptorRuby
4
+ class Client
5
+ module Resource
6
+ # The Rules API can be used to create, retrieve, update and delete mocking rules
7
+ module Rules
8
+ def create_rule(body)
9
+ request :post, '/rules', body
10
+ end
11
+
12
+ def get_rule(rule_id)
13
+ request :get, "/rules/#{rule_id}"
14
+ end
15
+
16
+ def list_rules
17
+ request :get, '/rules'
18
+ end
19
+
20
+ def update_rule(rule_id, body)
21
+ request :put, "/rules/#{rule_id}", body
22
+ end
23
+
24
+ def delete_rule(rule_id)
25
+ request :delete, "/rules/#{rule_id}"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeeceptorRuby
4
+ VERSION = '0.2.0'
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'beeceptor_ruby/version'
4
+ require_relative 'beeceptor_ruby/client'
5
+
6
+ module BeeceptorRuby
7
+ class Error < StandardError; end
8
+ end
@@ -0,0 +1,4 @@
1
+ module BeeceptorRuby
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beeceptor_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Davis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.7'
55
+ description: Allows users to use Beeceptor's REST API.
56
+ email:
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - CHANGELOG.md
62
+ - Gemfile
63
+ - LICENSE.txt
64
+ - README.md
65
+ - Rakefile
66
+ - lib/beeceptor_ruby.rb
67
+ - lib/beeceptor_ruby/client.rb
68
+ - lib/beeceptor_ruby/resource/history.rb
69
+ - lib/beeceptor_ruby/resource/rules.rb
70
+ - lib/beeceptor_ruby/version.rb
71
+ - sig/beeceptor_ruby.rbs
72
+ homepage: https://github.com/bodyshopbidsdotcom/beeceptor_ruby
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 2.6.0
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.2.33
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Beeceptor REST API Client for Ruby
95
+ test_files: []