Class: DoNotCall

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/do_not_call.rb

Overview

== Schema Information

Table name: do_not_calls
Database name: primary

id :integer not null, primary key
country_code :integer
do_not_call :boolean default(TRUE)
do_not_fax :boolean default(TRUE)
do_not_text :boolean default(TRUE)
extension :integer
notes :text
number :string(20)
created_at :datetime
updated_at :datetime
creator_id :integer
updater_id :integer

Constant Summary collapse

FORBIDDEN =
"listed as a do not call record and cannot be added back to the database without first getting customer authorization, check marketing dashboard > do not call list for details."

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Instance Attribute Summary collapse

Has many collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#hunt_reportObject

Returns the value of attribute hunt_report.



29
30
31
# File 'app/models/do_not_call.rb', line 29

def hunt_report
  @hunt_report
end

#numberObject (readonly)



25
# File 'app/models/do_not_call.rb', line 25

validates :number, presence: true, phone_format: true, uniqueness: true

Class Method Details

.cleanup_for_phone(phone) ⇒ Object

Remove DoNotCall entry for a phone number after customer places an order
This allows sales/support to call the customer about their order



35
36
37
38
39
40
# File 'app/models/do_not_call.rb', line 35

def self.cleanup_for_phone(phone)
  return if phone.blank?

  formatted_phone = PhoneNumber.parse_and_format(phone)
  where(number: formatted_phone).delete_all
end

Instance Method Details

#contact_pointsActiveRecord::Relation<ContactPoint>

Returns:

See Also:



27
# File 'app/models/do_not_call.rb', line 27

has_many :contact_points, foreign_key: :detail, primary_key: :number

#phone_numberObject



42
43
44
# File 'app/models/do_not_call.rb', line 42

def phone_number
  PhoneNumber.parse_and_format(number, display_format: :crm)
end

#to_sObject



46
47
48
# File 'app/models/do_not_call.rb', line 46

def to_s
  phone_number
end