mailslurp_client 4.3.3 → 5.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.
@@ -0,0 +1,250 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #For documentation see [developer guide](https://www.mailslurp.com/developers). [Create an account](https://app.mailslurp.com) in the MailSlurp Dashboard to [view your API Key](https://app). For all bugs, feature requests, or help please [see support](https://www.mailslurp.com/support/).
5
+
6
+ OpenAPI spec version: 0.0.1-alpha
7
+ Contact: contact@mailslurp.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.4
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ class MatchOption
17
+ # The email property to match on. One of SUBJECT, TO, BCC, CC or FROM
18
+ attr_accessor :field
19
+
20
+ # What criteria to apply. CONTAIN or EQUAL. Note CONTAIN is recommended due to some SMTP servers adding new lines
21
+ attr_accessor :should
22
+
23
+ # The value to compare to the field using EQUAL or CONTAIN
24
+ attr_accessor :value
25
+
26
+ class EnumAttributeValidator
27
+ attr_reader :datatype
28
+ attr_reader :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'field' => :'field',
52
+ :'should' => :'should',
53
+ :'value' => :'value'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'field' => :'String',
61
+ :'should' => :'String',
62
+ :'value' => :'String'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ return unless attributes.is_a?(Hash)
70
+
71
+ # convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
73
+
74
+ if attributes.has_key?(:'field')
75
+ self.field = attributes[:'field']
76
+ end
77
+
78
+ if attributes.has_key?(:'should')
79
+ self.should = attributes[:'should']
80
+ end
81
+
82
+ if attributes.has_key?(:'value')
83
+ self.value = attributes[:'value']
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ field_validator = EnumAttributeValidator.new('String', ['SUBJECT', 'TO', 'BCC', 'CC', 'FROM'])
98
+ return false unless field_validator.valid?(@field)
99
+ should_validator = EnumAttributeValidator.new('String', ['CONTAIN', 'EQUAL'])
100
+ return false unless should_validator.valid?(@should)
101
+ true
102
+ end
103
+
104
+ # Custom attribute writer method checking allowed values (enum).
105
+ # @param [Object] field Object to be assigned
106
+ def field=(field)
107
+ validator = EnumAttributeValidator.new('String', ['SUBJECT', 'TO', 'BCC', 'CC', 'FROM'])
108
+ unless validator.valid?(field)
109
+ fail ArgumentError, 'invalid value for "field", must be one of #{validator.allowable_values}.'
110
+ end
111
+ @field = field
112
+ end
113
+
114
+ # Custom attribute writer method checking allowed values (enum).
115
+ # @param [Object] should Object to be assigned
116
+ def should=(should)
117
+ validator = EnumAttributeValidator.new('String', ['CONTAIN', 'EQUAL'])
118
+ unless validator.valid?(should)
119
+ fail ArgumentError, 'invalid value for "should", must be one of #{validator.allowable_values}.'
120
+ end
121
+ @should = should
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ field == o.field &&
130
+ should == o.should &&
131
+ value == o.value
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(o)
137
+ self == o
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Fixnum] Hash code
142
+ def hash
143
+ [field, should, value].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
156
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
157
+ end
158
+ elsif !attributes[self.class.attribute_map[key]].nil?
159
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
161
+ end
162
+
163
+ self
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def _deserialize(type, value)
171
+ case type.to_sym
172
+ when :DateTime
173
+ DateTime.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :BOOLEAN
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ temp_model = MailSlurpClient.const_get(type).new
204
+ temp_model.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ next if value.nil?
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+ end
250
+ end
@@ -0,0 +1,187 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #For documentation see [developer guide](https://www.mailslurp.com/developers). [Create an account](https://app.mailslurp.com) in the MailSlurp Dashboard to [view your API Key](https://app). For all bugs, feature requests, or help please [see support](https://www.mailslurp.com/support/).
5
+
6
+ OpenAPI spec version: 0.0.1-alpha
7
+ Contact: contact@mailslurp.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.4
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ # Optional filter for matching emails based on fields
17
+ class MatchOptions
18
+ # 1 or more match options. Options are additive so if one does not match the email is excluded from results
19
+ attr_accessor :matches
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'matches' => :'matches'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'matches' => :'Array<MatchOption>'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
42
+
43
+ if attributes.has_key?(:'matches')
44
+ if (value = attributes[:'matches']).is_a?(Array)
45
+ self.matches = value
46
+ end
47
+ end
48
+ end
49
+
50
+ # Show invalid properties with the reasons. Usually used together with valid?
51
+ # @return Array for valid properties with the reasons
52
+ def list_invalid_properties
53
+ invalid_properties = Array.new
54
+ invalid_properties
55
+ end
56
+
57
+ # Check to see if the all the properties in the model are valid
58
+ # @return true if the model is valid
59
+ def valid?
60
+ true
61
+ end
62
+
63
+ # Checks equality by comparing each attribute.
64
+ # @param [Object] Object to be compared
65
+ def ==(o)
66
+ return true if self.equal?(o)
67
+ self.class == o.class &&
68
+ matches == o.matches
69
+ end
70
+
71
+ # @see the `==` method
72
+ # @param [Object] Object to be compared
73
+ def eql?(o)
74
+ self == o
75
+ end
76
+
77
+ # Calculates hash code according to all attributes.
78
+ # @return [Fixnum] Hash code
79
+ def hash
80
+ [matches].hash
81
+ end
82
+
83
+ # Builds the object from hash
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ # @return [Object] Returns the model itself
86
+ def build_from_hash(attributes)
87
+ return nil unless attributes.is_a?(Hash)
88
+ self.class.openapi_types.each_pair do |key, type|
89
+ if type =~ /\AArray<(.*)>/i
90
+ # check to ensure the input is an array given that the the attribute
91
+ # is documented as an array but the input is not
92
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
93
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
94
+ end
95
+ elsif !attributes[self.class.attribute_map[key]].nil?
96
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
97
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
98
+ end
99
+
100
+ self
101
+ end
102
+
103
+ # Deserializes the data based on type
104
+ # @param string type Data type
105
+ # @param string value Value to be deserialized
106
+ # @return [Object] Deserialized data
107
+ def _deserialize(type, value)
108
+ case type.to_sym
109
+ when :DateTime
110
+ DateTime.parse(value)
111
+ when :Date
112
+ Date.parse(value)
113
+ when :String
114
+ value.to_s
115
+ when :Integer
116
+ value.to_i
117
+ when :Float
118
+ value.to_f
119
+ when :BOOLEAN
120
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
121
+ true
122
+ else
123
+ false
124
+ end
125
+ when :Object
126
+ # generic object (usually a Hash), return directly
127
+ value
128
+ when /\AArray<(?<inner_type>.+)>\z/
129
+ inner_type = Regexp.last_match[:inner_type]
130
+ value.map { |v| _deserialize(inner_type, v) }
131
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
132
+ k_type = Regexp.last_match[:k_type]
133
+ v_type = Regexp.last_match[:v_type]
134
+ {}.tap do |hash|
135
+ value.each do |k, v|
136
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
137
+ end
138
+ end
139
+ else # model
140
+ temp_model = MailSlurpClient.const_get(type).new
141
+ temp_model.build_from_hash(value)
142
+ end
143
+ end
144
+
145
+ # Returns the string representation of the object
146
+ # @return [String] String presentation of the object
147
+ def to_s
148
+ to_hash.to_s
149
+ end
150
+
151
+ # to_body is an alias to to_hash (backward compatibility)
152
+ # @return [Hash] Returns the object in the form of hash
153
+ def to_body
154
+ to_hash
155
+ end
156
+
157
+ # Returns the object in the form of hash
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_hash
160
+ hash = {}
161
+ self.class.attribute_map.each_pair do |attr, param|
162
+ value = self.send(attr)
163
+ next if value.nil?
164
+ hash[param] = _to_hash(value)
165
+ end
166
+ hash
167
+ end
168
+
169
+ # Outputs non-array value in the form of hash
170
+ # For object, use to_hash. Otherwise, just return the value
171
+ # @param [Object] value Any valid value
172
+ # @return [Hash] Returns the value in the form of hash
173
+ def _to_hash(value)
174
+ if value.is_a?(Array)
175
+ value.compact.map { |v| _to_hash(v) }
176
+ elsif value.is_a?(Hash)
177
+ {}.tap do |hash|
178
+ value.each { |k, v| hash[k] = _to_hash(v) }
179
+ end
180
+ elsif value.respond_to? :to_hash
181
+ value.to_hash
182
+ else
183
+ value
184
+ end
185
+ end
186
+ end
187
+ end
@@ -15,10 +15,13 @@ require 'date'
15
15
  module MailSlurpClient
