sendmux-sending 1.0.0 → 1.2.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/LICENSE +21 -0
  4. data/README.md +95 -0
  5. data/lib/sendmux/sending/client.rb +9 -1
  6. data/lib/sendmux/sending/version.rb +1 -1
  7. data/lib/sendmux_sending_generated/api/attachments_api.rb +370 -0
  8. data/lib/sendmux_sending_generated/api/emails_api.rb +2 -20
  9. data/lib/sendmux_sending_generated/api/meta_api.rb +82 -0
  10. data/lib/sendmux_sending_generated/api_client.rb +9 -3
  11. data/lib/sendmux_sending_generated/api_error.rb +2 -2
  12. data/lib/sendmux_sending_generated/api_model_base.rb +2 -2
  13. data/lib/sendmux_sending_generated/configuration.rb +2 -2
  14. data/lib/sendmux_sending_generated/models/address.rb +2 -2
  15. data/lib/sendmux_sending_generated/models/attachment.rb +78 -249
  16. data/lib/sendmux_sending_generated/models/attachment_upload_data.rb +284 -0
  17. data/lib/sendmux_sending_generated/models/attachment_upload_intent_data.rb +337 -0
  18. data/lib/sendmux_sending_generated/models/attachment_upload_intent_request.rb +279 -0
  19. data/lib/sendmux_sending_generated/models/attachment_upload_intent_response.rb +223 -0
  20. data/lib/sendmux_sending_generated/models/attachment_upload_response.rb +223 -0
  21. data/lib/sendmux_sending_generated/models/batch_result_item.rb +2 -2
  22. data/lib/sendmux_sending_generated/models/batch_send_request.rb +2 -2
  23. data/lib/sendmux_sending_generated/models/batch_send_success_data.rb +2 -2
  24. data/lib/sendmux_sending_generated/models/batch_send_success_response.rb +2 -2
  25. data/lib/sendmux_sending_generated/models/batch_summary.rb +2 -2
  26. data/lib/sendmux_sending_generated/models/email_send_request.rb +3 -3
  27. data/lib/sendmux_sending_generated/models/error_detail.rb +2 -2
  28. data/lib/sendmux_sending_generated/models/error_issue.rb +2 -2
  29. data/lib/sendmux_sending_generated/models/error_response.rb +2 -2
  30. data/lib/sendmux_sending_generated/models/inline_attachment.rb +274 -0
  31. data/lib/sendmux_sending_generated/models/meta.rb +2 -2
  32. data/lib/sendmux_sending_generated/models/recipient.rb +2 -2
  33. data/lib/sendmux_sending_generated/models/send_success_data.rb +2 -2
  34. data/lib/sendmux_sending_generated/models/send_success_response.rb +2 -2
  35. data/lib/sendmux_sending_generated/models/success_envelope.rb +2 -2
  36. data/lib/sendmux_sending_generated/models/uploaded_attachment_ref.rb +176 -0
  37. data/lib/sendmux_sending_generated/version.rb +2 -2
  38. data/lib/sendmux_sending_generated.rb +11 -2
  39. metadata +22 -6
