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