mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
feat: Support Twilio Messaging Services (#4242)
This allows sending and receiving from multiple phone numbers using Twilio messaging services Fixes: #4204
This commit is contained in:
@@ -20,7 +20,7 @@ RSpec.describe '/api/v1/accounts/{account.id}/channels/twilio_channel', type: :r
|
||||
twilio_channel: {
|
||||
account_sid: 'sid',
|
||||
auth_token: 'token',
|
||||
phone_number: '+1234567890',
|
||||
messaging_service_sid: 'MGec8130512b5dd462cfe03095ec1342ed',
|
||||
name: 'SMS Channel',
|
||||
medium: 'sms'
|
||||
}
|
||||
@@ -48,7 +48,36 @@ RSpec.describe '/api/v1/accounts/{account.id}/channels/twilio_channel', type: :r
|
||||
json_response = JSON.parse(response.body)
|
||||
|
||||
expect(json_response['name']).to eq('SMS Channel')
|
||||
expect(json_response['phone_number']).to eq('+1234567890')
|
||||
expect(json_response['messaging_service_sid']).to eq('MGec8130512b5dd462cfe03095ec1342ed')
|
||||
end
|
||||
|
||||
context 'with a phone number' do # rubocop:disable RSpec/NestedGroups
|
||||
let(:params) do
|
||||
{
|
||||
twilio_channel: {
|
||||
account_sid: 'sid',
|
||||
auth_token: 'token',
|
||||
phone_number: '+1234567890',
|
||||
name: 'SMS Channel',
|
||||
medium: 'sms'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates inbox and returns inbox object' do
|
||||
allow(twilio_client).to receive(:messages).and_return(message_double)
|
||||
allow(message_double).to receive(:list).and_return([])
|
||||
|
||||
post api_v1_account_channels_twilio_channel_path(account),
|
||||
params: params,
|
||||
headers: admin.create_new_auth_token
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
|
||||
expect(json_response['name']).to eq('SMS Channel')
|
||||
expect(json_response['phone_number']).to eq('+1234567890')
|
||||
end
|
||||
end
|
||||
|
||||
it 'return error if Twilio tokens are incorrect' do
|
||||
|
||||
Reference in New Issue
Block a user