dyspatch_client 2.0.0 → 5.0.1

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/README.md +50 -34
  4. data/Rakefile +2 -0
  5. data/docs/APIError.md +12 -1
  6. data/docs/CompiledRead.md +13 -0
  7. data/docs/Cursor.md +11 -1
  8. data/docs/DraftMetaRead.md +27 -0
  9. data/docs/DraftRead.md +31 -0
  10. data/docs/DraftsApi.md +476 -0
  11. data/docs/DraftsRead.md +19 -0
  12. data/docs/InlineObject.md +17 -0
  13. data/docs/LocalizationKeyRead.md +19 -0
  14. data/docs/LocalizationMetaRead.md +15 -1
  15. data/docs/LocalizationRead.md +19 -1
  16. data/docs/LocalizationsApi.md +16 -18
  17. data/docs/TemplateMetaRead.md +15 -0
  18. data/docs/TemplateRead.md +16 -0
  19. data/docs/TemplatesApi.md +39 -40
  20. data/docs/TemplatesRead.md +10 -0
  21. data/dyspatch_client.gemspec +10 -16
  22. data/lib/dyspatch_client.rb +10 -4
  23. data/lib/dyspatch_client/api/drafts_api.rb +620 -0
  24. data/lib/dyspatch_client/api/localizations_api.rb +52 -34
  25. data/lib/dyspatch_client/api/templates_api.rb +100 -69
  26. data/lib/dyspatch_client/api_client.rb +54 -55
  27. data/lib/dyspatch_client/api_error.rb +23 -4
  28. data/lib/dyspatch_client/configuration.rb +49 -10
  29. data/lib/dyspatch_client/models/api_error.rb +50 -30
  30. data/lib/dyspatch_client/models/compiled_read.rb +49 -78
  31. data/lib/dyspatch_client/models/cursor.rb +47 -28
  32. data/lib/dyspatch_client/models/draft_meta_read.rb +258 -0
  33. data/lib/dyspatch_client/models/draft_read.rb +279 -0
  34. data/lib/dyspatch_client/models/drafts_read.rb +219 -0
  35. data/lib/dyspatch_client/models/inline_object.rb +206 -0
  36. data/lib/dyspatch_client/models/localization_key_read.rb +216 -0
  37. data/lib/dyspatch_client/models/localization_meta_read.rb +70 -39
  38. data/lib/dyspatch_client/models/localization_read.rb +73 -42
  39. data/lib/dyspatch_client/models/template_meta_read.rb +52 -33
  40. data/lib/dyspatch_client/models/template_read.rb +53 -34
  41. data/lib/dyspatch_client/models/templates_read.rb +45 -26
  42. data/lib/dyspatch_client/version.rb +5 -5
  43. data/pkg/dyspatch_client-5.0.0.gem +0 -0
  44. data/pkg/dyspatch_client-5.0.1.gem +0 -0
  45. data/spec/api/drafts_api_spec.rb +146 -0
  46. data/spec/api/localizations_api_spec.rb +12 -12
  47. data/spec/api/templates_api_spec.rb +24 -24
  48. data/spec/api_client_spec.rb +39 -39
  49. data/spec/configuration_spec.rb +12 -12
  50. data/spec/integration_spec.rb +41 -0
  51. data/spec/models/api_error_spec.rb +12 -13
  52. data/spec/models/compiled_read_spec.rb +10 -11
  53. data/spec/models/cursor_spec.rb +7 -8
  54. data/spec/models/draft_meta_read_spec.rb +77 -0
  55. data/spec/models/draft_read_spec.rb +83 -0
  56. data/spec/models/drafts_read_spec.rb +47 -0
  57. data/spec/models/inline_object_spec.rb +41 -0
  58. data/spec/models/localization_key_read_spec.rb +47 -0
  59. data/spec/models/localization_meta_read_spec.rb +18 -13
  60. data/spec/models/localization_read_spec.rb +20 -15
  61. data/spec/models/template_meta_read_spec.rb +12 -13
  62. data/spec/models/template_read_spec.rb +13 -14
  63. data/spec/models/templates_read_spec.rb +7 -8
  64. data/spec/spec_helper.rb +4 -4
  65. metadata +34 -128
  66. data/git_push.sh +0 -55
