reference_service 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +126 -0
  5. data/Rakefile +10 -0
  6. data/docs/ActiveSubscription.md +27 -0
  7. data/docs/Error.md +17 -0
  8. data/docs/ErrorErrors.md +17 -0
  9. data/docs/ErrorErrorsError.md +25 -0
  10. data/docs/ReportsApi.md +168 -0
  11. data/docs/Sector.md +19 -0
  12. data/docs/SectorApi.md +100 -0
  13. data/docs/SectorSpending.md +23 -0
  14. data/docs/SpendingReport.md +23 -0
  15. data/docs/SubscribeApi.md +244 -0
  16. data/docs/Subscription.md +17 -0
  17. data/docs/SubscriptionObject.md +27 -0
  18. data/docs/SubscriptionPaymentCard.md +21 -0
  19. data/docs/SubscriptionResponse.md +19 -0
  20. data/docs/TopLocationsReport.md +17 -0
  21. data/docs/UnsubscribedResponse.md +19 -0
  22. data/git_push.sh +55 -0
  23. data/lib/openapi_client.rb +55 -0
  24. data/lib/openapi_client/api/reports_api.rb +252 -0
  25. data/lib/openapi_client/api/sector_api.rb +151 -0
  26. data/lib/openapi_client/api/subscribe_api.rb +334 -0
  27. data/lib/openapi_client/api_client.rb +386 -0
  28. data/lib/openapi_client/api_error.rb +57 -0
  29. data/lib/openapi_client/configuration.rb +244 -0
  30. data/lib/openapi_client/models/active_subscription.rb +262 -0
  31. data/lib/openapi_client/models/error.rb +201 -0
  32. data/lib/openapi_client/models/error_errors.rb +203 -0
  33. data/lib/openapi_client/models/error_errors_error.rb +232 -0
  34. data/lib/openapi_client/models/sector.rb +216 -0
  35. data/lib/openapi_client/models/sector_spending.rb +244 -0
  36. data/lib/openapi_client/models/spending_report.rb +235 -0
  37. data/lib/openapi_client/models/subscription.rb +197 -0
  38. data/lib/openapi_client/models/subscription_object.rb +247 -0
  39. data/lib/openapi_client/models/subscription_payment_card.rb +254 -0
  40. data/lib/openapi_client/models/subscription_response.rb +206 -0
  41. data/lib/openapi_client/models/top_locations_report.rb +200 -0
  42. data/lib/openapi_client/models/unsubscribed_response.rb +207 -0
  43. data/lib/openapi_client/version.rb +15 -0
  44. data/openapi_client.gemspec +38 -0
  45. data/spec/api/reports_api_spec.rb +77 -0
  46. data/spec/api/sector_api_spec.rb +58 -0
  47. data/spec/api/subscribe_api_spec.rb +92 -0
  48. data/spec/api_client_spec.rb +226 -0
  49. data/spec/configuration_spec.rb +42 -0
  50. data/spec/models/active_subscription_spec.rb +71 -0
  51. data/spec/models/error_errors_error_spec.rb +65 -0
  52. data/spec/models/error_errors_spec.rb +41 -0
  53. data/spec/models/error_spec.rb +41 -0
  54. data/spec/models/sector_spec.rb +47 -0
  55. data/spec/models/sector_spending_spec.rb +59 -0
  56. data/spec/models/spending_report_spec.rb +59 -0
  57. data/spec/models/subscription_object_spec.rb +71 -0
  58. data/spec/models/subscription_payment_card_spec.rb +53 -0
  59. data/spec/models/subscription_response_spec.rb +47 -0
  60. data/spec/models/subscription_spec.rb +41 -0
  61. data/spec/models/top_locations_report_spec.rb +41 -0
  62. data/spec/models/unsubscribed_response_spec.rb +47 -0
  63. data/spec/spec_helper.rb +111 -0
  64. metadata +199 -0
