rankvectors 1.0.0

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.
Files changed (157) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +191 -0
  4. data/Rakefile +10 -0
  5. data/docs/AddCredits200Response.md +22 -0
  6. data/docs/AddCreditsRequest.md +20 -0
  7. data/docs/AutoRechargeSettings.md +22 -0
  8. data/docs/ChangeResult.md +24 -0
  9. data/docs/ContentVerification.md +22 -0
  10. data/docs/ContentVerificationApi.md +81 -0
  11. data/docs/Crawl.md +30 -0
  12. data/docs/CrawlingApi.md +155 -0
  13. data/docs/CreateProjectRequest.md +60 -0
  14. data/docs/CreditBalance.md +30 -0
  15. data/docs/CreditBalanceInfo.md +26 -0
  16. data/docs/CreditsApi.md +161 -0
  17. data/docs/CustomCredentials.md +20 -0
  18. data/docs/DeleteProject200Response.md +20 -0
  19. data/docs/Error.md +24 -0
  20. data/docs/GenerateSuggestions200Response.md +22 -0
  21. data/docs/GenerateSuggestionsRequest.md +18 -0
  22. data/docs/GetImplementation200Response.md +20 -0
  23. data/docs/Implementation.md +36 -0
  24. data/docs/ImplementationInstructions.md +28 -0
  25. data/docs/ImplementationRequest.md +26 -0
  26. data/docs/ImplementationResponse.md +22 -0
  27. data/docs/ImplementationResult.md +24 -0
  28. data/docs/ImplementationSummary.md +24 -0
  29. data/docs/ImplementationsApi.md +313 -0
  30. data/docs/LinkOpportunity.md +28 -0
  31. data/docs/ListImplementations200Response.md +24 -0
  32. data/docs/PageInfo.md +24 -0
  33. data/docs/PageLimitStatus.md +22 -0
  34. data/docs/PeriodCharges.md +22 -0
  35. data/docs/Project.md +70 -0
  36. data/docs/ProjectCount.md +20 -0
  37. data/docs/ProjectsApi.md +292 -0
  38. data/docs/ReportImplementationStatus200Response.md +20 -0
  39. data/docs/ReportImplementationStatusRequest.md +22 -0
  40. data/docs/Rollback.md +24 -0
  41. data/docs/RollbackImplementation200Response.md +22 -0
  42. data/docs/RollbackImplementationRequest.md +20 -0
  43. data/docs/SpendingLimitStatus.md +24 -0
  44. data/docs/StartCrawlRequest.md +18 -0
  45. data/docs/StepByStepInstructions.md +20 -0
  46. data/docs/Suggestion.md +38 -0
  47. data/docs/SuggestionsApi.md +235 -0
  48. data/docs/UpdateSuggestionRequest.md +18 -0
  49. data/docs/UsageHistoryItem.md +26 -0
  50. data/docs/VerifyContent200Response.md +20 -0
  51. data/docs/VerifyContentRequest.md +20 -0
  52. data/docs/WebhooksApi.md +151 -0
  53. data/git_push.sh +57 -0
  54. data/lib/openapi_client/api/content_verification_api.rb +96 -0
  55. data/lib/openapi_client/api/crawling_api.rb +155 -0
  56. data/lib/openapi_client/api/credits_api.rb +168 -0
  57. data/lib/openapi_client/api/implementations_api.rb +332 -0
  58. data/lib/openapi_client/api/projects_api.rb +273 -0
  59. data/lib/openapi_client/api/suggestions_api.rb +242 -0
  60. data/lib/openapi_client/api/webhooks_api.rb +154 -0
  61. data/lib/openapi_client/api_client.rb +393 -0
  62. data/lib/openapi_client/api_error.rb +58 -0
  63. data/lib/openapi_client/configuration.rb +316 -0
  64. data/lib/openapi_client/models/add_credits200_response.rb +238 -0
  65. data/lib/openapi_client/models/add_credits_request.rb +259 -0
  66. data/lib/openapi_client/models/auto_recharge_settings.rb +292 -0
  67. data/lib/openapi_client/models/change_result.rb +328 -0
  68. data/lib/openapi_client/models/content_verification.rb +274 -0
  69. data/lib/openapi_client/models/crawl.rb +373 -0
  70. data/lib/openapi_client/models/create_project_request.rb +541 -0
  71. data/lib/openapi_client/models/credit_balance.rb +379 -0
  72. data/lib/openapi_client/models/credit_balance_info.rb +329 -0
  73. data/lib/openapi_client/models/custom_credentials.rb +265 -0
  74. data/lib/openapi_client/models/delete_project200_response.rb +229 -0
  75. data/lib/openapi_client/models/error.rb +268 -0
  76. data/lib/openapi_client/models/generate_suggestions200_response.rb +261 -0
  77. data/lib/openapi_client/models/generate_suggestions_request.rb +249 -0
  78. data/lib/openapi_client/models/get_implementation200_response.rb +229 -0
  79. data/lib/openapi_client/models/implementation.rb +454 -0
  80. data/lib/openapi_client/models/implementation_instructions.rb +372 -0
  81. data/lib/openapi_client/models/implementation_request.rb +362 -0
  82. data/lib/openapi_client/models/implementation_response.rb +293 -0
  83. data/lib/openapi_client/models/implementation_result.rb +268 -0
  84. data/lib/openapi_client/models/implementation_summary.rb +319 -0
  85. data/lib/openapi_client/models/link_opportunity.rb +355 -0
  86. data/lib/openapi_client/models/list_implementations200_response.rb +251 -0
  87. data/lib/openapi_client/models/page_info.rb +285 -0
  88. data/lib/openapi_client/models/page_limit_status.rb +292 -0
  89. data/lib/openapi_client/models/period_charges.rb +292 -0
  90. data/lib/openapi_client/models/project.rb +634 -0
  91. data/lib/openapi_client/models/project_count.rb +230 -0
  92. data/lib/openapi_client/models/report_implementation_status200_response.rb +229 -0
  93. data/lib/openapi_client/models/report_implementation_status_request.rb +316 -0
  94. data/lib/openapi_client/models/rollback.rb +302 -0
  95. data/lib/openapi_client/models/rollback_implementation200_response.rb +239 -0
  96. data/lib/openapi_client/models/rollback_implementation_request.rb +247 -0
  97. data/lib/openapi_client/models/spending_limit_status.rb +319 -0
  98. data/lib/openapi_client/models/start_crawl_request.rb +249 -0
  99. data/lib/openapi_client/models/step_by_step_instructions.rb +267 -0
  100. data/lib/openapi_client/models/suggestion.rb +497 -0
  101. data/lib/openapi_client/models/update_suggestion_request.rb +262 -0
  102. data/lib/openapi_client/models/usage_history_item.rb +331 -0
  103. data/lib/openapi_client/models/verify_content200_response.rb +229 -0
  104. data/lib/openapi_client/models/verify_content_request.rb +265 -0
  105. data/lib/openapi_client/version.rb +15 -0
  106. data/lib/openapi_client.rb +87 -0
  107. data/openapi_client.gemspec +39 -0
  108. data/spec/api/content_verification_api_spec.rb +48 -0
  109. data/spec/api/crawling_api_spec.rb +60 -0
  110. data/spec/api/credits_api_spec.rb +63 -0
  111. data/spec/api/implementations_api_spec.rb +91 -0
  112. data/spec/api/projects_api_spec.rb +82 -0
  113. data/spec/api/suggestions_api_spec.rb +75 -0
  114. data/spec/api/webhooks_api_spec.rb +59 -0
  115. data/spec/models/add_credits200_response_spec.rb +48 -0
  116. data/spec/models/add_credits_request_spec.rb +42 -0
  117. data/spec/models/auto_recharge_settings_spec.rb +48 -0
  118. data/spec/models/change_result_spec.rb +62 -0
  119. data/spec/models/content_verification_spec.rb +48 -0
  120. data/spec/models/crawl_spec.rb +76 -0
  121. data/spec/models/create_project_request_spec.rb +170 -0
  122. data/spec/models/credit_balance_info_spec.rb +60 -0
  123. data/spec/models/credit_balance_spec.rb +72 -0
  124. data/spec/models/custom_credentials_spec.rb +42 -0
  125. data/spec/models/delete_project200_response_spec.rb +42 -0
  126. data/spec/models/error_spec.rb +54 -0
  127. data/spec/models/generate_suggestions200_response_spec.rb +48 -0
  128. data/spec/models/generate_suggestions_request_spec.rb +36 -0
  129. data/spec/models/get_implementation200_response_spec.rb +42 -0
  130. data/spec/models/implementation_instructions_spec.rb +66 -0
  131. data/spec/models/implementation_request_spec.rb +68 -0
  132. data/spec/models/implementation_response_spec.rb +48 -0
  133. data/spec/models/implementation_result_spec.rb +54 -0
  134. data/spec/models/implementation_spec.rb +102 -0
  135. data/spec/models/implementation_summary_spec.rb +54 -0
  136. data/spec/models/link_opportunity_spec.rb +66 -0
  137. data/spec/models/list_implementations200_response_spec.rb +54 -0
  138. data/spec/models/page_info_spec.rb +54 -0
  139. data/spec/models/page_limit_status_spec.rb +48 -0
  140. data/spec/models/period_charges_spec.rb +48 -0
  141. data/spec/models/project_count_spec.rb +42 -0
  142. data/spec/models/project_spec.rb +200 -0
  143. data/spec/models/report_implementation_status200_response_spec.rb +42 -0
  144. data/spec/models/report_implementation_status_request_spec.rb +52 -0
  145. data/spec/models/rollback_implementation200_response_spec.rb +48 -0
  146. data/spec/models/rollback_implementation_request_spec.rb +42 -0
  147. data/spec/models/rollback_spec.rb +54 -0
  148. data/spec/models/spending_limit_status_spec.rb +54 -0
  149. data/spec/models/start_crawl_request_spec.rb +36 -0
  150. data/spec/models/step_by_step_instructions_spec.rb +42 -0
  151. data/spec/models/suggestion_spec.rb +100 -0
  152. data/spec/models/update_suggestion_request_spec.rb +40 -0
  153. data/spec/models/usage_history_item_spec.rb +60 -0
  154. data/spec/models/verify_content200_response_spec.rb +42 -0
  155. data/spec/models/verify_content_request_spec.rb +42 -0
  156. data/spec/spec_helper.rb +111 -0
  157. metadata +288 -0
