forestvpn_cloud_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +139 -0
- data/Rakefile +10 -0
- data/docs/Action.md +32 -0
- data/docs/Activity.md +36 -0
- data/docs/Address.md +28 -0
- data/docs/Billing.md +24 -0
- data/docs/Country.md +26 -0
- data/docs/CreateBillingRequest.md +22 -0
- data/docs/CreateOrUpdateDataUsageLimitRequest.md +20 -0
- data/docs/CreateOrUpdatePaymentProfileRequest.md +34 -0
- data/docs/CreateOrUpdateProfileRequest.md +22 -0
- data/docs/DataUsageLimit.md +24 -0
- data/docs/Error.md +20 -0
- data/docs/GeoApi.md +77 -0
- data/docs/LimitsApi.md +447 -0
- data/docs/Location.md +28 -0
- data/docs/PaymentMethod.md +24 -0
- data/docs/PaymentProfile.md +32 -0
- data/docs/Profile.md +26 -0
- data/docs/ProfileStats.md +26 -0
- data/docs/ProfilesApi.md +996 -0
- data/docs/Project.md +22 -0
- data/docs/ResourceRef.md +20 -0
- data/docs/User.md +32 -0
- data/forestvpn_cloud_api.gemspec +39 -0
- data/git_push.sh +57 -0
- data/lib/forestvpn_cloud_api/api/geo_api.rb +77 -0
- data/lib/forestvpn_cloud_api/api/limits_api.rb +405 -0
- data/lib/forestvpn_cloud_api/api/profiles_api.rb +915 -0
- data/lib/forestvpn_cloud_api/api_client.rb +426 -0
- data/lib/forestvpn_cloud_api/api_error.rb +57 -0
- data/lib/forestvpn_cloud_api/configuration.rb +335 -0
- data/lib/forestvpn_cloud_api/models/action.rb +348 -0
- data/lib/forestvpn_cloud_api/models/activity.rb +360 -0
- data/lib/forestvpn_cloud_api/models/address.rb +269 -0
- data/lib/forestvpn_cloud_api/models/billing.rb +266 -0
- data/lib/forestvpn_cloud_api/models/country.rb +282 -0
- data/lib/forestvpn_cloud_api/models/create_billing_request.rb +252 -0
- data/lib/forestvpn_cloud_api/models/create_or_update_data_usage_limit_request.rb +230 -0
- data/lib/forestvpn_cloud_api/models/create_or_update_payment_profile_request.rb +328 -0
- data/lib/forestvpn_cloud_api/models/create_or_update_profile_request.rb +275 -0
- data/lib/forestvpn_cloud_api/models/data_usage_limit.rb +302 -0
- data/lib/forestvpn_cloud_api/models/error.rb +238 -0
- data/lib/forestvpn_cloud_api/models/location.rb +296 -0
- data/lib/forestvpn_cloud_api/models/payment_method.rb +261 -0
- data/lib/forestvpn_cloud_api/models/payment_profile.rb +313 -0
- data/lib/forestvpn_cloud_api/models/profile.rb +320 -0
- data/lib/forestvpn_cloud_api/models/profile_stats.rb +280 -0
- data/lib/forestvpn_cloud_api/models/project.rb +254 -0
- data/lib/forestvpn_cloud_api/models/resource_ref.rb +238 -0
- data/lib/forestvpn_cloud_api/models/user.rb +307 -0
- data/lib/forestvpn_cloud_api/version.rb +15 -0
- data/lib/forestvpn_cloud_api.rb +61 -0
- data/spec/api/geo_api_spec.rb +45 -0
- data/spec/api/limits_api_spec.rb +102 -0
- data/spec/api/profiles_api_spec.rb +195 -0
- data/spec/api_client_spec.rb +188 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/action_spec.rb +80 -0
- data/spec/models/activity_spec.rb +92 -0
- data/spec/models/address_spec.rb +64 -0
- data/spec/models/billing_spec.rb +52 -0
- data/spec/models/country_spec.rb +58 -0
- data/spec/models/create_billing_request_spec.rb +46 -0
- data/spec/models/create_or_update_data_usage_limit_request_spec.rb +40 -0
- data/spec/models/create_or_update_payment_profile_request_spec.rb +82 -0
- data/spec/models/create_or_update_profile_request_spec.rb +50 -0
- data/spec/models/data_usage_limit_spec.rb +56 -0
- data/spec/models/error_spec.rb +40 -0
- data/spec/models/location_spec.rb +64 -0
- data/spec/models/payment_method_spec.rb +52 -0
- data/spec/models/payment_profile_spec.rb +76 -0
- data/spec/models/profile_spec.rb +62 -0
- data/spec/models/profile_stats_spec.rb +58 -0
- data/spec/models/project_spec.rb +46 -0
- data/spec/models/resource_ref_spec.rb +40 -0
- data/spec/models/user_spec.rb +76 -0
- data/spec/spec_helper.rb +111 -0
- metadata +203 -0
@@ -0,0 +1,426 @@
|
|
1
|
+
=begin
|
2
|
+
#ForestVPN Cloud API
|
3
|
+
|
4
|
+
#ForestVPN Cloud - it's a Google Cloud but for VPN apps. Ready to use VPN Cloud Platform minimizes efforts to build fast, secure, and modern VPN apps.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0
|
7
|
+
Contact: support@forestvpn.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'json'
|
15
|
+
require 'logger'
|
16
|
+
require 'tempfile'
|
17
|
+
require 'time'
|
18
|
+
require 'faraday'
|
19
|
+
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
20
|
+
|
21
|
+
module ForestVPNCloudAPI
|
22
|
+
class ApiClient
|
23
|
+
# The Configuration object holding settings to be used in the API client.
|
24
|
+
attr_accessor :config
|
25
|
+
|
26
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
27
|
+
#
|
28
|
+
# @return [Hash]
|
29
|
+
attr_accessor :default_headers
|
30
|
+
|
31
|
+
# Initializes the ApiClient
|
32
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
33
|
+
def initialize(config = Configuration.default)
|
34
|
+
@config = config
|
35
|
+
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
|
36
|
+
@default_headers = {
|
37
|
+
'Content-Type' => 'application/json',
|
38
|
+
'User-Agent' => @user_agent
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.default
|
43
|
+
@@default ||= ApiClient.new
|
44
|
+
end
|
45
|
+
|
46
|
+
# Call an API with given options.
|
47
|
+
#
|
48
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
49
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
50
|
+
def call_api(http_method, path, opts = {})
|
51
|
+
begin
|
52
|
+
response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
|
53
|
+
build_request(http_method, path, req, opts)
|
54
|
+
end
|
55
|
+
|
56
|
+
if config.debugging
|
57
|
+
config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
58
|
+
end
|
59
|
+
|
60
|
+
unless response.success?
|
61
|
+
if response.status == 0
|
62
|
+
# Errors from libcurl will be made visible here
|
63
|
+
fail ApiError.new(code: 0,
|
64
|
+
message: response.return_message)
|
65
|
+
else
|
66
|
+
fail ApiError.new(code: response.status,
|
67
|
+
response_headers: response.headers,
|
68
|
+
response_body: response.body),
|
69
|
+
response.reason_phrase
|
70
|
+
end
|
71
|
+
end
|
72
|
+
rescue Faraday::TimeoutError
|
73
|
+
fail ApiError.new('Connection timed out')
|
74
|
+
end
|
75
|
+
|
76
|
+
if opts[:return_type]
|
77
|
+
data = deserialize(response, opts[:return_type])
|
78
|
+
else
|
79
|
+
data = nil
|
80
|
+
end
|
81
|
+
return data, response.status, response.headers
|
82
|
+
end
|
83
|
+
|
84
|
+
# Builds the HTTP request
|
85
|
+
#
|
86
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
87
|
+
# @param [String] path URL path (e.g. /account/new)
|
88
|
+
# @option opts [Hash] :header_params Header parameters
|
89
|
+
# @option opts [Hash] :query_params Query parameters
|
90
|
+
# @option opts [Hash] :form_params Query parameters
|
91
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
92
|
+
# @return [Faraday::Request] A Faraday Request
|
93
|
+
def build_request(http_method, path, request, opts = {})
|
94
|
+
url = build_request_url(path, opts)
|
95
|
+
http_method = http_method.to_sym.downcase
|
96
|
+
|
97
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
98
|
+
query_params = opts[:query_params] || {}
|
99
|
+
form_params = opts[:form_params] || {}
|
100
|
+
|
101
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
102
|
+
|
103
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
104
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
105
|
+
if config.debugging
|
106
|
+
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
request.headers = header_params
|
110
|
+
request.body = req_body
|
111
|
+
|
112
|
+
# Overload default options only if provided
|
113
|
+
request.options.params_encoder = config.params_encoder if config.params_encoder
|
114
|
+
request.options.timeout = config.timeout if config.timeout
|
115
|
+
request.options.verbose = config.debugging if config.debugging
|
116
|
+
|
117
|
+
request.url url
|
118
|
+
request.params = query_params
|
119
|
+
download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
120
|
+
request
|
121
|
+
end
|
122
|
+
|
123
|
+
# Builds the HTTP request body
|
124
|
+
#
|
125
|
+
# @param [Hash] header_params Header parameters
|
126
|
+
# @param [Hash] form_params Query parameters
|
127
|
+
# @param [Object] body HTTP body (JSON/XML)
|
128
|
+
# @return [String] HTTP body data in the form of string
|
129
|
+
def build_request_body(header_params, form_params, body)
|
130
|
+
# http form
|
131
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
132
|
+
data = URI.encode_www_form(form_params)
|
133
|
+
elsif header_params['Content-Type'] == 'multipart/form-data'
|
134
|
+
data = {}
|
135
|
+
form_params.each do |key, value|
|
136
|
+
case value
|
137
|
+
when ::File, ::Tempfile
|
138
|
+
# TODO hardcode to application/octet-stream, need better way to detect content type
|
139
|
+
data[key] = Faraday::UploadIO.new(value.path, 'application/octet-stream', value.path)
|
140
|
+
when ::Array, nil
|
141
|
+
# let Faraday handle Array and nil parameters
|
142
|
+
data[key] = value
|
143
|
+
else
|
144
|
+
data[key] = value.to_s
|
145
|
+
end
|
146
|
+
end
|
147
|
+
elsif body
|
148
|
+
data = body.is_a?(String) ? body : body.to_json
|
149
|
+
else
|
150
|
+
data = nil
|
151
|
+
end
|
152
|
+
data
|
153
|
+
end
|
154
|
+
|
155
|
+
def download_file(request)
|
156
|
+
@stream = []
|
157
|
+
|
158
|
+
# handle streaming Responses
|
159
|
+
request.options.on_data = Proc.new do |chunk, overall_received_bytes|
|
160
|
+
@stream << chunk
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def connection(opts)
|
165
|
+
opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
|
166
|
+
end
|
167
|
+
|
168
|
+
def connection_multipart
|
169
|
+
@connection_multipart ||= build_connection do |conn|
|
170
|
+
conn.request :multipart
|
171
|
+
conn.request :url_encoded
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def connection_regular
|
176
|
+
@connection_regular ||= build_connection
|
177
|
+
end
|
178
|
+
|
179
|
+
def build_connection
|
180
|
+
Faraday.new(url: config.base_url, ssl: ssl_options) do |conn|
|
181
|
+
basic_auth(conn)
|
182
|
+
config.configure_middleware(conn)
|
183
|
+
yield(conn) if block_given?
|
184
|
+
conn.adapter(Faraday.default_adapter)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def ssl_options
|
189
|
+
{
|
190
|
+
ca_file: config.ssl_ca_file,
|
191
|
+
verify: config.ssl_verify,
|
192
|
+
verify_mode: config.ssl_verify_mode,
|
193
|
+
client_cert: config.ssl_client_cert,
|
194
|
+
client_key: config.ssl_client_key
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
def basic_auth(conn)
|
199
|
+
if config.username && config.password
|
200
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
201
|
+
conn.request(:authorization, :basic, config.username, config.password)
|
202
|
+
else
|
203
|
+
conn.request(:basic_auth, config.username, config.password)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# Check if the given MIME is a JSON MIME.
|
209
|
+
# JSON MIME examples:
|
210
|
+
# application/json
|
211
|
+
# application/json; charset=UTF8
|
212
|
+
# APPLICATION/JSON
|
213
|
+
# */*
|
214
|
+
# @param [String] mime MIME
|
215
|
+
# @return [Boolean] True if the MIME is application/json
|
216
|
+
def json_mime?(mime)
|
217
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
218
|
+
end
|
219
|
+
|
220
|
+
# Deserialize the response to the given return type.
|
221
|
+
#
|
222
|
+
# @param [Response] response HTTP response
|
223
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
224
|
+
def deserialize(response, return_type)
|
225
|
+
body = response.body
|
226
|
+
|
227
|
+
# handle file downloading - return the File instance processed in request callbacks
|
228
|
+
# note that response body is empty when the file is written in chunks in request on_body callback
|
229
|
+
if return_type == 'File'
|
230
|
+
if @config.return_binary_data == true
|
231
|
+
# return byte stream
|
232
|
+
encoding = body.encoding
|
233
|
+
return @stream.join.force_encoding(encoding)
|
234
|
+
else
|
235
|
+
# return file instead of binary data
|
236
|
+
content_disposition = response.headers['Content-Disposition']
|
237
|
+
if content_disposition && content_disposition =~ /filename=/i
|
238
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
239
|
+
prefix = sanitize_filename(filename)
|
240
|
+
else
|
241
|
+
prefix = 'download-'
|
242
|
+
end
|
243
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
244
|
+
encoding = body.encoding
|
245
|
+
@tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
246
|
+
@tempfile.write(@stream.join.force_encoding(encoding))
|
247
|
+
@tempfile.close
|
248
|
+
@config.logger.info "Temp file written to #{@tempfile.path}, please copy the file to a proper folder "\
|
249
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
250
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
251
|
+
"explicitly with `tempfile.delete`"
|
252
|
+
return @tempfile
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
return nil if body.nil? || body.empty?
|
257
|
+
|
258
|
+
# return response body directly for String return type
|
259
|
+
return body if return_type == 'String'
|
260
|
+
|
261
|
+
# ensuring a default content type
|
262
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
263
|
+
|
264
|
+
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
265
|
+
|
266
|
+
begin
|
267
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
268
|
+
rescue JSON::ParserError => e
|
269
|
+
if %w(String Date Time).include?(return_type)
|
270
|
+
data = body
|
271
|
+
else
|
272
|
+
raise e
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
convert_to_type data, return_type
|
277
|
+
end
|
278
|
+
|
279
|
+
# Convert data to the given return type.
|
280
|
+
# @param [Object] data Data to be converted
|
281
|
+
# @param [String] return_type Return type
|
282
|
+
# @return [Mixed] Data in a particular type
|
283
|
+
def convert_to_type(data, return_type)
|
284
|
+
return nil if data.nil?
|
285
|
+
case return_type
|
286
|
+
when 'String'
|
287
|
+
data.to_s
|
288
|
+
when 'Integer'
|
289
|
+
data.to_i
|
290
|
+
when 'Float'
|
291
|
+
data.to_f
|
292
|
+
when 'Boolean'
|
293
|
+
data == true
|
294
|
+
when 'Time'
|
295
|
+
# parse date time (expecting ISO 8601 format)
|
296
|
+
Time.parse data
|
297
|
+
when 'Date'
|
298
|
+
# parse date time (expecting ISO 8601 format)
|
299
|
+
Date.parse data
|
300
|
+
when 'Object'
|
301
|
+
# generic object (usually a Hash), return directly
|
302
|
+
data
|
303
|
+
when /\AArray<(.+)>\z/
|
304
|
+
# e.g. Array<Pet>
|
305
|
+
sub_type = $1
|
306
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
307
|
+
when /\AHash\<String, (.+)\>\z/
|
308
|
+
# e.g. Hash<String, Integer>
|
309
|
+
sub_type = $1
|
310
|
+
{}.tap do |hash|
|
311
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
312
|
+
end
|
313
|
+
else
|
314
|
+
# models (e.g. Pet) or oneOf
|
315
|
+
klass = ForestVPNCloudAPI.const_get(return_type)
|
316
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
# Sanitize filename by removing path.
|
321
|
+
# e.g. ../../sun.gif becomes sun.gif
|
322
|
+
#
|
323
|
+
# @param [String] filename the filename to be sanitized
|
324
|
+
# @return [String] the sanitized filename
|
325
|
+
def sanitize_filename(filename)
|
326
|
+
filename.gsub(/.*[\/\\]/, '')
|
327
|
+
end
|
328
|
+
|
329
|
+
def build_request_url(path, opts = {})
|
330
|
+
# Add leading and trailing slashes to path
|
331
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
332
|
+
@config.base_url(opts[:operation]) + path
|
333
|
+
end
|
334
|
+
|
335
|
+
# Update header and query params based on authentication settings.
|
336
|
+
#
|
337
|
+
# @param [Hash] header_params Header parameters
|
338
|
+
# @param [Hash] query_params Query parameters
|
339
|
+
# @param [String] auth_names Authentication scheme name
|
340
|
+
def update_params_for_auth!(header_params, query_params, auth_names)
|
341
|
+
Array(auth_names).each do |auth_name|
|
342
|
+
auth_setting = @config.auth_settings[auth_name]
|
343
|
+
next unless auth_setting
|
344
|
+
case auth_setting[:in]
|
345
|
+
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
346
|
+
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
347
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
# Sets user agent in HTTP header
|
353
|
+
#
|
354
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
355
|
+
def user_agent=(user_agent)
|
356
|
+
@user_agent = user_agent
|
357
|
+
@default_headers['User-Agent'] = @user_agent
|
358
|
+
end
|
359
|
+
|
360
|
+
# Return Accept header based on an array of accepts provided.
|
361
|
+
# @param [Array] accepts array for Accept
|
362
|
+
# @return [String] the Accept header (e.g. application/json)
|
363
|
+
def select_header_accept(accepts)
|
364
|
+
return nil if accepts.nil? || accepts.empty?
|
365
|
+
# use JSON when present, otherwise use all of the provided
|
366
|
+
json_accept = accepts.find { |s| json_mime?(s) }
|
367
|
+
json_accept || accepts.join(',')
|
368
|
+
end
|
369
|
+
|
370
|
+
# Return Content-Type header based on an array of content types provided.
|
371
|
+
# @param [Array] content_types array for Content-Type
|
372
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
373
|
+
def select_header_content_type(content_types)
|
374
|
+
# return nil by default
|
375
|
+
return if content_types.nil? || content_types.empty?
|
376
|
+
# use JSON when present, otherwise use the first one
|
377
|
+
json_content_type = content_types.find { |s| json_mime?(s) }
|
378
|
+
json_content_type || content_types.first
|
379
|
+
end
|
380
|
+
|
381
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
382
|
+
# @param [Object] model object to be converted into JSON string
|
383
|
+
# @return [String] JSON string representation of the object
|
384
|
+
def object_to_http_body(model)
|
385
|
+
return model if model.nil? || model.is_a?(String)
|
386
|
+
local_body = nil
|
387
|
+
if model.is_a?(Array)
|
388
|
+
local_body = model.map { |m| object_to_hash(m) }
|
389
|
+
else
|
390
|
+
local_body = object_to_hash(model)
|
391
|
+
end
|
392
|
+
local_body.to_json
|
393
|
+
end
|
394
|
+
|
395
|
+
# Convert object(non-array) to hash.
|
396
|
+
# @param [Object] obj object to be converted into JSON string
|
397
|
+
# @return [String] JSON string representation of the object
|
398
|
+
def object_to_hash(obj)
|
399
|
+
if obj.respond_to?(:to_hash)
|
400
|
+
obj.to_hash
|
401
|
+
else
|
402
|
+
obj
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
# Build parameter value according to the given collection format.
|
407
|
+
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
408
|
+
def build_collection_param(param, collection_format)
|
409
|
+
case collection_format
|
410
|
+
when :csv
|
411
|
+
param.join(',')
|
412
|
+
when :ssv
|
413
|
+
param.join(' ')
|
414
|
+
when :tsv
|
415
|
+
param.join("\t")
|
416
|
+
when :pipes
|
417
|
+
param.join('|')
|
418
|
+
when :multi
|
419
|
+
# return the array directly as typhoeus will handle it as expected
|
420
|
+
param
|
421
|
+
else
|
422
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
=begin
|
2
|
+
#ForestVPN Cloud API
|
3
|
+
|
4
|
+
#ForestVPN Cloud - it's a Google Cloud but for VPN apps. Ready to use VPN Cloud Platform minimizes efforts to build fast, secure, and modern VPN apps.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0
|
7
|
+
Contact: support@forestvpn.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module ForestVPNCloudAPI
|
14
|
+
class ApiError < StandardError
|
15
|
+
attr_reader :code, :response_headers, :response_body
|
16
|
+
|
17
|
+
# Usage examples:
|
18
|
+
# ApiError.new
|
19
|
+
# ApiError.new("message")
|
20
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
21
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
22
|
+
def initialize(arg = nil)
|
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
|
+
|
30
|
+
arg.each do |k, v|
|
31
|
+
instance_variable_set "@#{k}", v
|
32
|
+
end
|
33
|
+
else
|
34
|
+
super arg
|
35
|
+
end
|
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
|
56
|
+
end
|
57
|
+
end
|