aylien_news_api 4.1.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/docs/AggregatedSentiment.md +21 -0
  3. data/docs/DefaultApi.md +316 -0
  4. data/docs/Entity.md +11 -5
  5. data/docs/EntityLinks.md +6 -2
  6. data/docs/EntitySentiment.md +19 -0
  7. data/docs/EntitySurfaceForm.md +19 -0
  8. data/docs/Logicals.md +21 -0
  9. data/docs/NestedEntity.md +33 -0
  10. data/docs/Parameter.md +127 -0
  11. data/docs/Query.md +31 -0
  12. data/docs/Story.md +3 -1
  13. data/docs/TimeSeries.md +3 -1
  14. data/docs/Trend.md +3 -1
  15. data/lib/aylien_news_api.rb +7 -0
  16. data/lib/aylien_news_api/api/default_api.rb +466 -1
  17. data/lib/aylien_news_api/models/aggregated_sentiment.rb +228 -0
  18. data/lib/aylien_news_api/models/entity.rb +45 -39
  19. data/lib/aylien_news_api/models/entity_links.rb +25 -5
  20. data/lib/aylien_news_api/models/entity_sentiment.rb +240 -0
  21. data/lib/aylien_news_api/models/entity_surface_form.rb +219 -0
  22. data/lib/aylien_news_api/models/logicals.rb +230 -0
  23. data/lib/aylien_news_api/models/nested_entity.rb +278 -0
  24. data/lib/aylien_news_api/models/parameter.rb +701 -0
  25. data/lib/aylien_news_api/models/query.rb +271 -0
  26. data/lib/aylien_news_api/models/story.rb +14 -4
  27. data/lib/aylien_news_api/models/time_series.rb +13 -4
  28. data/lib/aylien_news_api/models/trend.rb +13 -4
  29. data/lib/aylien_news_api/version.rb +1 -1
  30. data/spec/api/default_api_spec.rb +19 -0
  31. data/spec/models/aggregated_sentiment_spec.rb +53 -0
  32. data/spec/models/entity_links_spec.rb +6 -0
  33. data/spec/models/entity_sentiment_spec.rb +47 -0
  34. data/spec/models/entity_spec.rb +8 -2
  35. data/spec/models/entity_surface_form_spec.rb +47 -0
  36. data/spec/models/logicals_spec.rb +53 -0
  37. data/spec/models/nested_entity_spec.rb +71 -0
  38. data/spec/models/parameter_spec.rb +371 -0
  39. data/spec/models/query_spec.rb +83 -0
  40. metadata +30 -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,52 @@ 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
+
31
38
  # Attribute mapping from ruby-style variable name to JSON key.
32
39
  def self.attribute_map
33
40
  {
41
+ :'id' => :'id',
34
42
  :'indices' => :'indices',
35
43
  :'links' => :'links',
36
- :'score' => :'score',
37
44
  :'text' => :'text',
38
- :'types' => :'types'
45
+ :'stock_ticker' => :'stock_ticker',
46
+ :'types' => :'types',
47
+ :'sentiment' => :'sentiment',
48
+ :'surface_forms' => :'surface_forms'
39
49
  }
40
50
  end
41
51
 
42
52
  # Attribute type mapping.
43
53
  def self.openapi_types
44
54
  {
55
+ :'id' => :'String',
45
56
  :'indices' => :'Array<Array<Integer>>',
46
57
  :'links' => :'EntityLinks',
47
- :'score' => :'Float',
48
58
  :'text' => :'String',
49
- :'types' => :'Array<String>'
59
+ :'stock_ticker' => :'String',
60
+ :'types' => :'Array<String>',
61
+ :'sentiment' => :'EntitySentiment',
62
+ :'surface_forms' => :'Array<EntitySurfaceForm>'
50
63
  }
51
64
  end
52
65
 
@@ -71,6 +84,10 @@ module AylienNewsApi
71
84
  h[k.to_sym] = v
72
85
  }
73
86
 
87
+ if attributes.key?(:'id')
88
+ self.id = attributes[:'id']
89
+ end
90
+
74
91
  if attributes.key?(:'indices')
75
92
  if (value = attributes[:'indices']).is_a?(Array)
76
93
  self.indices = value
@@ -81,68 +98,57 @@ module AylienNewsApi
81
98
  self.links = attributes[:'links']
82
99
  end
83
100
 
84
- if attributes.key?(:'score')
85
- self.score = attributes[:'score']
86
- end
87
-
88
101
  if attributes.key?(:'text')
89
102
  self.text = attributes[:'text']
90
103
  end
91
104
 
105
+ if attributes.key?(:'stock_ticker')
106
+ self.stock_ticker = attributes[:'stock_ticker']
107
+ end
108
+
92
109
  if attributes.key?(:'types')
93
110
  if (value = attributes[:'types']).is_a?(Array)
94
111
  self.types = value
95
112
  end
96
113
  end
114
+
115
+ if attributes.key?(:'sentiment')
116
+ self.sentiment = attributes[:'sentiment']
117
+ end
118
+
119
+ if attributes.key?(:'surface_forms')
120
+ if (value = attributes[:'surface_forms']).is_a?(Array)
121
+ self.surface_forms = value
122
+ end
123
+ end
97
124
  end
98
125
 
99
126
  # Show invalid properties with the reasons. Usually used together with valid?
100
127
  # @return Array for valid properties with the reasons
101
128
  def list_invalid_properties
102
129
  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.')
105
- end
106
-
107
- if !@score.nil? && @score < 0
108
- invalid_properties.push('invalid value for "score", must be greater than or equal to 0.')
109
- end
110
-
111
130
  invalid_properties
112
131
  end
113
132
 
114
133
  # Check to see if the all the properties in the model are valid
115
134
  # @return true if the model is valid
116
135
  def valid?
117
- return false if !@score.nil? && @score > 1
118
- return false if !@score.nil? && @score < 0
119
136
  true
120
137
  end
121
138
 
122
- # 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.'
127
- end
128
-
129
- if !score.nil? && score < 0
130
- fail ArgumentError, 'invalid value for "score", must be greater than or equal to 0.'
131
- end
132
-
133
- @score = score
134
- end
135
-
136
139
  # Checks equality by comparing each attribute.
137
140
  # @param [Object] Object to be compared
138
141
  def ==(o)
139
142
  return true if self.equal?(o)
140
143
  self.class == o.class &&
144
+ id == o.id &&
141
145
  indices == o.indices &&
142
146
  links == o.links &&
143
- score == o.score &&
144
147
  text == o.text &&
145
- types == o.types
148
+ stock_ticker == o.stock_ticker &&
149
+ types == o.types &&
150
+ sentiment == o.sentiment &&
151
+ surface_forms == o.surface_forms
146
152
  end
147
153
 
148
154
  # @see the `==` method
@@ -154,7 +160,7 @@ module AylienNewsApi
154
160
  # Calculates hash code according to all attributes.
155
161
  # @return [Integer] Hash code
156
162
  def hash
157
- [indices, links, score, text, types].hash
163
+ [id, indices, links, text, stock_ticker, types, sentiment, surface_forms].hash
158
164
  end
159
165
 
160
166
  # 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