aylien_news_api 4.3.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/aylien_news_api.gemspec +1 -1
  3. data/docs/DefaultApi.md +205 -373
  4. data/docs/DeprecatedEntities.md +19 -0
  5. data/docs/DeprecatedEntity.md +33 -0
  6. data/docs/DeprecatedEntitySurfaceForm.md +21 -0
  7. data/docs/DeprecatedRelatedStories.md +27 -0
  8. data/docs/DeprecatedStories.md +25 -0
  9. data/docs/DeprecatedStory.md +61 -0
  10. data/docs/Entity.md +12 -10
  11. data/docs/EntityInText.md +19 -0
  12. data/docs/EntityMention.md +19 -0
  13. data/docs/EntityMentionIndex.md +19 -0
  14. data/docs/EntitySurfaceForm.md +4 -2
  15. data/docs/Parameter.md +12 -12
  16. data/docs/Story.md +1 -1
  17. data/lib/aylien_news_api.rb +4 -2
  18. data/lib/aylien_news_api/api/default_api.rb +297 -549
  19. data/lib/aylien_news_api/api_client.rb +1 -1
  20. data/lib/aylien_news_api/api_error.rb +1 -1
  21. data/lib/aylien_news_api/configuration.rb +1 -1
  22. data/lib/aylien_news_api/models/aggregated_sentiment.rb +1 -1
  23. data/lib/aylien_news_api/models/author.rb +1 -1
  24. data/lib/aylien_news_api/models/autocomplete.rb +1 -1
  25. data/lib/aylien_news_api/models/autocompletes.rb +1 -1
  26. data/lib/aylien_news_api/models/category.rb +1 -1
  27. data/lib/aylien_news_api/models/category_links.rb +1 -1
  28. data/lib/aylien_news_api/models/category_taxonomy.rb +1 -1
  29. data/lib/aylien_news_api/models/cluster.rb +1 -1
  30. data/lib/aylien_news_api/models/clusters.rb +1 -1
  31. data/lib/aylien_news_api/models/deprecated_entities.rb +221 -0
  32. data/lib/aylien_news_api/models/deprecated_entity.rb +314 -0
  33. data/lib/aylien_news_api/models/deprecated_entity_surface_form.rb +244 -0
  34. data/lib/aylien_news_api/models/deprecated_related_stories.rb +260 -0
  35. data/lib/aylien_news_api/models/deprecated_stories.rb +252 -0
  36. data/lib/aylien_news_api/models/deprecated_story.rb +429 -0
  37. data/lib/aylien_news_api/models/entity.rb +91 -45
  38. data/lib/aylien_news_api/models/entity_in_text.rb +217 -0
  39. data/lib/aylien_news_api/models/entity_links.rb +1 -1
  40. data/lib/aylien_news_api/models/entity_mention.rb +215 -0
  41. data/lib/aylien_news_api/models/entity_mention_index.rb +265 -0
  42. data/lib/aylien_news_api/models/entity_sentiment.rb +1 -1
  43. data/lib/aylien_news_api/models/entity_surface_form.rb +35 -10
  44. data/lib/aylien_news_api/models/error.rb +1 -1
  45. data/lib/aylien_news_api/models/error_links.rb +1 -1
  46. data/lib/aylien_news_api/models/errors.rb +1 -1
  47. data/lib/aylien_news_api/models/histogram_interval.rb +1 -1
  48. data/lib/aylien_news_api/models/histograms.rb +1 -1
  49. data/lib/aylien_news_api/models/location.rb +1 -1
  50. data/lib/aylien_news_api/models/logicals.rb +1 -1
  51. data/lib/aylien_news_api/models/media.rb +1 -1
  52. data/lib/aylien_news_api/models/media_format.rb +1 -1
  53. data/lib/aylien_news_api/models/media_type.rb +1 -1
  54. data/lib/aylien_news_api/models/nested_entity.rb +1 -1
  55. data/lib/aylien_news_api/models/parameter.rb +38 -38
  56. data/lib/aylien_news_api/models/query.rb +1 -1
  57. data/lib/aylien_news_api/models/rank.rb +1 -1
  58. data/lib/aylien_news_api/models/rankings.rb +1 -1
  59. data/lib/aylien_news_api/models/related_stories.rb +2 -1
  60. data/lib/aylien_news_api/models/representative_story.rb +1 -1
  61. data/lib/aylien_news_api/models/scope.rb +1 -1
  62. data/lib/aylien_news_api/models/scope_level.rb +1 -1
  63. data/lib/aylien_news_api/models/sentiment.rb +1 -1
  64. data/lib/aylien_news_api/models/sentiment_polarity.rb +1 -1
  65. data/lib/aylien_news_api/models/sentiments.rb +1 -1
  66. data/lib/aylien_news_api/models/share_count.rb +1 -1
  67. data/lib/aylien_news_api/models/share_counts.rb +1 -1
  68. data/lib/aylien_news_api/models/source.rb +1 -1
  69. data/lib/aylien_news_api/models/stories.rb +2 -1
  70. data/lib/aylien_news_api/models/story.rb +6 -3
  71. data/lib/aylien_news_api/models/story_cluster.rb +1 -1
  72. data/lib/aylien_news_api/models/story_links.rb +1 -1
  73. data/lib/aylien_news_api/models/story_translation.rb +1 -1
  74. data/lib/aylien_news_api/models/story_translations.rb +1 -1
  75. data/lib/aylien_news_api/models/summary.rb +1 -1
  76. data/lib/aylien_news_api/models/time_series.rb +1 -1
  77. data/lib/aylien_news_api/models/time_series_list.rb +1 -1
  78. data/lib/aylien_news_api/models/trend.rb +1 -1
  79. data/lib/aylien_news_api/models/trends.rb +1 -1
  80. data/lib/aylien_news_api/models/warning.rb +1 -1
  81. data/lib/aylien_news_api/version.rb +2 -2
  82. data/spec/api/default_api_spec.rb +109 -73
  83. data/spec/api_client_spec.rb +1 -1
  84. data/spec/configuration_spec.rb +1 -1
  85. data/spec/models/aggregated_sentiment_spec.rb +1 -1
  86. data/spec/models/author_spec.rb +1 -1
  87. data/spec/models/autocomplete_spec.rb +1 -1
  88. data/spec/models/autocompletes_spec.rb +1 -1
  89. data/spec/models/category_links_spec.rb +1 -1
  90. data/spec/models/category_spec.rb +1 -1
  91. data/spec/models/category_taxonomy_spec.rb +1 -1
  92. data/spec/models/cluster_spec.rb +1 -1
  93. data/spec/models/clusters_spec.rb +1 -1
  94. data/spec/models/deprecated_entities_spec.rb +47 -0
  95. data/spec/models/deprecated_entity_spec.rb +89 -0
  96. data/spec/models/deprecated_entity_surface_form_spec.rb +53 -0
  97. data/spec/models/deprecated_related_stories_spec.rb +71 -0
  98. data/spec/models/deprecated_stories_spec.rb +65 -0
  99. data/spec/models/deprecated_story_spec.rb +173 -0
  100. data/spec/models/entity_in_text_spec.rb +47 -0
  101. data/spec/models/entity_links_spec.rb +7 -1
  102. data/spec/models/entity_mention_index_spec.rb +47 -0
  103. data/spec/models/entity_mention_spec.rb +47 -0
  104. data/spec/models/entity_sentiment_spec.rb +1 -1
  105. data/spec/models/entity_spec.rb +24 -6
  106. data/spec/models/entity_surface_form_spec.rb +8 -2
  107. data/spec/models/error_links_spec.rb +1 -1
  108. data/spec/models/error_spec.rb +1 -1
  109. data/spec/models/errors_spec.rb +1 -1
  110. data/spec/models/histogram_interval_spec.rb +1 -1
  111. data/spec/models/histograms_spec.rb +1 -1
  112. data/spec/models/location_spec.rb +1 -1
  113. data/spec/models/logicals_spec.rb +1 -1
  114. data/spec/models/media_format_spec.rb +1 -1
  115. data/spec/models/media_spec.rb +1 -1
  116. data/spec/models/media_type_spec.rb +1 -1
  117. data/spec/models/nested_entity_spec.rb +20 -2
  118. data/spec/models/parameter_spec.rb +7 -7
  119. data/spec/models/query_spec.rb +1 -1
  120. data/spec/models/rank_spec.rb +1 -1
  121. data/spec/models/rankings_spec.rb +1 -1
  122. data/spec/models/related_stories_spec.rb +1 -1
  123. data/spec/models/representative_story_spec.rb +1 -1
  124. data/spec/models/scope_level_spec.rb +1 -1
  125. data/spec/models/scope_spec.rb +1 -1
  126. data/spec/models/sentiment_polarity_spec.rb +1 -1
  127. data/spec/models/sentiment_spec.rb +1 -1
  128. data/spec/models/sentiments_spec.rb +1 -1
  129. data/spec/models/share_count_spec.rb +1 -1
  130. data/spec/models/share_counts_spec.rb +1 -1
  131. data/spec/models/source_spec.rb +1 -1
  132. data/spec/models/stories_spec.rb +1 -1
  133. data/spec/models/story_cluster_spec.rb +1 -1
  134. data/spec/models/story_links_spec.rb +1 -1
  135. data/spec/models/story_spec.rb +7 -1
  136. data/spec/models/story_translation_spec.rb +1 -1
  137. data/spec/models/story_translations_spec.rb +1 -1
  138. data/spec/models/summary_spec.rb +1 -1
  139. data/spec/models/time_series_list_spec.rb +1 -1
  140. data/spec/models/time_series_spec.rb +7 -1
  141. data/spec/models/trend_spec.rb +7 -1
  142. data/spec/models/trends_spec.rb +1 -1
  143. data/spec/models/warning_spec.rb +1 -1
  144. data/spec/spec_helper.rb +1 -1
  145. metadata +38 -2
