2020-04-05 16:41:27 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: channel_twilio_sms
|
|
|
|
#
|
|
|
|
# id :bigint not null, primary key
|
|
|
|
# account_sid :string not null
|
|
|
|
# auth_token :string not null
|
2020-04-29 20:11:13 +00:00
|
|
|
# medium :integer default("sms")
|
2020-04-05 16:41:27 +00:00
|
|
|
# phone_number :string not null
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# account_id :integer not null
|
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_channel_twilio_sms_on_account_id_and_phone_number (account_id,phone_number) UNIQUE
|
|
|
|
#
|
|
|
|
|
|
|
|
class Channel::TwilioSms < ApplicationRecord
|
|
|
|
self.table_name = 'channel_twilio_sms'
|
|
|
|
|
|
|
|
validates :account_id, presence: true
|
|
|
|
validates :account_sid, presence: true
|
|
|
|
validates :auth_token, presence: true
|
|
|
|
validates :phone_number, uniqueness: { scope: :account_id }, presence: true
|
|
|
|
|
2020-04-29 20:11:13 +00:00
|
|
|
enum medium: { sms: 0, whatsapp: 1 }
|
|
|
|
|
2020-04-05 16:41:27 +00:00
|
|
|
belongs_to :account
|
|
|
|
|
|
|
|
has_one :inbox, as: :channel, dependent: :destroy
|
|
|
|
|
2020-09-04 13:43:47 +00:00
|
|
|
def name
|
2020-09-17 18:02:19 +00:00
|
|
|
medium == 'sms' ? 'Twilio SMS' : 'Whatsapp'
|
2020-07-25 17:24:45 +00:00
|
|
|
end
|
|
|
|
|
2020-09-04 13:43:47 +00:00
|
|
|
def has_24_hour_messaging_window?
|
2020-09-17 18:02:19 +00:00
|
|
|
medium == 'whatsapp'
|
2020-04-05 16:41:27 +00:00
|
|
|
end
|
|
|
|
end
|