dyspatch_client 3.0.0 → 6.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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/README.md +45 -53
  4. data/Rakefile +2 -0
  5. data/docs/APIError.md +13 -2
  6. data/docs/CompiledRead.md +15 -0
  7. data/docs/Cursor.md +11 -1
  8. data/docs/DraftMetaRead.md +14 -1
  9. data/docs/DraftRead.md +17 -1
  10. data/docs/DraftsApi.md +140 -131
  11. data/docs/DraftsRead.md +12 -2
  12. data/docs/{Body.md → InlineObject.md} +10 -1
  13. data/docs/LocalizationKeyRead.md +10 -0
  14. data/docs/LocalizationMetaRead.md +15 -2
  15. data/docs/LocalizationRead.md +19 -1
  16. data/docs/LocalizationsApi.md +75 -13
  17. data/docs/TemplateMetaRead.md +16 -1
  18. data/docs/TemplateRead.md +17 -1
  19. data/docs/TemplatesApi.md +40 -36
  20. data/docs/TemplatesRead.md +11 -1
  21. data/dyspatch_client.gemspec +5 -11
  22. data/lib/dyspatch_client.rb +5 -20
  23. data/lib/dyspatch_client/api/drafts_api.rb +375 -234
  24. data/lib/dyspatch_client/api/localizations_api.rb +135 -31
  25. data/lib/dyspatch_client/api/templates_api.rb +99 -65
  26. data/lib/dyspatch_client/api_client.rb +46 -47
  27. data/lib/dyspatch_client/api_error.rb +23 -4
  28. data/lib/dyspatch_client/configuration.rb +48 -9
  29. data/lib/dyspatch_client/models/api_error.rb +46 -22
  30. data/lib/dyspatch_client/models/compiled_read.rb +56 -67
  31. data/lib/dyspatch_client/models/cursor.rb +43 -20
  32. data/lib/dyspatch_client/models/draft_meta_read.rb +49 -35
  33. data/lib/dyspatch_client/models/draft_read.rb +49 -25
  34. data/lib/dyspatch_client/models/drafts_read.rb +42 -19
  35. data/lib/dyspatch_client/models/{body.rb → inline_object.rb} +40 -17
  36. data/lib/dyspatch_client/models/localization_key_read.rb +41 -17
  37. data/lib/dyspatch_client/models/localization_meta_read.rb +62 -36
  38. data/lib/dyspatch_client/models/localization_read.rb +71 -35
  39. data/lib/dyspatch_client/models/template_meta_read.rb +48 -24
  40. data/lib/dyspatch_client/models/template_read.rb +49 -25
  41. data/lib/dyspatch_client/models/templates_read.rb +41 -17
  42. data/lib/dyspatch_client/version.rb +5 -5
  43. data/spec/api/drafts_api_spec.rb +61 -53
  44. data/spec/api/localizations_api_spec.rb +26 -10
  45. data/spec/api/templates_api_spec.rb +22 -20
  46. data/spec/api_client_spec.rb +5 -5
  47. data/spec/configuration_spec.rb +4 -4
  48. data/spec/spec_helper.rb +4 -4
  49. metadata +11 -219
  50. data/LICENSE +0 -202
  51. data/docs/Body1.md +0 -8
  52. data/docs/CreatedAt.md +0 -7
  53. data/docs/DraftDescription.md +0 -7
  54. data/docs/DraftId.md +0 -7
  55. data/docs/DraftName.md +0 -7
  56. data/docs/DraftUrl.md +0 -7
  57. data/docs/LanguageId.md +0 -7
  58. data/docs/LocalizationId.md +0 -7
  59. data/docs/LocalizationName.md +0 -7
  60. data/docs/LocalizationUrl.md +0 -7
  61. data/docs/TemplateDescription.md +0 -7
  62. data/docs/TemplateId.md +0 -7
  63. data/docs/TemplateName.md +0 -7
  64. data/docs/TemplateUrl.md +0 -7
  65. data/docs/UpdatedAt.md +0 -7
  66. data/git_push.sh +0 -55
  67. data/lib/dyspatch_client/models/body_1.rb +0 -183
  68. data/lib/dyspatch_client/models/created_at.rb +0 -175
  69. data/lib/dyspatch_client/models/draft_description.rb +0 -175
  70. data/lib/dyspatch_client/models/draft_id.rb +0 -175
  71. data/lib/dyspatch_client/models/draft_name.rb +0 -175
  72. data/lib/dyspatch_client/models/draft_url.rb +0 -175
  73. data/lib/dyspatch_client/models/language_id.rb +0 -175
  74. data/lib/dyspatch_client/models/localization_id.rb +0 -175
  75. data/lib/dyspatch_client/models/localization_name.rb +0 -175
  76. data/lib/dyspatch_client/models/localization_url.rb +0 -175
  77. data/lib/dyspatch_client/models/template_description.rb +0 -175
  78. data/lib/dyspatch_client/models/template_id.rb +0 -175
  79. data/lib/dyspatch_client/models/template_name.rb +0 -175
  80. data/lib/dyspatch_client/models/template_url.rb +0 -175
  81. data/lib/dyspatch_client/models/updated_at.rb +0 -175
  82. data/spec/models/api_error_spec.rb +0 -57
  83. data/spec/models/body_1_spec.rb +0 -41
  84. data/spec/models/body_spec.rb +0 -41
  85. data/spec/models/compiled_read_spec.rb +0 -65
  86. data/spec/models/created_at_spec.rb +0 -35
  87. data/spec/models/cursor_spec.rb +0 -47
  88. data/spec/models/draft_description_spec.rb +0 -35
  89. data/spec/models/draft_id_spec.rb +0 -35
  90. data/spec/models/draft_meta_read_spec.rb +0 -77
  91. data/spec/models/draft_name_spec.rb +0 -35
  92. data/spec/models/draft_read_spec.rb +0 -83
  93. data/spec/models/draft_url_spec.rb +0 -35
  94. data/spec/models/drafts_read_spec.rb +0 -47
  95. data/spec/models/language_id_spec.rb +0 -35
  96. data/spec/models/localization_id_spec.rb +0 -35
  97. data/spec/models/localization_key_read_spec.rb +0 -47
  98. data/spec/models/localization_meta_read_spec.rb +0 -65
  99. data/spec/models/localization_name_spec.rb +0 -35
  100. data/spec/models/localization_read_spec.rb +0 -83
  101. data/spec/models/localization_url_spec.rb +0 -35
  102. data/spec/models/template_description_spec.rb +0 -35
  103. data/spec/models/template_id_spec.rb +0 -35
  104. data/spec/models/template_meta_read_spec.rb +0 -77
  105. data/spec/models/template_name_spec.rb +0 -35
  106. data/spec/models/template_read_spec.rb +0 -83
  107. data/spec/models/template_url_spec.rb +0 -35
  108. data/spec/models/templates_read_spec.rb +0 -47
  109. data/spec/models/updated_at_spec.rb +0 -35
