aylien_news_api 4.1.1 → 4.3.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 (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,271 @@
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 Query
17
+ attr_accessor :eq
18
+
19
+ attr_accessor :text
20
+
21
+ attr_accessor :_in
22
+
23
+ attr_accessor :gt
24
+
25
+ attr_accessor :gte
26
+
27
+ attr_accessor :lt
28
+
29
+ attr_accessor :lte
30
+
31
+ attr_accessor :boost
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'eq' => :'$eq',
37
+ :'text' => :'$text',
38
+ :'_in' => :'$in',
39
+ :'gt' => :'$gt',
40
+ :'gte' => :'$gte',
41
+ :'lt' => :'$lt',
42
+ :'lte' => :'$lte',
43
+ :'boost' => :'$boost'
44
+ }
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'eq' => :'OneOfstringnumber',
51
+ :'text' => :'OneOfstringnumber',
52
+ :'_in' => :'Array<OneOfstringnumber>',
53
+ :'gt' => :'Float',
54
+ :'gte' => :'Float',
55
+ :'lt' => :'Float',
56
+ :'lte' => :'Float',
57
+ :'boost' => :'Float'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::Query` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::Query`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'eq')
83
+ self.eq = attributes[:'eq']
84
+ end
85
+
86
+ if attributes.key?(:'text')
87
+ self.text = attributes[:'text']
88
+ end
89
+
90
+ if attributes.key?(:'_in')
91
+ if (value = attributes[:'_in']).is_a?(Array)
92
+ self._in = value
93
+ end
94
+ end
95
+
96
+ if attributes.key?(:'gt')
97
+ self.gt = attributes[:'gt']
98
+ end
99
+
100
+ if attributes.key?(:'gte')
101
+ self.gte = attributes[:'gte']
102
+ end
103
+
104
+ if attributes.key?(:'lt')
105
+ self.lt = attributes[:'lt']
106
+ end
107
+
108
+ if attributes.key?(:'lte')
109
+ self.lte = attributes[:'lte']
110
+ end
111
+
112
+ if attributes.key?(:'boost')
113
+ self.boost = attributes[:'boost']
114
+ end
115
+ end
116
+
117
+ # Show invalid properties with the reasons. Usually used together with valid?
118
+ # @return Array for valid properties with the reasons
119
+ def list_invalid_properties
120
+ invalid_properties = Array.new
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ true
128
+ end
129
+
130
+ # Checks equality by comparing each attribute.
131
+ # @param [Object] Object to be compared
132
+ def ==(o)
133
+ return true if self.equal?(o)
134
+ self.class == o.class &&
135
+ eq == o.eq &&
136
+ text == o.text &&
137
+ _in == o._in &&
138
+ gt == o.gt &&
139
+ gte == o.gte &&
140
+ lt == o.lt &&
141
+ lte == o.lte &&
142
+ boost == o.boost
143
+ end
144
+
145
+ # @see the `==` method
146
+ # @param [Object] Object to be compared
147
+ def eql?(o)
148
+ self == o
149
+ end
150
+
151
+ # Calculates hash code according to all attributes.
152
+ # @return [Integer] Hash code
153
+ def hash
154
+ [eq, text, _in, gt, gte, lt, lte, boost].hash
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def self.build_from_hash(attributes)
161
+ new.build_from_hash(attributes)
162
+ end
163
+
164
+ # Builds the object from hash
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ # @return [Object] Returns the model itself
167
+ def build_from_hash(attributes)
168
+ return nil unless attributes.is_a?(Hash)
169
+ self.class.openapi_types.each_pair do |key, type|
170
+ if type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
174
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
175
+ end
176
+ elsif !attributes[self.class.attribute_map[key]].nil?
177
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
178
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
179
+ end
180
+
181
+ self
182
+ end
183
+
184
+ # Deserializes the data based on type
185
+ # @param string type Data type
186
+ # @param string value Value to be deserialized
187
+ # @return [Object] Deserialized data
188
+ def _deserialize(type, value)
189
+ case type.to_sym
190
+ when :DateTime
191
+ DateTime.parse(value)
192
+ when :Date
193
+ Date.parse(value)
194
+ when :String
195
+ value.to_s
196
+ when :Integer
197
+ value.to_i
198
+ when :Float
199
+ value.to_f
200
+ when :Boolean
201
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
+ true
203
+ else
204
+ false
205
+ end
206
+ when :Object
207
+ # generic object (usually a Hash), return directly
208
+ value
209
+ when /\AArray<(?<inner_type>.+)>\z/
210
+ inner_type = Regexp.last_match[:inner_type]
211
+ value.map { |v| _deserialize(inner_type, v) }
212
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
213
+ k_type = Regexp.last_match[:k_type]
214
+ v_type = Regexp.last_match[:v_type]
215
+ {}.tap do |hash|
216
+ value.each do |k, v|
217
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
218
+ end
219
+ end
220
+ else # model
221
+ AylienNewsApi.const_get(type).build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+ end
271
+ end
@@ -72,6 +72,9 @@ module AylienNewsApi
72
72
  # Word count of the story body
