Skip to content

Commit 011aa1c

Browse files
authored
Merge pull request #33 from sendwithus/update-api-endpoint
Update api endpoint
2 parents 5531b2d + bec4510 commit 011aa1c

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var callback = function(err, response) {
2929

3030
```javascript
3131
var api = require('sendwithus')('API_KEY');
32-
api.emails(callback);
32+
api.templates(callback);
3333
```
3434

3535
### Create Template

lib/sendwithus.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var util = require('util');
55

66
var API_PROTOCOL = 'https';
77
var API_HOST = 'api.sendwithus.com';
8-
var API_VERSION = '1_0';
8+
var API_VERSION = '1';
99
var API_HEADER_KEY = 'X-SWU-API-KEY';
1010
var API_HEADER_CLIENT = 'X-SWU-API-CLIENT';
1111
var API_CLIENT = 'node-' + packageData.version;
@@ -104,8 +104,8 @@ Sendwithus.prototype.send = function(data, callback) {
104104
});
105105
};
106106

107-
Sendwithus.prototype.emails = function(callback) {
108-
var url = this._buildUrl('emails');
107+
Sendwithus.prototype.templates = function(callback) {
108+
var url = this._buildUrl('templates');
109109

110110
var options = this._getOptions();
111111

@@ -118,6 +118,11 @@ Sendwithus.prototype.emails = function(callback) {
118118
});
119119
};
120120

121+
/* 'emails' is a deprecated method since Sendwithus has changed their language
122+
* slightly. This is still kept around for backwards compatibility.
123+
*/
124+
Sendwithus.prototype.emails = Sendwithus.prototype.templates;
125+
121126
Sendwithus.prototype.customersUpdateOrCreate = function(data, callback) {
122127
var url = this._buildUrl('customers');
123128

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sendwithus",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"author": "Sendwithus <us@sendwithus.com>",
55
"description": "Sendwithus.com Node.js client",
66
"main": "index.js",

test/sendwithus.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ module.exports.send = {
101101

102102
this.sendwithus.once('request', function (method, url, headers, body) {
103103
test.equals(method, 'POST', 'Correct HTTP method');
104-
test.equals(url, 'https://api.sendwithus.com/api/v1_0/send', 'Correct HTTP url');
104+
test.equals(url, 'https://api.sendwithus.com/api/v1/send', 'Correct HTTP url');
105105
test.equals(headers['X-SWU-API-KEY'], API_KEY, 'Valid X-SWU-API-KEY');
106106
test.done();
107107
});
@@ -135,7 +135,7 @@ module.exports.send = {
135135
}
136136
};
137137

138-
module.exports.emails = {
138+
module.exports.templates = {
139139
setUp: function (callback) {
140140
this.sendwithus = sendwithusFactory(API_KEY);
141141
this.sendwithusBad = sendwithusFactory(INVALID_API_KEY);
@@ -146,13 +146,13 @@ module.exports.emails = {
146146
callback();
147147
},
148148
list: function (test) {
149-
this.sendwithus.emails(function (err, result) {
149+
this.sendwithus.templates(function (err, result) {
150150
test.ifError(err);
151151
test.done();
152152
});
153153
},
154154
listInvalidAPIKey: function (test) {
155-
this.sendwithusBad.emails(function (err, result) {
155+
this.sendwithusBad.templates(function (err, result) {
156156
test.ok(err, 'API Key was invalid');
157157
test.equals(err.statusCode, 403, 'Expected 403 status code');
158158
test.done();

0 commit comments

Comments
 (0)