16
16
  # Options for sending an email message from an inbox
17
17
  class SendEmailOptions
18
+ # Optional list of attachment IDs to send with this email. You must first upload each attachment separately in order to obtain attachment IDs
19
+ attr_accessor :attachments
20
+
18
21
  # Optional list of bcc destination email addresses
19
22
  attr_accessor :bcc
20
23
 
21
- # Contents of email
24
+ # Contents of email. If HTML set isHTML to true. You can use moustache templates here if you provide a templateVariables option
22
25
  attr_accessor :body
23
26
 
24
27
  # Optional list of cc destination email addresses
@@ -38,12 +41,16 @@ module MailSlurpClient
38
41
  # Optional email subject line
39
42
  attr_accessor :subject
40
43
 
44
+ # Optional map of template variables. Will replace moustache syntax variables in subject or body with the associated values
45
+ attr_accessor :template_variables
46
+
41
47
  # List of destination email addresses. Even single recipients must be in array form.
42
48
  attr_accessor :to
43
49
 
44
50
  # Attribute mapping from ruby-style variable name to JSON key.
45
51
  def self.attribute_map
46
52
  {
53
+ :'attachments' => :'attachments',
47
54
  :'bcc' => :'bcc',
48
55
  :'body' => :'body',
49
56
  :'cc' => :'cc',
@@ -52,6 +59,7 @@ module MailSlurpClient
52
59
  :'html' => :'html',
53
60
  :'reply_to' => :'replyTo',
54
61
  :'subject' => :'subject',
62
+ :'template_variables' => :'templateVariables',
55
63
  :'to' => :'to'
56
64
  }
