Class: TempmailSdk::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/tempmail_sdk/types.rb

Overview

标准化的邮件对象

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: "", from_addr: "", to: "", subject: "", text: "", html: "", date: "", is_read: false, attachments: nil) ⇒ Email

rubocop:disable Metrics/ParameterLists



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/tempmail_sdk/types.rb', line 67

def initialize(id: "", from_addr: "", to: "", subject: "", text: "", html: "",
               date: "", is_read: false, attachments: nil)
  @id = id
  @from_addr = from_addr
  @to = to
  @subject = subject
  @text = text
  @html = html
  @date = date
  @is_read = is_read
  @attachments = attachments || []
end

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def attachments
  @attachments
end

#dateObject

Returns the value of attribute date.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def date
  @date
end

#from_addrObject

Returns the value of attribute from_addr.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def from_addr
  @from_addr
end

#htmlObject

Returns the value of attribute html.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def html
  @html
end

#idObject

Returns the value of attribute id.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def id
  @id
end

#is_readObject

Returns the value of attribute is_read.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def is_read
  @is_read
end

#subjectObject

Returns the value of attribute subject.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def subject
  @subject
end

#textObject

Returns the value of attribute text.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def text
  @text
end

#toObject

Returns the value of attribute to.



64
65
66
# File 'lib/tempmail_sdk/types.rb', line 64

def to
  @to
end

Instance Method Details

#to_hObject

rubocop:enable Metrics/ParameterLists



81
82
83
84
85
86
87
# File 'lib/tempmail_sdk/types.rb', line 81

def to_h
  {
    id: @id, from_addr: @from_addr, to: @to, subject: @subject,
    text: @text, html: @html, date: @date, is_read: @is_read,
    attachments: @attachments.map { |a| a.respond_to?(:to_h) ? a.to_h : a }
  }
end