Skip to content

Commit e558484

Browse files
committed
pushing initial support for MMS
1 parent 7b6dd8d commit e558484

7 files changed

Lines changed: 1049 additions & 5 deletions

File tree

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CCAI Node.js Client
22

3-
A TypeScript client for the Cloud Contact AI API that allows you to easily send SMS messages.
3+
A TypeScript client for the Cloud Contact AI API that allows you to easily send SMS and MMS messages.
44

55
## Requirements
66

@@ -20,6 +20,8 @@ npm run build
2020

2121
## Usage
2222

23+
### SMS
24+
2325
```typescript
2426
import { CCAI } from 'ccai-node';
2527

@@ -58,6 +60,62 @@ ccai.sms.sendSingle(
5860
.catch(error => console.error('Error:', error));
5961
```
6062

63+
### MMS
64+
65+
```typescript
66+
import { CCAI, Account, SMSOptions } from 'ccai-node';
67+
68+
// Initialize the client
69+
const ccai = new CCAI({
70+
clientId: 'YOUR-CLIENT-ID',
71+
apiKey: 'API-KEY-TOKEN'
72+
});
73+
74+
// Define a progress callback
75+
const trackProgress = (status: string) => {
76+
console.log(`Progress: ${status}`);
77+
};
78+
79+
// Create options with progress tracking
80+
const options: SMSOptions = {
81+
timeout: 60000,
82+
onProgress: trackProgress
83+
};
84+
85+
// Complete MMS workflow (get URL, upload image, send MMS)
86+
async function sendMmsWithImage() {
87+
try {
88+
// Path to your image file
89+
const imagePath = 'path/to/your/image.jpg';
90+
const contentType = 'image/jpeg';
91+
92+
// Define recipient
93+
const account: Account = {
94+
firstName: 'John',
95+
lastName: 'Doe',
96+
phone: '+15551234567'
97+
};
98+
99+
// Send MMS with image in one step
100+
const response = await ccai.mms.sendWithImage(
101+
imagePath,
102+
contentType,
103+
[account],
104+
"Hello ${firstName}, check out this image!",
105+
"MMS Campaign Example",
106+
options
107+
);
108+
109+
console.log(`MMS sent! Campaign ID: ${response.campaignId}`);
110+
} catch (error) {
111+
console.error('Error sending MMS:', error);
112+
}
113+
}
114+
115+
// Call the function
116+
sendMmsWithImage();
117+
```
118+
61119
### Using Async/Await
62120

63121
```typescript
@@ -96,6 +154,7 @@ async function sendMessages() {
96154
- `ccai.ts` - Main CCAI client class
97155
- `sms/` - SMS-related functionality
98156
- `sms.ts` - SMS service class
157+
- `mms.ts` - MMS service class
99158
- `index.ts` - Main exports
100159
- `examples/` - Example usage
101160
- `__tests__/` - Test files
@@ -192,7 +251,9 @@ This project includes a `.gitignore` file that excludes:
192251

193252
- TypeScript support with full type definitions
194253
- Promise-based API with async/await support
195-
- Support for sending to multiple recipients
254+
- Support for sending SMS to multiple recipients
255+
- Support for sending MMS with images
256+
- Upload images to S3 with signed URLs
196257
- Support for template variables (firstName, lastName)
197258
- Progress tracking via callbacks
198259
- Comprehensive error handling

src/__tests__/ccai.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import axios from 'axios';
99
import { CCAI, CCAIConfig } from '../ccai';
10+
import { SMS } from '../sms/sms';
11+
import { MMS } from '../sms/mms';
1012

1113
// Mock axios
1214
jest.mock('axios');
@@ -46,6 +48,16 @@ describe('CCAI', () => {
4648
it('should throw an error if apiKey is missing', () => {
4749
expect(() => new CCAI({ clientId: 'test-client-id' } as CCAIConfig)).toThrow('API Key is required');
4850
});
51+
52+
it('should initialize the SMS service', () => {
53+
const ccai = new CCAI(defaultConfig);
54+
expect(ccai.sms).toBeInstanceOf(SMS);
55+
});
56+
57+
it('should initialize the MMS service', () => {
58+
const ccai = new CCAI(defaultConfig);
59+
expect(ccai.mms).toBeInstanceOf(MMS);
60+
});
4961
});
5062

5163
describe('request', () => {

0 commit comments

Comments
 (0)