@@ -0,0 +1,82 @@
1
+ =begin
2
+ #Sendmux Sending API
3
+
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Sendmux::Sending::Generated
16
+ class MetaApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # OpenAPI 3.1 specification
23
+ # Auto-generated OpenAPI 3.1 spec for the Sendmux Sending API. Public endpoint (no authentication). Emits a weak ETag; clients may send `If-None-Match` to receive 304 Not Modified.
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [String] :if_none_match Weak ETag from a previous response. When it matches the current resource, the server returns 304 Not Modified with no body.
26
+ # @return [Hash<String, Object>]
27
+ def sending_get_open_api_spec(opts = {})
28
+ data, _status_code, _headers = sending_get_open_api_spec_with_http_info(opts)
29
+ data
30
+ end
31
+
32
+ # OpenAPI 3.1 specification
33
+ # Auto-generated OpenAPI 3.1 spec for the Sendmux Sending API. Public endpoint (no authentication). Emits a weak ETag; clients may send &#x60;If-None-Match&#x60; to receive 304 Not Modified.
34
+ # @param [Hash] opts the optional parameters
35
+ # @option opts [String] :if_none_match Weak ETag from a previous response. When it matches the current resource, the server returns 304 Not Modified with no body.
36
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
37
+ def sending_get_open_api_spec_with_http_info(opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: MetaApi.sending_get_open_api_spec ...'
40
+ end
41
+ # resource path
42
+ local_var_path = '/openapi.json'
43
+
44
+ # query parameters
45
+ query_params = opts[:query_params] || {}
46
+
47
+ # header parameters
48
+ header_params = opts[:header_params] || {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
51
+ header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?
52
+
53
+ # form parameters
54
+ form_params = opts[:form_params] || {}
55
+
56
+ # http body (model)
57
+ post_body = opts[:debug_body]
58
+
59
+ # return_type
60
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
61
+
62
+ # auth_names
63
+ auth_names = opts[:debug_auth_names] || []
64
+
65
+ new_options = opts.merge(
66
+ :operation => :"MetaApi.sending_get_open_api_spec",
67
+ :header_params => header_params,
68
+ :query_params => query_params,
69
+ :form_params => form_params,
70
+ :body => post_body,
71
+ :auth_names => auth_names,
72
+ :return_type => return_type
73
+ )
74
+
75
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
76
+ if @api_client.config.debugging
77
+ @api_client.config.logger.debug "API called: MetaApi#sending_get_open_api_spec\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
78
+ end
79
+ return data, status_code, headers
80
+ end
81
+ end
82
+ end
@@ -1,7 +1,7 @@
1
1
  =begin
2
- #SendMux Sending API
2
+ #Sendmux Sending API
3
3
 
4
- #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
5
 
6
6
  The version of the OpenAPI document: 1.0.0
7
7
 
@@ -114,7 +114,7 @@ module Sendmux::Sending::Generated
114
114
  config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
115
115
  end
116
116
  end
117
- request.headers = header_params
117
+ request.headers = stringify_header_params(header_params)
118
118
  request.body = req_body
119
119
 
120
120
  # Overload default options only if provided
@@ -126,6 +126,12 @@ module Sendmux::Sending::Generated
126
126
  request
127
127
  end
128
128
 
129
+ def stringify_header_params(header_params)
130
+ header_params.each_with_object({}) do |(key, value), result|
131
+ result[key] = value.nil? ? value : value.to_s
132
+ end
133
+ end
134
+
129
135
  # Builds the HTTP request body
130
136
  #
131
137
  # @param [Hash] header_params Header parameters
@@ -1,7 +1,7 @@
1
1
  =begin
2
- #SendMux Sending API
2
+ #Sendmux Sending API
3
3
 
4
- #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
5
 
6
6
  The version of the OpenAPI document: 1.0.0
7
7
 
@@ -1,7 +1,7 @@
1
1
  =begin
2
- #SendMux Sending API
2
+ #Sendmux Sending API
3
3
 
4
- #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
5
 
6
6
  The version of the OpenAPI document: 1.0.0
7
7
 
@@ -1,7 +1,7 @@
1
1
  =begin
2
- #SendMux Sending API
2
+ #Sendmux Sending API
3
3
 
4
- #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
5
 
6
6
  The version of the OpenAPI document: 1.0.0
7
7
 
@@ -1,7 +1,7 @@
1
1
  =begin
2
- #SendMux Sending API
2
+ #Sendmux Sending API
3
3
 
4
- #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
5
 
6
6
  The version of the OpenAPI document: 1.0.0
7
7
 
@@ -1,7 +1,7 @@
1
1
  =begin
2
- #SendMux Sending API
2
+ #Sendmux Sending API
3
3
 
4
- #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
4
+ #Send emails programmatically via the Sendmux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
5
 
6
6
  The version of the OpenAPI document: 1.0.0
7
7
 
@@ -14,261 +14,90 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Sendmux::Sending::Generated
17
- class Attachment < ApiModelBase
18
- # Base64-encoded file content
19
- attr_accessor :content
20
-
21
- attr_accessor :encoding
22
-
23
- # Filename with allowed extension
24
- attr_accessor :filename
25
-
26
- # MIME type override
27
- attr_accessor :type
28
-
29
- class EnumAttributeValidator
30
- attr_reader :datatype
31
- attr_reader :allowable_values
32
-
33
- def initialize(datatype, allowable_values)
34
- @allowable_values = allowable_values.map do |value|
35
- case datatype.to_s
36
- when /Integer/i
37
- value.to_i
38
- when /Float/i
39
- value.to_f
40
- else
41
- value
17
+ module Attachment
18
+ class << self
19
+ # List of class defined in anyOf (OpenAPI v3)
20
+ def openapi_any_of
21
+ [
22
+ :'InlineAttachment',
23
+ :'UploadedAttachmentRef'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of anyOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of anyOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
34
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
35
+ # - TODO: scalar values are de facto behaving as if they were nullable.
36
+ # - TODO: logging when debugging is set.
37
+ openapi_any_of.each do |klass|
38
+ begin
39
+ next if klass == :AnyType # "nullable: true"
40
+ return find_and_cast_into_type(klass, data)
41
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
42
42
  end
43
43
  end
44
- end
45
-
46
- def valid?(value)
47
- !value || allowable_values.include?(value)
48
- end
49
- end
50
-
51
- # Attribute mapping from ruby-style variable name to JSON key.
52
- def self.attribute_map
53
- {
54
- :'content' => :'content',
55
- :'encoding' => :'encoding',
56
- :'filename' => :'filename',
57
- :'type' => :'type'
58
- }
59
- end
60
-
61
- # Returns attribute mapping this model knows about
62
- def self.acceptable_attribute_map
63
- attribute_map
64
- end
65
-
66
- # Returns all the JSON keys this model knows about
67
- def self.acceptable_attributes
68
- acceptable_attribute_map.values
69
- end
70
-
71
- # Attribute type mapping.
72
- def self.openapi_types
73
- {
74
- :'content' => :'String',
75
- :'encoding' => :'String',
76
- :'filename' => :'String',
77
- :'type' => :'String'
78
- }
79
- end
80
-
81
- # List of attributes with nullable: true
82
- def self.openapi_nullable
83
- Set.new([
84
- ])
85
- end
86
-
87
- # Initializes the object
88
- # @param [Hash] attributes Model attributes in the form of hash
89
- def initialize(attributes = {})
90
- if (!attributes.is_a?(Hash))
91
- fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::Attachment` initialize method"
92
- end
93
-
94
- # check to see if the attribute exists and convert string to symbol for hash key
95
- acceptable_attribute_map = self.class.acceptable_attribute_map
96
- attributes = attributes.each_with_object({}) { |(k, v), h|
97
- if (!acceptable_attribute_map.key?(k.to_sym))
98
- fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::Attachment`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
99
- end
100
- h[k.to_sym] = v
101
- }
102
-
103
- if attributes.key?(:'content')
104
- self.content = attributes[:'content']
105
- else
106
- self.content = nil
107
- end
108
-
109
- if attributes.key?(:'encoding')
110
- self.encoding = attributes[:'encoding']
111
- else
112
- self.encoding = 'base64'
113
- end
114
-
115
- if attributes.key?(:'filename')
116
- self.filename = attributes[:'filename']
117
- else
118
- self.filename = nil
119
- end
120
-
121
- if attributes.key?(:'type')
122
- self.type = attributes[:'type']
123
- end
124
- end
125
-
126
- # Show invalid properties with the reasons. Usually used together with valid?
127
- # @return Array for valid properties with the reasons
128
- def list_invalid_properties
129
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
130
- invalid_properties = Array.new
131
- if @content.nil?
132
- invalid_properties.push('invalid value for "content", content cannot be nil.')
133
- end
134
-
135
- if @content.to_s.length < 1
136
- invalid_properties.push('invalid value for "content", the character length must be greater than or equal to 1.')
137
- end
138
-
139
- if @filename.nil?
140
- invalid_properties.push('invalid value for "filename", filename cannot be nil.')
141
- end
142
44
 
143
- if @filename.to_s.length > 255
144
- invalid_properties.push('invalid value for "filename", the character length must be smaller than or equal to 255.')
145
- end
146
-
147
- if @filename.to_s.length < 1
148
- invalid_properties.push('invalid value for "filename", the character length must be greater than or equal to 1.')
149
- end
150
-
151
- invalid_properties
152
- end
153
-
154
- # Check to see if the all the properties in the model are valid
155
- # @return true if the model is valid
156
- def valid?
157
- warn '[DEPRECATED] the `valid?` method is obsolete'
158
- return false if @content.nil?
159
- return false if @content.to_s.length < 1
160
- encoding_validator = EnumAttributeValidator.new('String', ["base64", "unknown_default_open_api"])
161
- return false unless encoding_validator.valid?(@encoding)
162
- return false if @filename.nil?
163
- return false if @filename.to_s.length > 255
164
- return false if @filename.to_s.length < 1
165
- true
166
- end
167
-
168
- # Custom attribute writer method with validation
169
- # @param [Object] content Value to be assigned
170
- def content=(content)
171
- if content.nil?
172
- fail ArgumentError, 'content cannot be nil'
173
- end
174
-
175
- if content.to_s.length < 1
176
- fail ArgumentError, 'invalid value for "content", the character length must be greater than or equal to 1.'
177
- end
178
-
179
- @content = content
180
- end
181
-
182
- # Custom attribute writer method checking allowed values (enum).
183
- # @param [Object] encoding Object to be assigned
184
- def encoding=(encoding)
185
- validator = EnumAttributeValidator.new('String', ["base64", "unknown_default_open_api"])
186
- unless validator.valid?(encoding)
187
- fail ArgumentError, "invalid value for \"encoding\", must be one of #{validator.allowable_values}."
188
- end
189
- @encoding = encoding
190
- end
191
-
192
- # Custom attribute writer method with validation
193
- # @param [Object] filename Value to be assigned
194
- def filename=(filename)
195
- if filename.nil?
196
- fail ArgumentError, 'filename cannot be nil'
197
- end
198
-
199
- if filename.to_s.length > 255
200
- fail ArgumentError, 'invalid value for "filename", the character length must be smaller than or equal to 255.'
201
- end
202
-
203
- if filename.to_s.length < 1
204
- fail ArgumentError, 'invalid value for "filename", the character length must be greater than or equal to 1.'
205
- end
206
-
207
- @filename = filename
208
- end
209
-
210
- # Checks equality by comparing each attribute.
211
- # @param [Object] Object to be compared
212
- def ==(o)
213
- return true if self.equal?(o)
214
- self.class == o.class &&
215
- content == o.content &&
216
- encoding == o.encoding &&
217
- filename == o.filename &&
218
- type == o.type
219
- end
220
-
221
- # @see the `==` method
222
- # @param [Object] Object to be compared
223
- def eql?(o)
224
- self == o
225
- end
226
-
227
- # Calculates hash code according to all attributes.
228
- # @return [Integer] Hash code
229
- def hash
230
- [content, encoding, filename, type].hash
231
- end
232
-
233
- # Builds the object from hash
234
- # @param [Hash] attributes Model attributes in the form of hash
235
- # @return [Object] Returns the model itself
236
- def self.build_from_hash(attributes)
237
- return nil unless attributes.is_a?(Hash)
238
- attributes = attributes.transform_keys(&:to_sym)
239
- transformed_hash = {}
240
- openapi_types.each_pair do |key, type|
241
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
242
- transformed_hash["#{key}"] = nil
243
- elsif type =~ /\AArray<(.*)>/i
244
- # check to ensure the input is an array given that the attribute
245
- # is documented as an array but the input is not
246
- if attributes[attribute_map[key]].is_a?(Array)
247
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
45
+ openapi_any_of.include?(:AnyType) ? data : nil
46
+ end
47
+
48
+ private
49
+
50
+ SchemaMismatchError = Class.new(StandardError)
51
+
52
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
53
+ def find_and_cast_into_type(klass, data)
54
+ return if data.nil?
55
+
56
+ case klass.to_s
57
+ when 'Boolean'
58
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
59
+ when 'Float'
60
+ return data if data.instance_of?(Float)
61
+ when 'Integer'
62
+ return data if data.instance_of?(Integer)
63
+ when 'Time'
64
+ return Time.parse(data)
65
+ when 'Date'
66
+ return Date.iso8601(data)
67
+ when 'String'
68
+ return data if data.instance_of?(String)
69
+ when 'Object' # "type: object"
70
+ return data if data.instance_of?(Hash)
71
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
72
+ if data.instance_of?(Array)
73
+ sub_type = Regexp.last_match[:sub_type]
74
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
+ end
76
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
77
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
78
+ sub_type = Regexp.last_match[:sub_type]
79
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
80
+ end
81
+ else # model
82
+ const = Sendmux::Sending::Generated.const_get(klass)
83
+ if const
84
+ if const.respond_to?(:openapi_any_of) # nested anyOf model
85
+ model = const.build(data)
86
+ return model if model
87
+ else
88
+ # raise if data contains keys that are not known to the model
89
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
90
+ model = const.build_from_hash(data)
91
+ return model if model
92
+ end
248
93
  end
249
- elsif !attributes[attribute_map[key]].nil?
250
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
251
- end
252
- end
253
- new(transformed_hash)
254
- end
255
-
256
- # Returns the object in the form of hash
257
- # @return [Hash] Returns the object in the form of hash
258
- def to_hash
259
- hash = {}
260
- self.class.attribute_map.each_pair do |attr, param|
261
- value = self.send(attr)
262
- if value.nil?
263
- is_nullable = self.class.openapi_nullable.include?(attr)
264
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
94
  end
266
95
 
267
- hash[param] = _to_hash(value)
96
+ raise # if no match by now, raise
97
+ rescue
98
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
268
99
  end
269
- hash
270
100
  end
271
-
272
101
  end
273
102
 
274
103
  end