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,228 @@
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
+ # The aggregation of sentiments
17
+ class AggregatedSentiment
18
+ # Positive sentiments count
19
+ attr_accessor :positive
20
+
21
+ # Neutral sentiments count
22
+ attr_accessor :neutral
23
+
24
+ # Negative sentiments count
25
+ attr_accessor :negative
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'positive' => :'positive',
31
+ :'neutral' => :'neutral',
32
+ :'negative' => :'negative'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'positive' => :'Integer',
40
+ :'neutral' => :'Integer',
41
+ :'negative' => :'Integer'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::AggregatedSentiment` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::AggregatedSentiment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'positive')
67
+ self.positive = attributes[:'positive']
68
+ end
69
+
70
+ if attributes.key?(:'neutral')
71
+ self.neutral = attributes[:'neutral']
72
+ end
73
+
74
+ if attributes.key?(:'negative')
75
+ self.negative = attributes[:'negative']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ positive == o.positive &&
98
+ neutral == o.neutral &&
99
+ negative == o.negative
100
+ end
101
+
102
+ # @see the `==` method
103
+ # @param [Object] Object to be compared
104
+ def eql?(o)
105
+ self == o
106
+ end
107
+
108
+ # Calculates hash code according to all attributes.
109
+ # @return [Integer] Hash code
110
+ def hash
111
+ [positive, neutral, negative].hash
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def self.build_from_hash(attributes)
118
+ new.build_from_hash(attributes)
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+ self.class.openapi_types.each_pair do |key, type|
127
+ if type =~ /\AArray<(.*)>/i
128
+ # check to ensure the input is an array given that the attribute
129
+ # is documented as an array but the input is not
130
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
131
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
132
+ end
133
+ elsif !attributes[self.class.attribute_map[key]].nil?
134
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
135
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
136
+ end
137
+
138
+ self
139
+ end
140
+
141
+ # Deserializes the data based on type
142
+ # @param string type Data type
143
+ # @param string value Value to be deserialized
144
+ # @return [Object] Deserialized data
145
+ def _deserialize(type, value)
146
+ case type.to_sym
147
+ when :DateTime
148
+ DateTime.parse(value)
149
+ when :Date
150
+ Date.parse(value)
151
+ when :String
152
+ value.to_s
153
+ when :Integer
154
+ value.to_i
155
+ when :Float
156
+ value.to_f
157
+ when :Boolean
158
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
159
+ true
160
+ else
161
+ false
162
+ end
163
+ when :Object
164
+ # generic object (usually a Hash), return directly
165
+ value
166
+ when /\AArray<(?<inner_type>.+)>\z/
167
+ inner_type = Regexp.last_match[:inner_type]
168
+ value.map { |v| _deserialize(inner_type, v) }
169
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
+ k_type = Regexp.last_match[:k_type]
171
+ v_type = Regexp.last_match[:v_type]
172
+ {}.tap do |hash|
173
+ value.each do |k, v|
174
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
+ end
176
+ end
177
+ else # model
178
+ AylienNewsApi.const_get(type).build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ if value.nil?
201
+ is_nullable = self.class.openapi_nullable.include?(attr)
202
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
203
+ end
204
+
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+ end
228
+ end
@@ -14,39 +14,57 @@ require 'date'
14
14
 
15
15
  module AylienNewsApi
16
16
  class Entity
17
+ # The unique ID of the entity
18
+ attr_accessor :id
19
+
17
20
  # The indices of the entity text
18
21
  attr_accessor :indices
19
22
 
20
23
  attr_accessor :links
21
24
 
22
- # The entity score
23
- attr_accessor :score
24
-
25
25
  # The entity text
26
26
  attr_accessor :text
27
27
 
28
- # An array of the dbpedia types
28
+ # The stock_ticker of the entity (might be null)
29
+ attr_accessor :stock_ticker
30
+
31
+ # An array of the entity types
29
32
  attr_accessor :types
30
33
 
34
+ attr_accessor :sentiment
35
+
36
+ attr_accessor :surface_forms
37
+
38
+ # Describes how relevant an entity is to the article
39
+ attr_accessor :prominence_score
40
+
31
41
  # Attribute mapping from ruby-style variable name to JSON key.
32
42
  def self.attribute_map
33
43
  {
44
+ :'id' => :'id',
34
45
  :'indices' => :'indices',
35
46
  :'links' => :'links',
36
- :'score' => :'score',
37
47
  :'text' => :'text',
38
- :'types' => :'types'
48
+ :'stock_ticker' => :'stock_ticker',
49
+ :'types' => :'types',
50
+ :'sentiment' => :'sentiment',
51
+ :'surface_forms' => :'surface_forms',
52
+ :'prominence_score' => :'prominence_score'
39
53
  }
40
54
  end
41
55
 
42
56
  # Attribute type mapping.
43
57
  def self.openapi_types
44
58
  {
59
+ :'id' => :'String',
45
60
  :'indices' => :'Array<Array<Integer>>',
46
61
  :'links' => :'EntityLinks',
47
- :'score' => :'Float',
48
62
  :'text' => :'String',
49
- :'types' => :'Array<String>'
63
+ :'stock_ticker' => :'String',
64
+ :'types' => :'Array<String>',
65
+ :'sentiment' => :'EntitySentiment',
66
+ :'surface_forms' => :'Array<EntitySurfaceForm>',
67
+ :'prominence_score' => :'Float'
50
68
  }
51
69
  end
52
70
 
@@ -71,6 +89,10 @@ module AylienNewsApi
71
89
  h[k.to_sym] = v
72
90
  }
73
91
 
92
+ if attributes.key?(:'id')
93
+ self.id = attributes[:'id']
94
+ end
95
+
74
96
  if attributes.key?(:'indices')
75
97
  if (value = attributes[:'indices']).is_a?(Array)
76
98
  self.indices = value
@@ -81,31 +103,45 @@ module AylienNewsApi
81
103
  self.links = attributes[:'links']
82
104
  end
83
105
 
84
- if attributes.key?(:'score')
85
- self.score = attributes[:'score']
86
- end
87
-
88
106
  if attributes.key?(:'text')
89
107
  self.text = attributes[:'text']
90
108
  end
91
109
 
110
+ if attributes.key?(:'stock_ticker')
111
+ self.stock_ticker = attributes[:'stock_ticker']
112
+ end
113
+
92
114
  if attributes.key?(:'types')
93
115
  if (value = attributes[:'types']).is_a?(Array)
94
116
  self.types = value
95
117
  end
96
118
  end
119
+
120
+ if attributes.key?(:'sentiment')
121
+ self.sentiment = attributes[:'sentiment']
122
+ end
123
+
124
+ if attributes.key?(:'surface_forms')
125
+ if (value = attributes[:'surface_forms']).is_a?(Array)
126
+ self.surface_forms = value
127
+ end
128
+ end
129
+
130
+ if attributes.key?(:'prominence_score')
131
+ self.prominence_score = attributes[:'prominence_score']
132
+ end
97
133
  end
98
134
 
99
135
  # Show invalid properties with the reasons. Usually used together with valid?
100
136
  # @return Array for valid properties with the reasons
101
137
  def list_invalid_properties
102
138
  invalid_properties = Array.new
103
- if !@score.nil? && @score > 1
104
- invalid_properties.push('invalid value for "score", must be smaller than or equal to 1.')
139
+ if !@prominence_score.nil? && @prominence_score > 1
140
+ invalid_properties.push('invalid value for "prominence_score", must be smaller than or equal to 1.')
105
141
  end
106
142
 
107
- if !@score.nil? && @score < 0
108
- invalid_properties.push('invalid value for "score", must be greater than or equal to 0.')
143
+ if !@prominence_score.nil? && @prominence_score < 0
144
+ invalid_properties.push('invalid value for "prominence_score", must be greater than or equal to 0.')
109
145
  end
110
146
 
111
147
  invalid_properties
@@ -114,23 +150,23 @@ module AylienNewsApi
114
150
  # Check to see if the all the properties in the model are valid
115
151
  # @return true if the model is valid
116
152
  def valid?
117
- return false if !@score.nil? && @score > 1
118
- return false if !@score.nil? && @score < 0
153
+ return false if !@prominence_score.nil? && @prominence_score > 1
154
+ return false if !@prominence_score.nil? && @prominence_score < 0
119
155
  true
120
156
  end
121
157
 
122
158
  # Custom attribute writer method with validation
123
- # @param [Object] score Value to be assigned
124
- def score=(score)
125
- if !score.nil? && score > 1
126
- fail ArgumentError, 'invalid value for "score", must be smaller than or equal to 1.'
159
+ # @param [Object] prominence_score Value to be assigned
160
+ def prominence_score=(prominence_score)
161
+ if !prominence_score.nil? && prominence_score > 1
162
+ fail ArgumentError, 'invalid value for "prominence_score", must be smaller than or equal to 1.'
127
163
  end
128
164
 
129
- if !score.nil? && score < 0
130
- fail ArgumentError, 'invalid value for "score", must be greater than or equal to 0.'
165
+ if !prominence_score.nil? && prominence_score < 0
166
+ fail ArgumentError, 'invalid value for "prominence_score", must be greater than or equal to 0.'
131
167
  end
132
168
 
133
- @score = score
169
+ @prominence_score = prominence_score
134
170
  end
135
171
 
136
172
  # Checks equality by comparing each attribute.
@@ -138,11 +174,15 @@ module AylienNewsApi
138
174
  def ==(o)
139
175
  return true if self.equal?(o)
140
176
  self.class == o.class &&
177
+ id == o.id &&
141
178
  indices == o.indices &&
142
179
  links == o.links &&
143
- score == o.score &&
144
180
  text == o.text &&
145
- types == o.types
181
+ stock_ticker == o.stock_ticker &&
182
+ types == o.types &&
183
+ sentiment == o.sentiment &&
184
+ surface_forms == o.surface_forms &&
185
+ prominence_score == o.prominence_score
146
186
  end
147
187
 
148
188
  # @see the `==` method
@@ -154,7 +194,7 @@ module AylienNewsApi
154
194
  # Calculates hash code according to all attributes.
155
195
  # @return [Integer] Hash code
156
196
  def hash
157
- [indices, links, score, text, types].hash
197
+ [id, indices, links, text, stock_ticker, types, sentiment, surface_forms, prominence_score].hash
158
198
  end
159
199
 
160
200
  # Builds the object from hash
@@ -14,20 +14,30 @@ require 'date'
14
14
 
15
15
  module AylienNewsApi
16
16
  class EntityLinks
17
- # A dbpedia resource URL
17
+ # A dbpedia resource URL (deprecated)
18
18
  attr_accessor :dbpedia
19
19
 
20
+ # A wikipedia resource URL
21
+ attr_accessor :wikipedia
22
+
23
+ # A wikidata resource URL
24
+ attr_accessor :wikidata
25
+
20
26
  # Attribute mapping from ruby-style variable name to JSON key.
21
27
  def self.attribute_map
22
28
  {
23
- :'dbpedia' => :'dbpedia'
29
+ :'dbpedia' => :'dbpedia',
30
+ :'wikipedia' => :'wikipedia',
31
+ :'wikidata' => :'wikidata'
24
32
  }
25
33
  end
26
34
 
27
35
  # Attribute type mapping.
28
36
  def self.openapi_types
29
37
  {
30
- :'dbpedia' => :'String'
38
+ :'dbpedia' => :'String',
39
+ :'wikipedia' => :'String',
40
+ :'wikidata' => :'String'
31
41
  }
32
42
  end
33
43
 
@@ -55,6 +65,14 @@ module AylienNewsApi
55
65
  if attributes.key?(:'dbpedia')
56
66
  self.dbpedia = attributes[:'dbpedia']
57
67
  end
68
+
69
+ if attributes.key?(:'wikipedia')
70
+ self.wikipedia = attributes[:'wikipedia']
71
+ end
72
+
73
+ if attributes.key?(:'wikidata')
74
+ self.wikidata = attributes[:'wikidata']
75
+ end
58
76
  end
59
77
 
60
78
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -75,7 +93,9 @@ module AylienNewsApi
75
93
  def ==(o)
76
94
  return true if self.equal?(o)
77
95
  self.class == o.class &&
78
- dbpedia == o.dbpedia
96
+ dbpedia == o.dbpedia &&
97
+ wikipedia == o.wikipedia &&
98
+ wikidata == o.wikidata
79
99
  end
80
100
 
81
101
  # @see the `==` method
@@ -87,7 +107,7 @@ module AylienNewsApi
87
107
  # Calculates hash code according to all attributes.
88
108
  # @return [Integer] Hash code
89
109
  def hash
90
- [dbpedia].hash
110
+ [dbpedia, wikipedia, wikidata].hash
91
111
  end
92
112
 
93
113
  # Builds the object from hash