73
73
  attr_accessor :words_count
74
74
 
75
+ # License type of the story
76
+ attr_accessor :license_type
77
+
75
78
  # Attribute mapping from ruby-style variable name to JSON key.
76
79
  def self.attribute_map
77
80
  {
@@ -96,7 +99,8 @@ module AylienNewsApi
96
99
  :'summary' => :'summary',
97
100
  :'title' => :'title',
98
101
  :'translations' => :'translations',
99
- :'words_count' => :'words_count'
102
+ :'words_count' => :'words_count',
103
+ :'license_type' => :'license_type'
100
104
  }
101
105
  end
102
106
 
@@ -124,7 +128,8 @@ module AylienNewsApi
124
128
  :'summary' => :'Summary',
125
129
  :'title' => :'String',
126
130
  :'translations' => :'StoryTranslations',
127
- :'words_count' => :'Integer'
131
+ :'words_count' => :'Integer',
132
+ :'license_type' => :'Integer'
128
133
  }
129
134
  end
130
135
 
@@ -246,6 +251,10 @@ module AylienNewsApi
246
251
  if attributes.key?(:'words_count')
247
252
  self.words_count = attributes[:'words_count']
248
253
  end
254
+
255
+ if attributes.key?(:'license_type')
256
+ self.license_type = attributes[:'license_type']
257
+ end
249
258
  end
250
259
 
251
260
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -287,7 +296,8 @@ module AylienNewsApi
287
296
  summary == o.summary &&
288
297
  title == o.title &&
289
298
  translations == o.translations &&
290
- words_count == o.words_count
299
+ words_count == o.words_count &&
300
+ license_type == o.license_type
291
301
  end
292
302
 
293
303
  # @see the `==` method
@@ -299,7 +309,7 @@ module AylienNewsApi
299
309
  # Calculates hash code according to all attributes.
300
310
  # @return [Integer] Hash code
301
311
  def hash
302
- [author, body, categories, characters_count, clusters, entities, hashtags, id, keywords, language, links, media, paragraphs_count, published_at, sentences_count, sentiment, social_shares_count, source, summary, title, translations, words_count].hash
312
+ [author, body, categories, characters_count, clusters, entities, hashtags, id, keywords, language, links, media, paragraphs_count, published_at, sentences_count, sentiment, social_shares_count, source, summary, title, translations, words_count, license_type].hash
303
313
  end
304
314
 
305
315
  # Builds the object from hash
@@ -20,11 +20,14 @@ module AylienNewsApi
20
20
  # The published date of the time series bin
21
21
  attr_accessor :published_at
22
22
 
23
+ attr_accessor :sentiment
24
+
23
25
  # Attribute mapping from ruby-style variable name to JSON key.
24
26
  def self.attribute_map
25
27
  {
26
28
  :'count' => :'count',
27
- :'published_at' => :'published_at'
29
+ :'published_at' => :'published_at',
30
+ :'sentiment' => :'sentiment'
28
31
  }
29
32
  end
30
33
 
@@ -32,7 +35,8 @@ module AylienNewsApi
32
35
  def self.openapi_types
33
36
  {
34
37
  :'count' => :'Integer',
35
- :'published_at' => :'DateTime'
38
+ :'published_at' => :'DateTime',
39
+ :'sentiment' => :'AggregatedSentiment'
36
40
  }
37
41
  end
38
42
 
@@ -64,6 +68,10 @@ module AylienNewsApi
64
68
  if attributes.key?(:'published_at')
65
69
  self.published_at = attributes[:'published_at']
66
70
  end
71
+
72
+ if attributes.key?(:'sentiment')
73
+ self.sentiment = attributes[:'sentiment']
74
+ end
67
75
  end
68
76
 
69
77
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -85,7 +93,8 @@ module AylienNewsApi
85
93
  return true if self.equal?(o)
86
94
  self.class == o.class &&
87
95
  count == o.count &&
88
- published_at == o.published_at
96
+ published_at == o.published_at &&
97
+ sentiment == o.sentiment
89
98
  end
90
99
 
91
100
  # @see the `==` method
@@ -97,7 +106,7 @@ module AylienNewsApi
97
106
  # Calculates hash code according to all attributes.
98
107
  # @return [Integer] Hash code
99
108
  def hash
100
- [count, published_at].hash
109
+ [count, published_at, sentiment].hash
101
110
  end
102
111
 
103
112
  # Builds the object from hash