@@ -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 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)
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.03
6
+ The version of the OpenAPI document: 2020.04
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
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 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)
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.03
6
+ The version of the OpenAPI document: 2020.04
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
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
@@ -170,12 +168,11 @@ module DyspatchClient
170
168
  def base_path=(base_path)
171
169
  # Add leading and trailing slashes to base_path
172
170
  @base_path = "/#{base_path}".gsub(/\/+/, '/')
173
- @base_path = "" if @base_path == "/"
171
+ @base_path = '' if @base_path == '/'
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,21 +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 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)
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.03
6
+ The version of the OpenAPI document: 2020.04
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
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
-
16
+ # possible errors from the api
17
17
  class APIError
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.
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.
19
19
  attr_accessor :code
20
20
 
21
21
  # Human readable error message
@@ -56,7 +56,7 @@ module DyspatchClient
56
56
  end
57
57
 
58
58
  # Attribute type mapping.
59
- def self.swagger_types
59
+ def self.openapi_types
60
60
  {
61
61
  :'code' => :'String',
62
62
  :'message' => :'String',
@@ -64,49 +64,61 @@ module DyspatchClient
64
64
  }
65
65
  end
66
66
 
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
67
73
  # Initializes the object
68
74
  # @param [Hash] attributes Model attributes in the form of hash
69
75
  def initialize(attributes = {})
70
- 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
71
79
 
72
- # convert string to symbol for hash key
73
- 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
+ }
74
87
 
75
- if attributes.has_key?(:'code')
88
+ if attributes.key?(:'code')
76
89
  self.code = attributes[:'code']
77
90
  end
78
91
 
79
- if attributes.has_key?(:'message')
92
+ if attributes.key?(:'message')
80
93
  self.message = attributes[:'message']
81
94
  end
82
95
 
83
- if attributes.has_key?(:'parameter')
96
+ if attributes.key?(:'parameter')
84
97
  self.parameter = attributes[:'parameter']
85
98
  end
86
-
87
99
  end
88
100
 
89
101
  # Show invalid properties with the reasons. Usually used together with valid?
90
102
  # @return Array for valid properties with the reasons
91
103
  def list_invalid_properties
92
104
  invalid_properties = Array.new
93
- return invalid_properties
105
+ invalid_properties
94
106
  end
95
107
 
96
108
  # Check to see if the all the properties in the model are valid
97
109
  # @return true if the model is valid
98
110
  def valid?
99
- 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"])
100
112
  return false unless code_validator.valid?(@code)
101
- return true
113
+ true
102
114
  end
103
115
 
104
116
  # Custom attribute writer method checking allowed values (enum).
105
117
  # @param [Object] code Object to be assigned
106
118
  def code=(code)
107
- 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"])
108
120
  unless validator.valid?(code)
109
- 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}."
110
122
  end
111
123
  @code = code
112
124
  end
@@ -128,22 +140,29 @@ module DyspatchClient
128
140
  end
129
141
 
130
142
  # Calculates hash code according to all attributes.
131
- # @return [Fixnum] Hash code
143
+ # @return [Integer] Hash code
132
144
  def hash
133
145
  [code, message, parameter].hash
134
146
  end
135
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
+
136
155
  # Builds the object from hash
137
156
  # @param [Hash] attributes Model attributes in the form of hash
138
157
  # @return [Object] Returns the model itself
139
158
  def build_from_hash(attributes)
140
159
  return nil unless attributes.is_a?(Hash)
141
- self.class.swagger_types.each_pair do |key, type|
160
+ self.class.openapi_types.each_pair do |key, type|
142
161
  if type =~ /\AArray<(.*)>/i
143
- # 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
144
163
  # is documented as an array but the input is not
145
164
  if attributes[self.class.attribute_map[key]].is_a?(Array)
146
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
147
166
  end
148
167
  elsif !attributes[self.class.attribute_map[key]].nil?
149
168
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@@ -169,7 +188,7 @@ module DyspatchClient
169
188
  value.to_i
170
189
  when :Float
171
190
  value.to_f