@@ -0,0 +1,497 @@
1
+ =begin
2
+ #RankVectors API
3
+
4
+ #Intelligent internal linking optimization API using AI. RankVectors helps you automatically discover and implement optimal internal links across your website to improve SEO performance and user experience. ## Key Features - **AI-Powered Analysis**: Uses OpenAI embeddings to find optimal linking opportunities - **Smart Crawling**: Automatically crawls and analyzes your website content - **Automated Implementation**: Implement links via webhooks or manual instructions - **Credit-Based System**: Pay-per-use model with transparent pricing - **Multi-Platform Support**: Works with any CMS or platform via REST API ## Getting Started 1. Create a project with your website URL 2. Start a crawl to analyze your content 3. Generate AI-powered link suggestions 4. Implement suggestions via API or webhook 5. Track performance and manage credits ## Authentication All API endpoints require authentication using your RankVectors API key. Include your API key in the `Authorization` header: ``` Authorization: Bearer YOUR_API_KEY ``` Get your API key from your RankVectors dashboard: Settings → API Keys
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@rankvectors.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.16.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class Suggestion
18
+ # Unique suggestion identifier
19
+ attr_accessor :id
20
+
21
+ # Project identifier
22
+ attr_accessor :project_id
23
+
24
+ # Suggestion status
25
+ attr_accessor :status
26
+
27
+ # AI-calculated relevance score (0-1)
28
+ attr_accessor :relevance_score
29
+
30
+ # Suggested anchor text
31
+ attr_accessor :anchor_text
32
+
33
+ # Context where the link should be placed
34
+ attr_accessor :context
35
+
36
+ attr_accessor :source_page
37
+
38
+ attr_accessor :target_page
39
+
40
+ # AI reasoning for the suggestion
41
+ attr_accessor :reasoning
42
+
43
+ # Suggestion creation timestamp
44
+ attr_accessor :created_at
45
+
46
+ # Last update timestamp
47
+ attr_accessor :updated_at
48
+
49
+ class EnumAttributeValidator
50
+ attr_reader :datatype
51
+ attr_reader :allowable_values
52
+
53
+ def initialize(datatype, allowable_values)
54
+ @allowable_values = allowable_values.map do |value|
55
+ case datatype.to_s
56
+ when /Integer/i
57
+ value.to_i
58
+ when /Float/i
59
+ value.to_f
60
+ else
61
+ value
62
+ end
63
+ end
64
+ end
65
+
66
+ def valid?(value)
67
+ !value || allowable_values.include?(value)
68
+ end
69
+ end
70
+
71
+ # Attribute mapping from ruby-style variable name to JSON key.
72
+ def self.attribute_map
73
+ {
74
+ :'id' => :'id',
75
+ :'project_id' => :'projectId',
76
+ :'status' => :'status',
77
+ :'relevance_score' => :'relevanceScore',
78
+ :'anchor_text' => :'anchorText',
79
+ :'context' => :'context',
80
+ :'source_page' => :'sourcePage',
81
+ :'target_page' => :'targetPage',
82
+ :'reasoning' => :'reasoning',
83
+ :'created_at' => :'createdAt',
84
+ :'updated_at' => :'updatedAt'
85
+ }
86
+ end
87
+
88
+ # Returns attribute mapping this model knows about
89
+ def self.acceptable_attribute_map
90
+ attribute_map
91
+ end
92
+
93
+ # Returns all the JSON keys this model knows about
94
+ def self.acceptable_attributes
95
+ acceptable_attribute_map.values
96
+ end
97
+
98
+ # Attribute type mapping.
99
+ def self.openapi_types
100
+ {
101
+ :'id' => :'String',
102
+ :'project_id' => :'String',
103
+ :'status' => :'String',
104
+ :'relevance_score' => :'Float',
105
+ :'anchor_text' => :'String',
106
+ :'context' => :'String',
107
+ :'source_page' => :'PageInfo',
108
+ :'target_page' => :'PageInfo',
109
+ :'reasoning' => :'String',
110
+ :'created_at' => :'Time',
111
+ :'updated_at' => :'Time'
112
+ }
113
+ end
114
+
115
+ # List of attributes with nullable: true
116
+ def self.openapi_nullable
117
+ Set.new([
118
+ ])
119
+ end
120
+
121
+ # Initializes the object
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ def initialize(attributes = {})
124
+ if (!attributes.is_a?(Hash))
125
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Suggestion` initialize method"
126
+ end
127
+
128
+ # check to see if the attribute exists and convert string to symbol for hash key
129
+ acceptable_attribute_map = self.class.acceptable_attribute_map
130
+ attributes = attributes.each_with_object({}) { |(k, v), h|
131
+ if (!acceptable_attribute_map.key?(k.to_sym))
132
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Suggestion`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
133
+ end
134
+ h[k.to_sym] = v
135
+ }
136
+
137
+ if attributes.key?(:'id')
138
+ self.id = attributes[:'id']
139
+ else
140
+ self.id = nil
141
+ end
142
+
143
+ if attributes.key?(:'project_id')
144
+ self.project_id = attributes[:'project_id']
145
+ else
146
+ self.project_id = nil
147
+ end
148
+
149
+ if attributes.key?(:'status')
150
+ self.status = attributes[:'status']
151
+ else
152
+ self.status = nil
153
+ end
154
+
155
+ if attributes.key?(:'relevance_score')
156
+ self.relevance_score = attributes[:'relevance_score']
157
+ else
158
+ self.relevance_score = nil
159
+ end
160
+
161
+ if attributes.key?(:'anchor_text')
162
+ self.anchor_text = attributes[:'anchor_text']
163
+ else
164
+ self.anchor_text = nil
165
+ end
166
+
167
+ if attributes.key?(:'context')
168
+ self.context = attributes[:'context']
169
+ end
170
+
171
+ if attributes.key?(:'source_page')
172
+ self.source_page = attributes[:'source_page']
173
+ else
174
+ self.source_page = nil
175
+ end
176
+
177
+ if attributes.key?(:'target_page')
178
+ self.target_page = attributes[:'target_page']
179
+ else
180
+ self.target_page = nil
181
+ end
182
+
183
+ if attributes.key?(:'reasoning')
184
+ self.reasoning = attributes[:'reasoning']
185
+ end
186
+
187
+ if attributes.key?(:'created_at')
188
+ self.created_at = attributes[:'created_at']
189
+ else
190
+ self.created_at = nil
191
+ end
192
+
193
+ if attributes.key?(:'updated_at')
194
+ self.updated_at = attributes[:'updated_at']
195
+ end
196
+ end
197
+
198
+ # Show invalid properties with the reasons. Usually used together with valid?
199
+ # @return Array for valid properties with the reasons
200
+ def list_invalid_properties
201
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
202
+ invalid_properties = Array.new
203
+ if @id.nil?
204
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
205
+ end
206
+
207
+ if @project_id.nil?
208
+ invalid_properties.push('invalid value for "project_id", project_id cannot be nil.')
209
+ end
210
+
211
+ if @status.nil?
212
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
213
+ end
214
+
215
+ if @relevance_score.nil?
216
+ invalid_properties.push('invalid value for "relevance_score", relevance_score cannot be nil.')
217
+ end
218
+
219
+ if @relevance_score > 1
220
+ invalid_properties.push('invalid value for "relevance_score", must be smaller than or equal to 1.')
221
+ end
222
+
223
+ if @relevance_score < 0
224
+ invalid_properties.push('invalid value for "relevance_score", must be greater than or equal to 0.')
225
+ end
226
+
227
+ if @anchor_text.nil?
228
+ invalid_properties.push('invalid value for "anchor_text", anchor_text cannot be nil.')
229
+ end
230
+
231
+ if @source_page.nil?
232
+ invalid_properties.push('invalid value for "source_page", source_page cannot be nil.')
233
+ end
234
+
235
+ if @target_page.nil?
236
+ invalid_properties.push('invalid value for "target_page", target_page cannot be nil.')
237
+ end
238
+
239
+ if @created_at.nil?
240
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
241
+ end
242
+
243
+ invalid_properties
244
+ end
245
+
246
+ # Check to see if the all the properties in the model are valid
247
+ # @return true if the model is valid
248
+ def valid?
249
+ warn '[DEPRECATED] the `valid?` method is obsolete'
250
+ return false if @id.nil?
251
+ return false if @project_id.nil?
252
+ return false if @status.nil?
253
+ status_validator = EnumAttributeValidator.new('String', ["pending", "approved", "rejected", "implemented"])
254
+ return false unless status_validator.valid?(@status)
255
+ return false if @relevance_score.nil?
256
+ return false if @relevance_score > 1
257
+ return false if @relevance_score < 0
258
+ return false if @anchor_text.nil?
259
+ return false if @source_page.nil?
260
+ return false if @target_page.nil?
261
+ return false if @created_at.nil?
262
+ true
263
+ end
264
+
265
+ # Custom attribute writer method with validation
266
+ # @param [Object] id Value to be assigned
267
+ def id=(id)
268
+ if id.nil?
269
+ fail ArgumentError, 'id cannot be nil'
270
+ end
271
+
272
+ @id = id
273
+ end
274
+
275
+ # Custom attribute writer method with validation
276
+ # @param [Object] project_id Value to be assigned
277
+ def project_id=(project_id)
278
+ if project_id.nil?
279
+ fail ArgumentError, 'project_id cannot be nil'
280
+ end
281
+
282
+ @project_id = project_id
283
+ end
284
+
285
+ # Custom attribute writer method checking allowed values (enum).
286
+ # @param [Object] status Object to be assigned
287
+ def status=(status)
288
+ validator = EnumAttributeValidator.new('String', ["pending", "approved", "rejected", "implemented"])
289
+ unless validator.valid?(status)
290
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
291
+ end
292
+ @status = status
293
+ end
294
+
295
+ # Custom attribute writer method with validation
296
+ # @param [Object] relevance_score Value to be assigned
297
+ def relevance_score=(relevance_score)
298
+ if relevance_score.nil?
299
+ fail ArgumentError, 'relevance_score cannot be nil'
300
+ end
301
+
302
+ if relevance_score > 1
303
+ fail ArgumentError, 'invalid value for "relevance_score", must be smaller than or equal to 1.'
304
+ end
305
+
306
+ if relevance_score < 0
307
+ fail ArgumentError, 'invalid value for "relevance_score", must be greater than or equal to 0.'
308
+ end
309
+
310
+ @relevance_score = relevance_score
311
+ end
312
+
313
+ # Custom attribute writer method with validation
314
+ # @param [Object] anchor_text Value to be assigned
315
+ def anchor_text=(anchor_text)
316
+ if anchor_text.nil?
317
+ fail ArgumentError, 'anchor_text cannot be nil'
318
+ end
319
+
320
+ @anchor_text = anchor_text
321
+ end
322
+
323
+ # Custom attribute writer method with validation
324
+ # @param [Object] source_page Value to be assigned
325
+ def source_page=(source_page)
326
+ if source_page.nil?
327
+ fail ArgumentError, 'source_page cannot be nil'
328
+ end
329
+
330
+ @source_page = source_page
331
+ end
332
+
333
+ # Custom attribute writer method with validation
334
+ # @param [Object] target_page Value to be assigned
335
+ def target_page=(target_page)
336
+ if target_page.nil?
337
+ fail ArgumentError, 'target_page cannot be nil'
338
+ end
339
+
340
+ @target_page = target_page
341
+ end
342
+
343
+ # Custom attribute writer method with validation
344
+ # @param [Object] created_at Value to be assigned
345
+ def created_at=(created_at)
346
+ if created_at.nil?
347
+ fail ArgumentError, 'created_at cannot be nil'
348
+ end
349
+
350
+ @created_at = created_at
351
+ end
352
+
353
+ # Checks equality by comparing each attribute.
354
+ # @param [Object] Object to be compared
355
+ def ==(o)
356
+ return true if self.equal?(o)
357
+ self.class == o.class &&
358
+ id == o.id &&
359
+ project_id == o.project_id &&
360
+ status == o.status &&
361
+ relevance_score == o.relevance_score &&
362
+ anchor_text == o.anchor_text &&
363
+ context == o.context &&
364
+ source_page == o.source_page &&
365
+ target_page == o.target_page &&
366
+ reasoning == o.reasoning &&
367
+ created_at == o.created_at &&
368
+ updated_at == o.updated_at
369
+ end
370
+
371
+ # @see the `==` method
372
+ # @param [Object] Object to be compared
373
+ def eql?(o)
374
+ self == o
375
+ end
376
+
377
+ # Calculates hash code according to all attributes.
378
+ # @return [Integer] Hash code
379
+ def hash
380
+ [id, project_id, status, relevance_score, anchor_text, context, source_page, target_page, reasoning, created_at, updated_at].hash
381
+ end
382
+
383
+ # Builds the object from hash
384
+ # @param [Hash] attributes Model attributes in the form of hash
385
+ # @return [Object] Returns the model itself
386
+ def self.build_from_hash(attributes)
387
+ return nil unless attributes.is_a?(Hash)
388
+ attributes = attributes.transform_keys(&:to_sym)
389
+ transformed_hash = {}
390
+ openapi_types.each_pair do |key, type|
391
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
392
+ transformed_hash["#{key}"] = nil
393
+ elsif type =~ /\AArray<(.*)>/i
394
+ # check to ensure the input is an array given that the attribute
395
+ # is documented as an array but the input is not
396
+ if attributes[attribute_map[key]].is_a?(Array)
397
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
398
+ end
399
+ elsif !attributes[attribute_map[key]].nil?
400
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
401
+ end
402
+ end
403
+ new(transformed_hash)
404
+ end
405
+
406
+ # Deserializes the data based on type
407
+ # @param string type Data type
408
+ # @param string value Value to be deserialized
409
+ # @return [Object] Deserialized data
410
+ def self._deserialize(type, value)
411
+ case type.to_sym
412
+ when :Time
413
+ Time.parse(value)
414
+ when :Date
415
+ Date.parse(value)
416
+ when :String
417
+ value.to_s
418
+ when :Integer
419
+ value.to_i
420
+ when :Float
421
+ value.to_f
422
+ when :Boolean
423
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
424
+ true
425
+ else
426
+ false
427
+ end
428
+ when :Object
429
+ # generic object (usually a Hash), return directly
430
+ value
431
+ when /\AArray<(?<inner_type>.+)>\z/
432
+ inner_type = Regexp.last_match[:inner_type]
433
+ value.map { |v| _deserialize(inner_type, v) }
434
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
435
+ k_type = Regexp.last_match[:k_type]
436
+ v_type = Regexp.last_match[:v_type]
437
+ {}.tap do |hash|
438
+ value.each do |k, v|
439
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
440
+ end
441
+ end
442
+ else # model
443
+ # models (e.g. Pet) or oneOf
444
+ klass = OpenapiClient.const_get(type)
445
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
446
+ end
447
+ end
448
+
449
+ # Returns the string representation of the object
450
+ # @return [String] String presentation of the object
451
+ def to_s
452
+ to_hash.to_s
453
+ end
454
+
455
+ # to_body is an alias to to_hash (backward compatibility)
456
+ # @return [Hash] Returns the object in the form of hash
457
+ def to_body
458
+ to_hash
459
+ end
460
+
461
+ # Returns the object in the form of hash
462
+ # @return [Hash] Returns the object in the form of hash
463
+ def to_hash
464
+ hash = {}
465
+ self.class.attribute_map.each_pair do |attr, param|
466
+ value = self.send(attr)
467
+ if value.nil?
468
+ is_nullable = self.class.openapi_nullable.include?(attr)
469
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
470
+ end
471
+
472
+ hash[param] = _to_hash(value)
473
+ end
474
+ hash
475
+ end
476
+
477
+ # Outputs non-array value in the form of hash
478
+ # For object, use to_hash. Otherwise, just return the value
479
+ # @param [Object] value Any valid value
480
+ # @return [Hash] Returns the value in the form of hash
481
+ def _to_hash(value)
482
+ if value.is_a?(Array)
483
+ value.compact.map { |v| _to_hash(v) }
484
+ elsif value.is_a?(Hash)
485
+ {}.tap do |hash|
486
+ value.each { |k, v| hash[k] = _to_hash(v) }
487
+ end
488
+ elsif value.respond_to? :to_hash
489
+ value.to_hash
490
+ else
491
+ value
492
+ end
493
+ end
494
+
495
+ end
496
+
497
+ end