aylien_news_api 0.4.0 → 4.1.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.
- checksums.yaml +5 -5
- data/Gemfile +7 -1
- data/README.md +117 -4
- data/Rakefile +10 -0
- data/aylien_news_api.gemspec +20 -28
- data/docs/Author.md +12 -1
- data/docs/Autocomplete.md +10 -0
- data/docs/Autocompletes.md +9 -0
- data/docs/Category.md +19 -3
- data/docs/CategoryLinks.md +11 -1
- data/docs/CategoryTaxonomy.md +16 -0
- data/docs/Cluster.md +29 -0
- data/docs/Clusters.md +21 -0
- data/docs/Coverages.md +16 -4
- data/docs/DefaultApi.md +1299 -826
- data/docs/Entities.md +11 -1
- data/docs/Entity.md +16 -3
- data/docs/EntityLinks.md +9 -0
- data/docs/Error.md +16 -2
- data/docs/ErrorLinks.md +11 -0
- data/docs/Errors.md +9 -0
- data/docs/HistogramInterval.md +10 -0
- data/docs/Histograms.md +20 -3
- data/docs/Location.md +13 -2
- data/docs/Media.md +18 -4
- data/docs/MediaFormat.md +16 -0
- data/docs/MediaType.md +16 -0
- data/docs/Rank.md +12 -1
- data/docs/Rankings.md +9 -0
- data/docs/RelatedStories.md +18 -3
- data/docs/RepresentativeStory.md +23 -0
- data/docs/Scope.md +15 -3
- data/docs/ScopeLevel.md +16 -0
- data/docs/Sentiment.md +11 -1
- data/docs/SentimentPolarity.md +16 -0
- data/docs/Sentiments.md +12 -2
- data/docs/ShareCount.md +10 -0
- data/docs/ShareCounts.md +12 -0
- data/docs/Source.md +27 -8
- data/docs/Stories.md +17 -2
- data/docs/Story.md +48 -16
- data/docs/StoryCluster.md +14 -1
- data/docs/StoryLinks.md +14 -1
- data/docs/StoryTranslation.md +19 -0
- data/docs/StoryTranslations.md +17 -0
- data/docs/StoryTranslationsEn.md +21 -0
- data/docs/Summary.md +9 -0
- data/docs/TimeSeries.md +11 -1
- data/docs/TimeSeriesList.md +15 -3
- data/docs/Trend.md +11 -1
- data/docs/Trends.md +15 -1
- data/docs/Warning.md +21 -0
- data/git_push.sh +58 -0
- data/lib/aylien_news_api.rb +22 -14
- data/lib/aylien_news_api/api/default_api.rb +2407 -1520
- data/lib/aylien_news_api/api_client.rb +137 -111
- data/lib/aylien_news_api/api_error.rb +37 -18
- data/lib/aylien_news_api/configuration.rb +74 -36
- data/lib/aylien_news_api/models/author.rb +66 -50
- data/lib/aylien_news_api/models/autocomplete.rb +52 -36
- data/lib/aylien_news_api/models/autocompletes.rb +51 -35
- data/lib/aylien_news_api/models/category.rb +85 -94
- data/lib/aylien_news_api/models/category_links.rb +63 -47
- data/lib/aylien_news_api/models/category_taxonomy.rb +36 -0
- data/lib/aylien_news_api/models/cluster.rb +265 -0
- data/lib/aylien_news_api/models/clusters.rb +229 -0
- data/lib/aylien_news_api/models/coverages.rb +76 -72
- data/lib/aylien_news_api/models/entities.rb +64 -48
- data/lib/aylien_news_api/models/entity.rb +93 -79
- data/lib/aylien_news_api/models/entity_links.rb +51 -35
- data/lib/aylien_news_api/models/error.rb +76 -60
- data/lib/aylien_news_api/models/error_links.rb +62 -37
- data/lib/aylien_news_api/models/errors.rb +51 -35
- data/lib/aylien_news_api/models/histogram_interval.rb +52 -36
- data/lib/aylien_news_api/models/histograms.rb +96 -60
- data/lib/aylien_news_api/models/location.rb +67 -51
- data/lib/aylien_news_api/models/media.rb +83 -114
- data/lib/aylien_news_api/models/media_format.rb +44 -0
- data/lib/aylien_news_api/models/media_type.rb +36 -0
- data/lib/aylien_news_api/models/rank.rb +64 -48
- data/lib/aylien_news_api/models/rankings.rb +51 -35
- data/lib/aylien_news_api/models/related_stories.rb +84 -60
- data/lib/aylien_news_api/models/representative_story.rb +237 -0
- data/lib/aylien_news_api/models/scope.rb +73 -91
- data/lib/aylien_news_api/models/scope_level.rb +37 -0
- data/lib/aylien_news_api/models/sentiment.rb +63 -82
- data/lib/aylien_news_api/models/sentiment_polarity.rb +37 -0
- data/lib/aylien_news_api/models/sentiments.rb +62 -48
- data/lib/aylien_news_api/models/share_count.rb +52 -36
- data/lib/aylien_news_api/models/share_counts.rb +54 -38
- data/lib/aylien_news_api/models/source.rb +111 -96
- data/lib/aylien_news_api/models/stories.rb +86 -50
- data/lib/aylien_news_api/models/story.rb +188 -158
- data/lib/aylien_news_api/models/story_cluster.rb +68 -52
- data/lib/aylien_news_api/models/story_links.rb +70 -44
- data/lib/aylien_news_api/models/story_translation.rb +217 -0
- data/lib/aylien_news_api/models/story_translations.rb +207 -0
- data/lib/aylien_news_api/models/story_translations_en.rb +227 -0
- data/lib/aylien_news_api/models/summary.rb +51 -35
- data/lib/aylien_news_api/models/time_series.rb +63 -47
- data/lib/aylien_news_api/models/time_series_list.rb +72 -56
- data/lib/aylien_news_api/models/trend.rb +63 -47
- data/lib/aylien_news_api/models/trends.rb +77 -41
- data/lib/aylien_news_api/models/warning.rb +226 -0
- data/lib/aylien_news_api/version.rb +12 -14
- data/spec/api/default_api_spec.rb +620 -284
- data/spec/api_client_spec.rb +43 -161
- data/spec/configuration_spec.rb +22 -19
- data/spec/models/author_spec.rb +21 -34
- data/spec/models/autocomplete_spec.rb +17 -26
- data/spec/models/autocompletes_spec.rb +16 -21
- data/spec/models/category_links_spec.rb +19 -28
- data/spec/models/category_spec.rb +31 -50
- data/spec/models/category_taxonomy_spec.rb +35 -0
- data/spec/models/cluster_spec.rb +77 -0
- data/spec/models/clusters_spec.rb +53 -0
- data/spec/models/coverages_spec.rb +24 -45
- data/spec/models/entities_spec.rb +19 -28
- data/spec/models/entity_links_spec.rb +16 -21
- data/spec/models/entity_spec.rb +25 -46
- data/spec/models/error_links_spec.rb +22 -21
- data/spec/models/error_spec.rb +27 -52
- data/spec/models/errors_spec.rb +16 -21
- data/spec/models/histogram_interval_spec.rb +17 -26
- data/spec/models/histograms_spec.rb +36 -45
- data/spec/models/location_spec.rb +21 -34
- data/spec/models/media_format_spec.rb +35 -0
- data/spec/models/media_spec.rb +41 -26
- data/spec/models/media_type_spec.rb +35 -0
- data/spec/models/rank_spec.rb +20 -21
- data/spec/models/rankings_spec.rb +15 -16
- data/spec/models/related_stories_spec.rb +33 -38
- data/spec/models/representative_story_spec.rb +59 -0
- data/spec/models/scope_level_spec.rb +35 -0
- data/spec/models/scope_spec.rb +23 -40
- data/spec/models/sentiment_polarity_spec.rb +35 -0
- data/spec/models/sentiment_spec.rb +17 -26
- data/spec/models/sentiments_spec.rb +19 -28
- data/spec/models/share_count_spec.rb +17 -26
- data/spec/models/share_counts_spec.rb +19 -36
- data/spec/models/source_spec.rb +54 -49
- data/spec/models/stories_spec.rb +32 -33
- data/spec/models/story_cluster_spec.rb +23 -44
- data/spec/models/story_links_spec.rb +25 -32
- data/spec/models/story_spec.rb +65 -134
- data/spec/models/story_translation_spec.rb +47 -0
- data/spec/models/story_translations_en_spec.rb +53 -0
- data/spec/models/story_translations_spec.rb +41 -0
- data/spec/models/summary_spec.rb +16 -21
- data/spec/models/time_series_list_spec.rb +22 -39
- data/spec/models/time_series_spec.rb +19 -28
- data/spec/models/trend_spec.rb +19 -28
- data/spec/models/trends_spec.rb +30 -27
- data/spec/models/warning_spec.rb +53 -0
- data/spec/spec_helper.rb +11 -13
- metadata +91 -192
- data/Gemfile.lock +0 -65
- data/LICENSE +0 -13
- data/aylien_news_api-0.2.0.gem +0 -0
- data/aylien_news_api-0.3.0.gem +0 -0
@@ -1,24 +1,21 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
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
|
14
12
|
|
15
13
|
require 'date'
|
16
14
|
|
17
15
|
module AylienNewsApi
|
18
|
-
|
19
16
|
class RelatedStories
|
20
|
-
#
|
21
|
-
attr_accessor :
|
17
|
+
# An array of related stories for the input story
|
18
|
+
attr_accessor :related_stories
|
22
19
|
|
23
20
|
# The input story body
|
24
21
|
attr_accessor :story_body
|
@@ -26,80 +23,98 @@ module AylienNewsApi
|
|
26
23
|
# The input story language
|
27
24
|
attr_accessor :story_language
|
28
25
|
|
29
|
-
#
|
30
|
-
attr_accessor :
|
26
|
+
# The input story title
|
27
|
+
attr_accessor :story_title
|
31
28
|
|
32
|
-
#
|
33
|
-
attr_accessor :
|
29
|
+
# The end of a period in which searched stories were published
|
30
|
+
attr_accessor :published_at_end
|
34
31
|
|
32
|
+
# The start of a period in which searched stories were published
|
33
|
+
attr_accessor :published_at_start
|
35
34
|
|
36
35
|
# Attribute mapping from ruby-style variable name to JSON key.
|
37
36
|
def self.attribute_map
|
38
37
|
{
|
39
|
-
:'
|
38
|
+
:'related_stories' => :'related_stories',
|
40
39
|
:'story_body' => :'story_body',
|
41
40
|
:'story_language' => :'story_language',
|
42
|
-
:'
|
43
|
-
:'
|
41
|
+
:'story_title' => :'story_title',
|
42
|
+
:'published_at_end' => :'published_at.end',
|
43
|
+
:'published_at_start' => :'published_at.start'
|
44
44
|
}
|
45
45
|
end
|
46
46
|
|
47
47
|
# Attribute type mapping.
|
48
|
-
def self.
|
48
|
+
def self.openapi_types
|
49
49
|
{
|
50
|
-
:'
|
50
|
+
:'related_stories' => :'Array<Story>',
|
51
51
|
:'story_body' => :'String',
|
52
52
|
:'story_language' => :'String',
|
53
|
-
:'
|
54
|
-
:'
|
53
|
+
:'story_title' => :'String',
|
54
|
+
:'published_at_end' => :'DateTime',
|
55
|
+
:'published_at_start' => :'DateTime'
|
55
56
|
}
|
56
57
|
end
|
57
58
|
|
59
|
+
# List of attributes with nullable: true
|
60
|
+
def self.openapi_nullable
|
61
|
+
Set.new([
|
62
|
+
])
|
63
|
+
end
|
64
|
+
|
58
65
|
# Initializes the object
|
59
66
|
# @param [Hash] attributes Model attributes in the form of hash
|
60
67
|
def initialize(attributes = {})
|
61
|
-
|
68
|
+
if (!attributes.is_a?(Hash))
|
69
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::RelatedStories` initialize method"
|
70
|
+
end
|
62
71
|
|
63
|
-
# convert string to symbol for hash key
|
64
|
-
attributes = attributes.each_with_object({}){|(k,v), h|
|
72
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
73
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
74
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
75
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::RelatedStories`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
76
|
+
end
|
77
|
+
h[k.to_sym] = v
|
78
|
+
}
|
65
79
|
|
66
|
-
if attributes.
|
67
|
-
|
80
|
+
if attributes.key?(:'related_stories')
|
81
|
+
if (value = attributes[:'related_stories']).is_a?(Array)
|
82
|
+
self.related_stories = value
|
83
|
+
end
|
68
84
|
end
|
69
85
|
|
70
|
-
if attributes.
|
86
|
+
if attributes.key?(:'story_body')
|
71
87
|
self.story_body = attributes[:'story_body']
|
72
88
|
end
|
73
89
|
|
74
|
-
if attributes.
|
90
|
+
if attributes.key?(:'story_language')
|
75
91
|
self.story_language = attributes[:'story_language']
|
76
92
|
end
|
77
93
|
|
78
|
-
if attributes.
|
79
|
-
|
80
|
-
self.related_stories = value
|
81
|
-
end
|
94
|
+
if attributes.key?(:'story_title')
|
95
|
+
self.story_title = attributes[:'story_title']
|
82
96
|
end
|
83
97
|
|
84
|
-
if attributes.
|
85
|
-
|
86
|
-
self.clusters = value
|
87
|
-
end
|
98
|
+
if attributes.key?(:'published_at_end')
|
99
|
+
self.published_at_end = attributes[:'published_at_end']
|
88
100
|
end
|
89
101
|
|
102
|
+
if attributes.key?(:'published_at_start')
|
103
|
+
self.published_at_start = attributes[:'published_at_start']
|
104
|
+
end
|
90
105
|
end
|
91
106
|
|
92
107
|
# Show invalid properties with the reasons. Usually used together with valid?
|
93
|
-
# @return Array for valid
|
108
|
+
# @return Array for valid properties with the reasons
|
94
109
|
def list_invalid_properties
|
95
110
|
invalid_properties = Array.new
|
96
|
-
|
111
|
+
invalid_properties
|
97
112
|
end
|
98
113
|
|
99
114
|
# Check to see if the all the properties in the model are valid
|
100
115
|
# @return true if the model is valid
|
101
116
|
def valid?
|
102
|
-
|
117
|
+
true
|
103
118
|
end
|
104
119
|
|
105
120
|
# Checks equality by comparing each attribute.
|
@@ -107,11 +122,12 @@ module AylienNewsApi
|
|
107
122
|
def ==(o)
|
108
123
|
return true if self.equal?(o)
|
109
124
|
self.class == o.class &&
|
110
|
-
|
125
|
+
related_stories == o.related_stories &&
|
111
126
|
story_body == o.story_body &&
|
112
127
|
story_language == o.story_language &&
|
113
|
-
|
114
|
-
|
128
|
+
story_title == o.story_title &&
|
129
|
+
published_at_end == o.published_at_end &&
|
130
|
+
published_at_start == o.published_at_start
|
115
131
|
end
|
116
132
|
|
117
133
|
# @see the `==` method
|
@@ -121,9 +137,16 @@ module AylienNewsApi
|
|
121
137
|
end
|
122
138
|
|
123
139
|
# Calculates hash code according to all attributes.
|
124
|
-
# @return [
|
140
|
+
# @return [Integer] Hash code
|
125
141
|
def hash
|
126
|
-
[
|
142
|
+
[related_stories, story_body, story_language, story_title, published_at_end, published_at_start].hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Builds the object from hash
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
147
|
+
# @return [Object] Returns the model itself
|
148
|
+
def self.build_from_hash(attributes)
|
149
|
+
new.build_from_hash(attributes)
|
127
150
|
end
|
128
151
|
|
129
152
|
# Builds the object from hash
|
@@ -131,12 +154,12 @@ module AylienNewsApi
|
|
131
154
|
# @return [Object] Returns the model itself
|
132
155
|
def build_from_hash(attributes)
|
133
156
|
return nil unless attributes.is_a?(Hash)
|
134
|
-
self.class.
|
157
|
+
self.class.openapi_types.each_pair do |key, type|
|
135
158
|
if type =~ /\AArray<(.*)>/i
|
136
|
-
# check to ensure the input is an array given that the
|
159
|
+
# check to ensure the input is an array given that the attribute
|
137
160
|
# is documented as an array but the input is not
|
138
161
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
139
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
162
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
140
163
|
end
|
141
164
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
142
165
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
@@ -162,7 +185,7 @@ module AylienNewsApi
|
|
162
185
|
value.to_i
|
163
186
|
when :Float
|
164
187
|
value.to_f
|
165
|
-
when :
|
188
|
+
when :Boolean
|
166
189
|
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
167
190
|
true
|
168
191
|
else
|
@@ -183,8 +206,7 @@ module AylienNewsApi
|
|
183
206
|
end
|
184
207
|
end
|
185
208
|
else # model
|
186
|
-
|
187
|
-
temp_model.build_from_hash(value)
|
209
|
+
AylienNewsApi.const_get(type).build_from_hash(value)
|
188
210
|
end
|
189
211
|
end
|
190
212
|
|
@@ -206,7 +228,11 @@ module AylienNewsApi
|
|
206
228
|
hash = {}
|
207
229
|
self.class.attribute_map.each_pair do |attr, param|
|
208
230
|
value = self.send(attr)
|
209
|
-
|
231
|
+
if value.nil?
|
232
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
233
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
234
|
+
end
|
235
|
+
|
210
236
|
hash[param] = _to_hash(value)
|
211
237
|
end
|
212
238
|
hash
|
@@ -218,7 +244,7 @@ module AylienNewsApi
|
|
218
244
|
# @return [Hash] Returns the value in the form of hash
|
219
245
|
def _to_hash(value)
|
220
246
|
if value.is_a?(Array)
|
221
|
-
value.compact.map{ |v| _to_hash(v) }
|
247
|
+
value.compact.map { |v| _to_hash(v) }
|
222
248
|
elsif value.is_a?(Hash)
|
223
249
|
{}.tap do |hash|
|
224
250
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
@@ -229,7 +255,5 @@ module AylienNewsApi
|
|
229
255
|
value
|
230
256
|
end
|
231
257
|
end
|
232
|
-
|
233
258
|
end
|
234
|
-
|
235
259
|
end
|
@@ -0,0 +1,237 @@
|
|
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 RepresentativeStory
|
17
|
+
# ID of the story which is a unique identification
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
# The story permalink URL
|
21
|
+
attr_accessor :permalink
|
22
|
+
|
23
|
+
# Published date of the story
|
24
|
+
attr_accessor :published_at
|
25
|
+
|
26
|
+
# Title of the story
|
27
|
+
attr_accessor :title
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'id' => :'id',
|
33
|
+
:'permalink' => :'permalink',
|
34
|
+
:'published_at' => :'published_at',
|
35
|
+
:'title' => :'title'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.openapi_types
|
41
|
+
{
|
42
|
+
:'id' => :'Integer',
|
43
|
+
:'permalink' => :'String',
|
44
|
+
:'published_at' => :'DateTime',
|
45
|
+
:'title' => :'String'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# List of attributes with nullable: true
|
50
|
+
def self.openapi_nullable
|
51
|
+
Set.new([
|
52
|
+
])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Initializes the object
|
56
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
57
|
+
def initialize(attributes = {})
|
58
|
+
if (!attributes.is_a?(Hash))
|
59
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::RepresentativeStory` initialize method"
|
60
|
+
end
|
61
|
+
|
62
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
63
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
64
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
65
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::RepresentativeStory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
66
|
+
end
|
67
|
+
h[k.to_sym] = v
|
68
|
+
}
|
69
|
+
|
70
|
+
if attributes.key?(:'id')
|
71
|
+
self.id = attributes[:'id']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.key?(:'permalink')
|
75
|
+
self.permalink = attributes[:'permalink']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.key?(:'published_at')
|
79
|
+
self.published_at = attributes[:'published_at']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'title')
|
83
|
+
self.title = attributes[:'title']
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
88
|
+
# @return Array for valid properties with the reasons
|
89
|
+
def list_invalid_properties
|
90
|
+
invalid_properties = Array.new
|
91
|
+
invalid_properties
|
92
|
+
end
|
93
|
+
|
94
|
+
# Check to see if the all the properties in the model are valid
|
95
|
+
# @return true if the model is valid
|
96
|
+
def valid?
|
97
|
+
true
|
98
|
+
end
|
99
|
+
|
100
|
+
# Checks equality by comparing each attribute.
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def ==(o)
|
103
|
+
return true if self.equal?(o)
|
104
|
+
self.class == o.class &&
|
105
|
+
id == o.id &&
|
106
|
+
permalink == o.permalink &&
|
107
|
+
published_at == o.published_at &&
|
108
|
+
title == o.title
|
109
|
+
end
|
110
|
+
|
111
|
+
# @see the `==` method
|
112
|
+
# @param [Object] Object to be compared
|
113
|
+
def eql?(o)
|
114
|
+
self == o
|
115
|
+
end
|
116
|
+
|
117
|
+
# Calculates hash code according to all attributes.
|
118
|
+
# @return [Integer] Hash code
|
119
|
+
def hash
|
120
|
+
[id, permalink, published_at, title].hash
|
121
|
+
end
|
122
|
+
|
123
|
+
# Builds the object from hash
|
124
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
125
|
+
# @return [Object] Returns the model itself
|
126
|
+
def self.build_from_hash(attributes)
|
127
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
134
|
+
return nil unless attributes.is_a?(Hash)
|
135
|
+
self.class.openapi_types.each_pair do |key, type|
|
136
|
+
if type =~ /\AArray<(.*)>/i
|
137
|
+
# check to ensure the input is an array given that the attribute
|
138
|
+
# is documented as an array but the input is not
|
139
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
140
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
141
|
+
end
|
142
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
143
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
144
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
145
|
+
end
|
146
|
+
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
# Deserializes the data based on type
|
151
|
+
# @param string type Data type
|
152
|
+
# @param string value Value to be deserialized
|
153
|
+
# @return [Object] Deserialized data
|
154
|
+
def _deserialize(type, value)
|
155
|
+
case type.to_sym
|
156
|
+
when :DateTime
|
157
|
+
DateTime.parse(value)
|
158
|
+
when :Date
|
159
|
+
Date.parse(value)
|
160
|
+
when :String
|
161
|
+
value.to_s
|
162
|
+
when :Integer
|
163
|
+
value.to_i
|
164
|
+
when :Float
|
165
|
+
value.to_f
|
166
|
+
when :Boolean
|
167
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
168
|
+
true
|
169
|
+
else
|
170
|
+
false
|
171
|
+
end
|
172
|
+
when :Object
|
173
|
+
# generic object (usually a Hash), return directly
|
174
|
+
value
|
175
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
176
|
+
inner_type = Regexp.last_match[:inner_type]
|
177
|
+
value.map { |v| _deserialize(inner_type, v) }
|
178
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
179
|
+
k_type = Regexp.last_match[:k_type]
|
180
|
+
v_type = Regexp.last_match[:v_type]
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each do |k, v|
|
183
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
else # model
|
187
|
+
AylienNewsApi.const_get(type).build_from_hash(value)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the string representation of the object
|
192
|
+
# @return [String] String presentation of the object
|
193
|
+
def to_s
|
194
|
+
to_hash.to_s
|
195
|
+
end
|
196
|
+
|
197
|
+
# to_body is an alias to to_hash (backward compatibility)
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_body
|
200
|
+
to_hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the object in the form of hash
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_hash
|
206
|
+
hash = {}
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
208
|
+
value = self.send(attr)
|
209
|
+
if value.nil?
|
210
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
211
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
212
|
+
end
|
213
|
+
|
214
|
+
hash[param] = _to_hash(value)
|
215
|
+
end
|
216
|
+
hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Outputs non-array value in the form of hash
|
220
|
+
# For object, use to_hash. Otherwise, just return the value
|
221
|
+
# @param [Object] value Any valid value
|
222
|
+
# @return [Hash] Returns the value in the form of hash
|
223
|
+
def _to_hash(value)
|
224
|
+
if value.is_a?(Array)
|
225
|
+
value.compact.map { |v| _to_hash(v) }
|
226
|
+
elsif value.is_a?(Hash)
|
227
|
+
{}.tap do |hash|
|
228
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
229
|
+
end
|
230
|
+
elsif value.respond_to? :to_hash
|
231
|
+
value.to_hash
|
232
|
+
else
|
233
|
+
value
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|