aylien_news_api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -4
  3. data/README.md +8 -7
  4. data/aylien_news_api.gemspec +15 -2
  5. data/docs/CategoryLinks.md +2 -2
  6. data/docs/Coverages.md +1 -0
  7. data/docs/DefaultApi.md +315 -252
  8. data/docs/Media.md +1 -1
  9. data/docs/RelatedStories.md +1 -0
  10. data/docs/Scope.md +4 -4
  11. data/docs/Story.md +5 -5
  12. data/lib/aylien_news_api/api/default_api.rb +615 -549
  13. data/lib/aylien_news_api/api_client.rb +2 -2
  14. data/lib/aylien_news_api/configuration.rb +8 -0
  15. data/lib/aylien_news_api/models/author.rb +25 -6
  16. data/lib/aylien_news_api/models/autocomplete.rb +23 -5
  17. data/lib/aylien_news_api/models/autocompletes.rb +21 -4
  18. data/lib/aylien_news_api/models/category.rb +57 -12
  19. data/lib/aylien_news_api/models/category_links.rb +25 -7
  20. data/lib/aylien_news_api/models/coverages.rb +45 -12
  21. data/lib/aylien_news_api/models/entities.rb +23 -5
  22. data/lib/aylien_news_api/models/entity.rb +49 -8
  23. data/lib/aylien_news_api/models/entity_links.rb +21 -4
  24. data/lib/aylien_news_api/models/error.rb +31 -9
  25. data/lib/aylien_news_api/models/error_links.rb +21 -4
  26. data/lib/aylien_news_api/models/errors.rb +21 -4
  27. data/lib/aylien_news_api/models/histogram_interval.rb +23 -5
  28. data/lib/aylien_news_api/models/histograms.rb +29 -8
  29. data/lib/aylien_news_api/models/location.rb +25 -6
  30. data/lib/aylien_news_api/models/media.rb +50 -9
  31. data/lib/aylien_news_api/models/related_stories.rb +43 -11
  32. data/lib/aylien_news_api/models/scope.rb +57 -14
  33. data/lib/aylien_news_api/models/sentiment.rb +69 -8
  34. data/lib/aylien_news_api/models/sentiments.rb +23 -5
  35. data/lib/aylien_news_api/models/share_count.rb +23 -5
  36. data/lib/aylien_news_api/models/share_counts.rb +27 -7
  37. data/lib/aylien_news_api/models/source.rb +31 -9
  38. data/lib/aylien_news_api/models/stories.rb +25 -6
  39. data/lib/aylien_news_api/models/story.rb +64 -28
  40. data/lib/aylien_news_api/models/story_cluster.rb +29 -8
  41. data/lib/aylien_news_api/models/story_links.rb +25 -6
  42. data/lib/aylien_news_api/models/summary.rb +21 -4
  43. data/lib/aylien_news_api/models/time_series.rb +23 -5
  44. data/lib/aylien_news_api/models/time_series_list.rb +27 -7
  45. data/lib/aylien_news_api/models/trend.rb +23 -5
  46. data/lib/aylien_news_api/models/trends.rb +23 -5
  47. data/lib/aylien_news_api/version.rb +1 -1
  48. data/spec/api_client_spec.rb +306 -0
  49. data/spec/configuration_spec.rb +39 -0
  50. data/spec/spec_helper.rb +113 -0
  51. metadata +34 -49
  52. data/Rakefile +0 -8
  53. data/aylien_news_api-0.0.1.gem +0 -0
@@ -91,10 +91,10 @@ module AylienNewsApi
91
91
  update_params_for_auth! header_params, query_params, opts[:auth_names]
92
92
 
