aylien_news_api 4.0.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/docs/AggregatedSentiment.md +21 -0
  3. data/docs/DefaultApi.md +353 -1
  4. data/docs/Entity.md +13 -5
  5. data/docs/EntityLinks.md +6 -2
  6. data/docs/EntitySentiment.md +19 -0
  7. data/docs/EntitySurfaceForm.md +21 -0
  8. data/docs/ErrorLinks.md +3 -1
  9. data/docs/Logicals.md +21 -0
  10. data/docs/NestedEntity.md +33 -0
  11. data/docs/Parameter.md +127 -0
  12. data/docs/Query.md +31 -0
  13. data/docs/RelatedStories.md +5 -1
  14. data/docs/Stories.md +3 -1
  15. data/docs/Story.md +3 -1
  16. data/docs/TimeSeries.md +3 -1
  17. data/docs/Trend.md +3 -1
  18. data/docs/Warning.md +21 -0
  19. data/lib/aylien_news_api.rb +8 -0
  20. data/lib/aylien_news_api/api/default_api.rb +521 -2
  21. data/lib/aylien_news_api/models/aggregated_sentiment.rb +228 -0
  22. data/lib/aylien_news_api/models/entity.rb +68 -28
  23. data/lib/aylien_news_api/models/entity_links.rb +25 -5
  24. data/lib/aylien_news_api/models/entity_sentiment.rb +240 -0
  25. data/lib/aylien_news_api/models/entity_surface_form.rb +244 -0
  26. data/lib/aylien_news_api/models/error_links.rb +13 -4
  27. data/lib/aylien_news_api/models/logicals.rb +230 -0
  28. data/lib/aylien_news_api/models/nested_entity.rb +278 -0
  29. data/lib/aylien_news_api/models/parameter.rb +701 -0
  30. data/lib/aylien_news_api/models/query.rb +271 -0
  31. data/lib/aylien_news_api/models/related_stories.rb +24 -4
  32. data/lib/aylien_news_api/models/stories.rb +16 -4
  33. data/lib/aylien_news_api/models/story.rb +14 -4
  34. data/lib/aylien_news_api/models/time_series.rb +13 -4
  35. data/lib/aylien_news_api/models/trend.rb +13 -4
  36. data/lib/aylien_news_api/models/warning.rb +226 -0
  37. data/lib/aylien_news_api/version.rb +1 -1
  38. data/spec/api/default_api_spec.rb +145 -0
  39. data/spec/models/aggregated_sentiment_spec.rb +53 -0
  40. data/spec/models/entity_links_spec.rb +12 -0
  41. data/spec/models/entity_sentiment_spec.rb +47 -0
  42. data/spec/models/entity_spec.rb +26 -2
  43. data/spec/models/entity_surface_form_spec.rb +53 -0
  44. data/spec/models/error_links_spec.rb +6 -0
  45. data/spec/models/logicals_spec.rb +53 -0
  46. data/spec/models/nested_entity_spec.rb +89 -0
  47. data/spec/models/parameter_spec.rb +371 -0
  48. data/spec/models/query_spec.rb +83 -0
  49. data/spec/models/related_stories_spec.rb +12 -0
  50. data/spec/models/stories_spec.rb +6 -0
  51. data/spec/models/story_spec.rb +6 -0
  52. data/spec/models/time_series_spec.rb +6 -0
  53. data/spec/models/trend_spec.rb +6 -0
  54. data/spec/models/warning_spec.rb +53 -0
  55. metadata +34 -2
@@ -0,0 +1,240 @@
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 EntitySentiment
17
+ attr_accessor :polarity
18
+
19
+ # Polarity confidence of the sentiment
20
+ attr_accessor :confidence
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'polarity' => :'polarity',
26
+ :'confidence' => :'confidence'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.openapi_types
32
+ {
33
+ :'polarity' => :'SentimentPolarity',
34
+ :'confidence' => :'Float'
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new([
41
+ ])
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ if (!attributes.is_a?(Hash))
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::EntitySentiment` initialize method"
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::EntitySentiment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:'polarity')
60
+ self.polarity = attributes[:'polarity']
61
+ end
62
+
63
+ if attributes.key?(:'confidence')
64
+ self.confidence = attributes[:'confidence']
65
+ end
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ invalid_properties = Array.new
72
+ if !@confidence.nil? && @confidence > 1
73
+ invalid_properties.push('invalid value for "confidence", must be smaller than or equal to 1.')
74
+ end
75
+
76
+ if !@confidence.nil? && @confidence < 0
77
+ invalid_properties.push('invalid value for "confidence", must be greater than or equal to 0.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return false if !@confidence.nil? && @confidence > 1
87
+ return false if !@confidence.nil? && @confidence < 0
88
+ true
89
+ end
90
+
91
+ # Custom attribute writer method with validation
92
+ # @param [Object] confidence Value to be assigned
93
+ def confidence=(confidence)
94
+ if !confidence.nil? && confidence > 1
95
+ fail ArgumentError, 'invalid value for "confidence", must be smaller than or equal to 1.'
96
+ end
97
+
98
+ if !confidence.nil? && confidence < 0
99
+ fail ArgumentError, 'invalid value for "confidence", must be greater than or equal to 0.'
100
+ end
101
+
102
+ @confidence = confidence
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ polarity == o.polarity &&
111
+ confidence == o.confidence
112
+ end
113
+
114
+ # @see the `==` method
115
+ # @param [Object] Object to be compared
116
+ def eql?(o)
117
+ self == o
118
+ end
119
+
120
+ # Calculates hash code according to all attributes.
121
+ # @return [Integer] Hash code
122
+ def hash
123
+ [polarity, confidence].hash
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def self.build_from_hash(attributes)
130
+ new.build_from_hash(attributes)
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ self.class.openapi_types.each_pair do |key, type|
139
+ if type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :DateTime
160
+ DateTime.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :Boolean
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ AylienNewsApi.const_get(type).build_from_hash(value)
191
+ end
192
+ end
193
+
194
+ # Returns the string representation of the object
195
+ # @return [String] String presentation of the object
196
+ def to_s
197
+ to_hash.to_s
198
+ end
199
+
200
+ # to_body is an alias to to_hash (backward compatibility)
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_body
203
+ to_hash
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = self.send(attr)
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
217
+ hash[param] = _to_hash(value)
218
+ end
219
+ hash
220
+ end
221
+
222
+ # Outputs non-array value in the form of hash
223
+ # For object, use to_hash. Otherwise, just return the value
224
+ # @param [Object] value Any valid value
225
+ # @return [Hash] Returns the value in the form of hash
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map { |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+ end
240
+ end
@@ -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 EntitySurfaceForm
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::EntitySurfaceForm` 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::EntitySurfaceForm`. 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