feat: Add agent_reply_time_window in API channels (#4857)
This commit is contained in:
@@ -26,8 +26,22 @@ class Channel::Api < ApplicationRecord
|
||||
|
||||
has_secure_token :identifier
|
||||
has_secure_token :hmac_token
|
||||
validate :ensure_valid_agent_reply_time_window
|
||||
|
||||
def name
|
||||
'API'
|
||||
end
|
||||
|
||||
def messaging_window_enabled?
|
||||
additional_attributes.present? && additional_attributes['agent_reply_time_window'].present?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ensure_valid_agent_reply_time_window
|
||||
return if additional_attributes['agent_reply_time_window'].blank?
|
||||
return if additional_attributes['agent_reply_time_window'].to_i.positive?
|
||||
|
||||
errors.add(:agent_reply_time_window, 'agent_reply_time_window must be greater than 0')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ class Channel::FacebookPage < ApplicationRecord
|
||||
'Facebook'
|
||||
end
|
||||
|
||||
def has_24_hour_messaging_window?
|
||||
def messaging_window_enabled?
|
||||
false
|
||||
end
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Channel::TwilioSms < ApplicationRecord
|
||||
medium == 'sms' ? 'Twilio SMS' : 'Whatsapp'
|
||||
end
|
||||
|
||||
def has_24_hour_messaging_window?
|
||||
def messaging_window_enabled?
|
||||
medium == 'whatsapp'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ class Channel::Whatsapp < ApplicationRecord
|
||||
{ 'D360-API-KEY' => provider_config['api_key'], 'Content-Type' => 'application/json' }
|
||||
end
|
||||
|
||||
def has_24_hour_messaging_window?
|
||||
def messaging_window_enabled?
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user