@@ -0,0 +1,57 @@
1
+ =begin
2
+ #Golden Service API
3
+
4
+ #An API that conforms to the standards and best practices that should be adhered to in all Mastercard owned APIs. Can be used to create subscriptions to reports that are generated twice daily (6am & 6pm) that deliver e-commerce spending across multiple sectors and locations. <br/> --- * **All requests must be signed using oauth 1.0a. Please refer to: https://developer.mastercard.com/platform/documentation/using-oauth-1a-to-access-mastercard-apis/** --- * **The user must provide their card details when creating a subscription. These details must be encrypted before entering transit. Please refer to [Mastercard security](https://stage.developer.mastercard.com/platform/documentation/securing-sensitive-data-using-payload-encryption/)** ---
5
+
6
+ The version of the OpenAPI document: 1.1.0
7
+ Contact: developers@mastercard.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ module OpenapiClient
14
+ class ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ end
36
+ end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,244 @@
1
+ =begin
2
+ #Golden Service API
3
+
4
+ #An API that conforms to the standards and best practices that should be adhered to in all Mastercard owned APIs. Can be used to create subscriptions to reports that are generated twice daily (6am & 6pm) that deliver e-commerce spending across multiple sectors and locations. <br/> --- * **All requests must be signed using oauth 1.0a. Please refer to: https://developer.mastercard.com/platform/documentation/using-oauth-1a-to-access-mastercard-apis/** --- * **The user must provide their card details when creating a subscription. These details must be encrypted before entering transit. Please refer to [Mastercard security](https://stage.developer.mastercard.com/platform/documentation/securing-sensitive-data-using-payload-encryption/)** ---
5
+
6
+ The version of the OpenAPI document: 1.1.0
7
+ Contact: developers@mastercard.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'uri'
14
+
15
+ module OpenapiClient
16
+ class Configuration
17
+ # Defines url scheme
18
+ attr_accessor :scheme
19
+
20
+ # Defines url host
21
+ attr_accessor :host
22
+
23
+ # Defines url base path
24
+ attr_accessor :base_path
25
+
26
+ # Defines API keys used with API Key authentications.
27
+ #
28
+ # @return [Hash] key: parameter name, value: parameter value (API key)
29
+ #
30
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
31
+ # config.api_key['api_key'] = 'xxx'
32
+ attr_accessor :api_key
33
+
34
+ # Defines API key prefixes used with API Key authentications.
35
+ #
36
+ # @return [Hash] key: parameter name, value: API key prefix
37
+ #
38
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
39
+ # config.api_key_prefix['api_key'] = 'Token'
40
+ attr_accessor :api_key_prefix
41
+
42
+ # Defines the username used with HTTP basic authentication.
43
+ #
44
+ # @return [String]
45
+ attr_accessor :username
46
+
47
+ # Defines the password used with HTTP basic authentication.
48
+ #
49
+ # @return [String]
50
+ attr_accessor :password
51
+
52
+ # Defines the access token (Bearer) used with OAuth2.
53
+ attr_accessor :access_token
54
+
55
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
56
+ # details will be logged with `logger.debug` (see the `logger` attribute).
57
+ # Default to false.
58
+ #
59
+ # @return [true, false]
60
+ attr_accessor :debugging
61
+
62
+ # Defines the logger used for debugging.
63
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
64
+ #
65
+ # @return [#debug]
66
+ attr_accessor :logger
67
+
68
+ # Defines the temporary folder to store downloaded files
69
+ # (for API endpoints that have file response).
70
+ # Default to use `Tempfile`.
71
+ #
72
+ # @return [String]
73
+ attr_accessor :temp_folder_path
74
+
75
+ # The time limit for HTTP request in seconds.
76
+ # Default to 0 (never times out).
77
+ attr_accessor :timeout
78
+
79
+ # Set this to false to skip client side validation in the operation.
80
+ # Default to true.
81
+ # @return [true, false]
82
+ attr_accessor :client_side_validation
83
+
84
+ ### TLS/SSL setting
85
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
86
+ # Default to true.
87
+ #
88
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
89
+ #
90
+ # @return [true, false]
91
+ attr_accessor :verify_ssl
92
+
93
+ ### TLS/SSL setting
94
+ # Set this to false to skip verifying SSL host name
95
+ # Default to true.
96
+ #
97
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
98
+ #
99
+ # @return [true, false]
100
+ attr_accessor :verify_ssl_host
101
+
102
+ ### TLS/SSL setting
103
+ # Set this to customize the certificate file to verify the peer.
104
+ #
105
+ # @return [String] the path to the certificate file
106
+ #
107
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
108
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
109
+ attr_accessor :ssl_ca_cert
110
+
111
+ ### TLS/SSL setting
112
+ # Client certificate file (for client certificate)
113
+ attr_accessor :cert_file
114
+
115
+ ### TLS/SSL setting
116
+ # Client private key file (for client certificate)
117
+ attr_accessor :key_file
118
+
119
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
120
+ # Default to nil.
121
+ #
122
+ # @see The params_encoding option of Ethon. Related source code:
123
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
124
+ attr_accessor :params_encoding
125
+
126
+ attr_accessor :inject_format
127
+
128
+ attr_accessor :force_ending_format
129
+
130
+ def initialize
131
+ @scheme = 'https'
132
+ @host = 'stage.api.mastercard.com'
133
+ @base_path = '/golden-service'
134
+ @api_key = {}
135
+ @api_key_prefix = {}
136
+ @timeout = 0
137
+ @client_side_validation = true
138
+ @verify_ssl = true
139
+ @verify_ssl_host = true
140
+ @params_encoding = nil
141
+ @cert_file = nil
142
+ @key_file = nil
143
+ @debugging = false
144
+ @inject_format = false
145
+ @force_ending_format = false
146
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
147
+
148
+ yield(self) if block_given?
149
+ end
150
+
151
+ # The default Configuration object.
152
+ def self.default
153
+ @@default ||= Configuration.new
154
+ end
155
+
156
+ def configure
157
+ yield(self) if block_given?
158
+ end
159
+
160
+ def scheme=(scheme)
161
+ # remove :// from scheme
162
+ @scheme = scheme.sub(/:\/\//, '')
163
+ end
164
+
165
+ def host=(host)
166
+ # remove http(s):// and anything after a slash
167
+ @host = host.sub(/https?:\/\//, '').split('/').first
168
+ end
169
+
170
+ def base_path=(base_path)
171
+ # Add leading and trailing slashes to base_path
172
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
173
+ @base_path = '' if @base_path == '/'
174
+ end
175
+
176
+ def base_url
177
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
178
+ URI.encode(url)
179
+ end
180
+
181
+ # Gets API key (with prefix if set).
182
+ # @param [String] param_name the parameter name of API key auth
183
+ def api_key_with_prefix(param_name)
184
+ if @api_key_prefix[param_name]
185
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
186
+ else
187
+ @api_key[param_name]
188
+ end
189
+ end
190
+
191
+ # Gets Basic Auth token string
192
+ def basic_auth_token
193
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
194
+ end
195
+
196
+ # Returns Auth Settings hash for api client.
197
+ def auth_settings
198
+ {
199
+ }
200
+ end
201
+
202
+ # Returns an array of Server setting
203
+ def server_settings
204
+ [
205
+ {
206
+ url: "https://stage.api.mastercard.com/golden-service/",
207
+ description: "Golden Service - STAGE",
208
+ }
209
+ ]
210
+ end
211
+
212
+ # Returns URL based on server settings
213
+ #
214
+ # @param index array index of the server settings
215
+ # @param variables hash of variable and the corresponding value
216
+ def server_url(index, variables = {})
217
+ servers = server_settings
218
+
219
+ # check array index out of bound
220
+ if (index < 0 || index >= servers.size)
221
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
222
+ end
223
+
224
+ server = servers[index]
225
+ url = server[:url]
226
+
227
+ # go through variable and assign a value
228
+ server[:variables].each do |name, variable|
229
+ if variables.key?(name)
230
+ if (server[:variables][name][:enum_values].include? variables[name])
231
+ url.gsub! "{" + name.to_s + "}", variables[name]
232
+ else
233
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
234
+ end
235
+ else
236
+ # use default value
237
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
238
+ end
239
+ end
240
+
241
+ url
242
+ end
243
+ end
244
+ end
@@ -0,0 +1,262 @@
1
+ =begin
2
+ #Golden Service API
3
+
4
+ #An API that conforms to the standards and best practices that should be adhered to in all Mastercard owned APIs. Can be used to create subscriptions to reports that are generated twice daily (6am & 6pm) that deliver e-commerce spending across multiple sectors and locations. <br/> --- * **All requests must be signed using oauth 1.0a. Please refer to: https://developer.mastercard.com/platform/documentation/using-oauth-1a-to-access-mastercard-apis/** --- * **The user must provide their card details when creating a subscription. These details must be encrypted before entering transit. Please refer to [Mastercard security](https://stage.developer.mastercard.com/platform/documentation/securing-sensitive-data-using-payload-encryption/)** ---
5
+
6
+ The version of the OpenAPI document: 1.1.0
7
+ Contact: developers@mastercard.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module OpenapiClient
16
+ # Subscription representation object
17
+ class ActiveSubscription
18
+ # The email address of the active subscription
19
+ attr_accessor :email_address
20
+
21
+ # The unique identifier of the subscription (Version 4 UUID)
22
+ attr_accessor :subscription_id
23
+
24
+ # The location that reports are generated for as part of the subscription
25
+ attr_accessor :location
26
+
27
+ attr_accessor :sector
28
+
29
+ # b - Bi-Daily, d - Daily, w - Weekly
30
+ attr_accessor :frequency
31
+
32
+ # An image that can be included as part of the subscription. MUST be sent in base64 format.
33
+ attr_accessor :subscription_image
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'email_address' => :'emailAddress',
39
+ :'subscription_id' => :'subscriptionId',
40
+ :'location' => :'location',
41
+ :'sector' => :'sector',
42
+ :'frequency' => :'frequency',
43
+ :'subscription_image' => :'subscriptionImage'
44
+ }
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'email_address' => :'String',
51
+ :'subscription_id' => :'String',
52
+ :'location' => :'String',
53
+ :'sector' => :'Sector',
54
+ :'frequency' => :'String',
55
+ :'subscription_image' => :'String'
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::ActiveSubscription` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::ActiveSubscription`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'email_address')
75
+ self.email_address = attributes[:'email_address']
76
+ end
77
+
78
+ if attributes.key?(:'subscription_id')
79
+ self.subscription_id = attributes[:'subscription_id']
80
+ end
81
+
82
+ if attributes.key?(:'location')
83
+ self.location = attributes[:'location']
84
+ end
85
+
86
+ if attributes.key?(:'sector')
87
+ self.sector = attributes[:'sector']
88
+ end
89
+
90
+ if attributes.key?(:'frequency')
91
+ self.frequency = attributes[:'frequency']
92
+ end
93
+
94
+ if attributes.key?(:'subscription_image')
95
+ self.subscription_image = attributes[:'subscription_image']
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ if @subscription_id.nil?
104
+ invalid_properties.push('invalid value for "subscription_id", subscription_id cannot be nil.')
105
+ end
106
+
107
+ if @location.nil?
108
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
109
+ end
110
+
111
+ if @sector.nil?
112
+ invalid_properties.push('invalid value for "sector", sector cannot be nil.')
113
+ end
114
+
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ return false if @subscription_id.nil?
122
+ return false if @location.nil?
123
+ return false if @sector.nil?
124
+ true
125
+ end
126
+
127
+ # Checks equality by comparing each attribute.
128
+ # @param [Object] Object to be compared
129
+ def ==(o)
130
+ return true if self.equal?(o)
131
+ self.class == o.class &&
132
+ email_address == o.email_address &&
133
+ subscription_id == o.subscription_id &&
134
+ location == o.location &&
135
+ sector == o.sector &&
136
+ frequency == o.frequency &&
137
+ subscription_image == o.subscription_image
138
+ end
139
+
140
+ # @see the `==` method
141
+ # @param [Object] Object to be compared
142
+ def eql?(o)
143
+ self == o
144
+ end
145
+
146
+ # Calculates hash code according to all attributes.
147
+ # @return [Integer] Hash code
148
+ def hash
149
+ [email_address, subscription_id, location, sector, frequency, subscription_image].hash
150
+ end
151
+
152
+ # Builds the object from hash
153
+ # @param [Hash] attributes Model attributes in the form of hash
154
+ # @return [Object] Returns the model itself
155
+ def self.build_from_hash(attributes)
156
+ new.build_from_hash(attributes)
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+ self.class.openapi_types.each_pair do |key, type|
165
+ if type =~ /\AArray<(.*)>/i
166
+ # check to ensure the input is an array given that the attribute
167
+ # is documented as an array but the input is not
168
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
169
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
170
+ end
171
+ elsif !attributes[self.class.attribute_map[key]].nil?
172
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
173
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
174
+ end
175
+
176
+ self
177
+ end
178
+
179
+ # Deserializes the data based on type
180
+ # @param string type Data type
181
+ # @param string value Value to be deserialized
182
+ # @return [Object] Deserialized data
183
+ def _deserialize(type, value)
184
+ case type.to_sym
185
+ when :DateTime
186
+ DateTime.parse(value)
187
+ when :Date
188
+ Date.parse(value)
189
+ when :String
190
+ value.to_s
191
+ when :Integer
192
+ value.to_i
193
+ when :Float
194
+ value.to_f
195
+ when :Boolean
196
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
+ true
198
+ else
199
+ false
200
+ end
201
+ when :Object
202
+ # generic object (usually a Hash), return directly
203
+ value
204
+ when /\AArray<(?<inner_type>.+)>\z/
205
+ inner_type = Regexp.last_match[:inner_type]
206
+ value.map { |v| _deserialize(inner_type, v) }
207
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
+ k_type = Regexp.last_match[:k_type]
209
+ v_type = Regexp.last_match[:v_type]
210
+ {}.tap do |hash|
211
+ value.each do |k, v|
212
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
+ end
214
+ end
215
+ else # model
216
+ OpenapiClient.const_get(type).build_from_hash(value)
217
+ end
218
+ end
219
+
220
+ # Returns the string representation of the object
221
+ # @return [String] String presentation of the object
222
+ def to_s
223
+ to_hash.to_s
224
+ end
225
+
226
+ # to_body is an alias to to_hash (backward compatibility)
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_body
229
+ to_hash
230
+ end
231
+
232
+ # Returns the object in the form of hash
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_hash
235
+ hash = {}
236
+ self.class.attribute_map.each_pair do |attr, param|
237
+ value = self.send(attr)
238
+ next if value.nil?
239
+ hash[param] = _to_hash(value)
240
+ end
241
+ hash
242
+ end
243
+
244
+ # Outputs non-array value in the form of hash
245
+ # For object, use to_hash. Otherwise, just return the value
246
+ # @param [Object] value Any valid value
247
+ # @return [Hash] Returns the value in the form of hash
248
+ def _to_hash(value)
249
+ if value.is_a?(Array)
250
+ value.compact.map { |v| _to_hash(v) }
251
+ elsif value.is_a?(Hash)
252
+ {}.tap do |hash|
253
+ value.each { |k, v| hash[k] = _to_hash(v) }
254
+ end
255
+ elsif value.respond_to? :to_hash
256
+ value.to_hash
257
+ else
258
+ value
259
+ end
260
+ end
261
+ end
262
+ end