Class: Osm::Email::DeliveryReport::Recipient
- Defined in:
- lib/osm/email.rb,
lib/osm/email.rb
Overview
Ensure class exists for definition of validations
Constant Summary collapse
- SORT_BY =
[:delivery_report, :id]
- VALID_STATUSES =
Osm::Email::DeliveryReport::VALID_STATUSES.clone
Instance Attribute Summary collapse
-
#address ⇒ String
The email address of the recipient.
-
#delivery_report ⇒ Osm::Email::DeliveryReport
The report this recipient belongs to.
-
#id ⇒ Fixnum
The id of the email recipient.
-
#member_id ⇒ Fixnum
The id of the member the email was sent to.
-
#status ⇒ Symbol
The status of the email sent to the recipient.
Instance Method Summary collapse
-
#bounced? ⇒ Boolean
Check if the email to this recipient bounced.
-
#delivered? ⇒ Boolean
Check if the email to this recipient was delivered.
-
#get_email(api, options = {}) ⇒ Osm::Email::DeliveryReport::Email
Get email contents for this recipient.
-
#initialize ⇒ Object
constructor
Initialize a new DeliveryReport::Recipient.
- #inspect ⇒ Object
-
#processed? ⇒ Boolean
Check if the email to this recipient has been processes.
- #to_s ⇒ Object
-
#unblock_address(api) ⇒ Object
Unblock email address from being sent emails.
Methods inherited from Model
#<, #<=, #<=>, #>, #>=, #between?, #changed_attributes, configure, #reset_changed_attributes, #to_i
Constructor Details
#initialize ⇒ Object
Initialize a new DeliveryReport::Recipient
|
# File 'lib/osm/email.rb', line 255
|
Instance Attribute Details
#address ⇒ String
Returns the email address of the recipient.
238 |
# File 'lib/osm/email.rb', line 238 attribute :id, type: Integer |
#delivery_report ⇒ Osm::Email::DeliveryReport
Returns the report this recipient belongs to.
238 |
# File 'lib/osm/email.rb', line 238 attribute :id, type: Integer |
#id ⇒ Fixnum
Returns the id of the email recipient.
238 |
# File 'lib/osm/email.rb', line 238 attribute :id, type: Integer |
#member_id ⇒ Fixnum
Returns the id of the member the email was sent to.
238 |
# File 'lib/osm/email.rb', line 238 attribute :id, type: Integer |
#status ⇒ Symbol
Returns the status of the email sent to the recipient.
238 |
# File 'lib/osm/email.rb', line 238 attribute :id, type: Integer |
Instance Method Details
#bounced? ⇒ Boolean
Check if the email to this recipient bounced
306 307 308 309 310 |
# File 'lib/osm/email.rb', line 306 VALID_STATUSES.each do |attribute| define_method "#{attribute}?" do status.eql?(attribute) end end |
#delivered? ⇒ Boolean
Check if the email to this recipient was delivered
306 307 308 309 310 |
# File 'lib/osm/email.rb', line 306 VALID_STATUSES.each do |attribute| define_method "#{attribute}?" do status.eql?(attribute) end end |
#get_email(api, options = {}) ⇒ Osm::Email::DeliveryReport::Email
Get email contents for this recipient
264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/osm/email.rb', line 264 def get_email(api, ={}) Osm::Model.require_access_to_section(api, delivery_report.section_id, ) cache_key = ['email_delivery_reports_email', delivery_report.section_id, delivery_report.id, id] if ![:no_cache] && Osm::Model.cache_exist?(api, cache_key) return cache_read(api, cache_key) end email = Osm::Email::DeliveryReport::Email.fetch_from_osm(api, delivery_report.section_id, delivery_report.id, member_id, address) cache_write(api, cache_key, email) return email end |
#inspect ⇒ Object
316 317 318 |
# File 'lib/osm/email.rb', line 316 def inspect Osm::inspect_instance(self, {replace_with: {'delivery_report' => :id}}) end |
#processed? ⇒ Boolean
Check if the email to this recipient has been processes
306 307 308 309 310 |
# File 'lib/osm/email.rb', line 306 VALID_STATUSES.each do |attribute| define_method "#{attribute}?" do status.eql?(attribute) end end |
#to_s ⇒ Object
312 313 314 |
# File 'lib/osm/email.rb', line 312 def to_s "#{address} - #{status}" end |
#unblock_address(api) ⇒ Object
Unblock email address from being sent emails
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/osm/email.rb', line 281 def unblock_address(api) return true unless bounced? data = api.perform_query('ext/settings/emails/?action=unBlockEmail', { 'section_id' => delivery_report.section_id, 'email' => address, 'email_id' => delivery_report.id }) if data.is_a?(Hash) fail Osm::Error, data['error'].to_s unless data['error'].nil? return !!data['status'] end return false end |