-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from plivo/mms_changes
MMS changes
- Loading branch information
Showing
5 changed files
with
120 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
let plivo = require('plivo'); | ||
let client = new plivo.Client('', ''); | ||
|
||
let optionalParams = {}; | ||
client.messages.create( | ||
"", //from | ||
"", // to | ||
"", // text | ||
{ | ||
type: "", // sms or mms | ||
method: "", // GET or POST callback method | ||
url: "", // callback url | ||
media_urls: [".gif", ".jpg"] // to send MMS, mention the media urls | ||
} | ||
|
||
).then(function (message_created) { | ||
console.log(message_created) | ||
}).catch(function (error) { | ||
console.log(error); | ||
}); | ||
|
||
|
||
// get MMS Media detail | ||
client.messages.get("your message uuid").then(function (message) { | ||
return client.messages.listMedia(message.messageUuid) | ||
}) | ||
.then(function (result) { | ||
console.log("\n============ list Media ===========\n", result) | ||
}) | ||
.catch(function (response) { | ||
console.log("\n============ Error :: ===========\n", response); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,81 @@ | ||
import assert from 'assert'; | ||
import sinon from 'sinon'; | ||
import {Client} from '../lib/rest/client-test'; | ||
import {PlivoGenericResponse} from '../lib/base.js'; | ||
import { | ||
Client | ||
} from '../lib/rest/client-test'; | ||
import { | ||
PlivoGenericResponse | ||
} from '../lib/base.js'; | ||
|
||
let client = new Client('sampleid', 'sammpletoken', 'sampleproxy'); | ||
|
||
describe('message', function () { | ||
it('should get message', function () { | ||
return client.messages.get(1) | ||
.then(function(message) { | ||
.then(function (message) { | ||
assert.equal(message.id, 1) | ||
}) | ||
}); | ||
|
||
it('list messages', function () { | ||
return client.messages.list() | ||
.then(function(messages) { | ||
.then(function (messages) { | ||
assert.equal(messages.length, 2) | ||
}) | ||
}); | ||
|
||
it('should create message via interface', function () { | ||
return client.messages.create('src', 'dst', 'text') | ||
.then(function(message){ | ||
assert.equal(message.message, 'message(s) queued') | ||
.then(function (message) { | ||
assert.equal(message.message, 'message(s) queued') | ||
}) | ||
}); | ||
|
||
it('should send message via interface', function () { | ||
return client.messages.send('src', 'dst', 'text') | ||
.then(function(message){ | ||
assert.equal(message.message, 'message(s) queued') | ||
.then(function (message) { | ||
assert.equal(message.message, 'message(s) queued') | ||
}) | ||
}); | ||
|
||
|
||
it('should throw error - id is required via interface', function () { | ||
return client.messages.get() | ||
.catch(function(err){ | ||
.catch(function (err) { | ||
assert.equal(err.message, 'Missing mandatory field: id') | ||
}) | ||
}); | ||
|
||
it('should throw error - src and powerpack both not present', function () { | ||
return client.messages.send(null, 'dst', 'text', {}, null) | ||
.catch(function(err){ | ||
.catch(function (err) { | ||
assert.equal(err.message, 'Neither of src or powerpack uuid present, either one is required') | ||
}) | ||
}); | ||
|
||
it('should throw error - src and powerpack both are present', function () { | ||
return client.messages.send('91235456917375', 'dst', 'text', {}, '916386027476') | ||
.catch(function(err){ | ||
.catch(function (err) { | ||
assert.equal(err.message, 'Either of src or powerpack uuid, both of them are present') | ||
}) | ||
}); | ||
|
||
it('list media', function (done) { | ||
client.messages.get('xyz') | ||
.then(function (message) { | ||
return message.listMedia({}) | ||
}) | ||
.then(function (mmsmedia) { | ||
assert(mmsmedia instanceof PlivoGenericResponse) | ||
done() | ||
}) | ||
}); | ||
it('should list media via plivo interface!', function (done) { | ||
client.messages.listMedia('xyz') | ||
.then(function (mmsMedia) { | ||
assert(mmsMedia) | ||
done() | ||
}) | ||
}); | ||
|
||
}); |