172
- when :BOOLEAN
191
+ when :Boolean
173
192
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
174
193
  true
175
194
  else
@@ -190,8 +209,7 @@ module DyspatchClient
190
209
  end
191
210
  end
192
211
  else # model
193
- temp_model = DyspatchClient.const_get(type).new
194
- temp_model.build_from_hash(value)
212
+ DyspatchClient.const_get(type).build_from_hash(value)
195
213
  end
196
214
  end
197
215
 
@@ -213,7 +231,11 @@ module DyspatchClient
213
231
  hash = {}
214
232
  self.class.attribute_map.each_pair do |attr, param|
215
233
  value = self.send(attr)
216
- 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
+
217
239
  hash[param] = _to_hash(value)
218
240
  end
219
241
  hash
@@ -225,7 +247,7 @@ module DyspatchClient
225
247
  # @return [Hash] Returns the value in the form of hash
226
248
  def _to_hash(value)
227
249
  if value.is_a?(Array)
228
- value.compact.map{ |v| _to_hash(v) }
250
+ value.compact.map { |v| _to_hash(v) }
229
251
  elsif value.is_a?(Hash)
230
252
  {}.tap do |hash|
231
253
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -236,7 +258,5 @@ module DyspatchClient
236
258
  value
237
259
  end
238
260
  end
239
-
240
261
  end
241
-
242
262
  end
@@ -1,19 +1,19 @@
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 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)
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.03
6
+ The version of the OpenAPI document: 2020.04
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
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
-
16
+ # revision data
17
17
  class CompiledRead
18
18
  # Sender address
19
19
  attr_accessor :sender
@@ -30,7 +30,6 @@ module DyspatchClient
30
30
  # Base64 encoded template text body
31
31
  attr_accessor :text
32
32
 
33
-
34
33
  # Attribute mapping from ruby-style variable name to JSON key.
35
34
  def self.attribute_map
