Class: DefraRubyEmail::LastNotifyMessage
- Inherits:
-
Object
- Object
- DefraRubyEmail::LastNotifyMessage
- Includes:
- Singleton
- Defined in:
- lib/defra_ruby_email/last_notify_message.rb
Constant Summary collapse
- LETTER_ATTRIBUTES =
%i[line_1 line_2 line_3 line_4 line_5 line_6 postcode].freeze
Instance Attribute Summary collapse
-
#last_notify_message ⇒ Object
Returns the value of attribute last_notify_message.
Instance Method Summary collapse
- #last_notify_message_json ⇒ Object
-
#reset ⇒ Object
This is necessary to properly test the service functionality.
- #retrieve_last_notify_message ⇒ Object
Instance Attribute Details
#last_notify_message ⇒ Object
Returns the value of attribute last_notify_message.
11 12 13 |
# File 'lib/defra_ruby_email/last_notify_message.rb', line 11 def @last_notify_message end |
Instance Method Details
#last_notify_message_json ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/defra_ruby_email/last_notify_message.rb', line 24 def return JSON.generate(error: "No messages sent.") unless .present? = {} [:type] = .type [:template] = .template [:subject] = .subject [:body] = .body [:date] = .sent_at # Email and phone-specific attributes [:to] = .email_address || .phone_number # Letter-specific attributes LETTER_ATTRIBUTES.each do |attribute| [attribute] = .public_send(attribute) end JSON.generate(last_notify_message: ) end |
#reset ⇒ Object
This is necessary to properly test the service functionality
14 15 16 |
# File 'lib/defra_ruby_email/last_notify_message.rb', line 14 def reset @last_notify_message = nil end |
#retrieve_last_notify_message ⇒ Object
18 19 20 21 22 |
# File 'lib/defra_ruby_email/last_notify_message.rb', line 18 def client = Notifications::Client.new(DefraRubyEmail.configuration.notify_api_key) response = client.get_notifications @last_notify_message = response.collection.first end |