Class: Itrp::Export::Monitor::Mail
- Inherits:
-
Object
- Object
- Itrp::Export::Monitor::Mail
- Defined in:
- lib/itrp/export/monitor/mail.rb
Instance Method Summary collapse
-
#download_uri ⇒ Object
First hyperlink in the text, e.g.
-
#export_id ⇒ Object
value of mail header: X-ITRP-ExportID, e.g.
-
#filename ⇒ Object
the filename of the csv or zip file.
-
#ignore ⇒ Object
ignore the message.
-
#initialize(mail) ⇒ Mail
constructor
A new instance of Mail.
- #original ⇒ Object
-
#token ⇒ Object
value of mail header: X-ITRP-Export, e.g.
Constructor Details
#initialize(mail) ⇒ Mail
Returns a new instance of Mail.
5 6 7 |
# File 'lib/itrp/export/monitor/mail.rb', line 5 def initialize(mail) @mail = mail end |
Instance Method Details
#download_uri ⇒ Object
24 25 26 27 28 |
# File 'lib/itrp/export/monitor/mail.rb', line 24 def download_uri return nil unless self.export_id # the first match from https:// until a space or the end of the line @download_uri ||= @mail.text_part.body.decoded[/(https?:\/\/[^\s$]+)/, 1] end |
#export_id ⇒ Object
value of mail header: X-ITRP-ExportID, e.g. 2
14 15 16 |
# File 'lib/itrp/export/monitor/mail.rb', line 14 def export_id @export_id ||= @mail.header['X-ITRP-ExportID'].try(:value).try(:to_i) end |
#filename ⇒ Object
the filename of the csv or zip file
31 32 33 34 |
# File 'lib/itrp/export/monitor/mail.rb', line 31 def filename return nil if self.download_uri.blank? @filename ||= self.download_uri[/\/([^\/]+\.(?:csv|zip))/, 1] end |
#ignore ⇒ Object
ignore the message
37 38 39 |
# File 'lib/itrp/export/monitor/mail.rb', line 37 def ignore @mail.skip_deletion end |
#original ⇒ Object
9 10 11 |
# File 'lib/itrp/export/monitor/mail.rb', line 9 def original @mail end |
#token ⇒ Object
value of mail header: X-ITRP-Export, e.g. ‘0fad4fc0fd4a0130ad2a12313b0e50759969ab71899d2bb1d3e3d8f66e6e5133’
19 20 21 |
# File 'lib/itrp/export/monitor/mail.rb', line 19 def token @token ||= @mail.header['X-ITRP-Export'].try(:value) end |