Permalink
Browse files

[dist] example, test readme and package updates

  • Loading branch information...
1 parent f3566b8 commit 81c8a8605af406255e26b30294218df9efb97ee5 Paolo Fragomeni committed Mar 6, 2012
Showing with 75 additions and 22 deletions.
  1. +0 −1 .gitignore
  2. +34 −4 README.md
  3. +19 −4 examples/simple-sms.js
  4. +4 −3 lib/providers/twilio.js
  5. +6 −6 lib/telenode.js
  6. +1 −1 package.json
  7. +11 −3 test/twilio-sms-test.js
View
@@ -1,4 +1,3 @@
.DS_Store
-logs/*
node_modules/*
credentials/credentials.json
View
@@ -1,4 +1,4 @@
-# NOT READY YET! WORK IN PROGRESS! I JUST NEEDED TO SEND A TEXT MESSAGE =)
+# NOT READY YET! WORK IN PROGRESS!
# Synopsis
Multi-vendor cellular network services for node.js
@@ -16,7 +16,7 @@ Everything else sucks
# Usage
-## Simple example
+## Example
```js
var Telenode = require('telenode');
@@ -30,12 +30,42 @@ client.SMS.send({
```
+# Vendors and Authors
+Create a file that has the name of the service, place it in the providers directory. Everything that is exported is attached to the new `Telenode` instance. Let's say we create a file called `foobar.js`.
+
+```js
+//
+// this will become available on the new instance.
+//
+exports.getSomeInfo = function() {
+ console.log('here it is');
+};
+
+//
+// create containers one level deep. they get bound to the correct context for you.
+//
+exports.Container = {
+ getTheSameInfo: function() { this.getInfo(); },
+ getSomeNewInfo: function() { console.log('something new'); }
+};
+
+```
+
+```js
+var client = new Telenode(new Telenode.providers.foobar);
+
+//
+// This will output some text to the console.
+//
+client.Container.getTheSameInfo();
+client.Container.getSomeInfo();
+```
+
+
# Installation
# Build Status
# API
-# Vendors and Authors
-
# License
View
@@ -1,11 +1,13 @@
var Telenode = require('../lib/telenode');
-var client = new Telenode(new Telenode.providers.Twilio);
+var client = new Telenode(Telenode.providers.twilio);
-//
-// Signup at twilio.com to get a `sid` and `token`.
-//
client.credentials({
+
+ //
+ // add these two things however you want, if you
+ // do not have them, just signup at `twilio.com`.
+ //
sid: '',
token: ''
});
@@ -14,7 +16,20 @@ client.credentials({
// send an sms message
//
client.SMS.send({
+
+ //
+ // put your twillio phone number here.
+ //
from: '+1-111-111-1111',
+
+ //
+ // put your cell phone number here.
+ //
to: '+1-111-111-1111',
+
+ //
+ // some message goes here.
+ //
body: 'Hello'
+
});
View
@@ -111,8 +111,6 @@ exports.SMS = {
headers['Content-Type'] = 'application/x-www-form-urlencoded';
headers['Authorization'] = 'Basic ' + this.basicAuth;
- console.log(body)
-
request(
{
method: 'POST',
@@ -121,7 +119,10 @@ exports.SMS = {
body: body
},
function (err, response, body) {
- return err ? callback(err) : callback(null, body);
+
+ if (callback) {
+ return err ? callback(err) : callback(null, body);
+ }
}
);
View
@@ -28,6 +28,12 @@ var Telenode = module.exports = function Telenode(provider) {
var that = this;
+ this.HTTP = {};
+
+ for (var f in HTTP) {
+ typeof HTTP[f] === 'function' && (this.HTTP[f] = HTTP[f].bind(this));
+ }
+
for (var member in provider) {
if (typeof provider[member] === 'function') {
@@ -46,12 +52,6 @@ var Telenode = module.exports = function Telenode(provider) {
}
}
- this.HTTP = {};
-
- for (var f in HTTP) {
- typeof HTTP[f] === 'function' && (this.HTTP[f] = HTTP[f].bind(this));
- }
-
};
Telenode.providers = providers;
View
@@ -1,7 +1,7 @@
{
"name": "telenode",
"description": "A multi-vendor library for cellular network services",
- "version": "0.0.2",
+ "version": "0.0.3",
"author": "Nodejitsu Inc <info@nodejitsu.com>",
"contributors": [
{ "name": "Paolo Fragomeni", "email": "paolo@nodejitsu.com" }
View
@@ -1,5 +1,7 @@
-var Telenode = require('../lib/telenode');
+var Telenode = require('../lib/telenode'),
+ assert = require('assert');
+
var client = new Telenode(Telenode.providers.twilio);
//
@@ -22,6 +24,12 @@ client.SMS.send(
body: 'Hello'
},
function(err, data) {
- console.log(err || data);
+
+ //
+ // make sure we get a response that includes the
+ // sid that we sent in the original POST request.
+ //
+ data = JSON.parse(data);
+ assert.equal(data.sid, cred.sid);
}
-);
+);

0 comments on commit 81c8a86

Please sign in to comment.