hjhjhjnew 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +55 -0
- data/lib/tester.rb +56 -0
- data/lib/tester/api_helper.rb +261 -0
- data/lib/tester/configuration.rb +66 -0
- data/lib/tester/controllers/base_controller.rb +59 -0
- data/lib/tester/controllers/body_params_controller.rb +1270 -0
- data/lib/tester/controllers/echo_controller.rb +134 -0
- data/lib/tester/controllers/error_codes_controller.rb +179 -0
- data/lib/tester/controllers/form_params_controller.rb +1391 -0
- data/lib/tester/controllers/header_controller.rb +63 -0
- data/lib/tester/controllers/query_param_controller.rb +779 -0
- data/lib/tester/controllers/response_types_controller.rb +717 -0
- data/lib/tester/controllers/template_params_controller.rb +93 -0
- data/lib/tester/exceptions/api_exception.rb +18 -0
- data/lib/tester/exceptions/global_test_exception.rb +32 -0
- data/lib/tester/exceptions/local_test_exception.rb +30 -0
- data/lib/tester/exceptions/nested_model_exception.rb +37 -0
- data/lib/tester/http/faraday_client.rb +55 -0
- data/lib/tester/http/http_call_back.rb +22 -0
- data/lib/tester/http/http_client.rb +92 -0
- data/lib/tester/http/http_context.rb +18 -0
- data/lib/tester/http/http_method_enum.rb +11 -0
- data/lib/tester/http/http_request.rb +48 -0
- data/lib/tester/http/http_response.rb +21 -0
- data/lib/tester/models/additional_model_parameters.rb +70 -0
- data/lib/tester/models/base_model.rb +52 -0
- data/lib/tester/models/boss.rb +129 -0
- data/lib/tester/models/days.rb +30 -0
- data/lib/tester/models/delete_body.rb +52 -0
- data/lib/tester/models/echo_response.rb +88 -0
- data/lib/tester/models/employee.rb +155 -0
- data/lib/tester/models/job.rb +43 -0
- data/lib/tester/models/person.rb +113 -0
- data/lib/tester/models/query_parameter.rb +43 -0
- data/lib/tester/models/server_response.rb +61 -0
- data/lib/tester/models/suite_code.rb +21 -0
- data/lib/tester/models/test_nstring_encoding.rb +52 -0
- data/lib/tester/models/test_r_nstring_encoding.rb +52 -0
- data/lib/tester/models/test_rstring_encoding.rb +52 -0
- data/lib/tester/models/validate.rb +61 -0
- data/lib/tester/tester_client.rb +61 -0
- data/test/controllers/controller_test_base.rb +33 -0
- data/test/controllers/test_body_params_controller.rb +1210 -0
- data/test/controllers/test_echo_controller.rb +29 -0
- data/test/controllers/test_error_codes_controller.rb +47 -0
- data/test/controllers/test_form_params_controller.rb +1099 -0
- data/test/controllers/test_header_controller.rb +30 -0
- data/test/controllers/test_query_param_controller.rb +345 -0
- data/test/controllers/test_response_types_controller.rb +429 -0
- data/test/controllers/test_template_params_controller.rb +47 -0
- data/test/http_response_catcher.rb +16 -0
- data/test/test_helper.rb +91 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b6f53582f48660470fa78c5dc8f81bde3cdc321a9fa7d9ea81034d12ceb6401
|
4
|
+
data.tar.gz: a2dac8db9cce2b98ba5fcb0791a27c520a3eca5cbc5ebe05baeb009e3b9dbb21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fe1c7dd9e6d4644d4273a18f059665f5055985997516b0649f5726568172a3e0884b8a813ecff7c374e3de195b5ca446c15d46828efedf51b3bbe319bca8dfc4
|
7
|
+
data.tar.gz: 5a823e2da73c869ba95f8a5fd491514d89385a836ae58268f1933f3761916762a83db8bbaf3245750e353a65484fe9d67b944f432bb6e4823ce9d559281255eb
|
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 - 2016 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,55 @@
|
|
1
|
+
Tester
|
2
|
+
=================
|
3
|
+
This API SDK was automatically generated by APIMATIC v2.0
|
4
|
+
|
5
|
+
How to configure:
|
6
|
+
=================
|
7
|
+
The generated code might need to be configured with your API credentials. To do that,
|
8
|
+
open the file "configuration.rb" and edit it's contents.
|
9
|
+
|
10
|
+
Alternatively, you can modify the Configuration parameters at run-time through the following:
|
11
|
+
```
|
12
|
+
Tester::Configuration.your_paramater = YOUR_VALUE
|
13
|
+
```
|
14
|
+
|
15
|
+
How to build and install:
|
16
|
+
=============================
|
17
|
+
The generated code depends on a few Ruby gems. The references to these gems are
|
18
|
+
added in the gemspec file. The easiest way to resolve the dependencies,
|
19
|
+
build the gem and install it is through Rake:
|
20
|
+
|
21
|
+
1. Install Rake if not already installed: `gem install rake`
|
22
|
+
2. Install Bundler if not already installed: `gem install bundler`
|
23
|
+
3. From terminal/cmd navigate to the root directory of the SDK.
|
24
|
+
4. Invoke: `rake install`
|
25
|
+
|
26
|
+
Alternatively, you can build and install the gem manually:
|
27
|
+
|
28
|
+
1. From terminal/cmd navigate to the root directory of the SDK.
|
29
|
+
2. Run the build command: `gem build tester.gemspec`
|
30
|
+
3. Run the install command: `gem install ./tester-1.1.0.gem`
|
31
|
+
|
32
|
+
Note: You will need to have internet access for this step.
|
33
|
+
|
34
|
+
How to test:
|
35
|
+
=============
|
36
|
+
You can test the generated SDK and the server with automatically generated test
|
37
|
+
cases as follows:
|
38
|
+
|
39
|
+
1. From terminal/cmd navigate to the root directory of the SDK.
|
40
|
+
2. Invoke: `bundle exec rake`
|
41
|
+
|
42
|
+
How to use:
|
43
|
+
===========
|
44
|
+
After having installed the gem, you can easily use the SDK following these steps.
|
45
|
+
|
46
|
+
1. Create a "tester_test.rb" file in the root directory.
|
47
|
+
2. Use any controller as follows:
|
48
|
+
```ruby
|
49
|
+
require 'tester'
|
50
|
+
|
51
|
+
api_client = Tester::TesterClient.new
|
52
|
+
controller = api_client.response_types_controller
|
53
|
+
response = controller.get_date_array(<required parameters if any>)
|
54
|
+
p response
|
55
|
+
```
|
data/lib/tester.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# This file was automatically generated for Stamplay by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
require 'date'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
require 'certifi'
|
7
|
+
require 'logging'
|
8
|
+
|
9
|
+
require_relative 'tester/api_helper.rb'
|
10
|
+
require_relative 'tester/tester_client.rb'
|
11
|
+
|
12
|
+
# Http
|
13
|
+
require_relative 'tester/http/http_call_back.rb'
|
14
|
+
require_relative 'tester/http/http_client.rb'
|
15
|
+
require_relative 'tester/http/http_method_enum.rb'
|
16
|
+
require_relative 'tester/http/http_request.rb'
|
17
|
+
require_relative 'tester/http/http_response.rb'
|
18
|
+
require_relative 'tester/http/http_context.rb'
|
19
|
+
require_relative 'tester/http/faraday_client.rb'
|
20
|
+
|
21
|
+
# Models
|
22
|
+
require_relative 'tester/models/base_model.rb'
|
23
|
+
require_relative 'tester/models/employee.rb'
|
24
|
+
require_relative 'tester/models/boss.rb'
|
25
|
+
require_relative 'tester/models/delete_body.rb'
|
26
|
+
require_relative 'tester/models/echo_response.rb'
|
27
|
+
require_relative 'tester/models/person.rb'
|
28
|
+
require_relative 'tester/models/server_response.rb'
|
29
|
+
require_relative 'tester/models/query_parameter.rb'
|
30
|
+
require_relative 'tester/models/job.rb'
|
31
|
+
require_relative 'tester/models/additional_model_parameters.rb'
|
32
|
+
require_relative 'tester/models/validate.rb'
|
33
|
+
require_relative 'tester/models/test_nstring_encoding.rb'
|
34
|
+
require_relative 'tester/models/test_rstring_encoding.rb'
|
35
|
+
require_relative 'tester/models/test_r_nstring_encoding.rb'
|
36
|
+
require_relative 'tester/models/days.rb'
|
37
|
+
require_relative 'tester/models/suite_code.rb'
|
38
|
+
|
39
|
+
# Exceptions
|
40
|
+
require_relative 'tester/exceptions/api_exception.rb'
|
41
|
+
require_relative 'tester/exceptions/local_test_exception.rb'
|
42
|
+
require_relative 'tester/exceptions/global_test_exception.rb'
|
43
|
+
require_relative 'tester/exceptions/nested_model_exception.rb'
|
44
|
+
|
45
|
+
require_relative 'tester/configuration.rb'
|
46
|
+
|
47
|
+
# Controllers
|
48
|
+
require_relative 'tester/controllers/base_controller.rb'
|
49
|
+
require_relative 'tester/controllers/response_types_controller.rb'
|
50
|
+
require_relative 'tester/controllers/form_params_controller.rb'
|
51
|
+
require_relative 'tester/controllers/body_params_controller.rb'
|
52
|
+
require_relative 'tester/controllers/query_param_controller.rb'
|
53
|
+
require_relative 'tester/controllers/error_codes_controller.rb'
|
54
|
+
require_relative 'tester/controllers/echo_controller.rb'
|
55
|
+
require_relative 'tester/controllers/header_controller.rb'
|
56
|
+
require_relative 'tester/controllers/template_params_controller.rb'
|
@@ -0,0 +1,261 @@
|
|
1
|
+
# This file was automatically generated for Stamplay by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module Tester
|
5
|
+
# API utility class
|
6
|
+
class APIHelper
|
7
|
+
# Serializes an array parameter (creates key value pairs).
|
8
|
+
# @param [String] The name of the parameter.
|
9
|
+
# @param [Array] The value of the parameter.
|
10
|
+
# @param [String] The format of the serialization.
|
11
|
+
def self.serialize_array(key, array, formatting: 'indexed')
|
12
|
+
tuples = []
|
13
|
+
|
14
|
+
if formatting == 'unindexed'
|
15
|
+
tuples += array.map { |element| ["#{key}[]", element] }
|
16
|
+
elsif formatting == 'indexed'
|
17
|
+
tuples += array.map.with_index do |element, index|
|
18
|
+
["#{key}[#{index}]", element]
|
19
|
+
end
|
20
|
+
elsif formatting == 'plain'
|
21
|
+
tuples += array.map { |element| [key, element] }
|
22
|
+
else
|
23
|
+
raise ArgumentError, 'Invalid format provided.'
|
24
|
+
end
|
25
|
+
tuples
|
26
|
+
end
|
27
|
+
|
28
|
+
# Replaces template parameters in the given url.
|
29
|
+
# @param [String] The query string builder to replace the template
|
30
|
+
# parameters.
|
31
|
+
# @param [Hash] The parameters to replace in the url.
|
32
|
+
def self.append_url_with_template_parameters(query_builder, parameters)
|
33
|
+
# perform parameter validation
|
34
|
+
unless query_builder.instance_of? String
|
35
|
+
raise ArgumentError, 'Given value for parameter \"query_builder\" is
|
36
|
+
invalid.'
|
37
|
+
end
|
38
|
+
|
39
|
+
# Return if there are no parameters to replace.
|
40
|
+
return query_builder if parameters.nil?
|
41
|
+
|
42
|
+
# Iterate and append parameters.
|
43
|
+
parameters.each do |key, value|
|
44
|
+
replace_value = ''
|
45
|
+
|
46
|
+
if value.nil?
|
47
|
+
replace_value = ''
|
48
|
+
elsif value.instance_of? Array
|
49
|
+
value.map! { |element| CGI.escape(element.to_s) }
|
50
|
+
replace_value = value.join('/')
|
51
|
+
else
|
52
|
+
replace_value = CGI.escape(value.to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Find the template parameter and replace it with its value.
|
56
|
+
query_builder = query_builder.gsub('{' + key.to_s + '}', replace_value)
|
57
|
+
end
|
58
|
+
query_builder
|
59
|
+
end
|
60
|
+
|
61
|
+
# Appends the given set of parameters to the given query string.
|
62
|
+
# @param [String] The query string builder to add the query parameters to.
|
63
|
+
# @param [Hash] The parameters to append.
|
64
|
+
# @param [String] The format of array parameter serialization.
|
65
|
+
def self.append_url_with_query_parameters(query_builder, parameters,
|
66
|
+
array_serialization: 'indexed')
|
67
|
+
# Perform parameter validation.
|
68
|
+
unless query_builder.instance_of? String
|
69
|
+
raise ArgumentError, 'Given value for parameter \"query_builder\"
|
70
|
+
is invalid.'
|
71
|
+
end
|
72
|
+
|
73
|
+
# Return if there are no parameters to replace.
|
74
|
+
return query_builder if parameters.nil?
|
75
|
+
|
76
|
+
parameters.each do |key, value|
|
77
|
+
seperator = query_builder.include?('?') ? '&' : '?'
|
78
|
+
unless value.nil?
|
79
|
+
if value.instance_of? Array
|
80
|
+
value.compact!
|
81
|
+
query_builder += if array_serialization == 'csv'
|
82
|
+
"#{seperator}#{key}=#{value.map do |element|
|
83
|
+
CGI.escape(element.to_s)
|
84
|
+
end.join(',')}"
|
85
|
+
elsif array_serialization == 'psv'
|
86
|
+
"#{seperator}#{key}=#{value.map do |element|
|
87
|
+
CGI.escape(element.to_s)
|
88
|
+
end.join('|')}"
|
89
|
+
elsif array_serialization == 'tsv'
|
90
|
+
"#{seperator}#{key}=#{value.map do |element|
|
91
|
+
CGI.escape(element.to_s)
|
92
|
+
end.join("\t")}"
|
93
|
+
else
|
94
|
+
"#{seperator}#{APIHelper.serialize_array(
|
95
|
+
key, value, formatting: array_serialization
|
96
|
+
).map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }
|
97
|
+
.join('&')}"
|
98
|
+
end
|
99
|
+
else
|
100
|
+
query_builder += "#{seperator}#{key}=#{CGI.escape(value.to_s)}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
query_builder
|
105
|
+
end
|
106
|
+
|
107
|
+
# Validates and processes the given Url.
|
108
|
+
# @param [String] The given Url to process.
|
109
|
+
# @return [String] Pre-processed Url as string.
|
110
|
+
def self.clean_url(url)
|
111
|
+
# Perform parameter validation.
|
112
|
+
raise ArgumentError, 'Invalid Url.' unless url.instance_of? String
|
113
|
+
|
114
|
+
# Ensure that the urls are absolute.
|
115
|
+
matches = url.match(%r{^(https?:\/\/[^\/]+)})
|
116
|
+
raise ArgumentError, 'Invalid Url format.' if matches.nil?
|
117
|
+
|
118
|
+
# Get the http protocol match.
|
119
|
+
protocol = matches[1]
|
120
|
+
|
121
|
+
# Check if parameters exist.
|
122
|
+
index = url.index('?')
|
123
|
+
|
124
|
+
# Remove redundant forward slashes.
|
125
|
+
query = url[protocol.length...(!index.nil? ? index : url.length)]
|
126
|
+
query.gsub!(%r{\/\/+}, '/')
|
127
|
+
|
128
|
+
# Get the parameters.
|
129
|
+
parameters = !index.nil? ? url[url.index('?')...url.length] : ''
|
130
|
+
|
131
|
+
# Return processed url.
|
132
|
+
protocol + query + parameters
|
133
|
+
end
|
134
|
+
|
135
|
+
# Parses JSON string.
|
136
|
+
# @param [String] A JSON string.
|
137
|
+
def self.json_deserialize(json)
|
138
|
+
return JSON.parse(json)
|
139
|
+
rescue StandardError
|
140
|
+
raise TypeError, 'Server responded with invalid JSON.'
|
141
|
+
end
|
142
|
+
|
143
|
+
# Removes elements with empty values from a hash.
|
144
|
+
# @param [Hash] The hash to clean.
|
145
|
+
def self.clean_hash(hash)
|
146
|
+
hash.delete_if { |_key, value| value.to_s.strip.empty? }
|
147
|
+
end
|
148
|
+
|
149
|
+
# Form encodes a hash of parameters.
|
150
|
+
# @param [Hash] The hash of parameters to encode.
|
151
|
+
# @return [Hash] A hash with the same parameters form encoded.
|
152
|
+
def self.form_encode_parameters(form_parameters)
|
153
|
+
encoded = {}
|
154
|
+
form_parameters.each do |key, value|
|
155
|
+
encoded.merge!(APIHelper.form_encode(value, key, formatting:
|
156
|
+
Configuration.array_serialization))
|
157
|
+
end
|
158
|
+
encoded
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.custom_merge(a, b)
|
162
|
+
x = {}
|
163
|
+
a.each do |key, value_a|
|
164
|
+
b.each do |k, value_b|
|
165
|
+
next unless key == k
|
166
|
+
x[k] = []
|
167
|
+
if value_a.instance_of? Array
|
168
|
+
value_a.each do |v|
|
169
|
+
x[k].push(v)
|
170
|
+
end
|
171
|
+
else
|
172
|
+
x[k].push(value_a)
|
173
|
+
end
|
174
|
+
if value_b.instance_of? Array
|
175
|
+
value_b.each do |v|
|
176
|
+
x[k].push(v)
|
177
|
+
end
|
178
|
+
else
|
179
|
+
x[k].push(value_b)
|
180
|
+
end
|
181
|
+
a.delete(k)
|
182
|
+
b.delete(k)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
x.merge!(a)
|
186
|
+
x.merge!(b)
|
187
|
+
x
|
188
|
+
end
|
189
|
+
|
190
|
+
# Form encodes an object.
|
191
|
+
# @param [Dynamic] An object to form encode.
|
192
|
+
# @param [String] The name of the object.
|
193
|
+
# @return [Hash] A form encoded representation of the object in the form
|
194
|
+
# of a hash.
|
195
|
+
def self.form_encode(obj, instance_name, formatting: 'indexed')
|
196
|
+
retval = {}
|
197
|
+
|
198
|
+
serializable_types = [String, Numeric, TrueClass,
|
199
|
+
FalseClass, Date, DateTime]
|
200
|
+
|
201
|
+
# If this is a structure, resolve it's field names.
|
202
|
+
obj = obj.to_hash if obj.is_a? BaseModel
|
203
|
+
|
204
|
+
# Create a form encoded hash for this object.
|
205
|
+
if obj.nil?
|
206
|
+
nil
|
207
|
+
elsif obj.instance_of? Array
|
208
|
+
if formatting == 'indexed'
|
209
|
+
obj.each_with_index do |value, index|
|
210
|
+
retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
|
211
|
+
index.to_s + ']'))
|
212
|
+
end
|
213
|
+
elsif serializable_types.map { |x| obj[0].is_a? x }.any?
|
214
|
+
obj.each do |value|
|
215
|
+
abc = if formatting == 'unindexed'
|
216
|
+
APIHelper.form_encode(value, instance_name + '[]',
|
217
|
+
formatting: formatting)
|
218
|
+
else
|
219
|
+
APIHelper.form_encode(value, instance_name,
|
220
|
+
formatting: formatting)
|
221
|
+
end
|
222
|
+
retval = APIHelper.custom_merge(retval, abc)
|
223
|
+
# print retval
|
224
|
+
end
|
225
|
+
else
|
226
|
+
obj.each_with_index do |value, index|
|
227
|
+
retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
|
228
|
+
index.to_s + ']', formatting: formatting))
|
229
|
+
end
|
230
|
+
end
|
231
|
+
elsif obj.instance_of? Hash
|
232
|
+
obj.each do |key, value|
|
233
|
+
retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
|
234
|
+
key + ']', formatting: formatting))
|
235
|
+
end
|
236
|
+
else
|
237
|
+
retval[instance_name] = obj
|
238
|
+
end
|
239
|
+
retval
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
# Extend types to support to_bool.
|
245
|
+
module ToBoolean
|
246
|
+
def to_bool
|
247
|
+
return true if self == true || to_s.strip =~ /^(true|yes|y|1)$/i
|
248
|
+
false
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
# Extend NilClass type to support to_bool.
|
253
|
+
class NilClass; include ToBoolean; end
|
254
|
+
# Extend TrueClass type to support to_bool.
|
255
|
+
class TrueClass; include ToBoolean; end
|
256
|
+
# Extend FalseClass type to support to_bool.
|
257
|
+
class FalseClass; include ToBoolean; end
|
258
|
+
# Extend Numeric type to support to_bool.
|
259
|
+
class Numeric; include ToBoolean; end
|
260
|
+
# Extend String type to support to_bool.
|
261
|
+
class String; include ToBoolean; end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# This file was automatically generated for Stamplay by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module Tester
|
5
|
+
# All configuration including auth info and base URI for the API access
|
6
|
+
# are configured in this class.
|
7
|
+
class Configuration
|
8
|
+
# Set the array parameter serialization method.
|
9
|
+
# (allowed: indexed, unindexed, plain, csv, tsv, psv)
|
10
|
+
@array_serialization = 'indexed'
|
11
|
+
|
12
|
+
# An enum for SDK environments.
|
13
|
+
class Environment
|
14
|
+
ENVIRONMENT = [PRODUCTION = 0, TESTING = 1].freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
# An enum for API servers.
|
18
|
+
class Server
|
19
|
+
SERVER = [DEFAULT = 0, AUTH_SERVER = 1].freeze
|
20
|
+
end
|
21
|
+
|
22
|
+
# The environment in which the SDK is running.
|
23
|
+
@environment = Environment::PRODUCTION
|
24
|
+
|
25
|
+
# TODO: Set an appropriate value.
|
26
|
+
@port = '80'
|
27
|
+
|
28
|
+
# TODO: Set an appropriate value.
|
29
|
+
@suites = SuiteCode::HEARTS
|
30
|
+
|
31
|
+
# All the environments the SDK can run in.
|
32
|
+
@environments = {
|
33
|
+
Environment::PRODUCTION => {
|
34
|
+
Server::DEFAULT => 'http://apimatic.hopto.org:{suites}',
|
35
|
+
Server::AUTH_SERVER => 'http://apimaticauth.hopto.org:3000'
|
36
|
+
},
|
37
|
+
Environment::TESTING => {
|
38
|
+
Server::DEFAULT => 'http://localhost:3000',
|
39
|
+
Server::AUTH_SERVER => 'http://apimaticauth.xhopto.org:3000'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
# Generates the appropriate base URI for the environment and the server.
|
44
|
+
# @param [Configuration::Server] The server enum for which the base URI is
|
45
|
+
# required.
|
46
|
+
# @return [String] The base URI.
|
47
|
+
def self.get_base_uri(server = Server::DEFAULT)
|
48
|
+
parameters = {
|
49
|
+
'port' => port,
|
50
|
+
'suites' => suites
|
51
|
+
}
|
52
|
+
APIHelper.append_url_with_template_parameters(
|
53
|
+
environments[environment][server], parameters
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
# The attribute accessors for public properties.
|
58
|
+
class << self
|
59
|
+
attr_accessor :array_serialization
|
60
|
+
attr_accessor :environment
|
61
|
+
attr_accessor :environments
|
62
|
+
attr_accessor :port
|
63
|
+
attr_accessor :suites
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|