uniqueCalculator 1.1 → 1.2.7
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 +4 -4
- data/README.md +4 -3
- data/lib/apimatic_calculator/api_helper.rb +1 -440
- data/lib/apimatic_calculator/client.rb +9 -2
- data/lib/apimatic_calculator/configuration.rb +14 -40
- data/lib/apimatic_calculator/controllers/base_controller.rb +42 -36
- data/lib/apimatic_calculator/controllers/simple_calculator_controller.rb +13 -27
- data/lib/apimatic_calculator/exceptions/api_exception.rb +1 -11
- data/lib/apimatic_calculator/http/http_call_back.rb +1 -15
- data/lib/apimatic_calculator/http/http_method_enum.rb +1 -4
- data/lib/apimatic_calculator/http/http_request.rb +1 -45
- data/lib/apimatic_calculator/http/http_response.rb +1 -20
- data/lib/apimatic_calculator/models/base_model.rb +1 -1
- data/lib/apimatic_calculator/utilities/date_time_helper.rb +1 -146
- data/lib/apimatic_calculator/utilities/file_wrapper.rb +5 -5
- data/lib/apimatic_calculator.rb +6 -6
- data/test/controllers/controller_test_base.rb +9 -2
- data/test/controllers/test_simple_calculator_controller.rb +3 -2
- metadata +11 -111
- data/lib/apimatic_calculator/exceptions/validation_exception.rb +0 -18
- data/lib/apimatic_calculator/http/faraday_client.rb +0 -98
- data/lib/apimatic_calculator/http/http_client.rb +0 -123
- data/test/test_helper.rb +0 -94
metadata
CHANGED
@@ -1,153 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uniqueCalculator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- APIMatic SDK Generator
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: apimatic_core_interfaces
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: apimatic_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 2.0.1
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '2.0'
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 2.0.1
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: faraday-follow_redirects
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.2'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.2'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: faraday-multipart
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.0'
|
68
|
-
type: :runtime
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: faraday-gzip
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0.1'
|
33
|
+
version: 0.2.0
|
82
34
|
type: :runtime
|
83
35
|
prerelease: false
|
84
36
|
version_requirements: !ruby/object:Gem::Requirement
|
85
37
|
requirements:
|
86
38
|
- - "~>"
|
87
39
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: faraday-retry
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '1.0'
|
96
|
-
type: :runtime
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '1.0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: faraday-net_http_persistent
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '2.0'
|
110
|
-
type: :runtime
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '2.0'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: certifi
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '2018.1'
|
124
|
-
- - ">="
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: 2018.01.18
|
127
|
-
type: :runtime
|
128
|
-
prerelease: false
|
129
|
-
version_requirements: !ruby/object:Gem::Requirement
|
130
|
-
requirements:
|
131
|
-
- - "~>"
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '2018.1'
|
134
|
-
- - ">="
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 2018.01.18
|
40
|
+
version: 0.2.0
|
137
41
|
- !ruby/object:Gem::Dependency
|
138
|
-
name:
|
42
|
+
name: apimatic_faraday_client_adapter
|
139
43
|
requirement: !ruby/object:Gem::Requirement
|
140
44
|
requirements:
|
141
45
|
- - "~>"
|
142
46
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
47
|
+
version: 0.1.0
|
144
48
|
type: :runtime
|
145
49
|
prerelease: false
|
146
50
|
version_requirements: !ruby/object:Gem::Requirement
|
147
51
|
requirements:
|
148
52
|
- - "~>"
|
149
53
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
54
|
+
version: 0.1.0
|
151
55
|
- !ruby/object:Gem::Dependency
|
152
56
|
name: minitest
|
153
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,10 +102,7 @@ files:
|
|
198
102
|
- lib/apimatic_calculator/controllers/base_controller.rb
|
199
103
|
- lib/apimatic_calculator/controllers/simple_calculator_controller.rb
|
200
104
|
- lib/apimatic_calculator/exceptions/api_exception.rb
|
201
|
-
- lib/apimatic_calculator/exceptions/validation_exception.rb
|
202
|
-
- lib/apimatic_calculator/http/faraday_client.rb
|
203
105
|
- lib/apimatic_calculator/http/http_call_back.rb
|
204
|
-
- lib/apimatic_calculator/http/http_client.rb
|
205
106
|
- lib/apimatic_calculator/http/http_method_enum.rb
|
206
107
|
- lib/apimatic_calculator/http/http_request.rb
|
207
108
|
- lib/apimatic_calculator/http/http_response.rb
|
@@ -212,7 +113,6 @@ files:
|
|
212
113
|
- test/controllers/controller_test_base.rb
|
213
114
|
- test/controllers/test_simple_calculator_controller.rb
|
214
115
|
- test/http_response_catcher.rb
|
215
|
-
- test/test_helper.rb
|
216
116
|
homepage: ''
|
217
117
|
licenses:
|
218
118
|
- MIT
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# apimatic_calculator
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module ApimaticCalculator
|
7
|
-
# Class for exceptions when there is a schema validation error.
|
8
|
-
class ValidationException < StandardError
|
9
|
-
attr_reader :reason
|
10
|
-
|
11
|
-
# The constructor.
|
12
|
-
# @param [String] The reason for raising an exception.
|
13
|
-
def initialize(value, template)
|
14
|
-
@reason = "The value #{value} provided doesn't validate against the schema #{template}"
|
15
|
-
super(reason)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# apimatic_calculator
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
require 'faraday/http_cache'
|
7
|
-
require 'faraday/retry'
|
8
|
-
require 'faraday/multipart'
|
9
|
-
require 'faraday/follow_redirects'
|
10
|
-
require 'faraday/gzip'
|
11
|
-
require 'faraday/net_http_persistent'
|
12
|
-
|
13
|
-
module ApimaticCalculator
|
14
|
-
# An implementation of HttpClient.
|
15
|
-
class FaradayClient < HttpClient
|
16
|
-
# The attribute readers for properties.
|
17
|
-
attr_reader :connection
|
18
|
-
|
19
|
-
# The constructor.
|
20
|
-
def initialize(timeout:, max_retries:, retry_interval:,
|
21
|
-
backoff_factor:, retry_statuses:, retry_methods:,
|
22
|
-
connection:, adapter:, cache: false, verify: true)
|
23
|
-
@connection = if connection.nil?
|
24
|
-
create_connection(timeout: timeout, max_retries: max_retries,
|
25
|
-
retry_interval: retry_interval, backoff_factor: backoff_factor,
|
26
|
-
retry_statuses: retry_statuses, retry_methods: retry_methods,
|
27
|
-
adapter: adapter, cache: cache, verify: verify)
|
28
|
-
else
|
29
|
-
connection
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Method to initialize connection.
|
34
|
-
def create_connection(timeout:, max_retries:, retry_interval:,
|
35
|
-
backoff_factor:, retry_statuses:, retry_methods:,
|
36
|
-
adapter:, cache: false, verify: true)
|
37
|
-
Faraday.new do |faraday|
|
38
|
-
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
39
|
-
faraday.use Faraday::FollowRedirects::Middleware
|
40
|
-
faraday.request :gzip
|
41
|
-
faraday.request :multipart
|
42
|
-
faraday.request :url_encoded
|
43
|
-
faraday.ssl[:ca_file] = Certifi.where
|
44
|
-
faraday.ssl[:verify] = verify
|
45
|
-
faraday.request :retry, max: max_retries, interval: retry_interval,
|
46
|
-
backoff_factor: backoff_factor,
|
47
|
-
retry_statuses: retry_statuses,
|
48
|
-
methods: retry_methods,
|
49
|
-
retry_if: proc { |env, _exc|
|
50
|
-
env.request.context['forced_retry'] ||= false
|
51
|
-
}
|
52
|
-
faraday.adapter adapter
|
53
|
-
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
54
|
-
faraday.options[:timeout] = timeout if timeout.positive?
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Method overridden from HttpClient.
|
59
|
-
def execute_as_string(http_request)
|
60
|
-
response = @connection.send(
|
61
|
-
http_request.http_method.downcase,
|
62
|
-
http_request.query_url
|
63
|
-
) do |request|
|
64
|
-
request.headers = http_request.headers.map { |k, v| [k.to_s, v.to_s] }
|
65
|
-
request.options.context ||= {}
|
66
|
-
request.options.context.merge!(http_request.context)
|
67
|
-
unless http_request.http_method == HttpMethodEnum::GET &&
|
68
|
-
http_request.parameters.empty?
|
69
|
-
request.body = http_request.parameters
|
70
|
-
end
|
71
|
-
end
|
72
|
-
convert_response(response, http_request)
|
73
|
-
end
|
74
|
-
|
75
|
-
# Method overridden from HttpClient.
|
76
|
-
def execute_as_binary(http_request)
|
77
|
-
response = @connection.send(
|
78
|
-
http_request.http_method.downcase,
|
79
|
-
http_request.query_url
|
80
|
-
) do |request|
|
81
|
-
request.headers = http_request.headers
|
82
|
-
request.options.context ||= {}
|
83
|
-
request.options.context.merge!(http_request.context)
|
84
|
-
unless http_request.http_method == HttpMethodEnum::GET &&
|
85
|
-
http_request.parameters.empty?
|
86
|
-
request.body = http_request.parameters
|
87
|
-
end
|
88
|
-
end
|
89
|
-
convert_response(response, http_request)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Method overridden from HttpClient.
|
93
|
-
def convert_response(response, http_request)
|
94
|
-
HttpResponse.new(response.status, response.reason_phrase,
|
95
|
-
response.headers, response.body, http_request)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
# apimatic_calculator
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module ApimaticCalculator
|
7
|
-
# An interface for the methods that an HTTP Client must implement.
|
8
|
-
#
|
9
|
-
# This class should not be instantiated but should be used as a base class
|
10
|
-
# for HTTP Client classes.
|
11
|
-
class HttpClient
|
12
|
-
# Execute an HttpRequest when the response is expected to be a string.
|
13
|
-
# @param [HttpRequest] The HttpRequest to be executed.
|
14
|
-
def execute_as_string(_http_request)
|
15
|
-
raise NotImplementedError, 'This method needs
|
16
|
-
to be implemented in a child class.'
|
17
|
-
end
|
18
|
-
|
19
|
-
# Execute an HttpRequest when the response is expected to be binary.
|
20
|
-
# @param [HttpRequest] The HttpRequest to be executed.
|
21
|
-
def execute_as_binary(_http_request)
|
22
|
-
raise NotImplementedError, 'This method needs
|
23
|
-
to be implemented in a child class.'
|
24
|
-
end
|
25
|
-
|
26
|
-
# Converts the HTTP Response from the client to an HttpResponse object.
|
27
|
-
# @param [Dynamic] The response object received from the client.
|
28
|
-
def convert_response(_response)
|
29
|
-
raise NotImplementedError, 'This method needs
|
30
|
-
to be implemented in a child class.'
|
31
|
-
end
|
32
|
-
|
33
|
-
# Get a GET HttpRequest object.
|
34
|
-
# @param [String] The URL to send the request to.
|
35
|
-
# @param [Hash, Optional] The headers for the HTTP Request.
|
36
|
-
# @param [Hash, Optional] The context for the HTTP Request.
|
37
|
-
def get(query_url,
|
38
|
-
headers: {},
|
39
|
-
context: {})
|
40
|
-
HttpRequest.new(HttpMethodEnum::GET,
|
41
|
-
query_url,
|
42
|
-
headers: headers,
|
43
|
-
context: context)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Get a HEAD HttpRequest object.
|
47
|
-
# @param [String] The URL to send the request to.
|
48
|
-
# @param [Hash, Optional] The headers for the HTTP Request.
|
49
|
-
# @param [Hash, Optional] The context for the HTTP Request.
|
50
|
-
def head(query_url,
|
51
|
-
headers: {},
|
52
|
-
context: {})
|
53
|
-
HttpRequest.new(HttpMethodEnum::HEAD,
|
54
|
-
query_url,
|
55
|
-
headers: headers,
|
56
|
-
context: context)
|
57
|
-
end
|
58
|
-
|
59
|
-
# Get a POST HttpRequest object.
|
60
|
-
# @param [String] The URL to send the request to.
|
61
|
-
# @param [Hash, Optional] The headers for the HTTP Request.
|
62
|
-
# @param [Hash, Optional] The parameters for the HTTP Request.
|
63
|
-
# @param [Hash, Optional] The context for the HTTP Request.
|
64
|
-
def post(query_url,
|
65
|
-
headers: {},
|
66
|
-
parameters: {},
|
67
|
-
context: {})
|
68
|
-
HttpRequest.new(HttpMethodEnum::POST,
|
69
|
-
query_url,
|
70
|
-
headers: headers,
|
71
|
-
parameters: parameters,
|
72
|
-
context: context)
|
73
|
-
end
|
74
|
-
|
75
|
-
# Get a PUT HttpRequest object.
|
76
|
-
# @param [String] The URL to send the request to.
|
77
|
-
# @param [Hash, Optional] The headers for the HTTP Request.
|
78
|
-
# @param [Hash, Optional] The parameters for the HTTP Request.
|
79
|
-
# @param [Hash, Optional] The context for the HTTP Request.
|
80
|
-
def put(query_url,
|
81
|
-
headers: {},
|
82
|
-
parameters: {},
|
83
|
-
context: {})
|
84
|
-
HttpRequest.new(HttpMethodEnum::PUT,
|
85
|
-
query_url,
|
86
|
-
headers: headers,
|
87
|
-
parameters: parameters,
|
88
|
-
context: context)
|
89
|
-
end
|
90
|
-
|
91
|
-
# Get a PATCH HttpRequest object.
|
92
|
-
# @param [String] The URL to send the request to.
|
93
|
-
# @param [Hash, Optional] The headers for the HTTP Request.
|
94
|
-
# @param [Hash, Optional] The parameters for the HTTP Request.
|
95
|
-
# @param [Hash, Optional] The context for the HTTP Request.
|
96
|
-
def patch(query_url,
|
97
|
-
headers: {},
|
98
|
-
parameters: {},
|
99
|
-
context: {})
|
100
|
-
HttpRequest.new(HttpMethodEnum::PATCH,
|
101
|
-
query_url,
|
102
|
-
headers: headers,
|
103
|
-
parameters: parameters,
|
104
|
-
context: context)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Get a DELETE HttpRequest object.
|
108
|
-
# @param [String] The URL to send the request to.
|
109
|
-
# @param [Hash, Optional] The headers for the HTTP Request.
|
110
|
-
# @param [Hash, Optional] The parameters for the HTTP Request.
|
111
|
-
# @param [Hash, Optional] The context for the HTTP Request.
|
112
|
-
def delete(query_url,
|
113
|
-
headers: {},
|
114
|
-
parameters: nil,
|
115
|
-
context: {})
|
116
|
-
HttpRequest.new(HttpMethodEnum::DELETE,
|
117
|
-
query_url,
|
118
|
-
headers: headers,
|
119
|
-
parameters: parameters,
|
120
|
-
context: context)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# apimatic_calculator
|
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(URI.open(url, {ssl_ca_cert: Certifi.where}).read)
|
91
|
-
end
|
92
|
-
return @cache[url].path
|
93
|
-
end
|
94
|
-
end
|