Class: MailService::List
- Inherits:
-
Object
- Object
- MailService::List
- Includes:
- ActiveModel::Model
- Defined in:
- app/services/mail_service/list.rb
Class Method Summary collapse
- .all(options = {}) ⇒ Object
- .count(options = {}) ⇒ Object
-
.exists?(id) ⇒ Boolean
Class Methods —————————————————————————————.
- .fetch(options = {}) ⇒ Object
- .find_by_id(id) ⇒ Object
Class Method Details
.all(options = {}) ⇒ Object
89 90 91 |
# File 'app/services/mail_service/list.rb', line 89 def self.all( = {}) fetch()[:data].try(:map, &:with_indifferent_access) end |
.count(options = {}) ⇒ Object
93 94 95 |
# File 'app/services/mail_service/list.rb', line 93 def self.count( = {}) fetch()[:total] end |
.exists?(id) ⇒ Boolean
Class Methods
78 79 80 |
# File 'app/services/mail_service/list.rb', line 78 def self.exists?(id) find_by_id(id).present? end |
.fetch(options = {}) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'app/services/mail_service/list.rb', line 97 def self.fetch( = {}) begin parent.connection.lists.list().with_indifferent_access rescue => e Rails.logger.info "**[MailService Error][Exists] #{e.}" Rails.logger.warn "**[MailService Error][Exists] #{e.backtrace.join("\n")}" if Rails.env.development? {} end end |
.find_by_id(id) ⇒ Object
82 83 84 85 86 87 |
# File 'app/services/mail_service/list.rb', line 82 def self.find_by_id(id) return nil unless id response = fetch(filters: { list_id: id }).try(:with_indifferent_access) response[:data].try(:map, &:with_indifferent_access).try(:first) if response[:total] == 1 end |