aylien_news_api 0.0.1

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 (112) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +67 -0
  4. data/LICENSE +13 -0
  5. data/README.md +133 -0
  6. data/Rakefile +8 -0
  7. data/aylien_news_api.gemspec +33 -0
  8. data/docs/Author.md +10 -0
  9. data/docs/Autocomplete.md +9 -0
  10. data/docs/Autocompletes.md +8 -0
  11. data/docs/Category.md +13 -0
  12. data/docs/CategoryLinks.md +9 -0
  13. data/docs/Coverages.md +12 -0
  14. data/docs/DefaultApi.md +829 -0
  15. data/docs/Entities.md +9 -0
  16. data/docs/Entity.md +12 -0
  17. data/docs/EntityLinks.md +8 -0
  18. data/docs/Error.md +13 -0
  19. data/docs/ErrorLinks.md +8 -0
  20. data/docs/Errors.md +8 -0
  21. data/docs/HistogramInterval.md +9 -0
  22. data/docs/Histograms.md +12 -0
  23. data/docs/Location.md +10 -0
  24. data/docs/Media.md +9 -0
  25. data/docs/RelatedStories.md +11 -0
  26. data/docs/Scope.md +11 -0
  27. data/docs/Sentiment.md +9 -0
  28. data/docs/Sentiments.md +9 -0
  29. data/docs/ShareCount.md +9 -0
  30. data/docs/ShareCounts.md +11 -0
  31. data/docs/Source.md +13 -0
  32. data/docs/Stories.md +10 -0
  33. data/docs/Story.md +27 -0
  34. data/docs/StoryCluster.md +12 -0
  35. data/docs/StoryLinks.md +10 -0
  36. data/docs/Summary.md +8 -0
  37. data/docs/TimeSeries.md +9 -0
  38. data/docs/TimeSeriesList.md +11 -0
  39. data/docs/Trend.md +9 -0
  40. data/docs/Trends.md +9 -0
  41. data/lib/aylien_news_api.rb +74 -0
  42. data/lib/aylien_news_api/api/default_api.rb +1171 -0
  43. data/lib/aylien_news_api/api_client.rb +365 -0
  44. data/lib/aylien_news_api/api_error.rb +38 -0
  45. data/lib/aylien_news_api/configuration.rb +191 -0
  46. data/lib/aylien_news_api/models/author.rb +192 -0
  47. data/lib/aylien_news_api/models/autocomplete.rb +183 -0
  48. data/lib/aylien_news_api/models/autocompletes.rb +176 -0
  49. data/lib/aylien_news_api/models/category.rb +229 -0
  50. data/lib/aylien_news_api/models/category_links.rb +183 -0
  51. data/lib/aylien_news_api/models/coverages.rb +212 -0
  52. data/lib/aylien_news_api/models/entities.rb +187 -0
  53. data/lib/aylien_news_api/models/entity.rb +214 -0
  54. data/lib/aylien_news_api/models/entity_links.rb +174 -0
  55. data/lib/aylien_news_api/models/error.rb +213 -0
  56. data/lib/aylien_news_api/models/error_links.rb +173 -0
  57. data/lib/aylien_news_api/models/errors.rb +175 -0
  58. data/lib/aylien_news_api/models/histogram_interval.rb +183 -0
  59. data/lib/aylien_news_api/models/histograms.rb +211 -0
  60. data/lib/aylien_news_api/models/location.rb +192 -0
  61. data/lib/aylien_news_api/models/media.rb +193 -0
  62. data/lib/aylien_news_api/models/related_stories.rb +203 -0
  63. data/lib/aylien_news_api/models/scope.rb +211 -0
  64. data/lib/aylien_news_api/models/sentiment.rb +193 -0
  65. data/lib/aylien_news_api/models/sentiments.rb +183 -0
  66. data/lib/aylien_news_api/models/share_count.rb +183 -0
  67. data/lib/aylien_news_api/models/share_counts.rb +209 -0
  68. data/lib/aylien_news_api/models/source.rb +223 -0
  69. data/lib/aylien_news_api/models/stories.rb +196 -0
  70. data/lib/aylien_news_api/models/story.rb +353 -0
  71. data/lib/aylien_news_api/models/story_cluster.rb +214 -0
  72. data/lib/aylien_news_api/models/story_links.rb +192 -0
  73. data/lib/aylien_news_api/models/summary.rb +176 -0
  74. data/lib/aylien_news_api/models/time_series.rb +183 -0
  75. data/lib/aylien_news_api/models/time_series_list.rb +203 -0
  76. data/lib/aylien_news_api/models/trend.rb +183 -0
  77. data/lib/aylien_news_api/models/trends.rb +185 -0
  78. data/lib/aylien_news_api/version.rb +17 -0
  79. data/spec/api/default_api_spec.rb +357 -0
  80. data/spec/models/author_spec.rb +66 -0
  81. data/spec/models/autocomplete_spec.rb +56 -0
  82. data/spec/models/autocompletes_spec.rb +46 -0
  83. data/spec/models/category_links_spec.rb +56 -0
  84. data/spec/models/category_spec.rb +96 -0
  85. data/spec/models/coverages_spec.rb +86 -0
  86. data/spec/models/entities_spec.rb +56 -0
  87. data/spec/models/entity_links_spec.rb +46 -0
  88. data/spec/models/entity_spec.rb +86 -0
  89. data/spec/models/error_links_spec.rb +46 -0
  90. data/spec/models/error_spec.rb +96 -0
  91. data/spec/models/errors_spec.rb +46 -0
  92. data/spec/models/histogram_interval_spec.rb +56 -0
  93. data/spec/models/histograms_spec.rb +86 -0
  94. data/spec/models/location_spec.rb +66 -0
  95. data/spec/models/media_spec.rb +56 -0
  96. data/spec/models/related_stories_spec.rb +76 -0
  97. data/spec/models/scope_spec.rb +76 -0
  98. data/spec/models/sentiment_spec.rb +56 -0
  99. data/spec/models/sentiments_spec.rb +56 -0
  100. data/spec/models/share_count_spec.rb +56 -0
  101. data/spec/models/share_counts_spec.rb +76 -0
  102. data/spec/models/source_spec.rb +96 -0
  103. data/spec/models/stories_spec.rb +66 -0
  104. data/spec/models/story_cluster_spec.rb +86 -0
  105. data/spec/models/story_links_spec.rb +66 -0
  106. data/spec/models/story_spec.rb +236 -0
  107. data/spec/models/summary_spec.rb +46 -0
  108. data/spec/models/time_series_list_spec.rb +76 -0
  109. data/spec/models/time_series_spec.rb +56 -0
  110. data/spec/models/trend_spec.rb +56 -0
  111. data/spec/models/trends_spec.rb +56 -0
  112. metadata +391 -0
