aylien_news_api 0.2.0 → 4.0.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.
- checksums.yaml +5 -5
- data/Gemfile +7 -1
- data/README.md +36 -47
- data/Rakefile +10 -0
- data/aylien_news_api.gemspec +25 -32
- data/docs/Author.md +12 -1
- data/docs/Autocomplete.md +10 -0
- data/docs/Autocompletes.md +9 -0
- data/docs/Category.md +19 -3
- data/docs/CategoryLinks.md +11 -1
- data/docs/CategoryTaxonomy.md +16 -0
- data/docs/Cluster.md +29 -0
- data/docs/Clusters.md +21 -0
- data/docs/Coverages.md +16 -4
- data/docs/DefaultApi.md +1310 -576
- data/docs/Entities.md +11 -1
- data/docs/Entity.md +16 -3
- data/docs/EntityLinks.md +9 -0
- data/docs/Error.md +16 -2
- data/docs/ErrorLinks.md +9 -0
- data/docs/Errors.md +9 -0
- data/docs/HistogramInterval.md +10 -0
- data/docs/Histograms.md +20 -3
- data/docs/Location.md +13 -2
- data/docs/Media.md +19 -1
- data/docs/MediaFormat.md +16 -0
- data/docs/MediaType.md +16 -0
- data/docs/Rank.md +21 -0
- data/docs/Rankings.md +17 -0
- data/docs/RelatedStories.md +14 -3
- data/docs/RepresentativeStory.md +23 -0
- data/docs/Scope.md +15 -3
- data/docs/ScopeLevel.md +16 -0
- data/docs/Sentiment.md +11 -1
- data/docs/SentimentPolarity.md +16 -0
- data/docs/Sentiments.md +12 -2
- data/docs/ShareCount.md +10 -0
- data/docs/ShareCounts.md +12 -0
- data/docs/Source.md +27 -3
- data/docs/Stories.md +15 -2
- data/docs/Story.md +48 -16
- data/docs/StoryCluster.md +14 -1
- data/docs/StoryLinks.md +14 -1
- data/docs/StoryTranslation.md +19 -0
- data/docs/StoryTranslations.md +17 -0
- data/docs/StoryTranslationsEn.md +21 -0
- data/docs/Summary.md +9 -0
- data/docs/TimeSeries.md +11 -1
- data/docs/TimeSeriesList.md +15 -3
- data/docs/Trend.md +11 -1
- data/docs/Trends.md +15 -1
- data/git_push.sh +58 -0
- data/lib/aylien_news_api.rb +23 -14
- data/lib/aylien_news_api/api/default_api.rb +2755 -892
- data/lib/aylien_news_api/api_client.rb +141 -102
- data/lib/aylien_news_api/api_error.rb +37 -18
- data/lib/aylien_news_api/configuration.rb +94 -43
- data/lib/aylien_news_api/models/author.rb +69 -53
- data/lib/aylien_news_api/models/autocomplete.rb +55 -39
- data/lib/aylien_news_api/models/autocompletes.rb +54 -38
- data/lib/aylien_news_api/models/category.rb +88 -97
- data/lib/aylien_news_api/models/category_links.rb +66 -50
- data/lib/aylien_news_api/models/category_taxonomy.rb +36 -0
- data/lib/aylien_news_api/models/cluster.rb +265 -0
- data/lib/aylien_news_api/models/clusters.rb +229 -0
- data/lib/aylien_news_api/models/coverages.rb +79 -75
- data/lib/aylien_news_api/models/entities.rb +67 -51
- data/lib/aylien_news_api/models/entity.rb +100 -81
- data/lib/aylien_news_api/models/entity_links.rb +54 -38
- data/lib/aylien_news_api/models/error.rb +79 -63
- data/lib/aylien_news_api/models/error_links.rb +54 -38
- data/lib/aylien_news_api/models/errors.rb +54 -38
- data/lib/aylien_news_api/models/histogram_interval.rb +55 -39
- data/lib/aylien_news_api/models/histograms.rb +99 -63
- data/lib/aylien_news_api/models/location.rb +70 -54
- data/lib/aylien_news_api/models/media.rb +97 -76
- data/lib/aylien_news_api/models/media_format.rb +44 -0
- data/lib/aylien_news_api/models/media_type.rb +36 -0
- data/lib/aylien_news_api/models/rank.rb +227 -0
- data/lib/aylien_news_api/models/rankings.rb +208 -0
- data/lib/aylien_news_api/models/related_stories.rb +72 -68
- data/lib/aylien_news_api/models/representative_story.rb +237 -0
- data/lib/aylien_news_api/models/scope.rb +76 -94
- data/lib/aylien_news_api/models/scope_level.rb +37 -0
- data/lib/aylien_news_api/models/sentiment.rb +70 -84
- data/lib/aylien_news_api/models/sentiment_polarity.rb +37 -0
- data/lib/aylien_news_api/models/sentiments.rb +65 -51
- data/lib/aylien_news_api/models/share_count.rb +55 -39
- data/lib/aylien_news_api/models/share_counts.rb +57 -41
- data/lib/aylien_news_api/models/source.rb +129 -64
- data/lib/aylien_news_api/models/stories.rb +79 -55
- data/lib/aylien_news_api/models/story.rb +191 -161
- data/lib/aylien_news_api/models/story_cluster.rb +71 -55
- data/lib/aylien_news_api/models/story_links.rb +73 -47
- data/lib/aylien_news_api/models/story_translation.rb +217 -0
- data/lib/aylien_news_api/models/story_translations.rb +207 -0
- data/lib/aylien_news_api/models/story_translations_en.rb +227 -0
- data/lib/aylien_news_api/models/summary.rb +54 -38
- data/lib/aylien_news_api/models/time_series.rb +66 -50
- data/lib/aylien_news_api/models/time_series_list.rb +75 -59
- data/lib/aylien_news_api/models/trend.rb +66 -50
- data/lib/aylien_news_api/models/trends.rb +80 -44
- data/lib/aylien_news_api/version.rb +12 -14
- data/spec/api/default_api_spec.rb +620 -284
- data/spec/api_client_spec.rb +43 -161
- data/spec/configuration_spec.rb +22 -19
- data/spec/models/author_spec.rb +21 -34
- data/spec/models/autocomplete_spec.rb +17 -26
- data/spec/models/autocompletes_spec.rb +16 -21
- data/spec/models/category_links_spec.rb +19 -28
- data/spec/models/category_spec.rb +31 -50
- data/spec/models/category_taxonomy_spec.rb +35 -0
- data/spec/models/cluster_spec.rb +77 -0
- data/spec/models/clusters_spec.rb +53 -0
- data/spec/models/coverages_spec.rb +24 -45
- data/spec/models/entities_spec.rb +19 -28
- data/spec/models/entity_links_spec.rb +16 -21
- data/spec/models/entity_spec.rb +25 -46
- data/spec/models/error_links_spec.rb +16 -21
- data/spec/models/error_spec.rb +27 -52
- data/spec/models/errors_spec.rb +16 -21
- data/spec/models/histogram_interval_spec.rb +17 -26
- data/spec/models/histograms_spec.rb +36 -45
- data/spec/models/location_spec.rb +21 -34
- data/spec/models/media_format_spec.rb +35 -0
- data/spec/models/media_spec.rb +41 -26
- data/spec/models/media_type_spec.rb +35 -0
- data/spec/models/rank_spec.rb +53 -0
- data/spec/models/rankings_spec.rb +41 -0
- data/spec/models/related_stories_spec.rb +21 -38
- data/spec/models/representative_story_spec.rb +59 -0
- data/spec/models/scope_level_spec.rb +35 -0
- data/spec/models/scope_spec.rb +23 -40
- data/spec/models/sentiment_polarity_spec.rb +35 -0
- data/spec/models/sentiment_spec.rb +17 -26
- data/spec/models/sentiments_spec.rb +19 -28
- data/spec/models/share_count_spec.rb +17 -26
- data/spec/models/share_counts_spec.rb +19 -36
- data/spec/models/source_spec.rb +54 -49
- data/spec/models/stories_spec.rb +26 -33
- data/spec/models/story_cluster_spec.rb +23 -44
- data/spec/models/story_links_spec.rb +25 -32
- data/spec/models/story_spec.rb +65 -134
- data/spec/models/story_translation_spec.rb +47 -0
- data/spec/models/story_translations_en_spec.rb +53 -0
- data/spec/models/story_translations_spec.rb +41 -0
- data/spec/models/summary_spec.rb +16 -21
- data/spec/models/time_series_list_spec.rb +22 -39
- data/spec/models/time_series_spec.rb +19 -28
- data/spec/models/trend_spec.rb +19 -28
- data/spec/models/trends_spec.rb +30 -27
- data/spec/spec_helper.rb +11 -13
- metadata +95 -193
- data/Gemfile.lock +0 -65
- data/LICENSE +0 -13
@@ -1,23 +1,20 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
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
|
14
12
|
|
15
13
|
require 'date'
|
16
14
|
require 'json'
|
17
15
|
require 'logger'
|
18
16
|
require 'tempfile'
|
19
|
-
require '
|
20
|
-
require 'uri'
|
17
|
+
require 'faraday'
|
21
18
|
|
22
19
|
module AylienNewsApi
|
23
20
|
class ApiClient
|
@@ -30,12 +27,12 @@ module AylienNewsApi
|
|
30
27
|
attr_accessor :default_headers
|
31
28
|
|
32
29
|
# Initializes the ApiClient
|
33
|
-
# @option config [Configuration]
|
30
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
34
31
|
def initialize(config = Configuration.default)
|
35
32
|
@config = config
|
36
|
-
@user_agent = "
|
33
|
+
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
|
37
34
|
@default_headers = {
|
38
|
-
'Content-Type' =>
|
35
|
+
'Content-Type' => 'application/json',
|
39
36
|
'User-Agent' => @user_agent
|
40
37
|
}
|
41
38
|
end
|
@@ -46,21 +43,49 @@ module AylienNewsApi
|
|
46
43
|
|
47
44
|
# Call an API with given options.
|
48
45
|
#
|
49
|
-
# @return [Array<(Object,
|
46
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
50
47
|
# the data deserialized from response body (could be nil), response status code and response headers.
|
51
48
|
def call_api(http_method, path, opts = {})
|
52
|
-
|
53
|
-
|
49
|
+
ssl_options = {
|
50
|
+
:ca_file => @config.ssl_ca_file,
|
51
|
+
:verify => @config.ssl_verify,
|
52
|
+
:verify_mode => @config.ssl_verify_mode,
|
53
|
+
:client_cert => @config.ssl_client_cert,
|
54
|
+
:client_key => @config.ssl_client_key
|
55
|
+
}
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
+
connection = Faraday.new(:url => config.base_url, :ssl => ssl_options) do |conn|
|
58
|
+
conn.basic_auth(config.username, config.password)
|
59
|
+
if opts[:header_params]["Content-Type"] == "multipart/form-data"
|
60
|
+
conn.request :multipart
|
61
|
+
conn.request :url_encoded
|
62
|
+
end
|
63
|
+
conn.adapter(Faraday.default_adapter)
|
57
64
|
end
|
58
65
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
66
|
+
begin
|
67
|
+
response = connection.public_send(http_method.to_sym.downcase) do |req|
|
68
|
+
build_request(http_method, path, req, opts)
|
69
|
+
end
|
70
|
+
|
71
|
+
if @config.debugging
|
72
|
+
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
73
|
+
end
|
74
|
+
|
75
|
+
unless response.success?
|
76
|
+
if response.status == 0
|
77
|
+
# Errors from libcurl will be made visible here
|
78
|
+
fail ApiError.new(:code => 0,
|
79
|
+
:message => response.return_message)
|
80
|
+
else
|
81
|
+
fail ApiError.new(:code => response.status,
|
82
|
+
:response_headers => response.headers,
|
83
|
+
:response_body => response.body),
|
84
|
+
response.reason_phrase
|
85
|
+
end
|
86
|
+
end
|
87
|
+
rescue Faraday::TimeoutError
|
88
|
+
fail ApiError.new('Connection timed out')
|
64
89
|
end
|
65
90
|
|
66
91
|
if opts[:return_type]
|
@@ -68,7 +93,7 @@ module AylienNewsApi
|
|
68
93
|
else
|
69
94
|
data = nil
|
70
95
|
end
|
71
|
-
return data, response.
|
96
|
+
return data, response.status, response.headers
|
72
97
|
end
|
73
98
|
|
74
99
|
# Builds the HTTP request
|
@@ -80,7 +105,7 @@ module AylienNewsApi
|
|
80
105
|
# @option opts [Hash] :form_params Query parameters
|
81
106
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
82
107
|
# @return [Typhoeus::Request] A Typhoeus Request
|
83
|
-
def build_request(http_method, path, opts = {})
|
108
|
+
def build_request(http_method, path, request, opts = {})
|
84
109
|
url = build_request_url(path)
|
85
110
|
http_method = http_method.to_sym.downcase
|
86
111
|
|
@@ -96,14 +121,9 @@ module AylienNewsApi
|
|
96
121
|
:params => query_params,
|
97
122
|
:params_encoding => @config.params_encoding,
|
98
123
|
:timeout => @config.timeout,
|
99
|
-
:ssl_verifypeer => @config.verify_ssl,
|
100
|
-
:sslcert => @config.cert_file,
|
101
|
-
:sslkey => @config.key_file,
|
102
124
|
:verbose => @config.debugging
|
103
125
|
}
|
104
126
|
|
105
|
-
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
106
|
-
|
107
127
|
if [:post, :patch, :put, :delete].include?(http_method)
|
108
128
|
req_body = build_request_body(header_params, form_params, opts[:body])
|
109
129
|
req_opts.update :body => req_body
|
@@ -111,8 +131,44 @@ module AylienNewsApi
|
|
111
131
|
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
112
132
|
end
|
113
133
|
end
|
134
|
+
request.headers = header_params
|
135
|
+
request.body = req_body
|
136
|
+
request.url url
|
137
|
+
request.params = query_params
|
138
|
+
download_file(request) if opts[:return_type] == 'File'
|
139
|
+
request
|
140
|
+
end
|
114
141
|
|
115
|
-
|
142
|
+
# Builds the HTTP request body
|
143
|
+
#
|
144
|
+
# @param [Hash] header_params Header parameters
|
145
|
+
# @param [Hash] form_params Query parameters
|
146
|
+
# @param [Object] body HTTP body (JSON/XML)
|
147
|
+
# @return [String] HTTP body data in the form of string
|
148
|
+
def build_request_body(header_params, form_params, body)
|
149
|
+
# http form
|
150
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
151
|
+
data = URI.encode_www_form(form_params)
|
152
|
+
elsif header_params['Content-Type'] == 'multipart/form-data'
|
153
|
+
data = {}
|
154
|
+
form_params.each do |key, value|
|
155
|
+
case value
|
156
|
+
when ::File, ::Tempfile
|
157
|
+
# TODO hardcode to application/octet-stream, need better way to detect content type
|
158
|
+
data[key] = Faraday::UploadIO.new(value.path, 'application/octet-stream', value.path)
|
159
|
+
when ::Array, nil
|
160
|
+
# let Faraday handle Array and nil parameters
|
161
|
+
data[key] = value
|
162
|
+
else
|
163
|
+
data[key] = value.to_s
|
164
|
+
end
|
165
|
+
end
|
166
|
+
elsif body
|
167
|
+
data = body.is_a?(String) ? body : body.to_json
|
168
|
+
else
|
169
|
+
data = nil
|
170
|
+
end
|
171
|
+
data
|
116
172
|
end
|
117
173
|
|
118
174
|
# Check if the given MIME is a JSON MIME.
|
@@ -120,26 +176,29 @@ module AylienNewsApi
|
|
120
176
|
# application/json
|
121
177
|
# application/json; charset=UTF8
|
122
178
|
# APPLICATION/JSON
|
179
|
+
# */*
|
123
180
|
# @param [String] mime MIME
|
124
|
-
# @return [Boolean] True if the MIME is
|
181
|
+
# @return [Boolean] True if the MIME is application/json
|
125
182
|
def json_mime?(mime)
|
126
|
-
|
183
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
127
184
|
end
|
128
185
|
|
129
186
|
# Deserialize the response to the given return type.
|
130
187
|
#
|
131
188
|
# @param [Response] response HTTP response
|
132
|
-
# @param [String] return_type some examples: "User", "Array
|
189
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
133
190
|
def deserialize(response, return_type)
|
134
191
|
body = response.body
|
192
|
+
|
193
|
+
# handle file downloading - return the File instance processed in request callbacks
|
194
|
+
# note that response body is empty when the file is written in chunks in request on_body callback
|
195
|
+
return @tempfile if return_type == 'File'
|
196
|
+
|
135
197
|
return nil if body.nil? || body.empty?
|
136
198
|
|
137
199
|
# return response body directly for String return type
|
138
200
|
return body if return_type == 'String'
|
139
201
|
|
140
|
-
# handle file downloading - save response body into a tmp file and return the File instance
|
141
|
-
return download_file(response) if return_type == 'File'
|
142
|
-
|
143
202
|
# ensuring a default content type
|
144
203
|
content_type = response.headers['Content-Type'] || 'application/json'
|
145
204
|
|
@@ -171,7 +230,7 @@ module AylienNewsApi
|
|
171
230
|
data.to_i
|
172
231
|
when 'Float'
|
173
232
|
data.to_f
|
174
|
-
when '
|
233
|
+
when 'Boolean'
|
175
234
|
data == true
|
176
235
|
when 'DateTime'
|
177
236
|
# parse date time (expecting ISO 8601 format)
|
@@ -185,47 +244,55 @@ module AylienNewsApi
|
|
185
244
|
when /\AArray<(.+)>\z/
|
186
245
|
# e.g. Array<Pet>
|
187
246
|
sub_type = $1
|
188
|
-
data.map {|item| convert_to_type(item, sub_type) }
|
247
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
189
248
|
when /\AHash\<String, (.+)\>\z/
|
190
249
|
# e.g. Hash<String, Integer>
|
191
250
|
sub_type = $1
|
192
251
|
{}.tap do |hash|
|
193
|
-
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
252
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
194
253
|
end
|
195
254
|
else
|
196
255
|
# models, e.g. Pet
|
197
|
-
AylienNewsApi.const_get(return_type).
|
198
|
-
model.build_from_hash data
|
199
|
-
end
|
256
|
+
AylienNewsApi.const_get(return_type).build_from_hash(data)
|
200
257
|
end
|
201
258
|
end
|
202
259
|
|
203
260
|
# Save response body into a file in (the defined) temporary folder, using the filename
|
204
261
|
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
262
|
+
# The response body is written to the file in chunks in order to handle files which
|
263
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
264
|
+
# process can use.
|
205
265
|
#
|
206
266
|
# @see Configuration#temp_folder_path
|
207
|
-
|
208
|
-
def download_file(response)
|
209
|
-
content_disposition = response.headers['Content-Disposition']
|
210
|
-
if content_disposition and content_disposition =~ /filename=/i
|
211
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
212
|
-
prefix = sanitize_filename(filename)
|
213
|
-
else
|
214
|
-
prefix = 'download-'
|
215
|
-
end
|
216
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
217
|
-
|
267
|
+
def download_file(request)
|
218
268
|
tempfile = nil
|
219
|
-
encoding =
|
220
|
-
|
221
|
-
|
222
|
-
|
269
|
+
encoding = nil
|
270
|
+
request.on_headers do |response|
|
271
|
+
content_disposition = response.headers['Content-Disposition']
|
272
|
+
if content_disposition && content_disposition =~ /filename=/i
|
273
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
274
|
+
prefix = sanitize_filename(filename)
|
275
|
+
else
|
276
|
+
prefix = 'download-'
|
277
|
+
end
|
278
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
279
|
+
encoding = response.body.encoding
|
280
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
281
|
+
@tempfile = tempfile
|
282
|
+
end
|
283
|
+
request.on_body do |chunk|
|
284
|
+
chunk.force_encoding(encoding)
|
285
|
+
tempfile.write(chunk)
|
286
|
+
end
|
287
|
+
request.on_complete do |response|
|
288
|
+
if tempfile
|
289
|
+
tempfile.close
|
290
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
291
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
292
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
293
|
+
"explicitly with `tempfile.delete`"
|
294
|
+
end
|
223
295
|
end
|
224
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
225
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
226
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
227
|
-
"explicitly with `tempfile.delete`"
|
228
|
-
tempfile
|
229
296
|
end
|
230
297
|
|
231
298
|
# Sanitize filename by removing path.
|
@@ -240,41 +307,13 @@ module AylienNewsApi
|
|
240
307
|
def build_request_url(path)
|
241
308
|
# Add leading and trailing slashes to path
|
242
309
|
path = "/#{path}".gsub(/\/+/, '/')
|
243
|
-
|
244
|
-
end
|
245
|
-
|
246
|
-
# Builds the HTTP request body
|
247
|
-
#
|
248
|
-
# @param [Hash] header_params Header parameters
|
249
|
-
# @param [Hash] form_params Query parameters
|
250
|
-
# @param [Object] body HTTP body (JSON/XML)
|
251
|
-
# @return [String] HTTP body data in the form of string
|
252
|
-
def build_request_body(header_params, form_params, body)
|
253
|
-
# http form
|
254
|
-
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
255
|
-
header_params['Content-Type'] == 'multipart/form-data'
|
256
|
-
data = {}
|
257
|
-
form_params.each do |key, value|
|
258
|
-
case value
|
259
|
-
when File, Array, nil
|
260
|
-
# let typhoeus handle File, Array and nil parameters
|
261
|
-
data[key] = value
|
262
|
-
else
|
263
|
-
data[key] = value.to_s
|
264
|
-
end
|
265
|
-
end
|
266
|
-
elsif body
|
267
|
-
data = body.is_a?(String) ? body : body.to_json
|
268
|
-
else
|
269
|
-
data = nil
|
270
|
-
end
|
271
|
-
data
|
310
|
+
@config.base_url + path
|
272
311
|
end
|
273
312
|
|
274
313
|
# Update hearder and query params based on authentication settings.
|
275
314
|
#
|
276
315
|
# @param [Hash] header_params Header parameters
|
277
|
-
# @param [Hash]
|
316
|
+
# @param [Hash] query_params Query parameters
|
278
317
|
# @param [String] auth_names Authentication scheme name
|
279
318
|
def update_params_for_auth!(header_params, query_params, auth_names)
|
280
319
|
Array(auth_names).each do |auth_name|
|
@@ -290,7 +329,7 @@ module AylienNewsApi
|
|
290
329
|
|
291
330
|
# Sets user agent in HTTP header
|
292
331
|
#
|
293
|
-
# @param [String] user_agent User agent
|
332
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
294
333
|
def user_agent=(user_agent)
|
295
334
|
@user_agent = user_agent
|
296
335
|
@default_headers['User-Agent'] = @user_agent
|
@@ -303,7 +342,7 @@ module AylienNewsApi
|
|
303
342
|
return nil if accepts.nil? || accepts.empty?
|
304
343
|
# use JSON when present, otherwise use all of the provided
|
305
344
|
json_accept = accepts.find { |s| json_mime?(s) }
|
306
|
-
|
345
|
+
json_accept || accepts.join(',')
|
307
346
|
end
|
308
347
|
|
309
348
|
# Return Content-Type header based on an array of content types provided.
|
@@ -314,7 +353,7 @@ module AylienNewsApi
|
|
314
353
|
return 'application/json' if content_types.nil? || content_types.empty?
|
315
354
|
# use JSON when present, otherwise use the first one
|
316
355
|
json_content_type = content_types.find { |s| json_mime?(s) }
|
317
|
-
|
356
|
+
json_content_type || content_types.first
|
318
357
|
end
|
319
358
|
|
320
359
|
# Convert object (array, hash, object, etc) to JSON string.
|
@@ -324,7 +363,7 @@ module AylienNewsApi
|
|
324
363
|
return model if model.nil? || model.is_a?(String)
|
325
364
|
local_body = nil
|
326
365
|
if model.is_a?(Array)
|
327
|
-
local_body = model.map{|m| object_to_hash(m) }
|
366
|
+
local_body = model.map { |m| object_to_hash(m) }
|
328
367
|
else
|
329
368
|
local_body = object_to_hash(model)
|
330
369
|
end
|
@@ -1,16 +1,14 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
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
|
14
12
|
|
15
13
|
module AylienNewsApi
|
16
14
|
class ApiError < StandardError
|
@@ -23,16 +21,37 @@ module AylienNewsApi
|
|
23
21
|
# ApiError.new(:code => 404, :message => "Not Found")
|
24
22
|
def initialize(arg = nil)
|
25
23
|
if arg.is_a? Hash
|
24
|
+
if arg.key?(:message) || arg.key?('message')
|
25
|
+
super(arg[:message] || arg['message'])
|
26
|
+
else
|
27
|
+
super arg
|
28
|
+
end
|
29
|
+
|
26
30
|
arg.each do |k, v|
|
27
|
-
|
28
|
-
super v
|
29
|
-
else
|
30
|
-
instance_variable_set "@#{k}", v
|
31
|
-
end
|
31
|
+
instance_variable_set "@#{k}", v
|
32
32
|
end
|
33
33
|
else
|
34
34
|
super arg
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
# Override to_s to display a friendly error message
|
39
|
+
def to_s
|
40
|
+
message
|
41
|
+
end
|
42
|
+
|
43
|
+
def message
|
44
|
+
if @message.nil?
|
45
|
+
msg = "Error message: the server returns an error"
|
46
|
+
else
|
47
|
+
msg = @message
|
48
|
+
end
|
49
|
+
|
50
|
+
msg += "\nHTTP status code: #{code}" if code
|
51
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
52
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
53
|
+
|
54
|
+
msg
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|