|
| 1 | +# Unit tests for Bandwidth::MultiChannelApi |
| 2 | +describe 'MultiChannelApi' do |
| 3 | + before(:all) do |
| 4 | + Bandwidth.configure do |config| |
| 5 | + config.debugging = true |
| 6 | + config.username = BW_USERNAME |
| 7 | + config.password = BW_PASSWORD |
| 8 | + config.ignore_operation_servers = true |
| 9 | + config.host = '127.0.0.1:4010' |
| 10 | + end |
| 11 | + @multi_channel_api_instance = Bandwidth::MultiChannelApi.new |
| 12 | + |
| 13 | + @expiration_time = (Time.now + 60).round.to_datetime.rfc3339 |
| 14 | + end |
| 15 | + |
| 16 | + describe 'test an instance of MultiChannelApi' do |
| 17 | + it 'should create an instance of MultiChannelApi' do |
| 18 | + expect(@multi_channel_api_instance).to be_instance_of(Bandwidth::MultiChannelApi) |
| 19 | + end |
| 20 | + end |
| 21 | + |
| 22 | + # Create Multi-Channel Message |
| 23 | + describe 'create_multi_channel_message' do |
| 24 | + it 'creates a multi channel message' do |
| 25 | + message_body = Bandwidth::MultiChannelChannelListObject.new( |
| 26 | + from: BW_NUMBER, |
| 27 | + application_id: BW_MESSAGING_APPLICATION_ID, |
| 28 | + channel: Bandwidth::MultiChannelMessageChannelEnum::MMS, |
| 29 | + content: Bandwidth::SmsMessageContent.new( |
| 30 | + text: 'Hello, this is a test message.', |
| 31 | + ) |
| 32 | + # content: Bandwidth::MultiChannelChannelListObjectContent.build( |
| 33 | + # text: 'Hello, this is a test message.', |
| 34 | + # ) |
| 35 | + ) |
| 36 | + multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new( |
| 37 | + to: USER_NUMBER, |
| 38 | + channel_list: [message_body], |
| 39 | + tag: 'tag', |
| 40 | + priority: 'high', |
| 41 | + expiration: @expiration_time, |
| 42 | + ) |
| 43 | + |
| 44 | + data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request) |
| 45 | + |
| 46 | + expect(status_code).to eq(202) |
| 47 | + expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse) |
| 48 | + end if false # skip because prism can't handle a oneOf with differing required fields |
| 49 | + |
| 50 | + it 'causes an ArgumentError for a missing account_id' do |
| 51 | + expect { |
| 52 | + @multi_channel_api_instance.create_multi_channel_message(nil, {}) |
| 53 | + }.to raise_error(ArgumentError) |
| 54 | + end |
| 55 | + |
| 56 | + it 'causes an ArgumentError for a missing message_request' do |
| 57 | + expect { |
| 58 | + @multi_channel_api_instance.create_multi_channel_message(BW_ACCOUNT_ID, nil) |
| 59 | + }.to raise_error(ArgumentError) |
| 60 | + end |
| 61 | + end |
| 62 | +end |
0 commit comments