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 =

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.".freeze

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

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::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#hunt_reportObject

Returns the value of attribute hunt_report.



33
34
35
# File 'app/models/do_not_call.rb', line 33

def hunt_report
  @hunt_report
end

#numberString

Returns Raw phone number.

Returns:

  • (String)

    Raw phone number.



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

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

Class Method Details

.cleanup_for_phone(phone) ⇒ Integer

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

Parameters:

  • phone (String)

    phone number to clean up

Returns:

  • (Integer)


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

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:



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

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

#phone_numberString

Returns:

  • (String)


51
52
53
# File 'app/models/do_not_call.rb', line 51

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

#to_sString

Returns:

  • (String)


56
57
58
# File 'app/models/do_not_call.rb', line 56

def to_s
  phone_number
end