@@ -0,0 +1,244 @@
1
+ =begin
2
+ #AYLIEN News API
3
+
4
+ #The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.
5
+
6
+ The version of the OpenAPI document: 3.0
7
+ Contact: support@aylien.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AylienNewsApi
16
+ class DeprecatedEntitySurfaceForm
17
+ # The entity text
18
+ attr_accessor :text
19
+
20
+ # The indices of the entity text
21
+ attr_accessor :indices
22
+
23
+ # Amount of entity surface form mentions in the article
24
+ attr_accessor :frequency
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'text' => :'text',
30
+ :'indices' => :'indices',
31
+ :'frequency' => :'frequency'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'text' => :'String',
39
+ :'indices' => :'Array<Array<Integer>>',
40
+ :'frequency' => :'Integer'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::DeprecatedEntitySurfaceForm` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::DeprecatedEntitySurfaceForm`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'text')
66
+ self.text = attributes[:'text']
67
+ end
68
+
69
+ if attributes.key?(:'indices')
70
+ if (value = attributes[:'indices']).is_a?(Array)
71
+ self.indices = value
72
+ end
73
+ end
74
+
75
+ if attributes.key?(:'frequency')
76
+ self.frequency = attributes[:'frequency']
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ invalid_properties = Array.new
84
+ if !@frequency.nil? && @frequency < 0
85
+ invalid_properties.push('invalid value for "frequency", must be greater than or equal to 0.')
86
+ end
87
+
88
+ invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ return false if !@frequency.nil? && @frequency < 0
95
+ true
96
+ end
97
+
98
+ # Custom attribute writer method with validation
99
+ # @param [Object] frequency Value to be assigned
100
+ def frequency=(frequency)
101
+ if !frequency.nil? && frequency < 0
102
+ fail ArgumentError, 'invalid value for "frequency", must be greater than or equal to 0.'
103
+ end
104
+
105
+ @frequency = frequency
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ text == o.text &&
114
+ indices == o.indices &&
115
+ frequency == o.frequency
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Integer] Hash code
126
+ def hash
127
+ [text, indices, frequency].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def self.build_from_hash(attributes)
134
+ new.build_from_hash(attributes)
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def build_from_hash(attributes)
141
+ return nil unless attributes.is_a?(Hash)
142
+ self.class.openapi_types.each_pair do |key, type|
143
+ if type =~ /\AArray<(.*)>/i
144
+ # check to ensure the input is an array given that the attribute
145
+ # is documented as an array but the input is not
146
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
147
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
148
+ end
149
+ elsif !attributes[self.class.attribute_map[key]].nil?
150
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
151
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
152
+ end
153
+
154
+ self
155
+ end
156
+
157
+ # Deserializes the data based on type
158
+ # @param string type Data type
159
+ # @param string value Value to be deserialized
160
+ # @return [Object] Deserialized data
161
+ def _deserialize(type, value)
162
+ case type.to_sym
163
+ when :DateTime
164
+ DateTime.parse(value)
165
+ when :Date
166
+ Date.parse(value)
167
+ when :String
168
+ value.to_s
169
+ when :Integer
170
+ value.to_i
171
+ when :Float
172
+ value.to_f
173
+ when :Boolean
174
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
175
+ true
176
+ else
177
+ false
178
+ end
179
+ when :Object
180
+ # generic object (usually a Hash), return directly
181
+ value
182
+ when /\AArray<(?<inner_type>.+)>\z/
183
+ inner_type = Regexp.last_match[:inner_type]
184
+ value.map { |v| _deserialize(inner_type, v) }
185
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
186
+ k_type = Regexp.last_match[:k_type]
187
+ v_type = Regexp.last_match[:v_type]
188
+ {}.tap do |hash|
189
+ value.each do |k, v|
190
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
191
+ end
192
+ end
193
+ else # model
194
+ AylienNewsApi.const_get(type).build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map { |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+ end
244
+ end
@@ -0,0 +1,260 @@
1
+ =begin
2
+ #AYLIEN News API
3
+
4
+ #The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.
5
+
6
+ The version of the OpenAPI document: 3.0
7
+ Contact: support@aylien.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AylienNewsApi
16
+ # Story with deprecated entities
17
+ class DeprecatedRelatedStories
18
+ # An array of related stories for the input story
19
+ attr_accessor :related_stories
20
+
21
+ # The input story body
22
+ attr_accessor :story_body
23
+
24
+ # The input story language
25
+ attr_accessor :story_language
26
+
27
+ # The input story title
28
+ attr_accessor :story_title
29
+
30
+ # The end of a period in which searched stories were published
31
+ attr_accessor :published_at_end
32
+
33
+ # The start of a period in which searched stories were published
34
+ attr_accessor :published_at_start
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'related_stories' => :'related_stories',
40
+ :'story_body' => :'story_body',
41
+ :'story_language' => :'story_language',
42
+ :'story_title' => :'story_title',
43
+ :'published_at_end' => :'published_at.end',
44
+ :'published_at_start' => :'published_at.start'
45
+ }
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.openapi_types
50
+ {
51
+ :'related_stories' => :'Array<DeprecatedStory>',
52
+ :'story_body' => :'String',
53
+ :'story_language' => :'String',
54
+ :'story_title' => :'String',
55
+ :'published_at_end' => :'DateTime',
56
+ :'published_at_start' => :'DateTime'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::DeprecatedRelatedStories` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::DeprecatedRelatedStories`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'related_stories')
82
+ if (value = attributes[:'related_stories']).is_a?(Array)
83
+ self.related_stories = value
84
+ end
85
+ end
86
+
87
+ if attributes.key?(:'story_body')
88
+ self.story_body = attributes[:'story_body']
89
+ end
90
+
91
+ if attributes.key?(:'story_language')
92
+ self.story_language = attributes[:'story_language']
93
+ end
94
+
95
+ if attributes.key?(:'story_title')
96
+ self.story_title = attributes[:'story_title']
97
+ end
98
+
99
+ if attributes.key?(:'published_at_end')
100
+ self.published_at_end = attributes[:'published_at_end']
101
+ end
102
+
103
+ if attributes.key?(:'published_at_start')
104
+ self.published_at_start = attributes[:'published_at_start']
105
+ end
106
+ end
107
+
108
+ # Show invalid properties with the reasons. Usually used together with valid?
109
+ # @return Array for valid properties with the reasons
110
+ def list_invalid_properties
111
+ invalid_properties = Array.new
112
+ invalid_properties
113
+ end
114
+
115
+ # Check to see if the all the properties in the model are valid
116
+ # @return true if the model is valid
117
+ def valid?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ related_stories == o.related_stories &&
127
+ story_body == o.story_body &&
128
+ story_language == o.story_language &&
129
+ story_title == o.story_title &&
130
+ published_at_end == o.published_at_end &&
131
+ published_at_start == o.published_at_start
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(o)
137
+ self == o
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Integer] Hash code
142
+ def hash
143
+ [related_stories, story_body, story_language, story_title, published_at_end, published_at_start].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def self.build_from_hash(attributes)
150
+ new.build_from_hash(attributes)
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def build_from_hash(attributes)
157
+ return nil unless attributes.is_a?(Hash)
158
+ self.class.openapi_types.each_pair do |key, type|
159
+ if type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
163
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
164
+ end
165
+ elsif !attributes[self.class.attribute_map[key]].nil?
166
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
167
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
168
+ end
169
+
170
+ self
171
+ end
172
+
173
+ # Deserializes the data based on type
174
+ # @param string type Data type
175
+ # @param string value Value to be deserialized
176
+ # @return [Object] Deserialized data
177
+ def _deserialize(type, value)
178
+ case type.to_sym
179
+ when :DateTime
180
+ DateTime.parse(value)
181
+ when :Date
182
+ Date.parse(value)
183
+ when :String
184
+ value.to_s
185
+ when :Integer
186
+ value.to_i
187
+ when :Float
188
+ value.to_f
189
+ when :Boolean
190
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
+ true
192
+ else
193
+ false
194
+ end
195
+ when :Object
196
+ # generic object (usually a Hash), return directly
197
+ value
198
+ when /\AArray<(?<inner_type>.+)>\z/
199
+ inner_type = Regexp.last_match[:inner_type]
200
+ value.map { |v| _deserialize(inner_type, v) }
201
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
202
+ k_type = Regexp.last_match[:k_type]
203
+ v_type = Regexp.last_match[:v_type]
204
+ {}.tap do |hash|
205
+ value.each do |k, v|
206
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
207
+ end
208
+ end
209
+ else # model
210
+ AylienNewsApi.const_get(type).build_from_hash(value)
211
+ end
212
+ end
213
+
214
+ # Returns the string representation of the object
215
+ # @return [String] String presentation of the object
216
+ def to_s
217
+ to_hash.to_s
218
+ end
219
+
220
+ # to_body is an alias to to_hash (backward compatibility)
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_body
223
+ to_hash
224
+ end
225
+
226
+ # Returns the object in the form of hash
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_hash
229
+ hash = {}
230
+ self.class.attribute_map.each_pair do |attr, param|
231
+ value = self.send(attr)
232
+ if value.nil?
233
+ is_nullable = self.class.openapi_nullable.include?(attr)
234
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
235
+ end
236
+
237
+ hash[param] = _to_hash(value)
238
+ end
239
+ hash
240
+ end
241
+
242
+ # Outputs non-array value in the form of hash
243
+ # For object, use to_hash. Otherwise, just return the value
244
+ # @param [Object] value Any valid value
245
+ # @return [Hash] Returns the value in the form of hash
246
+ def _to_hash(value)
247
+ if value.is_a?(Array)
248
+ value.compact.map { |v| _to_hash(v) }
249
+ elsif value.is_a?(Hash)
250
+ {}.tap do |hash|
251
+ value.each { |k, v| hash[k] = _to_hash(v) }
252
+ end
253
+ elsif value.respond_to? :to_hash
254
+ value.to_hash
255
+ else
256
+ value
257
+ end
258
+ end
259
+ end
260
+ end