chore: Provider API prototype (#3112)
Enabling Support for Whatsapp via 360Dialog as a prototype for the provider APIs. Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -9,12 +9,18 @@ class Contacts::ContactableInboxesService
|
||||
private
|
||||
|
||||
def get_contactable_inbox(inbox)
|
||||
return twilio_contactable_inbox(inbox) if inbox.channel_type == 'Channel::TwilioSms'
|
||||
return email_contactable_inbox(inbox) if inbox.channel_type == 'Channel::Email'
|
||||
return api_contactable_inbox(inbox) if inbox.channel_type == 'Channel::Api'
|
||||
return website_contactable_inbox(inbox) if inbox.channel_type == 'Channel::WebWidget'
|
||||
|
||||
nil
|
||||
case inbox.channel_type
|
||||
when 'Channel::TwilioSms'
|
||||
twilio_contactable_inbox(inbox)
|
||||
when 'Channel::Whatsapp'
|
||||
whatsapp_contactable_inbox(inbox)
|
||||
when 'Channel::Email'
|
||||
email_contactable_inbox(inbox)
|
||||
when 'Channel::Api'
|
||||
api_contactable_inbox(inbox)
|
||||
when 'Channel::WebWidget'
|
||||
website_contactable_inbox(inbox)
|
||||
end
|
||||
end
|
||||
|
||||
def website_contactable_inbox(inbox)
|
||||
@@ -39,6 +45,13 @@ class Contacts::ContactableInboxesService
|
||||
{ source_id: @contact.email, inbox: inbox }
|
||||
end
|
||||
|
||||
def whatsapp_contactable_inbox(inbox)
|
||||
return unless @contact.phone_number
|
||||
|
||||
# Remove the plus since thats the format 360 dialog uses
|
||||
{ source_id: @contact.phone_number.delete('+'), inbox: inbox }
|
||||
end
|
||||
|
||||
def twilio_contactable_inbox(inbox)
|
||||
return if @contact.phone_number.blank?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user