2017-06-16 09:06:14 -04:00
|
|
|
module Emails
|
2017-06-19 08:51:46 -04:00
|
|
|
class DestroyService < ::Emails::BaseService
|
2017-06-22 05:27:37 -04:00
|
|
|
def execute
|
2017-06-23 05:34:07 -04:00
|
|
|
Email.find_by_email!(@email).destroy && update_secondary_emails!
|
2017-06-22 02:55:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_secondary_emails!
|
2017-06-23 10:44:34 -04:00
|
|
|
result = ::Users::UpdateService.new(@user).execute do |user|
|
2017-06-22 02:55:07 -04:00
|
|
|
user.update_secondary_emails!
|
|
|
|
end
|
|
|
|
|
|
|
|
result[:status] == 'success'
|
2017-06-16 09:06:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|