batesterwithcustomparamdemov1 1.2.6

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.
@@ -0,0 +1,13 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Batesterwithcustomparamdemov1
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum
9
+ HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
10
+ PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
11
+ DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
12
+ end
13
+ end
@@ -0,0 +1,50 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Batesterwithcustomparamdemov1
7
+ # Represents a single Http Request.
8
+ class HttpRequest
9
+ attr_accessor :http_method, :query_url, :headers,
10
+ :parameters, :username, :password
11
+
12
+ # The constructor.
13
+ # @param [HttpMethodEnum] The HTTP method.
14
+ # @param [String] The URL to send the request to.
15
+ # @param [Hash, Optional] The headers for the HTTP Request.
16
+ # @param [Hash, Optional] The parameters for the HTTP Request.
17
+ def initialize(http_method,
18
+ query_url,
19
+ headers: {},
20
+ parameters: {})
21
+ @http_method = http_method
22
+ @query_url = query_url
23
+ @headers = headers
24
+ @parameters = parameters
25
+ end
26
+
27
+ # Add a header to the HttpRequest.
28
+ # @param [String] The name of the header.
29
+ # @param [String] The value of the header.
30
+ def add_header(name, value)
31
+ @headers[name] = value
32
+ end
33
+
34
+ # Add a parameter to the HttpRequest.
35
+ # @param [String] The name of the parameter.
36
+ # @param [String] The value of the parameter.
37
+ def add_parameter(name, value)
38
+ @parameters[name] = value
39
+ end
40
+
41
+ # Add a query parameter to the HttpRequest.
42
+ # @param [String] The name of the query parameter.
43
+ # @param [String] The value of the query parameter.
44
+ def add_query_parameter(name, value)
45
+ @query_url = APIHelper.append_url_with_query_parameters(@query_url,
46
+ name => value)
47
+ @query_url = APIHelper.clean_url(@query_url)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,23 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Batesterwithcustomparamdemov1
7
+ # Http response received.
8
+ class HttpResponse
9
+ attr_accessor :status_code, :headers, :raw_body
10
+
11
+ # The constructor
12
+ # @param [Integer] The status code returned by the server.
13
+ # @param [Hash] The headers sent by the server in the response.
14
+ # @param [String] The raw body of the response.
15
+ def initialize(status_code,
16
+ headers,
17
+ raw_body)
18
+ @status_code = status_code
19
+ @headers = headers
20
+ @raw_body = raw_body
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Batesterwithcustomparamdemov1
7
+ # Base model.
8
+ class BaseModel
9
+ # Returns a Hash representation of the current object.
10
+ def to_hash
11
+ hash = {}
12
+ instance_variables.each do |name|
13
+ value = instance_variable_get(name)
14
+ name = name[1..-1]
15
+ key = self.class.names.key?(name) ? self.class.names[name] : name
16
+ if value.instance_of? Array
17
+ hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
18
+ elsif value.instance_of? Hash
19
+ hash[key] = {}
20
+ value.each do |k, v|
21
+ hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
22
+ end
23
+ else
24
+ hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
25
+ end
26
+ end
27
+ hash
28
+ end
29
+
30
+ # Returns a JSON representation of the curent object.
31
+ def to_json(options = {})
32
+ hash = to_hash
33
+ hash.to_json(options)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Batesterwithcustomparamdemov1
7
+ # A integer based enum representing a Suite in a game of cards
8
+ class SuiteCodeEnum
9
+ SUITE_CODE_ENUM = [
10
+ # TODO: Write general description for HEARTS
11
+ HEARTS = 1,
12
+
13
+ # TODO: Write general description for SPADES
14
+ SPADES = 2,
15
+
16
+ # TODO: Write general description for CLUBS
17
+ CLUBS = 3,
18
+
19
+ # TODO: Write general description for DIAMONDS
20
+ DIAMONDS = 4
21
+ ].freeze
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'json'
7
+ require 'test/unit'
8
+ require 'batesterwithcustomparamdemov1.rb'
9
+ require_relative '../test_helper.rb'
10
+ require_relative '../http_response_catcher.rb'
11
+
12
+ class ControllerTestBase < Test::Unit::TestCase
13
+ include Batesterwithcustomparamdemov1
14
+
15
+ class << self
16
+ attr_accessor :controller
17
+ end
18
+
19
+ # Called only once for a test class before any test has executed.
20
+ def self.startup
21
+ @@api_client = Batesterwithcustomparamdemov1Client.new
22
+ @@request_timeout = 100
23
+ @@assert_precision = 0.01
24
+
25
+ # Set Configuration parameters for test execution
26
+ Configuration.environment = Configuration::Environment::TESTING
27
+ end
28
+
29
+ # Called once before every test case.
30
+ def setup
31
+ @response_catcher = HttpResponseCatcher.new
32
+ self.class.controller.http_call_back = @response_catcher
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class APIControllerTests < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def self.startup
11
+ self.controller = @@api_client.client
12
+ end
13
+
14
+ # Todo: Add description for test test_basic_auth_test
15
+ def test_basic_auth_test()
16
+
17
+ # Perform the API call through the SDK function
18
+ result = self.class.controller.get_basic_auth_test()
19
+
20
+ # Test response code
21
+ assert_equal(@response_catcher.response.status_code, 200)
22
+
23
+ # Test whether the captured response is as we expected
24
+ assert_not_nil(result)
25
+ assert_equal('You\'ve passed the test!', @response_catcher.response.raw_body)
26
+ end
27
+
28
+ end
@@ -0,0 +1,19 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ class HttpResponseCatcher < Batesterwithcustomparamdemov1::HttpCallBack
7
+ attr_accessor :response
8
+
9
+ def on_before_request(request)
10
+ end
11
+
12
+ # Catching the response
13
+ def on_after_response(context)
14
+ @response = context.response
15
+ end
16
+ end
17
+
18
+
19
+
@@ -0,0 +1,94 @@
1
+ # batesterwithcustomparamdemov1
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'tempfile'
7
+ require 'open-uri'
8
+
9
+ class TestHelper
10
+
11
+ @cache = Hash.new
12
+
13
+ # Class method to compare the received headers with the expected headers.
14
+ # @param [Hash] A hash of expected headers (keys in lower case).
15
+ # @param [Hash] A hash of received headers.
16
+ # @param [Boolean, optional] A flag which determines if we allow extra headers.
17
+ def self.match_headers(expected_headers,
18
+ received_headers,
19
+ allow_extra: true)
20
+ return false if ((received_headers.length < expected_headers.length) ||
21
+ ((allow_extra == false) && (received_headers.length > expected_headers.length)))
22
+
23
+ received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
24
+ expected_headers.each do |e_key, e_value|
25
+ return false unless received_headers.key?(e_key)
26
+ return false if ((e_value != nil) &&
27
+ (e_value != received_headers[e_key]))
28
+ end
29
+
30
+ return true
31
+ end
32
+
33
+ # Class method to compare the received body with the expected body.
34
+ # @param [Dynamic] The expected body.
35
+ # @param [Dynamic] The received body.
36
+ # @param [Boolean, optional] A flag which determines if we check values in dictionaries.
37
+ # @param [Boolean, optional] A flag which determines if we check the order of array elements.
38
+ # @param [Boolean, optional] A flag which determines if we check the count of array elements.
39
+ def self.match_body(expected_body,
40
+ received_body,
41
+ check_values: false,
42
+ check_order: false,
43
+ check_count: false)
44
+ if expected_body.instance_of? Hash
45
+ return false unless received_body.instance_of? Hash
46
+ for key in expected_body.keys
47
+ return false unless received_body.keys.include? key
48
+ if check_values or expected_body[key].instance_of? Hash
49
+ return false unless TestHelper.match_body(expected_body[key],
50
+ received_body[key],
51
+ check_values: check_values,
52
+ check_order: check_order,
53
+ check_count: check_count)
54
+ end
55
+ end
56
+ elsif expected_body.instance_of? Array
57
+ return False unless received_body.instance_of? Array
58
+ if check_count == true && (expected_body.length != received_body.length)
59
+ return false
60
+ else
61
+ previous_matches = Array.new
62
+ expected_body.each.with_index do |expected_element, i|
63
+ matches = (received_body.map.with_index do |received_element, j|
64
+ j if TestHelper.match_body(expected_element,
65
+ received_element,
66
+ check_values: check_values,
67
+ check_order: check_order,
68
+ check_count: check_count)
69
+ end).compact
70
+ return false if matches.length == 0
71
+ if check_order == true
72
+ return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
73
+ previous_matches = matches
74
+ end
75
+ end
76
+ end
77
+ elsif expected_body != received_body
78
+ return false
79
+ end
80
+ return true
81
+ end
82
+
83
+ # Class method which takes a URL, downloads the file (if not already downloaded
84
+ # for this test session) and returns the path of the file.
85
+ # @param [String] The URL of the required file.
86
+ def self.get_file(url)
87
+ unless @cache.keys.include? url
88
+ @cache[url] = Tempfile.new('APIMatic')
89
+ @cache[url].binmode
90
+ @cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
91
+ end
92
+ return @cache[url].path
93
+ end
94
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: batesterwithcustomparamdemov1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.6
5
+ platform: ruby
6
+ authors:
7
+ - APIMatic SDK Generator
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logging
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.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.10.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: certifi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2016.9'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 2016.09.26
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '2016.9'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 2016.09.26
89
+ - !ruby/object:Gem::Dependency
90
+ name: faraday-http-cache
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.2'
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 1.2.2
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '1.2'
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 1.2.2
109
+ description: ''
110
+ email: support@apimatic.io
111
+ executables: []
112
+ extensions: []
113
+ extra_rdoc_files: []
114
+ files:
115
+ - LICENSE
116
+ - README.md
117
+ - lib/batesterwithcustomparamdemov1.rb
118
+ - lib/batesterwithcustomparamdemov1/api_helper.rb
119
+ - lib/batesterwithcustomparamdemov1/batesterwithcustomparamdemov1_client.rb
120
+ - lib/batesterwithcustomparamdemov1/configuration.rb
121
+ - lib/batesterwithcustomparamdemov1/controllers/api_controller.rb
122
+ - lib/batesterwithcustomparamdemov1/controllers/base_controller.rb
123
+ - lib/batesterwithcustomparamdemov1/exceptions/api_exception.rb
124
+ - lib/batesterwithcustomparamdemov1/http/auth/basic_auth.rb
125
+ - lib/batesterwithcustomparamdemov1/http/faraday_client.rb
126
+ - lib/batesterwithcustomparamdemov1/http/http_call_back.rb
127
+ - lib/batesterwithcustomparamdemov1/http/http_client.rb
128
+ - lib/batesterwithcustomparamdemov1/http/http_context.rb
129
+ - lib/batesterwithcustomparamdemov1/http/http_method_enum.rb
130
+ - lib/batesterwithcustomparamdemov1/http/http_request.rb
131
+ - lib/batesterwithcustomparamdemov1/http/http_response.rb
132
+ - lib/batesterwithcustomparamdemov1/models/base_model.rb
133
+ - lib/batesterwithcustomparamdemov1/models/suite_code_enum.rb
134
+ - test/controllers/controller_test_base.rb
135
+ - test/controllers/test_api_controller.rb
136
+ - test/http_response_catcher.rb
137
+ - test/test_helper.rb
138
+ homepage: https://apimatic.io
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: '2.0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.7.5
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: batesterwithcustomparamdemov1
162
+ test_files: []