Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added headers parameter on transfer. New transfer sample script.

  • Loading branch information...
commit 9583b2f9ddd54c42c749a283aad73a00689926cd 1 parent 27e5a52
@mheadd mheadd authored
Showing with 28 additions and 6 deletions.
  1. +3 −2 lib/base.js
  2. +4 −4 lib/tropo-webapi.js
  3. +21 −0 samples/transfer.js
View
5 lib/base.js
@@ -150,15 +150,16 @@ startRecording = function(format, method, url, username, password) {
stopRecording = function() {};
-Transfer = function(to, answerOnMedia, choices, from, name, on, required, timeout) {
+Transfer = function(to, answerOnMedia, choices, from, headers, name, on, required, terminator, timeout) {
this.to = to;
this.answerOnMedia = answerOnMedia;
this.choices = serializeProperty(choices);
this.from = from;
+ this.headers = serializeProperty(headers);
this.name = name;
this.on = (typeof(on) == 'Object') ? serializeProperty(on) : on;
this.required = required;
-// this.terminator = terminator;
+ this.terminator = terminator;
this.timeout = timeout;
};
View
8 lib/tropo-webapi.js
@@ -59,17 +59,17 @@ TropoWebAPI.prototype.say = function(value, as, name, required, voice) {
};
TropoWebAPI.prototype.startRecording = function(format, method, url, username, password) {
- var startRecording = new base.startRecording(format, method, url, username, password);
+ var startRecording = new base.StartRecording(format, method, url, username, password);
this.tropo.push(serializeObject("startRecording", startRecording));
};
TropoWebAPI.prototype.stopRecording = function() {
- var stopRecording = new base.stopRecording();
+ var stopRecording = new base.StopRecording();
this.tropo.push(serializeObject("stopRecording", stopRecording));
};
-TropoWebAPI.prototype.transfer = function(to, answerOnMedia, choices, from, name, required, terminator, timeout) {
- var transfer = new base.Transfer(to, answerOnMedia, choices, from, name, required, terminator, timeout);
+TropoWebAPI.prototype.transfer = function(to, answerOnMedia, choices, from, headers, name, on, required, terminator, timeout) {
+ var transfer = new base.Transfer(to, answerOnMedia, choices, from, headers, name, on, required, terminator, timeout);
this.tropo.push(serializeObject("transfer", transfer));
};
View
21 samples/transfer.js
@@ -0,0 +1,21 @@
+/**
+ * A very simple node web server that will respond to requests
+ * with a transfer to a SIP or PSTN number.
+ */
+
+var http = require('http');
+require('../lib/tropo-webapi');
+
+var server = http.createServer(function (request, response) {
+
+ // Create a new instance of the TropoWebAPI object.
+ var tropo = new TropoWebAPI();
+
+ tropo.say('Please hold while your call is transferred.');
+ tropo.transfer('mheadd@sip2sip.info', false, null, null, {'x-caller-name' : 'Mark Headd'}, null, null, true, '#', 60.0);
+
+ // Render out the JSON for Tropo to consume.
+ response.writeHead(200, {'Content-Type': 'application/json'});
+ response.end(TropoJSON(tropo));
+
+}).listen(8000); // Listen on port 8000 for requests.
Please sign in to comment.
Something went wrong with that request. Please try again.