57
65
  end
@@ -59,6 +67,7 @@ module MailSlurpClient
59
67
  # Attribute type mapping.
60
68
  def self.openapi_types
61
69
  {
70
+ :'attachments' => :'Array<String>',
62
71
  :'bcc' => :'Array<String>',
63
72
  :'body' => :'String',
64
73
  :'cc' => :'Array<String>',
@@ -67,6 +76,7 @@ module MailSlurpClient
67
76
  :'html' => :'BOOLEAN',
68
77
  :'reply_to' => :'String',
69
78
  :'subject' => :'String',
79
+ :'template_variables' => :'Object',
70
80
  :'to' => :'Array<String>'
71
81
  }
72
82
  end
@@ -79,6 +89,12 @@ module MailSlurpClient
79
89
  # convert string to symbol for hash key
80
90
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
81
91
 
92
+ if attributes.has_key?(:'attachments')
93
+ if (value = attributes[:'attachments']).is_a?(Array)
94
+ self.attachments = value
95
+ end
96
+ end
97
+
82
98
  if attributes.has_key?(:'bcc')
83
99
  if (value = attributes[:'bcc']).is_a?(Array)
84
100
  self.bcc = value
@@ -115,6 +131,10 @@ module MailSlurpClient
115
131
  self.subject = attributes[:'subject']
116
132
  end
117
133
 
134
+ if attributes.has_key?(:'templateVariables')
135
+ self.template_variables = attributes[:'templateVariables']
136
+ end
137
+
118
138
  if attributes.has_key?(:'to')
119
139
  if (value = attributes[:'to']).is_a?(Array)
120
140
  self.to = value
@@ -145,6 +165,7 @@ module MailSlurpClient
145
165
  def ==(o)
146
166
  return true if self.equal?(o)
147
167
  self.class == o.class &&
168
+ attachments == o.attachments &&
148
169
  bcc == o.bcc &&
149
170
  body == o.body &&
150
171
  cc == o.cc &&
@@ -153,6 +174,7 @@ module MailSlurpClient
153
174
  html == o.html &&
154
175
  reply_to == o.reply_to &&
155
176
  subject == o.subject &&
177
+ template_variables == o.template_variables &&
156
178
  to == o.to
157
179
  end
158
180
 
@@ -165,7 +187,7 @@ module MailSlurpClient
165
187
  # Calculates hash code according to all attributes.
166
188
  # @return [Fixnum] Hash code
167
189
  def hash
168
- [bcc, body, cc, charset, from, html, reply_to, subject, to].hash
190
+ [attachments, bcc, body, cc, charset, from, html, reply_to, subject, template_variables, to].hash
169
191
  end
170
192
 
171
193
  # Builds the object from hash