Class: Assistant::EmailPreferenceUpdater
- Inherits:
-
Object
- Object
- Assistant::EmailPreferenceUpdater
- Defined in:
- app/services/assistant/email_preference_updater.rb
Overview
Applies one consent-sensitive email-preference update behind a row lock.
Class Method Summary collapse
-
.call(attributes, actor_id:) ⇒ String
Runs a preference update and returns the JSON tool response.
Instance Method Summary collapse
-
#call ⇒ String
Applies the requested preference changes.
- #initialize(attributes, actor_id) ⇒ void constructor
Constructor Details
#initialize(attributes, actor_id) ⇒ void
19 20 21 22 |
# File 'app/services/assistant/email_preference_updater.rb', line 19 def initialize(attributes, actor_id) @request = EmailPreferenceUpdateRequest.new(attributes) @actor_id = actor_id end |
Class Method Details
.call(attributes, actor_id:) ⇒ String
Runs a preference update and returns the JSON tool response.
12 13 14 |
# File 'app/services/assistant/email_preference_updater.rb', line 12 def self.call(attributes, actor_id:) new(attributes, actor_id).call end |
Instance Method Details
#call ⇒ String
Applies the requested preference changes.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/assistant/email_preference_updater.rb', line 27 def call error = request.preflight_error return error if error preference, before, error = persist_update(request.email) return { error: error }.to_json if error success_payload(preference, before).to_json rescue StandardError => e { error: e. }.to_json end |