Class: MessagingPreference

Inherits:
Common::Base show all
Includes:
ActiveModel::Validations
Defined in:
app/models/messaging_preference.rb

Overview

Secure Messaging Notification Preference Model

Constant Summary collapse

FREQUENCY_UPDATE_MAP =
{
  'none' => 0,
  'each_message' => 1,
  'daily' => 2
}.freeze
FREQUENCY_GET_MAP =
{
  'None' => 'none',
  'Each message' => 'each_message',
  'Once daily' => 'daily'
}.freeze

Instance Attribute Summary

Attributes inherited from Common::Base

#errors_hash, #metadata

Instance Method Summary collapse

Methods inherited from Common::Base

#changed, #changed?, #changes, default_sort, filterable_attributes, #initialize, max_per_page, per_page, sortable_attributes

Constructor Details

This class inherits a constructor from Common::Base

Instance Method Details

#idObject



38
39
40
# File 'app/models/messaging_preference.rb', line 38

def id
  Digest::SHA256.hexdigest(instance_variable_get(:@original_attributes).to_json)
end

#mhv_paramsObject



32
33
34
35
36
# File 'app/models/messaging_preference.rb', line 32

def mhv_params
  raise Common::Exceptions::ValidationErrors, self unless valid?

  { email_address:, notify_me: FREQUENCY_UPDATE_MAP.fetch(frequency) }
end