ruby-gems-publish-test 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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +233 -0
  3. data/lib/ruby_gems_publish_test/async/services/pet.rb +64 -0
  4. data/lib/ruby_gems_publish_test/async/services/store.rb +44 -0
  5. data/lib/ruby_gems_publish_test/async/services/user.rb +59 -0
  6. data/lib/ruby_gems_publish_test/async_client.rb +54 -0
  7. data/lib/ruby_gems_publish_test/client.rb +63 -0
  8. data/lib/ruby_gems_publish_test/config.rb +54 -0
  9. data/lib/ruby_gems_publish_test/environment.rb +7 -0
  10. data/lib/ruby_gems_publish_test/error.rb +32 -0
  11. data/lib/ruby_gems_publish_test/http/auth.rb +19 -0
  12. data/lib/ruby_gems_publish_test/http/connection.rb +321 -0
  13. data/lib/ruby_gems_publish_test/http/hooks.rb +17 -0
  14. data/lib/ruby_gems_publish_test/http/response.rb +35 -0
  15. data/lib/ruby_gems_publish_test/models/api_response.rb +70 -0
  16. data/lib/ruby_gems_publish_test/models/category.rb +60 -0
  17. data/lib/ruby_gems_publish_test/models/find_pets_by_status_status.rb +12 -0
  18. data/lib/ruby_gems_publish_test/models/open_model.rb +30 -0
  19. data/lib/ruby_gems_publish_test/models/order.rb +104 -0
  20. data/lib/ruby_gems_publish_test/models/order_status.rb +12 -0
  21. data/lib/ruby_gems_publish_test/models/pet.rb +107 -0
  22. data/lib/ruby_gems_publish_test/models/pet_status.rb +12 -0
  23. data/lib/ruby_gems_publish_test/models/serializable.rb +63 -0
  24. data/lib/ruby_gems_publish_test/models/tag.rb +60 -0
  25. data/lib/ruby_gems_publish_test/models/union_type.rb +12 -0
  26. data/lib/ruby_gems_publish_test/models/user.rb +121 -0
  27. data/lib/ruby_gems_publish_test/serializers/form_serializer.rb +41 -0
  28. data/lib/ruby_gems_publish_test/serializers/json_serializer.rb +41 -0
  29. data/lib/ruby_gems_publish_test/serializers/xml_serializer.rb +56 -0
  30. data/lib/ruby_gems_publish_test/services/pet.rb +151 -0
  31. data/lib/ruby_gems_publish_test/services/store.rb +79 -0
  32. data/lib/ruby_gems_publish_test/services/user.rb +114 -0
  33. data/lib/ruby_gems_publish_test/validator.rb +42 -0
  34. data/lib/ruby_gems_publish_test/version.rb +5 -0
  35. data/lib/ruby_gems_publish_test.rb +37 -0
  36. metadata +196 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac8bd8ba7b57798389ba503764caa99a0c1b3f6b7af024861292d3fde5e57f28
