saeed_ba_tester 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d31eb18abfa9b11baf8d82f092278aeffab6231615ea0aa534f12b5ce41ca8ce
4
+ data.tar.gz: 95625eba01b8aa0ce6ec6bf3d6895835a024296db81d1ef65d25165ce82387c5
5
+ SHA512:
6
+ metadata.gz: 1948464bc7784bce210de80de851b02ef39982e18570ea941944d1cf1ec4ed5eb2ccb50f9fdb0937063b0b7339f63765cf11c279034aa6ec444f6f83d9c351ba
7
+ data.tar.gz: dde09527006ba49fcb46374ca9415221421452eec06bc594e0e9304182a6f4f90411e0c883f9eacda8178cfacad19daa396838816d5f2a978671e08e5fd94bd4
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2020 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
+ APIMATIC is a trade mark for APIMATIC Limited
data/README.md ADDED
@@ -0,0 +1,128 @@
1
+
2
+ # Getting Started with BATester
3
+
4
+ ## Building
5
+
6
+ The generated code depends on a few Ruby gems. The references to these gems are added in the gemspec file. The easiest way to resolve the dependencies, build the gem and install it is through Rake:
7
+
8
+ 1. Install Rake if not already installed: `gem install rake`
9
+ 2. Install Bundler if not already installed: `gem install bundler`
10
+ 3. From terminal/cmd navigate to the root directory of the SDK.
11
+ 4. Invoke: `rake install`
12
+
13
+ Alternatively, you can build and install the gem manually:
14
+
15
+ 1. From terminal/cmd navigate to the root directory of the SDK.
16
+ 2. Run the build command: `gem build ba_tester.gemspec`
17
+ 3. Run the install command: `gem install ba_tester-1.0.0.gem`
18
+
19
+ ![Installing Gem](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&gemVer=1.0.0&gemName=ba_tester&step=buildSDK)
20
+
21
+ ## Installation
22
+
23
+ The following section explains how to use the ba_tester ruby gem in a new Rails project using RubyMine™. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
24
+
25
+ ### 1. Starting a new project
26
+
27
+ Close any existing projects in RubyMine™ by selecting `File -> Close Project`. Next, click on `Create New Project` to create a new project from scratch.
28
+
29
+ ![Create a new project in RubyMine - Step 1](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&step=createNewProject0)
30
+
31
+ Next, provide `TestApp` as the project name, choose `Rails Application` as the project type, and click `OK`.
32
+
33
+ ![Create a new Rails Application in RubyMine - Step 2](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&step=createNewProject1)
34
+
35
+ In the next dialog make sure that the correct Ruby SDK is being used (>= 2.5.0 and < 3.0.0) and click `OK`.
36
+
37
+ ![Create a new Rails Application in RubyMine - Step 3](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&step=createNewProject2)
38
+
39
+ ### 2. Add reference of the gem
40
+
41
+ In order to use the Tester gem in the new project we must add a gem reference. Locate the `Gemfile` in the Project Explorer window under the `TestApp` project node. The file contains references to all gems being used in the project. Here, add the reference to the library gem by adding the following line: `gem 'ba_tester', '1.0.0'`
42
+
43
+ ![Add new reference to the Gemfile](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&gemVer=1.0.0&gemName=ba_tester&step=addReference)
44
+
45
+ ### 3. Adding a new Rails Controller
46
+
47
+ Once the `TestApp` project is created, a folder named `controllers` will be visible in the *Project Explorer* under the following path: `TestApp > app > controllers`. Right click on this folder and select `New -> Run Rails Generator...`.
48
+
49
+ ![Run Rails Generator on Controllers Folder](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&gemVer=1.0.0&gemName=ba_tester&step=addCode0)
50
+
51
+ Selecting the said option will popup a small window where the generator names are displayed. Here, select the `controller` template.
52
+
53
+ ![Create a new Controller](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&step=addCode1)
54
+
55
+ Next, a popup window will ask you for a Controller name and included Actions. For controller name provide `Hello` and include an action named `Index` and click `OK`.
56
+
57
+ ![Add a new Controller](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&gemVer=1.0.0&gemName=ba_tester&step=addCode2)
58
+
59
+ A new controller class named `HelloController` will be created in a file named `hello_controller.rb` containing a method named `Index`. In this method, add code for initialization and a sample for its usage.
60
+
61
+ ![Initialize the library](https://apidocs.io/illustration/ruby?workspaceFolder=BaTester&gemName=ba_tester&step=addCode3)
62
+
63
+ ## Test the SDK
64
+
65
+ To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
66
+
67
+ ```
68
+ rake
69
+ ```
70
+
71
+ ## Initialize the API Client
72
+
73
+ **_Note:_** Documentation for the client can be found [here.](/doc/client.md)
74
+
75
+ The following parameters are configurable for the API Client:
76
+
77
+ | Parameter | Type | Description |
78
+ | --- | --- | --- |
79
+ | `basic_auth_user_name` | `String` | The username to use with basic authentication |
80
+ | `basic_auth_password` | `String` | The password to use with basic authentication |
81
+ | `port` | `String` | *Default*: `'80'` |
82
+ | `suites` | `SuiteCodeEnum` | *Default*: `SuiteCodeEnum::HEARTS` |
83
+ | `environment` | Environment | The API environment. <br> **Default: `Environment.TESTING`** |
84
+ | `http_client_instance` | `HttpClient` | The Http Client passed from the sdk user for making requests |
85
+ | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
86
+ | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
87
+ | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
88
+ | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
89
+ | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
90
+ | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
91
+
92
+ The API client can be initialized as follows:
93
+
94
+ ```ruby
95
+ client = BaTester::Client.new(
96
+ basic_auth_user_name: 'BasicAuthUserName',
97
+ basic_auth_password: 'BasicAuthPassword',
98
+ environment: Environment::TESTING,
99
+ port: '80',
100
+ suites: SuiteCodeEnum::HEARTS,
101
+ )
102
+ ```
103
+
104
+ ## Environments
105
+
106
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
107
+
108
+ ### Fields
109
+
110
+ | Name | Description |
111
+ | --- | --- |
112
+ | production | - |
113
+ | testing | **Default** |
114
+
115
+ ## Authorization
116
+
117
+ This API uses `Basic Authentication`.
118
+
119
+ ## List of APIs
120
+
121
+ * [API](/doc/controllers/api.md)
122
+
123
+ ## Classes Documentation
124
+
125
+ * [Utility Classes](/doc/utility-classes.md)
126
+ * [HttpResponse](/doc/http-response.md)
127
+ * [HttpRequest](/doc/http-request.md)
128
+
@@ -0,0 +1,279 @@
1
+ # ba_tester
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module BaTester
7
+ # API utility class
8
+ class APIHelper
9
+ # Serializes an array parameter (creates key value pairs).
10
+ # @param [String] The name of the parameter.
11
+ # @param [Array] The value of the parameter.
12
+ # @param [String] The format of the serialization.
13
+ def self.serialize_array(key, array, formatting: 'indexed')
14
+ tuples = []
15
+
16
+ case formatting
17
+ when 'unindexed'
18
+ tuples += array.map { |element| ["#{key}[]", element] }
19
+ when 'indexed'
20
+ tuples += array.map.with_index do |element, index|
21
+ ["#{key}[#{index}]", element]
22
+ end
23
+ when 'plain'
24
+ tuples += array.map { |element| [key, element] }
25
+ else
26
+ raise ArgumentError, 'Invalid format provided.'
27
+ end
28
+ tuples
29
+ end
30
+
31
+ # Replaces template parameters in the given url.
32
+ # @param [String] The query string builder to replace the template
33
+ # parameters.
34
+ # @param [Hash] The parameters to replace in the url.
35
+ def self.append_url_with_template_parameters(query_builder, parameters)
36
+ # perform parameter validation
37
+ unless query_builder.instance_of? String
38
+ raise ArgumentError, 'Given value for parameter \"query_builder\" is
39
+ invalid.'
40
+ end
41
+
42
+ # Return if there are no parameters to replace.
43
+ return query_builder if parameters.nil?
44
+
45
+ parameters.each do |key, val|
46
+ if val.nil?
47
+ replace_value = ''
48
+ elsif val['value'].instance_of? Array
49
+ if val['encode'] == true
50
+ val['value'].map! { |element| CGI.escape(element.to_s) }
51
+ else
52
+ val['value'].map!(&:to_s)
53
+ end
54
+ replace_value = val['value'].join('/')
55
+ else
56
+ replace_value = if val['encode'] == true
57
+ CGI.escape(val['value'].to_s)
58
+ else
59
+ val['value'].to_s
60
+ end
61
+ end
62
+
63
+ # Find the template parameter and replace it with its value.
64
+ query_builder = query_builder.gsub("{#{key}}", replace_value)
65
+ end
66
+ query_builder
67
+ end
68
+
69
+ # Appends the given set of parameters to the given query string.
70
+ # @param [String] The query string builder to add the query parameters to.
71
+ # @param [Hash] The parameters to append.
72
+ def self.append_url_with_query_parameters(query_builder, parameters)
73
+ # Perform parameter validation.
74
+ unless query_builder.instance_of? String
75
+ raise ArgumentError, 'Given value for parameter \"query_builder\"
76
+ is invalid.'
77
+ end
78
+
79
+ # Return if there are no parameters to replace.
80
+ return query_builder if parameters.nil?
81
+
82
+ array_serialization = 'indexed'
83
+
84
+ parameters.each do |key, value|
85
+ seperator = query_builder.include?('?') ? '&' : '?'
86
+ unless value.nil?
87
+ if value.instance_of? Array
88
+ value.compact!
89
+ query_builder += case array_serialization
90
+ when 'csv'
91
+ "#{seperator}#{key}=#{value.map do |element|
92
+ CGI.escape(element.to_s)
93
+ end.join(',')}"
94
+ when 'psv'
95
+ "#{seperator}#{key}=#{value.map do |element|
96
+ CGI.escape(element.to_s)
97
+ end.join('|')}"
98
+ when 'tsv'
99
+ "#{seperator}#{key}=#{value.map do |element|
100
+ CGI.escape(element.to_s)
101
+ end.join("\t")}"
102
+ else
103
+ "#{seperator}#{APIHelper.serialize_array(
104
+ key, value, formatting: array_serialization
105
+ ).map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }
106
+ .join('&')}"
107
+ end
108
+ else
109
+ query_builder += "#{seperator}#{key}=#{CGI.escape(value.to_s)}"
110
+ end
111
+ end
112
+ end
113
+ query_builder
114
+ end
115
+
116
+ # Validates and processes the given Url.
117
+ # @param [String] The given Url to process.
118
+ # @return [String] Pre-processed Url as string.
119
+ def self.clean_url(url)
120
+ # Perform parameter validation.
121
+ raise ArgumentError, 'Invalid Url.' unless url.instance_of? String
122
+
123
+ # Ensure that the urls are absolute.
124
+ matches = url.match(%r{^(https?://[^/]+)})
125
+ raise ArgumentError, 'Invalid Url format.' if matches.nil?
126
+
127
+ # Get the http protocol match.
128
+ protocol = matches[1]
129
+
130
+ # Check if parameters exist.
131
+ index = url.index('?')
132
+
133
+ # Remove redundant forward slashes.
134
+ query = url[protocol.length...(!index.nil? ? index : url.length)]
135
+ query.gsub!(%r{//+}, '/')
136
+
137
+ # Get the parameters.
138
+ parameters = !index.nil? ? url[url.index('?')...url.length] : ''
139
+
140
+ # Return processed url.
141
+ protocol + query + parameters
142
+ end
143
+
144
+ # Parses JSON string.
145
+ # @param [String] A JSON string.
146
+ def self.json_deserialize(json)
147
+ JSON.parse(json)
148
+ rescue StandardError
149
+ raise TypeError, 'Server responded with invalid JSON.'
150
+ end
151
+
152
+ # Removes elements with empty values from a hash.
153
+ # @param [Hash] The hash to clean.
154
+ def self.clean_hash(hash)
155
+ hash.delete_if { |_key, value| value.to_s.strip.empty? }
156
+ end
157
+
158
+ # Form encodes a hash of parameters.
159
+ # @param [Hash] The hash of parameters to encode.
160
+ # @return [Hash] A hash with the same parameters form encoded.
161
+ def self.form_encode_parameters(form_parameters)
162
+ array_serialization = 'indexed'
163
+ encoded = {}
164
+ form_parameters.each do |key, value|
165
+ encoded.merge!(APIHelper.form_encode(value, key, formatting:
166
+ array_serialization))
167
+ end
168
+ encoded
169
+ end
170
+
171
+ def self.custom_merge(a, b)
172
+ x = {}
173
+ a.each do |key, value_a|
174
+ b.each do |k, value_b|
175
+ next unless key == k
176
+
177
+ x[k] = []
178
+ if value_a.instance_of? Array
179
+ value_a.each do |v|
180
+ x[k].push(v)
181
+ end
182
+ else
183
+ x[k].push(value_a)
184
+ end
185
+ if value_b.instance_of? Array
186
+ value_b.each do |v|
187
+ x[k].push(v)
188
+ end
189
+ else
190
+ x[k].push(value_b)
191
+ end
192
+ a.delete(k)
193
+ b.delete(k)
194
+ end
195
+ end
196
+ x.merge!(a)
197
+ x.merge!(b)
198
+ x
199
+ end
200
+
201
+ # Form encodes an object.
202
+ # @param [Dynamic] An object to form encode.
203
+ # @param [String] The name of the object.
204
+ # @return [Hash] A form encoded representation of the object in the form
205
+ # of a hash.
206
+ def self.form_encode(obj, instance_name, formatting: 'indexed')
207
+ retval = {}
208
+
209
+ serializable_types = [String, Numeric, TrueClass,
210
+ FalseClass, Date, DateTime]
211
+
212
+ # If this is a structure, resolve it's field names.
213
+ obj = obj.to_hash if obj.is_a? BaseModel
214
+
215
+ # Create a form encoded hash for this object.
216
+ if obj.nil?
217
+ nil
218
+ elsif obj.instance_of? Array
219
+ if formatting == 'indexed'
220
+ obj.each_with_index do |value, index|
221
+ retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]"))
222
+ end
223
+ elsif serializable_types.map { |x| obj[0].is_a? x }.any?
224
+ obj.each do |value|
225
+ abc = if formatting == 'unindexed'
226
+ APIHelper.form_encode(value, "#{instance_name}[]",
227
+ formatting: formatting)
228
+ else
229
+ APIHelper.form_encode(value, instance_name,
230
+ formatting: formatting)
231
+ end
232
+ retval = APIHelper.custom_merge(retval, abc)
233
+ end
234
+ else
235
+ obj.each_with_index do |value, index|
236
+ retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]",
237
+ formatting: formatting))
238
+ end
239
+ end
240
+ elsif obj.instance_of? Hash
241
+ obj.each do |key, value|
242
+ retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{key}]",
243
+ formatting: formatting))
244
+ end
245
+ elsif obj.instance_of? File
246
+ retval[instance_name] = UploadIO.new(
247
+ obj, 'application/octet-stream', File.basename(obj.path)
248
+ )
249
+ else
250
+ retval[instance_name] = obj
251
+ end
252
+ retval
253
+ end
254
+
255
+ # Retrieves a field from a Hash/Array based on an Array of keys/indexes
256
+ # @param [Hash, Array] The hash to extract data from
257
+ # @param [Array<String, Integer>] The keys/indexes to use
258
+ # @return [Object] The extracted value
259
+ def self.map_response(obj, keys)
260
+ val = obj
261
+ begin
262
+ keys.each do |key|
263
+ val = if val.is_a? Array
264
+ if key.to_i.to_s == key
265
+ val[key.to_i]
266
+ else
267
+ val = nil
268
+ end
269
+ else
270
+ val.fetch(key.to_sym)
271
+ end
272
+ end
273
+ rescue NoMethodError, TypeError, IndexError
274
+ val = nil
275
+ end
276
+ val
277
+ end
278
+ end
279
+ end
@@ -0,0 +1,41 @@
1
+ # ba_tester
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module BaTester
7
+ # ba_tester client class.
8
+ class Client
9
+ attr_reader :config
10
+
11
+ # Access to client controller.
12
+ # @return [APIController] Returns the controller instance.
13
+ def client
14
+ @client ||= APIController.new config
15
+ end
16
+
17
+ def initialize(http_client_instance: nil, timeout: 60, max_retries: 0,
18
+ retry_interval: 1, backoff_factor: 2,
19
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
20
+ retry_methods: %i[get put],
21
+ environment: Environment::TESTING, port: '80',
22
+ suites: SuiteCodeEnum::HEARTS,
23
+ basic_auth_user_name: 'TODO: Replace',
24
+ basic_auth_password: 'TODO: Replace', config: nil)
25
+ @config = if config.nil?
26
+ Configuration.new(http_client_instance: http_client_instance,
27
+ timeout: timeout, max_retries: max_retries,
28
+ retry_interval: retry_interval,
29
+ backoff_factor: backoff_factor,
30
+ retry_statuses: retry_statuses,
31
+ retry_methods: retry_methods,
32
+ environment: environment, port: port,
33
+ suites: suites,
34
+ basic_auth_user_name: basic_auth_user_name,
35
+ basic_auth_password: basic_auth_password)
36
+ else
37
+ config
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,148 @@
1
+ # ba_tester
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module BaTester
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze,
11
+ TESTING = 'testing'.freeze
12
+ ].freeze
13
+ end
14
+
15
+ # An enum for API servers.
16
+ class Server
17
+ SERVER = [
18
+ DEFAULT = 'default'.freeze,
19
+ AUTH_SERVER = 'auth server'.freeze
20
+ ].freeze
21
+ end
22
+
23
+ # All configuration including auth info and base URI for the API access
24
+ # are configured in this class.
25
+ class Configuration
26
+ # The attribute readers for properties.
27
+ attr_reader :http_client, :http_client_instance, :timeout, :max_retries, :retry_interval,
28
+ :backoff_factor, :retry_statuses, :retry_methods, :environment, :port, :suites,
29
+ :basic_auth_user_name, :basic_auth_password
30
+
31
+ class << self
32
+ attr_reader :environments
33
+ end
34
+
35
+ def initialize(http_client_instance: nil, timeout: 60, max_retries: 0,
36
+ retry_interval: 1, backoff_factor: 2,
37
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
38
+ retry_methods: %i[get put],
39
+ environment: Environment::TESTING, port: '80',
40
+ suites: SuiteCodeEnum::HEARTS,
41
+ basic_auth_user_name: 'TODO: Replace',
42
+ basic_auth_password: 'TODO: Replace')
43
+ # The Http Client passed from the sdk user for making requests
44
+ @http_client_instance = http_client_instance
45
+
46
+ # The value to use for connection timeout
47
+ @timeout = timeout
48
+
49
+ # The number of times to retry an endpoint call if it fails
50
+ @max_retries = max_retries
51
+
52
+ # Pause in seconds between retries
53
+ @retry_interval = retry_interval
54
+
55
+ # The amount to multiply each successive retry's interval amount
56
+ # by in order to provide backoff
57
+ @backoff_factor = backoff_factor
58
+
59
+ # A list of HTTP statuses to retry
60
+ @retry_statuses = retry_statuses
61
+
62
+ # A list of HTTP methods to retry
63
+ @retry_methods = retry_methods
64
+
65
+ # Current API environment
66
+ @environment = String(environment)
67
+
68
+ # port value
69
+ @port = port
70
+
71
+ # suites value
72
+ @suites = suites
73
+
74
+ # The username to use with basic authentication
75
+ @basic_auth_user_name = basic_auth_user_name
76
+
77
+ # The password to use with basic authentication
78
+ @basic_auth_password = basic_auth_password
79
+
80
+ # The Http Client to use for making requests.
81
+ @http_client = create_http_client
82
+ end
83
+
84
+ def clone_with(http_client_instance: nil, timeout: nil, max_retries: nil,
85
+ retry_interval: nil, backoff_factor: nil,
86
+ retry_statuses: nil, retry_methods: nil, environment: nil,
87
+ port: nil, suites: nil, basic_auth_user_name: nil,
88
+ basic_auth_password: nil)
89
+ http_client_instance ||= self.http_client_instance
90
+ timeout ||= self.timeout
91
+ max_retries ||= self.max_retries
92
+ retry_interval ||= self.retry_interval
93
+ backoff_factor ||= self.backoff_factor
94
+ retry_statuses ||= self.retry_statuses
95
+ retry_methods ||= self.retry_methods
96
+ environment ||= self.environment
97
+ port ||= self.port
98
+ suites ||= self.suites
99
+ basic_auth_user_name ||= self.basic_auth_user_name
100
+ basic_auth_password ||= self.basic_auth_password
101
+
102
+ Configuration.new(http_client_instance: http_client_instance,
103
+ timeout: timeout, max_retries: max_retries,
104
+ retry_interval: retry_interval,
105
+ backoff_factor: backoff_factor,
106
+ retry_statuses: retry_statuses,
107
+ retry_methods: retry_methods, environment: environment,
108
+ port: port, suites: suites,
109
+ basic_auth_user_name: basic_auth_user_name,
110
+ basic_auth_password: basic_auth_password)
111
+ end
112
+
113
+ def create_http_client
114
+ FaradayClient.new(timeout: timeout, max_retries: max_retries,
115
+ retry_interval: retry_interval,
116
+ backoff_factor: backoff_factor,
117
+ retry_statuses: retry_statuses,
118
+ retry_methods: retry_methods,
119
+ http_client_instance: http_client_instance)
120
+ end
121
+
122
+ # All the environments the SDK can run in.
123
+ ENVIRONMENTS = {
124
+ Environment::PRODUCTION => {
125
+ Server::DEFAULT => 'http://apimatic.hopto.org:{suites}',
126
+ Server::AUTH_SERVER => 'http://apimaticauth.hopto.org:3000'
127
+ },
128
+ Environment::TESTING => {
129
+ Server::DEFAULT => 'http://localhost:3000',
130
+ Server::AUTH_SERVER => 'http://apimaticauth.xhopto.org:3000'
131
+ }
132
+ }.freeze
133
+
134
+ # Generates the appropriate base URI for the environment and the server.
135
+ # @param [Configuration::Server] The server enum for which the base URI is
136
+ # required.
137
+ # @return [String] The base URI.
138
+ def get_base_uri(server = Server::DEFAULT)
139
+ parameters = {
140
+ 'port' => { 'value' => port, 'encode' => false },
141
+ 'suites' => { 'value' => suites, 'encode' => false }
142
+ }
143
+ APIHelper.append_url_with_template_parameters(
144
+ ENVIRONMENTS[environment][server], parameters
145
+ )
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,33 @@
1
+ # ba_tester
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module BaTester
7
+ # APIController
8
+ class APIController < BaseController
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # TODO: type endpoint description here
14
+ # @return [String] response from the API call
15
+ def get_basic_auth_test
16
+ # Prepare query url.
17
+ _query_builder = config.get_base_uri
18
+ _query_builder << '/auth/basic'
19
+ _query_url = APIHelper.clean_url _query_builder
20
+
21
+ # Prepare and execute HttpRequest.
22
+ _request = config.http_client.get(
23
+ _query_url
24
+ )
25
+ BasicAuth.apply(config, _request)
26
+ _response = execute_request(_request)
27
+ validate_response(_response)
28
+
29
+ # Return appropriate response type.
30
+ _response.raw_body
31
+ end
32
+ end
33
+ end