Class: Sendmux::Sending::Generated::EmailSendRequest

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/sendmux_sending_generated/models/email_send_request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ EmailSendRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 102

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::EmailSendRequest` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::EmailSendRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'attachments')
    if (value = attributes[:'attachments']).is_a?(Array)
      self.attachments = value
    end
  end

  if attributes.key?(:'bcc')
    if (value = attributes[:'bcc']).is_a?(Array)
      self.bcc = value
    end
  end

  if attributes.key?(:'cc')
    if (value = attributes[:'cc']).is_a?(Array)
      self.cc = value
    end
  end

  if attributes.key?(:'custom_headers')
    if (value = attributes[:'custom_headers']).is_a?(Hash)
      self.custom_headers = value
    end
  end

  if attributes.key?(:'from')
    self.from = attributes[:'from']
  else
    self.from = nil
  end

  if attributes.key?(:'html_body')
    self.html_body = attributes[:'html_body']
  else
    self.html_body = nil
  end

  if attributes.key?(:'reply_to')
    self.reply_to = attributes[:'reply_to']
  end

  if attributes.key?(:'return_path')
    self.return_path = attributes[:'return_path']
  end

  if attributes.key?(:'subject')
    self.subject = attributes[:'subject']
  else
    self.subject = nil
  end

  if attributes.key?(:'text_body')
    self.text_body = attributes[:'text_body']
  end

  if attributes.key?(:'to')
    self.to = attributes[:'to']
  else
    self.to = nil
  end
end

Instance Attribute Details

#attachmentsObject

File attachments (max 10)



19
20
21
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 19

def attachments
  @attachments
end

#bccObject

BCC recipients (max 100)



22
23
24
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 22

def bcc
  @bcc
end

#ccObject

CC recipients (max 100)



25
26
27
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 25

def cc
  @cc
end

#custom_headersObject

Custom X-* headers to include in the email



28
29
30
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 28

def custom_headers
  @custom_headers
end

#fromObject

Returns the value of attribute from.



30
31
32
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 30

def from
  @from
end

#html_bodyObject

HTML email content (max 25MB)



33
34
35
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 33

def html_body
  @html_body
end

#reply_toObject

Reply-To address



36
37
38
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 36

def reply_to
  @reply_to
end

#return_pathObject

Envelope sender for VERP support



39
40
41
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 39

def return_path
  @return_path
end

#subjectObject

Email subject line (max 998 chars, RFC 5322)



42
43
44
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 42

def subject
  @subject
end

#text_bodyObject

Plain text alternative (max 25MB)



45
46
47
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 45

def text_body
  @text_body
end

#toObject

Primary recipient



48
49
50
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 48

def to
  @to
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



68
69
70
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 68

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



73
74
75
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 73

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 51

def self.attribute_map
  {
    :'attachments' => :'attachments',
    :'bcc' => :'bcc',
    :'cc' => :'cc',
    :'custom_headers' => :'custom_headers',
    :'from' => :'from',
    :'html_body' => :'html_body',
    :'reply_to' => :'reply_to',
    :'return_path' => :'return_path',
    :'subject' => :'subject',
    :'text_body' => :'text_body',
    :'to' => :'to'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 427

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



95
96
97
98
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 95

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 78

def self.openapi_types
  {
    :'attachments' => :'Array<Attachment>',
    :'bcc' => :'Array<Recipient>',
    :'cc' => :'Array<Recipient>',
    :'custom_headers' => :'Hash<String, String>',
    :'from' => :'Address',
    :'html_body' => :'String',
    :'reply_to' => :'Address',
    :'return_path' => :'String',
    :'subject' => :'String',
    :'text_body' => :'String',
    :'to' => :'Address'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 396

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      attachments == o.attachments &&
      bcc == o.bcc &&
      cc == o.cc &&
      custom_headers == o.custom_headers &&
      from == o.from &&
      html_body == o.html_body &&
      reply_to == o.reply_to &&
      return_path == o.return_path &&
      subject == o.subject &&
      text_body == o.text_body &&
      to == o.to
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


414
415
416
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 414

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



420
421
422
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 420

def hash
  [attachments, bcc, cc, custom_headers, from, html_body, reply_to, return_path, subject, text_body, to].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 179

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@attachments.nil? && @attachments.length > 10
    invalid_properties.push('invalid value for "attachments", number of items must be less than or equal to 10.')
  end

  if !@bcc.nil? && @bcc.length > 100
    invalid_properties.push('invalid value for "bcc", number of items must be less than or equal to 100.')
  end

  if !@cc.nil? && @cc.length > 100
    invalid_properties.push('invalid value for "cc", number of items must be less than or equal to 100.')
  end

  if @from.nil?
    invalid_properties.push('invalid value for "from", from cannot be nil.')
  end

  if @html_body.nil?
    invalid_properties.push('invalid value for "html_body", html_body cannot be nil.')
  end

  if @html_body.to_s.length > 26214400
    invalid_properties.push('invalid value for "html_body", the character length must be smaller than or equal to 26214400.')
  end

  if @html_body.to_s.length < 1
    invalid_properties.push('invalid value for "html_body", the character length must be greater than or equal to 1.')
  end

  if !@return_path.nil? && @return_path.to_s.length > 254
    invalid_properties.push('invalid value for "return_path", the character length must be smaller than or equal to 254.')
  end

  if @subject.nil?
    invalid_properties.push('invalid value for "subject", subject cannot be nil.')
  end

  if @subject.to_s.length > 998
    invalid_properties.push('invalid value for "subject", the character length must be smaller than or equal to 998.')
  end

  if @subject.to_s.length < 1
    invalid_properties.push('invalid value for "subject", the character length must be greater than or equal to 1.')
  end

  pattern = Regexp.new(/^[^\r\n]*$/)
  if @subject !~ pattern
    invalid_properties.push("invalid value for \"subject\", must conform to the pattern #{pattern}.")
  end

  if !@text_body.nil? && @text_body.to_s.length > 26214400
    invalid_properties.push('invalid value for "text_body", the character length must be smaller than or equal to 26214400.')
  end

  if @to.nil?
    invalid_properties.push('invalid value for "to", to cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 449

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/sendmux_sending_generated/models/email_send_request.rb', line 244

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@attachments.nil? && @attachments.length > 10
  return false if !@bcc.nil? && @bcc.length > 100
  return false if !@cc.nil? && @cc.length > 100
  return false if @from.nil?
  return false if @html_body.nil?
  return false if @html_body.to_s.length > 26214400
  return false if @html_body.to_s.length < 1
  return false if !@return_path.nil? && @return_path.to_s.length > 254
  return false if @subject.nil?
  return false if @subject.to_s.length > 998
  return false if @subject.to_s.length < 1
  return false if @subject !~ Regexp.new(/^[^\r\n]*$/)
  return false if !@text_body.nil? && @text_body.to_s.length > 26214400
  return false if @to.nil?
  true
end