36
35
  {
@@ -43,7 +42,7 @@ module DyspatchClient
43
42
  end
44
43
 
45
44
  # Attribute type mapping.
46
- def self.swagger_types
45
+ def self.openapi_types
47
46
  {
48
47
  :'sender' => :'String',
49
48
  :'reply_to' => :'String',
@@ -53,95 +52,59 @@ module DyspatchClient
53
52
  }
54
53
  end
55
54
 
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
56
61
  # Initializes the object
57
62
  # @param [Hash] attributes Model attributes in the form of hash
58
63
  def initialize(attributes = {})
59
- return unless attributes.is_a?(Hash)
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DyspatchClient::CompiledRead` initialize method"
66
+ end
60
67
 
61
- # convert string to symbol for hash key
62
- attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DyspatchClient::CompiledRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
63
75
 
64
- if attributes.has_key?(:'sender')
76
+ if attributes.key?(:'sender')
65
77
  self.sender = attributes[:'sender']
66
78
  end
67
79
 
68
- if attributes.has_key?(:'replyTo')
69
- self.reply_to = attributes[:'replyTo']
80
+ if attributes.key?(:'reply_to')
81
+ self.reply_to = attributes[:'reply_to']
70
82
  end
71
83
 
72
- if attributes.has_key?(:'subject')
84
+ if attributes.key?(:'subject')
73
85
  self.subject = attributes[:'subject']
74
86
  end
75
87
 
76
- if attributes.has_key?(:'html')
88
+ if attributes.key?(:'html')
77
89
  self.html = attributes[:'html']
78
90
  end
79
91
 
80
- if attributes.has_key?(:'text')
92
+ if attributes.key?(:'text')
81
93
  self.text = attributes[:'text']
82
94
  end
83
-
84
95
  end
85
96
 
86
97
  # Show invalid properties with the reasons. Usually used together with valid?
87
98
  # @return Array for valid properties with the reasons
88
99
  def list_invalid_properties
89
100
  invalid_properties = Array.new
90
- if !@subject.nil? && @subject !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
91
- invalid_properties.push("invalid value for 'subject', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.")
92
- end
93
-
94
- if !@html.nil? && @html !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
95
- invalid_properties.push("invalid value for 'html', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.")
96
- end
97
-
98
- if !@text.nil? && @text !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
99
- invalid_properties.push("invalid value for 'text', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.")
100
- end
101
-
102
- return invalid_properties
101
+ invalid_properties
103
102
  end
104
103
 
105
104
  # Check to see if the all the properties in the model are valid
106
105
  # @return true if the model is valid
107
106
  def valid?
108
- return false if !@subject.nil? && @subject !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
109
- return false if !@html.nil? && @html !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
110
- return false if !@text.nil? && @text !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
111
- return true
112
- end
113
-
114
- # Custom attribute writer method with validation
115
- # @param [Object] subject Value to be assigned
116
- def subject=(subject)
117
-
118
- if !subject.nil? && subject !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
119
- fail ArgumentError, "invalid value for 'subject', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."
120
- end
121
-
122
- @subject = subject
123
- end
124
-
125
- # Custom attribute writer method with validation
126
- # @param [Object] html Value to be assigned
127
- def html=(html)
128
-
129
- if !html.nil? && html !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
130
- fail ArgumentError, "invalid value for 'html', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."
131
- end
132
-
133
- @html = html
134
- end
135
-
136
- # Custom attribute writer method with validation
137
- # @param [Object] text Value to be assigned
138
- def text=(text)
139
-
140
- if !text.nil? && text !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
141
- fail ArgumentError, "invalid value for 'text', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."
142
- end
143
-
144
- @text = text
107
+ true
145
108
  end
146
109
 
147
110
  # Checks equality by comparing each attribute.
@@ -163,22 +126,29 @@ module DyspatchClient
163
126
  end
164
127
 
165
128
  # Calculates hash code according to all attributes.
166
- # @return [Fixnum] Hash code
129
+ # @return [Integer] Hash code
167
130
  def hash
168
131
  [sender, reply_to, subject, html, text].hash
169
132
  end
170
133
 
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
171
141
  # Builds the object from hash
172
142
  # @param [Hash] attributes Model attributes in the form of hash
173
143
  # @return [Object] Returns the model itself
174
144
  def build_from_hash(attributes)
175
145
  return nil unless attributes.is_a?(Hash)
176
- self.class.swagger_types.each_pair do |key, type|
146
+ self.class.openapi_types.each_pair do |key, type|
177
147
  if type =~ /\AArray<(.*)>/i
178
- # check to ensure the input is an array given that the the attribute
148
+ # check to ensure the input is an array given that the attribute
179
149
  # is documented as an array but the input is not
180
150
  if attributes[self.class.attribute_map[key]].is_a?(Array)
181
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
182
152
  end
183
153
  elsif !attributes[self.class.attribute_map[key]].nil?
184
154
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@@ -204,7 +174,7 @@ module DyspatchClient
204
174
  value.to_i
205
175
  when :Float
206
176
  value.to_f
207
- when :BOOLEAN
177
+ when :Boolean
208
178
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
209
179
  true
210
180
  else
@@ -225,8 +195,7 @@ module DyspatchClient
225
195
  end
226
196
  end
227
197
  else # model
228
- temp_model = DyspatchClient.const_get(type).new
229
- temp_model.build_from_hash(value)
198
+ DyspatchClient.const_get(type).build_from_hash(value)
230
199
  end
231
200
  end
232
201
 
@@ -248,7 +217,11 @@ module DyspatchClient
248
217
  hash = {}
249
218
  self.class.attribute_map.each_pair do |attr, param|
250
219
  value = self.send(attr)
251
- next if value.nil?
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
252
225
  hash[param] = _to_hash(value)
253
226
  end
254
227
  hash
@@ -260,7 +233,7 @@ module DyspatchClient
260
233
  # @return [Hash] Returns the value in the form of hash
261
234
  def _to_hash(value)
262
235
  if value.is_a?(Array)
263
- value.compact.map{ |v| _to_hash(v) }
236
+ value.compact.map { |v| _to_hash(v) }
264
237
  elsif value.is_a?(Hash)
265
238
  {}.tap do |hash|
266
239
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -271,7 +244,5 @@ module DyspatchClient
271
244
  value
272
245
  end
273
246
  end
274
-
275
247
  end
276
-
277
248
  end