@@ -1,12 +1,12 @@
1
1
  =begin
2
2
  #Dyspatch API
3
3
 
4
- ## Introduction The Dyspatch API is based on the REST paradigm and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for the following languages and web frameworks: - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
5
5
 
6
- OpenAPI spec version: 2019.10
6
+ The version of the OpenAPI document: 2020.11
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.9
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -15,7 +15,6 @@ require 'json'
15
15
  require 'logger'
16
16
  require 'tempfile'
17
17
  require 'typhoeus'
18
- require 'uri'
19
18
 
20
19
  module DyspatchClient
21
20
  class ApiClient
@@ -31,7 +30,7 @@ module DyspatchClient
31
30
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
31
  def initialize(config = Configuration.default)
33
32
  @config = config
34
- @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
33
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
35
34
  @default_headers = {
36
35
  'Content-Type' => 'application/json',
37
36
  'User-Agent' => @user_agent
@@ -44,7 +43,7 @@ module DyspatchClient
44
43
 
45
44
  # Call an API with given options.
46
45
  #
47
- # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
46
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
48
47
  # the data deserialized from response body (could be nil), response status code and response headers.
49
48
  def call_api(http_method, path, opts = {})
50
49
  request = build_request(http_method, path, opts)
@@ -128,6 +127,34 @@ module DyspatchClient
128
127
  request
129
128
  end
130
129
 
130
+ # Builds the HTTP request body
131
+ #
132
+ # @param [Hash] header_params Header parameters
133
+ # @param [Hash] form_params Query parameters
134
+ # @param [Object] body HTTP body (JSON/XML)
135
+ # @return [String] HTTP body data in the form of string
136
+ def build_request_body(header_params, form_params, body)
137
+ # http form
138
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
139
+ header_params['Content-Type'] == 'multipart/form-data'
140
+ data = {}
141
+ form_params.each do |key, value|
142
+ case value
143
+ when ::File, ::Array, nil
144
+ # let typhoeus handle File, Array and nil parameters
145
+ data[key] = value
146
+ else
147
+ data[key] = value.to_s
148
+ end
149
+ end
150
+ elsif body
151
+ data = body.is_a?(String) ? body : body.to_json
152
+ else
153
+ data = nil
154
+ end
155
+ data
156
+ end
157
+
131
158
  # Check if the given MIME is a JSON MIME.
132
159
  # JSON MIME examples:
133
160
  # application/json
@@ -143,7 +170,7 @@ module DyspatchClient
143
170
  # Deserialize the response to the given return type.
144
171
  #
145
172
  # @param [Response] response HTTP response
146
- # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
173
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
147
174
  def deserialize(response, return_type)
148
175
  body = response.body
149
176
 
@@ -187,7 +214,7 @@ module DyspatchClient
187
214
  data.to_i
188
215
  when 'Float'
189
216
  data.to_f
190
- when 'BOOLEAN'
217
+ when 'Boolean'
191
218
  data == true
192
219
  when 'DateTime'
193
220
  # parse date time (expecting ISO 8601 format)
@@ -210,9 +237,7 @@ module DyspatchClient
210
237
  end
211
238
  else
212
239
  # models, e.g. Pet
213
- DyspatchClient.const_get(return_type).new.tap do |model|
214
- model.build_from_hash data
215
- end
240
+ DyspatchClient.const_get(return_type).build_from_hash(data)
216
241
  end
217
242
  end
218
243
 
@@ -244,11 +269,13 @@ module DyspatchClient
244
269
  tempfile.write(chunk)
245
270
  end
246
271
  request.on_complete do |response|
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`"
272
+ if tempfile
273
+ tempfile.close
274
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
+ "explicitly with `tempfile.delete`"
278
+ end
252
279
  end
253
280
  end
254
281
 
@@ -264,35 +291,7 @@ module DyspatchClient
264
291
  def build_request_url(path)
265
292
  # Add leading and trailing slashes to path
266
293
  path = "/#{path}".gsub(/\/+/, '/')
267
- URI.encode(@config.base_url + path)
268
- end
269
-
270
- # Builds the HTTP request body
271
- #
272
- # @param [Hash] header_params Header parameters
273
- # @param [Hash] form_params Query parameters
274
- # @param [Object] body HTTP body (JSON/XML)
275
- # @return [String] HTTP body data in the form of string
276
- def build_request_body(header_params, form_params, body)
277
- # http form
278
- if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
279
- header_params['Content-Type'] == 'multipart/form-data'
280
- data = {}
281
- form_params.each do |key, value|
282
- case value
283
- when ::File, ::Array, nil
284
- # let typhoeus handle File, Array and nil parameters
285
- data[key] = value
286
- else
287
- data[key] = value.to_s
288
- end
289
- end
290
- elsif body
291
- data = body.is_a?(String) ? body : body.to_json
292
- else
293
- data = nil
294
- end
295
- data
294
+ @config.base_url + path
296
295
  end
297
296
 
298
297
  # Update hearder and query params based on authentication settings.
@@ -314,7 +313,7 @@ module DyspatchClient
314
313
 
315
314
  # Sets user agent in HTTP header
316
315
  #
317
- # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
316
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
318
317
  def user_agent=(user_agent)
319
318
  @user_agent = user_agent
320
319
  @default_headers['User-Agent'] = @user_agent
@@ -1,12 +1,12 @@
1
1
  =begin
2
2
  #Dyspatch API
3
3
 
4
- ## Introduction The Dyspatch API is based on the REST paradigm and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for the following languages and web frameworks: - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
5
5
 
6
- OpenAPI spec version: 2019.10
6
+ The version of the OpenAPI document: 2020.11
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.9
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -34,5 +34,24 @@ module DyspatchClient
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
@@ -1,17 +1,15 @@
1
1
  =begin
2
2
  #Dyspatch API
3
3
 
4
- ## Introduction The Dyspatch API is based on the REST paradigm and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for the following languages and web frameworks: - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
5
5
 
6
- OpenAPI spec version: 2019.10
6
+ The version of the OpenAPI document: 2020.11
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.9
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
13
- require 'uri'
14
-
15
13
  module DyspatchClient
16
14
  class Configuration
17
15
  # Defines url scheme
@@ -130,7 +128,7 @@ module DyspatchClient
130
128
  def initialize
131
129
  @scheme = 'https'
132
130
  @host = 'api.dyspatch.io'
133
- @base_path = '/'
131
+ @base_path = ''
134
132
  @api_key = {}
135
133
  @api_key_prefix = {}
136
134
  @timeout = 0
@@ -174,8 +172,7 @@ module DyspatchClient
174
172
  end
175
173
 
176
174
  def base_url
177
- url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
178
- URI.encode(url)
175
+ "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
179
176
  end
180
177
 
181
178
  # Gets API key (with prefix if set).
@@ -205,5 +202,47 @@ module DyspatchClient
205
202
  },
206
203
  }
207
204
  end
205
+
206
+ # Returns an array of Server setting
207
+ def server_settings
208
+ [
209
+ {
210
+ url: "https://api.dyspatch.io",
211
+ description: "No description provided",
212
+ }
213
+ ]
214
+ end
215
+
216
+ # Returns URL based on server settings
217
+ #
218
+ # @param index array index of the server settings
219
+ # @param variables hash of variable and the corresponding value
220
+ def server_url(index, variables = {})
221
+ servers = server_settings
222
+
223
+ # check array index out of bound
224
+ if (index < 0 || index >= servers.size)
225
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
226
+ end
227
+
228
+ server = servers[index]
229
+ url = server[:url]
230
+
231
+ # go through variable and assign a value
232
+ server[:variables].each do |name, variable|
233
+ if variables.key?(name)
234
+ if (server[:variables][name][:enum_values].include? variables[name])
235
+ url.gsub! "{" + name.to_s + "}", variables[name]
236
+ else
237
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
238
+ end
239
+ else
240
+ # use default value
241
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
242
+ end
243
+ end
244
+
245
+ url
246
+ end
208
247
  end
209
248
  end
@@ -1,20 +1,21 @@
1
1
  =begin
2
2
  #Dyspatch API
3
3
 
4
- ## Introduction The Dyspatch API is based on the REST paradigm and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for the following languages and web frameworks: - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
5
5
 
6
- OpenAPI spec version: 2019.10
6
+ The version of the OpenAPI document: 2020.11
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.9
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
14
 
15
15
  module DyspatchClient
16
+ # possible errors from the api
16
17
  class APIError
17
- # Error code: * server_error - Internal server error. * invalid_parameter - Validation error, parameter will contain invalid field and message will contain the reason. * invalid_body - Body could not be parsed, message will contain the reason. * invalid_request - Validation error, the protocol used to make the request was not https. * unauthorized - Credentials were found but permissions were not sufficient. * unauthenticated - Credentials were not found or were not valid. * not_found - The requested resource was not found. * rate_limited - The request was refused because a rate limit was exceeded. There is an account wide rate limit of 3600 requests per-minute, although that is subject to change. The current remaining rate limit can be viewed by checking the X-Ratelimit-Remaining header.
18
+ # Error code: * server_error - Internal server error. * invalid_parameter - Validation error, parameter will contain invalid field and message will contain the reason. * invalid_body - Body could not be parsed, message will contain the reason. * invalid_request - Validation error, the protocol used to make the request was not https. * unauthorized - Credentials were found but permissions were not sufficient. * unauthenticated - Credentials were not found or were not valid. * not_found - The requested resource was not found. * rate_limited - The request was refused because a rate limit was exceeded. There is an account wide rate limit of 3600 requests per-minute, although that is subject to change. The current remaining rate limit can be viewed by checking the X-Ratelimit-Remaining header. * prohibited_action - The request was refused because an action was not valid for the requested resource. Typically this will happen if you try to make changes to a locked resource.
18
19
  attr_accessor :code
19
20
 
20
21
  # Human readable error message
@@ -55,7 +56,7 @@ module DyspatchClient
55
56
  end
56
57
 
57
58
  # Attribute type mapping.
58
- def self.swagger_types
59
+ def self.openapi_types
59
60
  {
60
61
  :'code' => :'String',
61
62
  :'message' => :'String',
@@ -63,23 +64,36 @@ module DyspatchClient
63
64
  }
64
65
  end
65
66
 
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
66
73
  # Initializes the object
67
74
  # @param [Hash] attributes Model attributes in the form of hash
68
75
  def initialize(attributes = {})
69
- return unless attributes.is_a?(Hash)
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DyspatchClient::APIError` initialize method"
78
+ end
70
79
 
71
- # convert string to symbol for hash key
72
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DyspatchClient::APIError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
73
87
 
74
- if attributes.has_key?(:'code')
88
+ if attributes.key?(:'code')
75
89
  self.code = attributes[:'code']
76
90
  end
77
91
 
78
- if attributes.has_key?(:'message')
92
+ if attributes.key?(:'message')
79
93
  self.message = attributes[:'message']
80
94
  end
81
95
 
82
- if attributes.has_key?(:'parameter')
96
+ if attributes.key?(:'parameter')
83
97
  self.parameter = attributes[:'parameter']
84
98
  end
85
99
  end
@@ -94,7 +108,7 @@ module DyspatchClient
94
108
  # Check to see if the all the properties in the model are valid
95
109
  # @return true if the model is valid
96
110
  def valid?
97
- code_validator = EnumAttributeValidator.new('String', ['server_error', 'invalid_parameter', 'invalid_body', 'invalid_request', 'unauthorized', 'unauthenticated', 'not_found', 'rate_limited'])
111
+ code_validator = EnumAttributeValidator.new('String', ["server_error", "invalid_parameter", "invalid_body", "invalid_request", "unauthorized", "unauthenticated", "not_found", "rate_limited", "prohibited_action"])
98
112
  return false unless code_validator.valid?(@code)
99
113
  true
100
114
  end
@@ -102,9 +116,9 @@ module DyspatchClient
102
116
  # Custom attribute writer method checking allowed values (enum).
103
117
  # @param [Object] code Object to be assigned
104
118
  def code=(code)
105
- validator = EnumAttributeValidator.new('String', ['server_error', 'invalid_parameter', 'invalid_body', 'invalid_request', 'unauthorized', 'unauthenticated', 'not_found', 'rate_limited'])
119
+ validator = EnumAttributeValidator.new('String', ["server_error", "invalid_parameter", "invalid_body", "invalid_request", "unauthorized", "unauthenticated", "not_found", "rate_limited", "prohibited_action"])
106
120
  unless validator.valid?(code)
107
- fail ArgumentError, 'invalid value for "code", must be one of #{validator.allowable_values}.'
121
+ fail ArgumentError, "invalid value for \"code\", must be one of #{validator.allowable_values}."
108
122
  end
109
123
  @code = code
110
124
  end
@@ -126,19 +140,26 @@ module DyspatchClient
126
140
  end
127
141
 
128
142
  # Calculates hash code according to all attributes.
129
- # @return [Fixnum] Hash code
143
+ # @return [Integer] Hash code
130
144
  def hash
131
145
  [code, message, parameter].hash
132
146
  end
133
147
 
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def self.build_from_hash(attributes)
152
+ new.build_from_hash(attributes)
153
+ end
154
+
134
155
  # Builds the object from hash
135
156
  # @param [Hash] attributes Model attributes in the form of hash
136
157
  # @return [Object] Returns the model itself
137
158
  def build_from_hash(attributes)
138
159
  return nil unless attributes.is_a?(Hash)
139
- self.class.swagger_types.each_pair do |key, type|
160
+ self.class.openapi_types.each_pair do |key, type|
140
161
  if type =~ /\AArray<(.*)>/i
141
- # check to ensure the input is an array given that the the attribute
162
+ # check to ensure the input is an array given that the attribute
142
163
  # is documented as an array but the input is not
143
164
  if attributes[self.class.attribute_map[key]].is_a?(Array)
144
165
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -167,7 +188,7 @@ module DyspatchClient
167
188
  value.to_i
168
189
  when :Float
169
190
  value.to_f
170
- when :BOOLEAN
191
+ when :Boolean
171
192
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
193
  true
173
194
  else
@@ -188,8 +209,7 @@ module DyspatchClient
188
209
  end
189
210
  end
190
211
  else # model
191
- temp_model = DyspatchClient.const_get(type).new
192
- temp_model.build_from_hash(value)
212
+ DyspatchClient.const_get(type).build_from_hash(value)
193
213
  end
194
214
  end
195
215
 
@@ -211,7 +231,11 @@ module DyspatchClient
211
231
  hash = {}
212
232
  self.class.attribute_map.each_pair do |attr, param|
213
233
  value = self.send(attr)
214
- next if value.nil?
234
+ if value.nil?
235
+ is_nullable = self.class.openapi_nullable.include?(attr)
236
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
237
+ end
238
+
215
239
  hash[param] = _to_hash(value)
216
240
  end
217
241
  hash