4
+ data.tar.gz: 49cde772617f5d22f632b07428cd5e12cddc1acaaf1ba129b0bda0f696900ef2
5
+ SHA512:
6
+ metadata.gz: 4ff4ecd518225a2d57e82db5d7f793b5ecce32e2ce8eae5b4dee7709e1001bf85ac19e578a840c2553a0298972f31659b0d8f1ac89faab144e41d1f43030d140
7
+ data.tar.gz: 7ba25bde4bc48d3e2459cf0f6d57fc3dec5b07b979264da6184f7a9fd076d6987438e1714fdd11a8663d33d304ba9a2853820868b659eaf75c117003d2745b18
data/README.md ADDED
@@ -0,0 +1,233 @@
1
+ # RubyGemsPublishTest Ruby SDK 0.1.0
2
+
3
+
4
+ Welcome to the RubyGemsPublishTest SDK documentation. This guide will help you get started with integrating and using the RubyGemsPublishTest SDK in your project.
5
+
6
+ ## Versions
7
+
8
+ - API version: `1.0.0`
9
+ - SDK version: `0.1.0`
10
+
11
+ ## About the API
12
+
13
+ This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about
14
+ Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
15
+ You can now help us improve the API whether it's by making changes to the definition itself or to the code.
16
+ That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
17
+
18
+ Some useful links:
19
+ - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
20
+ - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
21
+
22
+ ## Table of Contents
23
+ - [Setup & Configuration](#setup--configuration)
24
+ - [Supported Language Versions](#supported-language-versions)
25
+ - [Installation](#installation)
26
+ - [Authentication](#authentication)
27
+ - [Access Token Authentication](#access-token-authentication)
28
+ - [API Key Authentication](#api-key-authentication)
29
+ - [Sample Usage](#sample-usage)
30
+ - [Services](#services)
31
+ - [Models](#models)
32
+ - [License](#license)
33
+
34
+ # Setup & Configuration
35
+
36
+ ## Supported Language Versions
37
+
38
+ This SDK is compatible with the following versions: `Ruby >= 3.3`
39
+
40
+ ## Installation
41
+
42
+ ### Using RubyGems
43
+
44
+ If the gem is published to RubyGems or a private gem server, install it directly:
45
+
46
+ ```bash
47
+ gem install ruby_gems_publish_test
48
+ ```
49
+
50
+ ### Using Bundler (recommended)
51
+
52
+ Add the gem to your application's `Gemfile`:
53
+
54
+ ```ruby
55
+ gem 'ruby_gems_publish_test'
56
+ ```
57
+
58
+ Then run:
59
+
60
+ ```bash
61
+ bundle install
62
+ ```
63
+
64
+ ## Verifying the SDK setup
65
+
66
+ To verify the SDK works correctly, you can run the included example:
67
+
68
+ 1. Install dependencies:
69
+
70
+ ```bash
71
+ bundle install
72
+ ```
73
+
74
+ 2. Run the example:
75
+
76
+ ```bash
77
+ bundle exec ruby example/example.rb
78
+ ```
79
+
80
+ ## Configuration Scopes
81
+
82
+ The SDK supports three nested configuration scopes. The most-specific scope always wins; changes made at a narrower scope do not persist beyond that scope.
83
+
84
+ ### SDK-level (default)
85
+
86
+ Set once at initialization and applied to every request unless overridden.
87
+
88
+ ```ruby
89
+ require 'ruby_gems_publish_test'
90
+
91
+ sdk = RubyGemsPublishTest::Client.new(
92
+ base_url: 'https://api.example.com',
93
+ timeout: 30,
94
+ # auth credentials are also set here — see the Authentication section below
95
+ )
96
+ ```
97
+
98
+ ### Service-level
99
+
100
+ Override config for all requests made through a particular service instance. The original client and other services are not affected.
101
+
102
+ ```ruby
103
+ override = RubyGemsPublishTest::Config.new(token: 'SERVICE_TOKEN')
104
+ service = sdk.pet(config: override)
105
+ response = service.some_method
106
+ ```
107
+
108
+ ### Per-request
109
+
110
+ Override config for a single call only. The next call automatically reverts to the enclosing scope.
111
+
112
+ ```ruby
113
+ response = sdk.pet.some_method(
114
+ config: RubyGemsPublishTest::Config.new(token: 'REQUEST_TOKEN'),
115
+ )
116
+
117
+ # The next call uses the original SDK-level config automatically
118
+ response = sdk.pet.some_method
119
+ ```
120
+
121
+ Passing `config: nil` explicitly bypasses any service-level override for that single call, falling back directly to the SDK-level (connection) defaults.
122
+
123
+
124
+ ## Authentication
125
+
126
+ ### Access Token Authentication
127
+ The RubyGemsPublishTest API uses an Access Token for authentication.
128
+
129
+ This token must be provided to authenticate your requests to the API.
130
+
131
+ #### Setting the Access Token
132
+
133
+ When you initialize the SDK, you can set the access token as follows:
134
+
135
+ ```ruby
136
+ require 'ruby_gems_publish_test'
137
+
138
+ sdk = RubyGemsPublishTest::Client.new(token: 'YOUR_TOKEN')
139
+ ```
140
+
141
+ If you need to set or update the access token after initializing the SDK, you can use:
142
+
143
+ ```ruby
144
+ require 'ruby_gems_publish_test'
145
+
146
+ sdk = RubyGemsPublishTest::Client.new
147
+
148
+ sdk.token = 'YOUR_TOKEN'
149
+ ```
150
+ ### API Key Authentication
151
+ The RubyGemsPublishTest API uses API keys as a form of authentication. An API key is a unique identifier used to authenticate a user, developer, or a program that is calling the API.
152
+
153
+ #### Setting the API key
154
+
155
+ When you initialize the SDK, you can set the API key as follows:
156
+
157
+ ```ruby
158
+ require 'ruby_gems_publish_test'
159
+
160
+ sdk = RubyGemsPublishTest::Client.new(api_key: 'YOUR_API_KEY')
161
+ ```
162
+
163
+ If you need to set or update the API key after initializing the SDK, you can use:
164
+
165
+ ```ruby
166
+ require 'ruby_gems_publish_test'
167
+
168
+ sdk = RubyGemsPublishTest::Client.new
169
+
170
+ sdk.api_key = 'YOUR_API_KEY'
171
+ ```
172
+
173
+
174
+
175
+
176
+ # Sample Usage
177
+
178
+ Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
179
+
180
+ ```ruby
181
+ require 'ruby_gems_publish_test'
182
+
183
+ sdk = RubyGemsPublishTest::Client.new(api_key: 'YOUR_API_KEY')
184
+
185
+ response = sdk.store.get_inventory
186
+
187
+ puts response
188
+
189
+ ```
190
+
191
+ ## Services
192
+
193
+ The SDK provides various services to interact with the API.
194
+
195
+
196
+ <details>
197
+ <summary>Below is a list of all available services with links to their detailed documentation:</summary>
198
+
199
+ | Name |
200
+ | :--- |
201
+ | [Pet](documentation/services/pet.md) |
202
+ | [Store](documentation/services/store.md) |
203
+ | [User](documentation/services/user.md) |
204
+ </details>
205
+
206
+
207
+ ## Models
208
+
209
+ The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.
210
+
211
+
212
+ <details>
213
+ <summary>Below is a list of all available models with links to their detailed documentation:</summary>
214
+
215
+ | Name | Description |
216
+ | :--------- | :---------- |
217
+ | [Pet](documentation/models/pet.md) | |
218
+ | [Category](documentation/models/category.md) | |
219
+ | [Tag](documentation/models/tag.md) | |
220
+ | [FindPetsByStatusStatus](documentation/models/find_pets_by_status_status.md) | |
221
+ | [ApiResponse](documentation/models/api_response.md) | |
222
+ | [Order](documentation/models/order.md) | |
223
+ | [User](documentation/models/user.md) | |
224
+ </details>
225
+
226
+
227
+ ## License
228
+
229
+ This SDK is licensed under the MIT License.
230
+
231
+ See the [LICENSE](LICENSE) file for more details.
232
+
233
+
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'concurrent'
4
+
5
+ module RubyGemsPublishTest
6
+ module Async
7
+ # Async variant of ::RubyGemsPublishTest::Pet. Each method returns a
8
+ # +Concurrent::Promises::Future+ that runs the corresponding synchronous call on a
9
+ # background thread; resolve it with +#value!+ (re-raises the SDK's typed errors) or
10
+ # +#value+ (returns nil on failure).
11
+ class Pet
12
+ def initialize(connection_factory, config = nil)
13
+ @connection_factory = connection_factory
14
+ @config = config
15
+ end
16
+
17
+ # Async variant of #add_pet; returns a Concurrent::Promises::Future.
18
+ def add_pet(*args, **kwargs, &block)
19
+ Concurrent::Promises.future { service.add_pet(*args, **kwargs, &block) }
20
+ end
21
+
22
+ # Async variant of #update_pet; returns a Concurrent::Promises::Future.
23
+ def update_pet(*args, **kwargs, &block)
24
+ Concurrent::Promises.future { service.update_pet(*args, **kwargs, &block) }
25
+ end
26
+
27
+ # Async variant of #find_pets_by_status; returns a Concurrent::Promises::Future.
28
+ def find_pets_by_status(*args, **kwargs, &block)
29
+ Concurrent::Promises.future { service.find_pets_by_status(*args, **kwargs, &block) }
30
+ end
31
+
32
+ # Async variant of #find_pets_by_tags; returns a Concurrent::Promises::Future.
33
+ def find_pets_by_tags(*args, **kwargs, &block)
34
+ Concurrent::Promises.future { service.find_pets_by_tags(*args, **kwargs, &block) }
35
+ end
36
+
37
+ # Async variant of #get_pet_by_id; returns a Concurrent::Promises::Future.
38
+ def get_pet_by_id(*args, **kwargs, &block)
39
+ Concurrent::Promises.future { service.get_pet_by_id(*args, **kwargs, &block) }
40
+ end
41
+
42
+ # Async variant of #update_pet_with_form; returns a Concurrent::Promises::Future.
43
+ def update_pet_with_form(*args, **kwargs, &block)
44
+ Concurrent::Promises.future { service.update_pet_with_form(*args, **kwargs, &block) }
45
+ end
46
+
47
+ # Async variant of #delete_pet; returns a Concurrent::Promises::Future.
48
+ def delete_pet(*args, **kwargs, &block)
49
+ Concurrent::Promises.future { service.delete_pet(*args, **kwargs, &block) }
50
+ end
51
+
52
+ # Async variant of #upload_file; returns a Concurrent::Promises::Future.
53
+ def upload_file(*args, **kwargs, &block)
54
+ Concurrent::Promises.future { service.upload_file(*args, **kwargs, &block) }
55
+ end
56
+
57
+ private
58
+
59
+ def service
60
+ ::RubyGemsPublishTest::Pet.new(@connection_factory.call, @config)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'concurrent'
4
+
5
+ module RubyGemsPublishTest
6
+ module Async
7
+ # Async variant of ::RubyGemsPublishTest::Store. Each method returns a
8
+ # +Concurrent::Promises::Future+ that runs the corresponding synchronous call on a
9
+ # background thread; resolve it with +#value!+ (re-raises the SDK's typed errors) or
10
+ # +#value+ (returns nil on failure).
11
+ class Store
12
+ def initialize(connection_factory, config = nil)
13
+ @connection_factory = connection_factory
14
+ @config = config
15
+ end
16
+
17
+ # Async variant of #get_inventory; returns a Concurrent::Promises::Future.
18
+ def get_inventory(*args, **kwargs, &block)
19
+ Concurrent::Promises.future { service.get_inventory(*args, **kwargs, &block) }
20
+ end
21
+
22
+ # Async variant of #place_order; returns a Concurrent::Promises::Future.
23
+ def place_order(*args, **kwargs, &block)
24
+ Concurrent::Promises.future { service.place_order(*args, **kwargs, &block) }
25
+ end
26
+
27
+ # Async variant of #get_order_by_id; returns a Concurrent::Promises::Future.
28
+ def get_order_by_id(*args, **kwargs, &block)
29
+ Concurrent::Promises.future { service.get_order_by_id(*args, **kwargs, &block) }
30
+ end
31
+
32
+ # Async variant of #delete_order; returns a Concurrent::Promises::Future.
33
+ def delete_order(*args, **kwargs, &block)
34
+ Concurrent::Promises.future { service.delete_order(*args, **kwargs, &block) }
35
+ end
36
+
37
+ private
38
+
39
+ def service
40
+ ::RubyGemsPublishTest::Store.new(@connection_factory.call, @config)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'concurrent'
4
+
5
+ module RubyGemsPublishTest
6
+ module Async
7
+ # Async variant of ::RubyGemsPublishTest::User. Each method returns a
8
+ # +Concurrent::Promises::Future+ that runs the corresponding synchronous call on a
9
+ # background thread; resolve it with +#value!+ (re-raises the SDK's typed errors) or
10
+ # +#value+ (returns nil on failure).
11
+ class User
12
+ def initialize(connection_factory, config = nil)
13
+ @connection_factory = connection_factory
14
+ @config = config
15
+ end
16
+
17
+ # Async variant of #create_user; returns a Concurrent::Promises::Future.
18
+ def create_user(*args, **kwargs, &block)
19
+ Concurrent::Promises.future { service.create_user(*args, **kwargs, &block) }
20
+ end
21
+
22
+ # Async variant of #create_users_with_list_input; returns a Concurrent::Promises::Future.
23
+ def create_users_with_list_input(*args, **kwargs, &block)
24
+ Concurrent::Promises.future { service.create_users_with_list_input(*args, **kwargs, &block) }
25
+ end
26
+
27
+ # Async variant of #login_user; returns a Concurrent::Promises::Future.
28
+ def login_user(*args, **kwargs, &block)
29
+ Concurrent::Promises.future { service.login_user(*args, **kwargs, &block) }
30
+ end
31
+
32
+ # Async variant of #logout_user; returns a Concurrent::Promises::Future.
33
+ def logout_user(*args, **kwargs, &block)
34
+ Concurrent::Promises.future { service.logout_user(*args, **kwargs, &block) }
35
+ end
36
+
37
+ # Async variant of #get_user_by_name; returns a Concurrent::Promises::Future.
38
+ def get_user_by_name(*args, **kwargs, &block)
39
+ Concurrent::Promises.future { service.get_user_by_name(*args, **kwargs, &block) }
40
+ end
41
+
42
+ # Async variant of #update_user; returns a Concurrent::Promises::Future.
43
+ def update_user(*args, **kwargs, &block)
44
+ Concurrent::Promises.future { service.update_user(*args, **kwargs, &block) }
45
+ end
46
+
47
+ # Async variant of #delete_user; returns a Concurrent::Promises::Future.
48
+ def delete_user(*args, **kwargs, &block)
49
+ Concurrent::Promises.future { service.delete_user(*args, **kwargs, &block) }
50
+ end
51
+
52
+ private
53
+
54
+ def service
55
+ ::RubyGemsPublishTest::User.new(@connection_factory.call, @config)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyGemsPublishTest
4
+ class AsyncClient
5
+ DEFAULT_BASE_URL = Environment::DEFAULT
6
+
7
+ def initialize(base_url: DEFAULT_BASE_URL, timeout: nil, timeout_ms: nil, token: nil, api_key: nil)
8
+ unless timeout_ms.nil?
9
+ warn '[DEPRECATION] `timeout_ms` is deprecated; use `timeout` (seconds) instead.', uplevel: 1
10
+ timeout = timeout_ms / 1000.0 if timeout.nil?
11
+ end
12
+ @token = token
13
+ @api_key = api_key
14
+ @base_url = base_url
15
+ @timeout = timeout
16
+ factory = method(:build_connection)
17
+ @pet = Async::Pet.new(factory)
18
+ @store = Async::Store.new(factory)
19
+ @user = Async::User.new(factory)
20
+ end
21
+
22
+ def pet(config: nil)
23
+ return @pet unless config
24
+
25
+ Async::Pet.new(method(:build_connection), config)
26
+ end
27
+
28
+ def store(config: nil)
29
+ return @store unless config
30
+
31
+ Async::Store.new(method(:build_connection), config)
32
+ end
33
+
34
+ def user(config: nil)
35
+ return @user unless config
36
+
37
+ Async::User.new(method(:build_connection), config)
38
+ end
39
+
40
+ attr_writer :token, :api_key, :base_url
41
+
42
+ def environment=(env)
43
+ self.base_url = Environment.const_get(env.to_s.upcase)
44
+ rescue NameError
45
+ raise ArgumentError, "Unknown environment: #{env.inspect}"
46
+ end
47
+
48
+ private
49
+
50
+ def build_connection
51
+ HTTP::Connection.new(@base_url, HTTP::Auth.new(token: @token, api_key: @api_key).headers, timeout: @timeout)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyGemsPublishTest
4
+ class Client
5
+ DEFAULT_BASE_URL = Environment::DEFAULT
6
+
7
+ def initialize(base_url: DEFAULT_BASE_URL, timeout: nil, timeout_ms: nil, token: nil, api_key: nil, http_client: nil)
8
+ unless timeout_ms.nil?
9
+ warn '[DEPRECATION] `timeout_ms` is deprecated; use `timeout` (seconds) instead.', uplevel: 1
10
+ timeout = timeout_ms / 1000.0 if timeout.nil?
11
+ end
12
+ @token = token
13
+ @api_key = api_key
14
+ @connection = HTTP::Connection.new(
15
+ base_url,
16
+ HTTP::Auth.new(token: @token, api_key: @api_key).headers,
17
+ timeout: timeout,
18
+ http_client: http_client,
19
+ )
20
+ @pet = Pet.new(@connection)
21
+ @store = Store.new(@connection)
22
+ @user = User.new(@connection)
23
+ end
24
+
25
+ def pet(config: nil)
26
+ return @pet unless config
27
+
28
+ Pet.new(@connection, config)
29
+ end
30
+
31
+ def store(config: nil)
32
+ return @store unless config
33
+
34
+ Store.new(@connection, config)
35
+ end
36
+
37
+ def user(config: nil)
38
+ return @user unless config
39
+
40
+ User.new(@connection, config)
41
+ end
42
+
43
+ def token=(token)
44
+ @token = token
45
+ @connection.default_headers = HTTP::Auth.new(token: @token, api_key: @api_key).headers
46
+ end
47
+
48
+ def api_key=(api_key)
49
+ @api_key = api_key
50
+ @connection.default_headers = HTTP::Auth.new(token: @token, api_key: @api_key).headers
51
+ end
52
+
53
+ def environment=(env)
54
+ self.base_url = Environment.const_get(env.to_s.upcase)
55
+ rescue NameError
56
+ raise ArgumentError, "Unknown environment: #{env.inspect}"
57
+ end
58
+
59
+ def base_url=(url)
60
+ @connection.base_url = url
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyGemsPublishTest
4
+ class Config
5
+ attr_reader :base_url, :timeout, :enable_response_validation, :return_raw, :additional_headers, :additional_query_parameters, :retry_config, :token, :api_key
6
+
7
+ def initialize(
8
+ base_url: nil,
9
+ timeout: nil,
10
+ timeout_ms: nil,
11
+ enable_response_validation: false,
12
+ return_raw: false,
13
+ additional_headers: nil,
14
+ additional_query_parameters: nil,
15
+ retry_config: nil,
16
+ token: nil,
17
+ api_key: nil
18
+ )
19
+ unless timeout_ms.nil?
20
+ warn '[DEPRECATION] `timeout_ms` is deprecated; use `timeout` (seconds) instead.', uplevel: 1
21
+ timeout = timeout_ms / 1000.0 if timeout.nil?
22
+ end
23
+ @base_url = base_url
24
+ @timeout = timeout
25
+ @enable_response_validation = enable_response_validation
26
+ @return_raw = return_raw
27
+ @additional_headers = additional_headers
28
+ @additional_query_parameters = additional_query_parameters
29
+ @retry_config = retry_config
30
+ @token = token
31
+ @api_key = api_key
32
+ end
33
+
34
+ def with(**overrides)
35
+ base = to_h
36
+ base.delete(:timeout) if overrides.key?(:timeout_ms) && !overrides.key?(:timeout)
37
+ self.class.new(**base, **overrides)
38
+ end
39
+
40
+ def to_h
41
+ {
42
+ base_url: @base_url,
43
+ timeout: @timeout,
44
+ enable_response_validation: @enable_response_validation,
45
+ return_raw: @return_raw,
46
+ additional_headers: @additional_headers,
47
+ additional_query_parameters: @additional_query_parameters,
48
+ retry_config: @retry_config,
49
+ token: @token,
50
+ api_key: @api_key,
51
+ }
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyGemsPublishTest
4
+ module Environment
5
+ DEFAULT = 'https://petstore3.swagger.io/api/v3'
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyGemsPublishTest
4
+ class Error < StandardError; end
5
+
6
+ class APIError < Error
7
+ attr_reader :status, :body, :headers
8
+
9
+ def initialize(status, body, headers = {})
10
+ @status = status
11
+ @body = body
12
+ @headers = headers || {}
13
+ super("HTTP #{status}: #{body}")
14
+ end
15
+ end
16
+
17
+ class TimeoutError < Error
18
+ def initialize(msg = 'Request timed out')
19
+ super
20
+ end
21
+ end
22
+
23
+ class ValidationError < Error
24
+ attr_reader :field, :validation_message
25
+
26
+ def initialize(field, message)
27
+ @field = field
28
+ @validation_message = message
29
+ super("Validation failed for #{field}: #{message}")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyGemsPublishTest
4
+ module HTTP
5
+ class Auth
6
+ def initialize(token: nil, api_key: nil)
7
+ @token = token
8
+ @api_key = api_key
9
+ end
10
+
11
+ def headers
12
+ result = {}
13
+ result['Authorization'] = "Bearer #{@token}" unless @token.nil?
14
+ result['api_key'] = @api_key unless @api_key.nil?
15
+ result
16
+ end
17
+ end
18
+ end
19
+ end