@@ -0,0 +1,203 @@
1
+ # Copyright 2016 Aylien, Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'date'
16
+
17
+ module AylienNewsApi
18
+ class TimeSeriesList
19
+ # An array of time series
20
+ attr_accessor :time_series
21
+
22
+ # The size of each date range expressed as an interval to be added to the lower bound.
23
+ attr_accessor :period
24
+
25
+ # The start published date of the time series
26
+ attr_accessor :published_at_start
27
+
28
+ # The end published date of the time series
29
+ attr_accessor :published_at_end
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'time_series' => :'time_series',
35
+ :'period' => :'period',
36
+ :'published_at_start' => :'published_at.start',
37
+ :'published_at_end' => :'published_at.end'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.api_types
43
+ {
44
+ :'time_series' => :'Array<TimeSeries>',
45
+ :'period' => :'String',
46
+ :'published_at_start' => :'DateTime',
47
+ :'published_at_end' => :'DateTime'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
58
+
59
+ if attributes[:'time_series']
60
+ if (value = attributes[:'time_series']).is_a?(Array)
61
+ self.time_series = value
62
+ end
63
+ end
64
+ if attributes[:'period']
65
+ self.period = attributes[:'period']
66
+ end
67
+ if attributes[:'published_at.start']
68
+ self.published_at_start = attributes[:'published_at.start']
69
+ end
70
+ if attributes[:'published_at.end']
71
+ self.published_at_end = attributes[:'published_at.end']
72
+ end
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(o)
78
+ return true if self.equal?(o)
79
+ self.class == o.class &&
80
+ time_series == o.time_series &&
81
+ period == o.period &&
82
+ published_at_start == o.published_at_start &&
83
+ published_at_end == o.published_at_end
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Fixnum] Hash code
94
+ def hash
95
+ [time_series, period, published_at_start, published_at_end].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def build_from_hash(attributes)
102
+ return nil unless attributes.is_a?(Hash)
103
+ self.class.api_types.each_pair do |key, type|
104
+ if type =~ /^Array<(.*)>/i
105
+ # check to ensure the input is an array given that the the attribute
106
+ # is documented as an array but the input is not
107
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
108
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
109
+ end
110
+ elsif !attributes[self.class.attribute_map[key]].nil?
111
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
112
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
113
+ end
114
+
115
+ self
116
+ end
117
+
118
+ # Deserializes the data based on type
119
+ # @param string type Data type
120
+ # @param string value Value to be deserialized
121
+ # @return [Object] Deserialized data
122
+ def _deserialize(type, value)
123
+ case type.to_sym
124
+ when :DateTime
125
+ DateTime.parse(value)
126
+ when :Date
127
+ Date.parse(value)
128
+ when :String
129
+ value.to_s
130
+ when :Integer
131
+ value.to_i
132
+ when :Float
133
+ value.to_f
134
+ when :BOOLEAN
135
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
136
+ true
137
+ else
138
+ false
139
+ end
140
+ when :Object
141
+ # generic object (usually a Hash), return directly
142
+ value
143
+ when /\AArray<(?<inner_type>.+)>\z/
144
+ inner_type = Regexp.last_match[:inner_type]
145
+ value.map { |v| _deserialize(inner_type, v) }
146
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
147
+ k_type = Regexp.last_match[:k_type]
148
+ v_type = Regexp.last_match[:v_type]
149
+ {}.tap do |hash|
150
+ value.each do |k, v|
151
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
152
+ end
153
+ end
154
+ else # model
155
+ temp_model = AylienNewsApi.const_get(type).new
156
+ temp_model.build_from_hash(value)
157
+ end
158
+ end
159
+
160
+ # Returns the string representation of the object
161
+ # @return [String] String presentation of the object
162
+ def to_s
163
+ to_hash.to_s
164
+ end
165
+
166
+ # to_body is an alias to to_hash (backward compatibility)
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_body
169
+ to_hash
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = self.send(attr)
178
+ next if value.nil?
179
+ hash[param] = _to_hash(value)
180
+ end
181
+ hash
182
+ end
183
+
184
+ # Outputs non-array value in the form of hash
185
+ # For object, use to_hash. Otherwise, just return the value
186
+ # @param [Object] value Any valid value
187
+ # @return [Hash] Returns the value in the form of hash
188
+ def _to_hash(value)
189
+ if value.is_a?(Array)
190
+ value.compact.map{ |v| _to_hash(v) }
191
+ elsif value.is_a?(Hash)
192
+ {}.tap do |hash|
193
+ value.each { |k, v| hash[k] = _to_hash(v) }
194
+ end
195
+ elsif value.respond_to? :to_hash
196
+ value.to_hash
197
+ else
198
+ value
199
+ end
200
+ end
201
+
202
+ end
203
+ end
@@ -0,0 +1,183 @@
1
+ # Copyright 2016 Aylien, Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'date'
16
+
17
+ module AylienNewsApi
18
+ class Trend
19
+ # The value of the trend
20
+ attr_accessor :value
21
+
22
+ # The count of the trend
23
+ attr_accessor :count
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'value' => :'value',
29
+ :'count' => :'count'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.api_types
35
+ {
36
+ :'value' => :'String',
37
+ :'count' => :'Integer'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
+
49
+ if attributes[:'value']
50
+ self.value = attributes[:'value']
51
+ end
52
+ if attributes[:'count']
53
+ self.count = attributes[:'count']
54
+ end
55
+ end
56
+
57
+ # Checks equality by comparing each attribute.
58
+ # @param [Object] Object to be compared
59
+ def ==(o)
60
+ return true if self.equal?(o)
61
+ self.class == o.class &&
62
+ value == o.value &&
63
+ count == o.count
64
+ end
65
+
66
+ # @see the `==` method
67
+ # @param [Object] Object to be compared
68
+ def eql?(o)
69
+ self == o
70
+ end
71
+
72
+ # Calculates hash code according to all attributes.
73
+ # @return [Fixnum] Hash code
74
+ def hash
75
+ [value, count].hash
76
+ end
77
+
78
+ # Builds the object from hash
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ # @return [Object] Returns the model itself
81
+ def build_from_hash(attributes)
82
+ return nil unless attributes.is_a?(Hash)
83
+ self.class.api_types.each_pair do |key, type|
84
+ if type =~ /^Array<(.*)>/i
85
+ # check to ensure the input is an array given that the the attribute
86
+ # is documented as an array but the input is not
87
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
88
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
89
+ end
90
+ elsif !attributes[self.class.attribute_map[key]].nil?
91
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
92
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
93
+ end
94
+
95
+ self
96
+ end
97
+
98
+ # Deserializes the data based on type
99
+ # @param string type Data type
100
+ # @param string value Value to be deserialized
101
+ # @return [Object] Deserialized data
102
+ def _deserialize(type, value)
103
+ case type.to_sym
104
+ when :DateTime
105
+ DateTime.parse(value)
106
+ when :Date
107
+ Date.parse(value)
108
+ when :String
109
+ value.to_s
110
+ when :Integer
111
+ value.to_i
112
+ when :Float
113
+ value.to_f
114
+ when :BOOLEAN
115
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
116
+ true
117
+ else
118
+ false
119
+ end
120
+ when :Object
121
+ # generic object (usually a Hash), return directly
122
+ value
123
+ when /\AArray<(?<inner_type>.+)>\z/
124
+ inner_type = Regexp.last_match[:inner_type]
125
+ value.map { |v| _deserialize(inner_type, v) }
126
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
127
+ k_type = Regexp.last_match[:k_type]
128
+ v_type = Regexp.last_match[:v_type]
129
+ {}.tap do |hash|
130
+ value.each do |k, v|
131
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
132
+ end
133
+ end
134
+ else # model
135
+ temp_model = AylienNewsApi.const_get(type).new
136
+ temp_model.build_from_hash(value)
137
+ end
138
+ end
139
+
140
+ # Returns the string representation of the object
141
+ # @return [String] String presentation of the object
142
+ def to_s
143
+ to_hash.to_s
144
+ end
145
+
146
+ # to_body is an alias to to_hash (backward compatibility)
147
+ # @return [Hash] Returns the object in the form of hash
148
+ def to_body
149
+ to_hash
150
+ end
151
+
152
+ # Returns the object in the form of hash
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_hash
155
+ hash = {}
156
+ self.class.attribute_map.each_pair do |attr, param|
157
+ value = self.send(attr)
158
+ next if value.nil?
159
+ hash[param] = _to_hash(value)
160
+ end
161
+ hash
162
+ end
163
+
164
+ # Outputs non-array value in the form of hash
165
+ # For object, use to_hash. Otherwise, just return the value
166
+ # @param [Object] value Any valid value
167
+ # @return [Hash] Returns the value in the form of hash
168
+ def _to_hash(value)
169
+ if value.is_a?(Array)
170
+ value.compact.map{ |v| _to_hash(v) }
171
+ elsif value.is_a?(Hash)
172
+ {}.tap do |hash|
173
+ value.each { |k, v| hash[k] = _to_hash(v) }
174
+ end
175
+ elsif value.respond_to? :to_hash
176
+ value.to_hash
177
+ else
178
+ value
179
+ end
180
+ end
181
+
182
+ end
183
+ end
@@ -0,0 +1,185 @@
1
+ # Copyright 2016 Aylien, Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'date'
16
+
17
+ module AylienNewsApi
18
+ class Trends
19
+ # An array of trends
20
+ attr_accessor :trends
21
+
22
+ # The field of trends
23
+ attr_accessor :field
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'trends' => :'trends',
29
+ :'field' => :'field'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.api_types
35
+ {
36
+ :'trends' => :'Array<Trend>',
37
+ :'field' => :'String'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
+
49
+ if attributes[:'trends']
50
+ if (value = attributes[:'trends']).is_a?(Array)
51
+ self.trends = value
52
+ end
53
+ end
54
+ if attributes[:'field']
55
+ self.field = attributes[:'field']
56
+ end
57
+ end
58
+
59
+ # Checks equality by comparing each attribute.
60
+ # @param [Object] Object to be compared
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ trends == o.trends &&
65
+ field == o.field
66
+ end
67
+
68
+ # @see the `==` method
69
+ # @param [Object] Object to be compared
70
+ def eql?(o)
71
+ self == o
72
+ end
73
+
74
+ # Calculates hash code according to all attributes.
75
+ # @return [Fixnum] Hash code
76
+ def hash
77
+ [trends, field].hash
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
83
+ def build_from_hash(attributes)
84
+ return nil unless attributes.is_a?(Hash)
85
+ self.class.api_types.each_pair do |key, type|
86
+ if type =~ /^Array<(.*)>/i
87
+ # check to ensure the input is an array given that the the attribute
88
+ # is documented as an array but the input is not
89
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
90
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
91
+ end
92
+ elsif !attributes[self.class.attribute_map[key]].nil?
93
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
94
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
95
+ end
96
+
97
+ self
98
+ end
99
+
100
+ # Deserializes the data based on type
101
+ # @param string type Data type
102
+ # @param string value Value to be deserialized
103
+ # @return [Object] Deserialized data
104
+ def _deserialize(type, value)
105
+ case type.to_sym
106
+ when :DateTime
107
+ DateTime.parse(value)
108
+ when :Date
109
+ Date.parse(value)
110
+ when :String
111
+ value.to_s
112
+ when :Integer
113
+ value.to_i
114
+ when :Float
115
+ value.to_f
116
+ when :BOOLEAN
117
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
118
+ true
119
+ else
120
+ false
121
+ end
122
+ when :Object
123
+ # generic object (usually a Hash), return directly
124
+ value
125
+ when /\AArray<(?<inner_type>.+)>\z/
126
+ inner_type = Regexp.last_match[:inner_type]
127
+ value.map { |v| _deserialize(inner_type, v) }
128
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
129
+ k_type = Regexp.last_match[:k_type]
130
+ v_type = Regexp.last_match[:v_type]
131
+ {}.tap do |hash|
132
+ value.each do |k, v|
133
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
134
+ end
135
+ end
136
+ else # model
137
+ temp_model = AylienNewsApi.const_get(type).new
138
+ temp_model.build_from_hash(value)
139
+ end
140
+ end
141
+
142
+ # Returns the string representation of the object
143
+ # @return [String] String presentation of the object
144
+ def to_s
145
+ to_hash.to_s
146
+ end
147
+
148
+ # to_body is an alias to to_hash (backward compatibility)
149
+ # @return [Hash] Returns the object in the form of hash
150
+ def to_body
151
+ to_hash
152
+ end
153
+
154
+ # Returns the object in the form of hash
155
+ # @return [Hash] Returns the object in the form of hash
156
+ def to_hash
157
+ hash = {}
158
+ self.class.attribute_map.each_pair do |attr, param|
159
+ value = self.send(attr)
160
+ next if value.nil?
161
+ hash[param] = _to_hash(value)
162
+ end
163
+ hash
164
+ end
165
+
166
+ # Outputs non-array value in the form of hash
167
+ # For object, use to_hash. Otherwise, just return the value
168
+ # @param [Object] value Any valid value
169
+ # @return [Hash] Returns the value in the form of hash
170
+ def _to_hash(value)
171
+ if value.is_a?(Array)
172
+ value.compact.map{ |v| _to_hash(v) }
173
+ elsif value.is_a?(Hash)
174
+ {}.tap do |hash|
175
+ value.each { |k, v| hash[k] = _to_hash(v) }
176
+ end
177
+ elsif value.respond_to? :to_hash
178
+ value.to_hash
179
+ else
180
+ value
181
+ end
182
+ end
183
+
184
+ end
185
+ end