93
93
  req_opts = {
94
- :params_encoding => :multi,
95
94
  :method => http_method,
96
95
  :headers => header_params,
97
96
  :params => query_params,
97
+ :params_encoding => @config.params_encoding,
98
98
  :timeout => @config.timeout,
99
99
  :ssl_verifypeer => @config.verify_ssl,
100
100
  :sslcert => @config.cert_file,
@@ -207,7 +207,7 @@ module AylienNewsApi
207
207
  # @return [Tempfile] the file downloaded
208
208
  def download_file(response)
209
209
  content_disposition = response.headers['Content-Disposition']
210
- if content_disposition
210
+ if content_disposition and content_disposition =~ /filename=/i
211
211
  filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
212
212
  prefix = sanitize_filename(filename)
213
213
  else
@@ -87,6 +87,13 @@ module AylienNewsApi
87
87
  # @return [true, false]
88
88
  attr_accessor :verify_ssl
89
89
 
90
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
91
+ # Default to nil.
92
+ #
93
+ # @see The params_encoding option of Ethon. Related source code:
94
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
95
+ attr_accessor :params_encoding
96
+
90
97
  # Set this to customize the certificate file to verify the peer.
91
98
  #
92
99
  # @return [String] the path to the certificate file
@@ -113,6 +120,7 @@ module AylienNewsApi
113
120
  @api_key_prefix = {}
114
121
  @timeout = 0
115
122
  @verify_ssl = true
123
+ @params_encoding = :multi
116
124
  @cert_file = nil
117
125
  @key_file = nil
118
126
  @debugging = false
@@ -15,6 +15,7 @@
15
15
  require 'date'
16
16
 
17
17
  module AylienNewsApi
18
+
18
19
  class Author
19
20
  # A unique identification for the author
20
21
  attr_accessor :id
@@ -25,6 +26,7 @@ module AylienNewsApi
25
26
  # A URL which points to the author avatar
26
27
  attr_accessor :avatar_url
27
28
 
29
+
28
30
  # Attribute mapping from ruby-style variable name to JSON key.
29
31
  def self.attribute_map
30
32
  {
@@ -51,19 +53,35 @@ module AylienNewsApi
51
53
  # convert string to symbol for hash key
52
54
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
55
 
54
- if attributes[:'id']
56
+ if attributes.has_key?(:'id')
55
57
  self.id = attributes[:'id']
56
58
  end
57
- if attributes[:'name']
59
+
60
+ if attributes.has_key?(:'name')
58
61
  self.name = attributes[:'name']
59
62
  end
60
- if attributes[:'avatar_url']
63
+
64
+ if attributes.has_key?(:'avatar_url')
61
65
  self.avatar_url = attributes[:'avatar_url']
62
66
  end
67
+
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properies with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ return invalid_properties
75
+ end
76
+
77
+ # Check to see if the all the properties in the model are valid
78
+ # @return true if the model is valid
79
+ def valid?
80
+ return true
63
81
  end
64
82
 
65
83
  # Checks equality by comparing each attribute.
66
- # @param [Object] Object to be compared
84
+ # @param [Object] Object to be compared
67
85
  def ==(o)
68
86
  return true if self.equal?(o)
69
87
  self.class == o.class &&
@@ -73,7 +91,7 @@ module AylienNewsApi
73
91
  end
74
92
 
75
93
  # @see the `==` method
76
- # @param [Object] Object to be compared
94
+ # @param [Object] Object to be compared
77
95
  def eql?(o)
78
96
  self == o
79
97
  end
@@ -172,7 +190,7 @@ module AylienNewsApi
172
190
 
173
191
  # Outputs non-array value in the form of hash
174
192
  # For object, use to_hash. Otherwise, just return the value
175
- # @param [Object] value Any valid value
193
+ # @param [Object] value Any valid value
176
194
  # @return [Hash] Returns the value in the form of hash
177
195
  def _to_hash(value)
178
196
  if value.is_a?(Array)
@@ -189,4 +207,5 @@ module AylienNewsApi
189
207
  end
190
208
 
191
209
  end
210
+
192
211
  end
@@ -15,6 +15,7 @@
15
15
  require 'date'
16
16
 
17
17
  module AylienNewsApi
18
+
18
19
  class Autocomplete
19
20
  # ID of the autocomplete
20
21
  attr_accessor :id
@@ -22,6 +23,7 @@ module AylienNewsApi
22
23
  # Text of the autocomplete
23
24
  attr_accessor :text
24
25
 
26
+
25
27
  # Attribute mapping from ruby-style variable name to JSON key.
26
28
  def self.attribute_map
27
29
  {
@@ -46,16 +48,31 @@ module AylienNewsApi
46
48
  # convert string to symbol for hash key
47
49
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
50
 
49
- if attributes[:'id']
51
+ if attributes.has_key?(:'id')
50
52
  self.id = attributes[:'id']
51
53
  end
52
- if attributes[:'text']
54
+
55
+ if attributes.has_key?(:'text')
53
56
  self.text = attributes[:'text']
54
57
  end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properies with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return true
55
72
  end
56
73
 
57
74
  # Checks equality by comparing each attribute.
58
- # @param [Object] Object to be compared
75
+ # @param [Object] Object to be compared
59
76
  def ==(o)
60
77
  return true if self.equal?(o)
61
78
  self.class == o.class &&
@@ -64,7 +81,7 @@ module AylienNewsApi
64
81
  end
65
82
 
66
83
  # @see the `==` method
67
- # @param [Object] Object to be compared
84
+ # @param [Object] Object to be compared
68
85
  def eql?(o)
69
86
  self == o
70
87
  end
@@ -163,7 +180,7 @@ module AylienNewsApi
163
180
 
164
181
  # Outputs non-array value in the form of hash
165
182
  # For object, use to_hash. Otherwise, just return the value
166
- # @param [Object] value Any valid value
183
+ # @param [Object] value Any valid value
167
184
  # @return [Hash] Returns the value in the form of hash
168
185
  def _to_hash(value)
169
186
  if value.is_a?(Array)
@@ -180,4 +197,5 @@ module AylienNewsApi
180
197
  end
181
198
 
182
199
  end
200
+
183
201
  end
@@ -15,10 +15,12 @@
15
15
  require 'date'
16
16
 
17
17
  module AylienNewsApi
18
+
18
19
  class Autocompletes
19
20
  # An array of autocompletes
20
21
  attr_accessor :autocompletes
21
22
 
23
+
22
24
  # Attribute mapping from ruby-style variable name to JSON key.
23
25
  def self.attribute_map
24
26
  {
@@ -41,15 +43,29 @@ module AylienNewsApi
41
43
  # convert string to symbol for hash key
42
44
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
43
45
 
44
- if attributes[:'autocompletes']
46
+ if attributes.has_key?(:'autocompletes')
45
47
  if (value = attributes[:'autocompletes']).is_a?(Array)
46
48
  self.autocompletes = value
47
49
  end
48
50
  end
51
+
52
+ end
53
+
54
+ # Show invalid properties with the reasons. Usually used together with valid?
55
+ # @return Array for valid properies with the reasons
56
+ def list_invalid_properties
57
+ invalid_properties = Array.new
58
+ return invalid_properties
59
+ end
60
+
61
+ # Check to see if the all the properties in the model are valid
62
+ # @return true if the model is valid
63
+ def valid?
64
+ return true
49
65
  end
50
66
 
51
67
  # Checks equality by comparing each attribute.
52
- # @param [Object] Object to be compared
68
+ # @param [Object] Object to be compared
53
69
  def ==(o)
54
70
  return true if self.equal?(o)
55
71
  self.class == o.class &&
@@ -57,7 +73,7 @@ module AylienNewsApi
57
73
  end
58
74
 
59
75
  # @see the `==` method
60
- # @param [Object] Object to be compared
76
+ # @param [Object] Object to be compared
61
77
  def eql?(o)
62
78
  self == o
63
79
  end
@@ -156,7 +172,7 @@ module AylienNewsApi
156
172
 
157
173
  # Outputs non-array value in the form of hash
158
174
  # For object, use to_hash. Otherwise, just return the value
159
- # @param [Object] value Any valid value
175
+ # @param [Object] value Any valid value
160
176
  # @return [Hash] Returns the value in the form of hash
161
177
  def _to_hash(value)
162
178
  if value.is_a?(Array)
@@ -173,4 +189,5 @@ module AylienNewsApi
173
189
  end
174
190
 
175
191
  end
192
+
176
193
  end
@@ -15,6 +15,7 @@
15
15
  require 'date'
16
16
 
17
17
  module AylienNewsApi
18
+
18
19
  class Category
19
20
  # The ID of the category
20
21
  attr_accessor :id
@@ -34,6 +35,28 @@ module AylienNewsApi
34
35
  # Related links for the category
35
36
  attr_accessor :links
36
37
 
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
37
60
  # Attribute mapping from ruby-style variable name to JSON key.
38
61
  def self.attribute_map
39
62
  {
@@ -66,38 +89,59 @@ module AylienNewsApi
66
89
  # convert string to symbol for hash key
67
90
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
68
91
 
69
- if attributes[:'id']
92
+ if attributes.has_key?(:'id')
70
93
  self.id = attributes[:'id']
71
94
  end
72
- if attributes[:'taxonomy']
95
+
96
+ if attributes.has_key?(:'taxonomy')
73
97
  self.taxonomy = attributes[:'taxonomy']
74
98
  end
75
- if attributes[:'level']
99
+
100
+ if attributes.has_key?(:'level')
76
101
  self.level = attributes[:'level']
77
102
  end
78
- if attributes[:'score']
103
+
104
+ if attributes.has_key?(:'score')
79
105
  self.score = attributes[:'score']
80
106
  end
81
- if attributes[:'confident']
107
+
108
+ if attributes.has_key?(:'confident')
82
109
  self.confident = attributes[:'confident']
83
110
  end
84
- if attributes[:'links']
111
+
112
+ if attributes.has_key?(:'links')
85
113
  self.links = attributes[:'links']
86
114
  end
115
+
116
+ end
117
+
118
+ # Show invalid properties with the reasons. Usually used together with valid?
119
+ # @return Array for valid properies with the reasons
120
+ def list_invalid_properties
121
+ invalid_properties = Array.new
122
+ return invalid_properties
123
+ end
124
+
125
+ # Check to see if the all the properties in the model are valid
126
+ # @return true if the model is valid
127
+ def valid?
128
+ taxonomy_validator = EnumAttributeValidator.new('String', ["iab-qag", "iptc-subjectcode"])
129
+ return false unless taxonomy_validator.valid?(@taxonomy)
130
+ return true
87
131
  end
88
132
 
89
133
  # Custom attribute writer method checking allowed values (enum).
90
134
  # @param [Object] taxonomy Object to be assigned
91
135
  def taxonomy=(taxonomy)
92
- allowed_values = ["iab-qag", "iptc-subjectcode"]
93
- if taxonomy && !allowed_values.include?(taxonomy)
94
- fail "invalid value for 'taxonomy', must be one of #{allowed_values}"
136
+ validator = EnumAttributeValidator.new('String', ["iab-qag", "iptc-subjectcode"])
137
+ unless validator.valid?(taxonomy)
138
+ fail ArgumentError, "invalid value for 'taxonomy', must be one of #{validator.allowable_values}."
95
139
  end
96
140
  @taxonomy = taxonomy
97
141
  end
98
142
 
99
143
  # Checks equality by comparing each attribute.
100
- # @param [Object] Object to be compared
144
+ # @param [Object] Object to be compared
101
145
  def ==(o)
102
146
  return true if self.equal?(o)
103
147
  self.class == o.class &&
@@ -110,7 +154,7 @@ module AylienNewsApi
110
154
  end
111
155
 
112
156
  # @see the `==` method
113
- # @param [Object] Object to be compared
157
+ # @param [Object] Object to be compared
114
158
  def eql?(o)
115
159
  self == o
116
160
  end
@@ -209,7 +253,7 @@ module AylienNewsApi
209
253
 
210
254
  # Outputs non-array value in the form of hash
211
255
  # For object, use to_hash. Otherwise, just return the value
212
- # @param [Object] value Any valid value
256
+ # @param [Object] value Any valid value
213
257
  # @return [Hash] Returns the value in the form of hash
214
258
  def _to_hash(value)
215
259
  if value.is_a?(Array)
@@ -226,4 +270,5 @@ module AylienNewsApi
226
270
  end
227
271
 
228
272
  end
273
+
229
274
  end
@@ -15,13 +15,15 @@
15
15
  require 'date'
16
16
 
17
17
  module AylienNewsApi
18
+
18
19
  class CategoryLinks
19
- # A URL points to the category
20
+ # A URL pointing to the category
20
21
  attr_accessor :_self
21
22
 
22
- # A URL points to the parent category
23
+ # A URL pointing to the parent category
23
24
  attr_accessor :parent
24
25
 
26
+
25
27
  # Attribute mapping from ruby-style variable name to JSON key.
26
28
  def self.attribute_map
27
29
  {
@@ -46,16 +48,31 @@ module AylienNewsApi
46
48
  # convert string to symbol for hash key
47
49
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
50
 
49
- if attributes[:'self']
51
+ if attributes.has_key?(:'self')
50
52
  self._self = attributes[:'self']
51
53
  end
52
- if attributes[:'parent']
54
+
55
+ if attributes.has_key?(:'parent')
53
56
  self.parent = attributes[:'parent']
54
57
  end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properies with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return true
55
72
  end
56
73
 
57
74
  # Checks equality by comparing each attribute.
58
- # @param [Object] Object to be compared
75
+ # @param [Object] Object to be compared
59
76
  def ==(o)
60
77
  return true if self.equal?(o)
61
78
  self.class == o.class &&
@@ -64,7 +81,7 @@ module AylienNewsApi
64
81
  end
65
82
 
66
83
  # @see the `==` method
67
- # @param [Object] Object to be compared
84
+ # @param [Object] Object to be compared
68
85
  def eql?(o)
69
86
  self == o
70
87
  end
@@ -163,7 +180,7 @@ module AylienNewsApi
163
180
 
164
181
  # Outputs non-array value in the form of hash
165
182
  # For object, use to_hash. Otherwise, just return the value
166
- # @param [Object] value Any valid value
183
+ # @param [Object] value Any valid value
167
184
  # @return [Hash] Returns the value in the form of hash
168
185
  def _to_hash(value)
169
186
  if value.is_a?(Array)
@@ -180,4 +197,5 @@ module AylienNewsApi
180
197
  end
181
198
 
182
199
  end
200
+
183
201
  end