@@ -20,11 +20,14 @@ module AylienNewsApi
20
20
  # The value of the trend
21
21
  attr_accessor :value
22
22
 
23
+ attr_accessor :sentiment
24
+
23
25
  # Attribute mapping from ruby-style variable name to JSON key.
24
26
  def self.attribute_map
25
27
  {
26
28
  :'count' => :'count',
27
- :'value' => :'value'
29
+ :'value' => :'value',
30
+ :'sentiment' => :'sentiment'
28
31
  }
29
32
  end
30
33
 
@@ -32,7 +35,8 @@ module AylienNewsApi
32
35
  def self.openapi_types
33
36
  {
34
37
  :'count' => :'Integer',
35
- :'value' => :'String'
38
+ :'value' => :'String',
39
+ :'sentiment' => :'AggregatedSentiment'
36
40
  }
37
41
  end
38
42
 
@@ -64,6 +68,10 @@ module AylienNewsApi
64
68
  if attributes.key?(:'value')
65
69
  self.value = attributes[:'value']
66
70
  end
71
+
72
+ if attributes.key?(:'sentiment')
73
+ self.sentiment = attributes[:'sentiment']
74
+ end
67
75
  end
68
76
 
69
77
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -85,7 +93,8 @@ module AylienNewsApi
85
93
  return true if self.equal?(o)
86
94
  self.class == o.class &&
87
95
  count == o.count &&
88
- value == o.value
96
+ value == o.value &&
97
+ sentiment == o.sentiment
89
98
  end
90
99
 
91
100
  # @see the `==` method
@@ -97,7 +106,7 @@ module AylienNewsApi
97
106
  # Calculates hash code according to all attributes.
98
107
  # @return [Integer] Hash code
99
108
  def hash
100
- [count, value].hash
109
+ [count, value, sentiment].hash
101
110
  end
102
111
 
103
112
  # Builds the object from hash
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
11
11
  =end
12
12
 
13
13
  module AylienNewsApi
14
- VERSION = '4.1.1'
14
+ VERSION = '4.3.0'
15
15
  end
@@ -32,6 +32,25 @@ describe 'DefaultApi' do
32
32
  end
33
33
  end
34
34
 
35
+ # unit tests for advanced_list_stories
36
+ # List Stories
37
+ # The stories endpoint is used to return stories based on the json query you set in your request body. The News API crawler gathers articles in near real-time and stores information about them, or metadata. Below you can see all of the query parameters, and JSON schema for the body, which you can use to narrow down your query.
38
+ # @param unknown_base_type /stories body schema to perform an advanced search with logical operators and nested objects.
39
+ # @param [Hash] opts the optional parameters
40
+ # @option opts [String] :published_at_start This parameter is used for finding stories whose published at time is greater than the specified value. [Here](https://newsapi.aylien.com/docs/working-with-dates) you can find more information about how [to work with dates](https://newsapi.aylien.com/docs/working-with-dates).
41
+ # @option opts [String] :published_at_end This parameter is used for finding stories whose published at time is less than the specified value. [Here](https://newsapi.aylien.com/docs/working-with-dates) you can find more information about how [to work with dates](https://newsapi.aylien.com/docs/working-with-dates).
42
+ # @option opts [Array<String>] :_return This parameter is used for specifying return fields.
43
+ # @option opts [String] :sort_by This parameter is used for changing the order column of the results. You can read about sorting results [here](https://newsapi.aylien.com/docs/sorting-results).
44
+ # @option opts [String] :sort_direction This parameter is used for changing the order direction of the result. You can read about sorting results [here](https://newsapi.aylien.com/docs/sorting-results).
45
+ # @option opts [String] :cursor This parameter is used for finding a specific page. You can read more about pagination of results [here](https://newsapi.aylien.com/docs/pagination-of-results).
46
+ # @option opts [Integer] :per_page This parameter is used for specifying number of items in each page You can read more about pagination of results [here](https://newsapi.aylien.com/docs/pagination-of-results)
47
+ # @return [Stories]
48
+ describe 'advanced_list_stories test' do
49
+ it 'should work' do
50
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
51
+ end
52
+ end
53
+
35
54
  # unit tests for list_autocompletes
36
55
  # List autocompletes
37
56
  # The autocompletes endpoint a string of characters provided to it, and then returns suggested terms that are the most likely full words or strings. The terms returned by the News API are based on parameters the type parameters you can see below. For example, if you provide the autocompletes endpoint with the term &#x60;New York C&#x60; and select the type &#x60;dbpedia_resources&#x60;, the API will return links to the DBpedia resources &#x60;New_York_City&#x60;, &#x60;New_York_City_Subway&#x60;, &#x60;New_York_City_Police_Department&#x60;, and so on.