uwygtfvjha 1.1

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: 6506c8ec2daae9240ee9a42bbb72488b33300a3ed6a7de51a3d03b19ec17c056
4
+ data.tar.gz: 3de7085dad56942020b8253dd38eed30709376c61ee8c3d39224e563d9728adb
5
+ SHA512:
6
+ metadata.gz: 58c3d0dc48e4a6c4d4aebfc0685e5681f99db8f2b455d388de592853261d060f891bc726aa0fbef74e89290675d247c3a5df45b32e3930cb36e3e6f2fb2f80cb
7
+ data.tar.gz: a7123a8f26be9f0ae5b27b17c4afdd152cf9f983542b2147d68a3ab2e36afc0c3e56af901906ee5aed75824a27a0ca7dec464a10065467be059618a65f641cdd
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,133 @@
1
+ # Getting started
2
+
3
+ ## How to Build
4
+
5
+ This client library is a Ruby gem which can be compiled and used in your Ruby and Ruby on Rails project. This library requires a few gems from the RubyGems repository.
6
+
7
+ 1. Open the command line interface or the terminal and navigate to the folder containing the source code.
8
+ 2. Run ``` gem build uwygtfvjha.gemspec ``` to build the gem.
9
+ 3. Once built, the gem can be installed on the current work environment using ``` gem install uwygtfvjha-1.1.gem ```
10
+
11
+ ![Building Gem](https://apidocs.io/illustration/ruby?step=buildSDK&workspaceFolder=BATester-Ruby&workspaceName=BATester-Ruby&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
12
+
13
+ ## How to Use
14
+
15
+ The following section explains how to use the BaTester 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.
16
+
17
+ ### 1. Starting a new project
18
+
19
+ Close any existing projects in RubyMine™ by selecting ``` File -> Close Project ```. Next, click on ``` Create New Project ``` to create a new project from scratch.
20
+
21
+ ![Create a new project in RubyMine](https://apidocs.io/illustration/ruby?step=createNewProject0&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
22
+
23
+ Next, provide ``` TestApp ``` as the project name, choose ``` Rails Application ``` as the project type, and click ``` OK ```.
24
+
25
+ ![Create a new Rails Application in RubyMine - step 1](https://apidocs.io/illustration/ruby?step=createNewProject1&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
26
+
27
+ In the next dialog make sure that correct *Ruby SDK* is being used (minimum 2.0.0) and click ``` OK ```.
28
+
29
+ ![Create a new Rails Application in RubyMine - step 2](https://apidocs.io/illustration/ruby?step=createNewProject2&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
30
+
31
+ This will create a new Rails Application project with an existing set of files and folder.
32
+
33
+ ### 2. Add reference of the gem
34
+
35
+ In order to use the BaTester 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 'uwygtfvjha', '~> 1.1' ```
36
+
37
+ ![Add references of the Gemfile](https://apidocs.io/illustration/ruby?step=addReference&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
38
+
39
+ ### 3. Adding a new Rails Controller
40
+
41
+ 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... ```.
42
+
43
+ ![Run Rails Generator on Controllers Folder](https://apidocs.io/illustration/ruby?step=addCode0&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
44
+
45
+ Selecting the said option will popup a small window where the generator names are displayed. Here, select the ``` controller ``` template.
46
+
47
+ ![Create a new Controller](https://apidocs.io/illustration/ruby?step=addCode1&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
48
+
49
+ 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 ```.
50
+
51
+ ![Add a new Controller](https://apidocs.io/illustration/ruby?step=addCode2&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
52
+
53
+ A new controller class anmed ``` 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.
54
+
55
+ ![Initialize the library](https://apidocs.io/illustration/ruby?step=addCode3&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1)
56
+
57
+ ## How to Test
58
+
59
+ You can test the generated SDK and the server with automatically generated test
60
+ cases as follows:
61
+
62
+ 1. From terminal/cmd navigate to the root directory of the SDK.
63
+ 2. Invoke: `bundle exec rake`
64
+
65
+ ## Initialization
66
+
67
+ ### Authentication
68
+ In order to setup authentication and initialization of the API client, you need the following information.
69
+
70
+ | Parameter | Description |
71
+ |-----------|-------------|
72
+ | basic_auth_user_name | The username to use with basic authentication |
73
+ | basic_auth_password | The password to use with basic authentication |
74
+
75
+
76
+
77
+ API client can be initialized as following.
78
+
79
+ ```ruby
80
+ # Configuration parameters and credentials
81
+ basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
82
+ basic_auth_password = 'basic_auth_password' # The password to use with basic authentication
83
+
84
+ client = Uwygtfvjha::UwygtfvjhaClient.new(
85
+ basic_auth_user_name: basic_auth_user_name,
86
+ basic_auth_password: basic_auth_password
87
+ )
88
+ ```
89
+
90
+ The added initlization code can be debugged by putting a breakpoint in the ``` Index ``` method and running the project in debug mode by selecting ``` Run -> Debug 'Development: TestApp' ```.
91
+
92
+ ![Debug the TestApp](https://apidocs.io/illustration/ruby?step=addCode4&workspaceFolder=BATester-Ruby&workspaceName=BaTester&projectName=uwygtfvjha&gemName=uwygtfvjha&gemVer=1.1&initLine=client%2520%253D%2520UwygtfvjhaClient.new%2528%2527basic_auth_user_name%2527%252C%2520%2527basic_auth_password%2527%2529)
93
+
94
+
95
+
96
+ # Class Reference
97
+
98
+ ## <a name="list_of_controllers"></a>List of Controllers
99
+
100
+ * [APIController](#api_controller)
101
+
102
+ ## <a name="api_controller"></a>![Class: ](https://apidocs.io/img/class.png ".APIController") APIController
103
+
104
+ ### Get singleton instance
105
+
106
+ The singleton instance of the ``` APIController ``` class can be accessed from the API Client.
107
+
108
+ ```ruby
109
+ client_controller = client.client
110
+ ```
111
+
112
+ ### <a name="get_basic_auth_test"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.get_basic_auth_test") get_basic_auth_test
113
+
114
+ > TODO: Add a method description
115
+
116
+
117
+ ```ruby
118
+ def get_basic_auth_test; end
119
+ ```
120
+
121
+ #### Example Usage
122
+
123
+ ```ruby
124
+
125
+ result = client_controller.get_basic_auth_test()
126
+
127
+ ```
128
+
129
+
130
+ [Back to List of Controllers](#list_of_controllers)
131
+
132
+
133
+
data/lib/uwygtfvjha.rb ADDED
@@ -0,0 +1,36 @@
1
+ # uwygtfvjha
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'date'
7
+ require 'json'
8
+ require 'faraday'
9
+ require 'certifi'
10
+ require 'logging'
11
+
12
+ require_relative 'uwygtfvjha/api_helper.rb'
13
+ require_relative 'uwygtfvjha/uwygtfvjha_client.rb'
14
+
15
+ # Http
16
+ require_relative 'uwygtfvjha/http/http_call_back.rb'
17
+ require_relative 'uwygtfvjha/http/http_client.rb'
18
+ require_relative 'uwygtfvjha/http/http_method_enum.rb'
19
+ require_relative 'uwygtfvjha/http/http_request.rb'
20
+ require_relative 'uwygtfvjha/http/http_response.rb'
21
+ require_relative 'uwygtfvjha/http/http_context.rb'
22
+ require_relative 'uwygtfvjha/http/faraday_client.rb'
23
+ require_relative 'uwygtfvjha/http/auth/basic_auth.rb'
24
+
25
+ # Models
26
+ require_relative 'uwygtfvjha/models/base_model.rb'
27
+ require_relative 'uwygtfvjha/models/suite_code_enum.rb'
28
+
29
+ # Exceptions
30
+ require_relative 'uwygtfvjha/exceptions/api_exception.rb'
31
+
32
+ require_relative 'uwygtfvjha/configuration.rb'
33
+
34
+ # Controllers
35
+ require_relative 'uwygtfvjha/controllers/base_controller.rb'
36
+ require_relative 'uwygtfvjha/controllers/api_controller.rb'
@@ -0,0 +1,275 @@
1
+ # uwygtfvjha
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Uwygtfvjha
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
+ if formatting == 'unindexed'
17
+ tuples += array.map { |element| ["#{key}[]", element] }
18
+ elsif formatting == 'indexed'
19
+ tuples += array.map.with_index do |element, index|
20
+ ["#{key}[#{index}]", element]
21
+ end
22
+ elsif formatting == 'plain'
23
+ tuples += array.map { |element| [key, element] }
24
+ else
25
+ raise ArgumentError, 'Invalid format provided.'
26
+ end
27
+ tuples
28
+ end
29
+
30
+ # Replaces template parameters in the given url.
31
+ # @param [String] The query string builder to replace the template
32
+ # parameters.
33
+ # @param [Hash] The parameters to replace in the url.
34
+ def self.append_url_with_template_parameters(query_builder, parameters)
35
+ # perform parameter validation
36
+ unless query_builder.instance_of? String
37
+ raise ArgumentError, 'Given value for parameter \"query_builder\" is
38
+ invalid.'
39
+ end
40
+
41
+ # Return if there are no parameters to replace.
42
+ return query_builder if parameters.nil?
43
+
44
+ # Iterate and append parameters.
45
+ parameters.each do |key, value|
46
+ replace_value = ''
47
+
48
+ if value.nil?
49
+ replace_value = ''
50
+ elsif value.instance_of? Array
51
+ value.map! { |element| CGI.escape(element.to_s) }
52
+ replace_value = value.join('/')
53
+ else
54
+ replace_value = CGI.escape(value.to_s)
55
+ end
56
+
57
+ # Find the template parameter and replace it with its value.
58
+ query_builder = query_builder.gsub('{' + key.to_s + '}', replace_value)
59
+ end
60
+ query_builder
61
+ end
62
+
63
+ # Appends the given set of parameters to the given query string.
64
+ # @param [String] The query string builder to add the query parameters to.
65
+ # @param [Hash] The parameters to append.
66
+ # @param [String] The format of array parameter serialization.
67
+ def self.append_url_with_query_parameters(query_builder, parameters,
68
+ array_serialization: 'indexed')
69
+ # Perform parameter validation.
70
+ unless query_builder.instance_of? String
71
+ raise ArgumentError, 'Given value for parameter \"query_builder\"
72
+ is invalid.'
73
+ end
74
+
75
+ # Return if there are no parameters to replace.
76
+ return query_builder if parameters.nil?
77
+
78
+ parameters.each do |key, value|
79
+ seperator = query_builder.include?('?') ? '&' : '?'
80
+ unless value.nil?
81
+ if value.instance_of? Array
82
+ value.compact!
83
+ query_builder += if array_serialization == 'csv'
84
+ "#{seperator}#{key}=#{value.map do |element|
85
+ CGI.escape(element.to_s)
86
+ end.join(',')}"
87
+ elsif array_serialization == 'psv'
88
+ "#{seperator}#{key}=#{value.map do |element|
89
+ CGI.escape(element.to_s)
90
+ end.join('|')}"
91
+ elsif array_serialization == 'tsv'
92
+ "#{seperator}#{key}=#{value.map do |element|
93
+ CGI.escape(element.to_s)
94
+ end.join("\t")}"
95
+ else
96
+ "#{seperator}#{APIHelper.serialize_array(
97
+ key, value, formatting: array_serialization
98
+ ).map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }
99
+ .join('&')}"
100
+ end
101
+ else
102
+ query_builder += "#{seperator}#{key}=#{CGI.escape(value.to_s)}"
103
+ end
104
+ end
105
+ end
106
+ query_builder
107
+ end
108
+
109
+ # Validates and processes the given Url.
110
+ # @param [String] The given Url to process.
111
+ # @return [String] Pre-processed Url as string.
112
+ def self.clean_url(url)
113
+ # Perform parameter validation.
114
+ raise ArgumentError, 'Invalid Url.' unless url.instance_of? String
115
+
116
+ # Ensure that the urls are absolute.
117
+ matches = url.match(%r{^(https?:\/\/[^\/]+)})
118
+ raise ArgumentError, 'Invalid Url format.' if matches.nil?
119
+
120
+ # Get the http protocol match.
121
+ protocol = matches[1]
122
+
123
+ # Check if parameters exist.
124
+ index = url.index('?')
125
+
126
+ # Remove redundant forward slashes.
127
+ query = url[protocol.length...(!index.nil? ? index : url.length)]
128
+ query.gsub!(%r{\/\/+}, '/')
129
+
130
+ # Get the parameters.
131
+ parameters = !index.nil? ? url[url.index('?')...url.length] : ''
132
+
133
+ # Return processed url.
134
+ protocol + query + parameters
135
+ end
136
+
137
+ # Parses JSON string.
138
+ # @param [String] A JSON string.
139
+ def self.json_deserialize(json)
140
+ return JSON.parse(json)
141
+ rescue StandardError
142
+ raise TypeError, 'Server responded with invalid JSON.'
143
+ end
144
+
145
+ # Removes elements with empty values from a hash.
146
+ # @param [Hash] The hash to clean.
147
+ def self.clean_hash(hash)
148
+ hash.delete_if { |_key, value| value.to_s.strip.empty? }
149
+ end
150
+
151
+ # Form encodes a hash of parameters.
152
+ # @param [Hash] The hash of parameters to encode.
153
+ # @return [Hash] A hash with the same parameters form encoded.
154
+ def self.form_encode_parameters(form_parameters)
155
+ encoded = {}
156
+ form_parameters.each do |key, value|
157
+ encoded.merge!(APIHelper.form_encode(value, key, formatting:
158
+ Configuration.array_serialization))
159
+ end
160
+ encoded
161
+ end
162
+
163
+ def self.custom_merge(a, b)
164
+ x = {}
165
+ a.each do |key, value_a|
166
+ b.each do |k, value_b|
167
+ next unless key == k
168
+ x[k] = []
169
+ if value_a.instance_of? Array
170
+ value_a.each do |v|
171
+ x[k].push(v)
172
+ end
173
+ else
174
+ x[k].push(value_a)
175
+ end
176
+ if value_b.instance_of? Array
177
+ value_b.each do |v|
178
+ x[k].push(v)
179
+ end
180
+ else
181
+ x[k].push(value_b)
182
+ end
183
+ a.delete(k)
184
+ b.delete(k)
185
+ end
186
+ end
187
+ x.merge!(a)
188
+ x.merge!(b)
189
+ x
190
+ end
191
+
192
+ # Form encodes an object.
193
+ # @param [Dynamic] An object to form encode.
194
+ # @param [String] The name of the object.
195
+ # @return [Hash] A form encoded representation of the object in the form
196
+ # of a hash.
197
+ def self.form_encode(obj, instance_name, formatting: 'indexed')
198
+ retval = {}
199
+
200
+ serializable_types = [String, Numeric, TrueClass,
201
+ FalseClass, Date, DateTime]
202
+
203
+ # If this is a structure, resolve it's field names.
204
+ obj = obj.to_hash if obj.is_a? BaseModel
205
+
206
+ # Create a form encoded hash for this object.
207
+ if obj.nil?
208
+ nil
209
+ elsif obj.instance_of? Array
210
+ if formatting == 'indexed'
211
+ obj.each_with_index do |value, index|
212
+ retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
213
+ index.to_s + ']'))
214
+ end
215
+ elsif serializable_types.map { |x| obj[0].is_a? x }.any?
216
+ obj.each do |value|
217
+ abc = if formatting == 'unindexed'
218
+ APIHelper.form_encode(value, instance_name + '[]',
219
+ formatting: formatting)
220
+ else
221
+ APIHelper.form_encode(value, instance_name,
222
+ formatting: formatting)
223
+ end
224
+ retval = APIHelper.custom_merge(retval, abc)
225
+ # print retval
226
+ end
227
+ else
228
+ obj.each_with_index do |value, index|
229
+ retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
230
+ index.to_s + ']', formatting: formatting))
231
+ end
232
+ end
233
+ elsif obj.instance_of? Hash
234
+ obj.each do |key, value|
235
+ retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
236
+ key + ']', formatting: formatting))
237
+ end
238
+ else
239
+ retval[instance_name] = obj
240
+ end
241
+ retval
242
+ end
243
+
244
+ # Safely converts a string into an rfc3339 DateTime object
245
+ # @param [String] The datetime string
246
+ # @return [DateTime] A DateTime object of rfc3339 format
247
+ def self.rfc3339(date_time)
248
+ # missing timezone information
249
+ if date_time.end_with?('Z') || date_time.index('+')
250
+ DateTime.rfc3339(date_time)
251
+ else
252
+ DateTime.rfc3339(date_time + 'Z')
253
+ end
254
+ end
255
+ end
256
+ end
257
+
258
+ # Extend types to support to_bool.
259
+ module ToBoolean
260
+ def to_bool
261
+ return true if self == true || to_s.strip =~ /^(true|yes|y|1)$/i
262
+ false
263
+ end
264
+ end
265
+
266
+ # Extend NilClass type to support to_bool.
267
+ class NilClass; include ToBoolean; end
268
+ # Extend TrueClass type to support to_bool.
269
+ class TrueClass; include ToBoolean; end
270
+ # Extend FalseClass type to support to_bool.
271
+ class FalseClass; include ToBoolean; end
272
+ # Extend Numeric type to support to_bool.
273
+ class Numeric; include ToBoolean; end
274
+ # Extend String type to support to_bool.
275
+ class String; include ToBoolean; end