Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added the Product Advertising Client and some tests. #3

Merged
merged 5 commits into from

2 participants

@andymoon

Also updated to use the extended libraries.

@doug-martin
Owner

Please remove the .idea files

lib/aws/sns.js
((3 lines not shown))
BaseService = require("./baseService");
-comb.define(BaseService, {
+extd.declare(BaseService, {
@doug-martin Owner

Maybe we should use BaseService.extend just for conistency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/aws/sns.js
((17 lines not shown))
query["AWSAccountId.1"] = actions.accountId;
query["ActionName.1"] = actions.actionName;
}
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ this.doRequest(query).then(ret.callback.bind(ret), ret.errback.bind(this));
@doug-martin Owner

It look like you can change this to return this.doRequest(query)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/aws/sns.js
((36 lines not shown))
if (this.topicArn) {
if (label) {
var query = {Action : "RemovePermission", TopicArn : this.topicArn, label : label};
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ this.doRequest(query).then(ret.callback.bind(ret), ret.errback.bind(this));
@doug-martin Owner

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@doug-martin doug-martin commented on the diff
lib/aws/sns.js
((57 lines not shown))
var createTopicResult;
- if ((createTopicResult = createTopicResponse.CreateTopicResult) != null) {
- ret.callback(res.TopicArn, res);
@doug-martin Owner

This should be changed to use the chainable .then api

return this.doRequest(query).then(function(res){
     if ((createTopicResult = res.CreateTopicResult) != null) {
        return res.CreateTopicResult.TopicArc[0];
     } else {
        throw new Error("Error" + res);
     }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@doug-martin doug-martin commented on the diff
lib/aws/sns.js
((89 lines not shown))
if (this.topicArn) {
- this.doRequest({Action : "GetTopicAttributes", TopicArn: this.topicArn}).then(com.hitch(this, function(res) {
+ this.doRequest({Action : "GetTopicAttributes", TopicArn: this.topicArn}).then(function(res) {
@doug-martin Owner

Same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@doug-martin doug-martin merged commit cfb0064 into doug-martin:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -1,2 +1,4 @@
+.idea
+atlassian-ide-plugin.xml
node_modules
*.iml
View
4 .travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
View
20 Readme.md
@@ -110,6 +110,26 @@ snsClient.publish({
```
+###Product Advertising
+
+Available opertations. See Product Advertising API for description of parameters
+
+ * search(query)
+ * lookup(query)
+
+```js
+var productClient = new aws.ProductAdvertising({
+ awsAccessKeyId: '<Your key>',
+ awsSecretAccessKey: '<Your Secret>',
+ associateTag: '<Your Associate Tag>'
+});
+
+productClient.search({SearchIndex: "Books", Keyword: "Harry Potter"}).then(function(results){
+ <Do something with the results>
+});
+
+```
+
##License
(The MIT License)
View
138 lib/aws/baseService.js
@@ -1,55 +1,55 @@
-var comb = require("comb"),
- format = comb.string.format,
- Logger = comb.logging.Logger,
+var extd = require("../extended"),
qs = require("querystring");
xml2js = require('xml2js'),
crypto = require("crypto"),
http = require("http"),
https = require("https");
-var hmacSha256 = function(key, toSign) {
+var hmacSha256 = function (key, toSign) {
var hash = crypto.createHmac("sha256", key);
return hash.update(toSign).digest("base64");
};
+var BaseService = extd.declare({
-var LOGGER = Logger.getLogger("amazon-lib");
-comb.define(null, {
+ instance: {
- instance : {
+ X_AMZN_AUTHORIZATION_FORMAT: "AWS3-HTTPS AWSAccessKeyId=%s, Algorithm=HmacSHA256, Signature=%s",
- X_AMZN_AUTHORIZATION_FORMAT : "AWS3-HTTPS AWSAccessKeyId=%s, Algorithm=HmacSHA256, Signature=%s",
+ awsAccessKeyId: null,
- awsAccessKeyId : null,
+ awsSecretAccessKey: null,
- awsSecretAccessKey : null,
+ useSSL: true,
- useSSL : true,
+ signHeader: false,
- signHeader : false,
+ parse: null,
- parse : null,
+ __host: "",
- __host : "",
+ __path: "/",
- __path : "/",
+ _version: "",
- _version : "",
-
- constructor : function(args) {
- comb.merge(this, args || {});
+ constructor: function (args) {
+ extd.merge(this, args || {});
+ if (!this.http) {
+ this.http = http;
+ }
+ if (!this.https) {
+ this.https = https;
+ }
if (!this.awsAccessKeyId || !this.awsSecretAccessKey) {
- LOGGER.error("AWSAccessKeyId and AWSSecretAccessKey required");
- throw "AWSAccessKeyId and AWSSecretAccessKey required";
+ throw new Error("AWSAccessKeyId and AWSSecretAccessKey required");
} else {
if (!this._version) {
- LOGGER.error("Internal error");
- throw "Internal error";
+ throw new Error("Missing version");
}
}
},
- _tranformOptions : function(options) {
+ _tranformOptions: function (options) {
var ret = {};
for (var i in options) {
var action = i.charAt(0).toUpperCase() + i.substr(1);
@@ -58,26 +58,26 @@ comb.define(null, {
return ret;
},
- doAction : function(options) {
- var ret = new comb.Promise();
- if (comb.isObject(options) && !comb.isEmpty(options) && options.action) {
- this.doRequest(this._tranformOptions(options)).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ doAction: function (options) {
+ var ret = new extd.Promise();
+ if (extd.isObject(options) && !extd.isEmpty(options) && options.action) {
+ this.doRequest(this._tranformOptions(options)).then(ret.callback.bind(ret), ret.errback.bind(ret));
} else {
- ret.errback("Inalid query params");
+ ret.errback(new Error("Inalid query params"));
}
return ret;
},
- _makeQuery : function(options) {
+ _makeQuery: function (options) {
var query = {};
if (!this.signHeader) {
- query = comb.merge({
- SignatureMethod : "HmacSHA256",
- Version : this._version,
- SignatureVersion : "2",
- Timestamp : new Date().toISOString(),
- AWSAccessKeyId : this.awsAccessKeyId
+ query = extd.merge({
+ SignatureMethod: "HmacSHA256",
+ Version: this._version,
+ SignatureVersion: "2",
+ Timestamp: new Date().toISOString(),
+ AWSAccessKeyId: this.awsAccessKeyId
}, options);
query.Signature = this.__sign(query);
}
@@ -85,7 +85,7 @@ comb.define(null, {
},
- _makeHeaders : function(body, options) {
+ _makeHeaders: function (body, options) {
var now = new Date().toUTCString();
var ret = {
Host: this.host,
@@ -93,9 +93,9 @@ comb.define(null, {
"content-length": body.length
};
if (this.signHeader) {
- comb.merge(ret, {
- Date : now,
- "x-amzn-authorization" : format(this.X_AMZN_AUTHORIZATION_FORMAT, this.awsAccessKeyId, hmacSha256(this.awsSecretAccessKey, now))
+ extd.merge(ret, {
+ Date: now,
+ "x-amzn-authorization": format(this.X_AMZN_AUTHORIZATION_FORMAT, this.awsAccessKeyId, hmacSha256(this.awsSecretAccessKey, now))
});
}
return ret;
@@ -105,9 +105,9 @@ comb.define(null, {
/*
* Calculate HMAC signature of the query
*/
- __sign : function (query) {
+ __sign: function (query) {
var sorted = {};
- Object.keys(query).sort().forEach(function(key) {
+ Object.keys(query).sort().forEach(function (key) {
sorted[key] = query[key]
});
var sign = ["POST", this.host, this.path, qs.stringify(sorted)].join("\n")
@@ -120,76 +120,74 @@ comb.define(null, {
return hmacSha256(this.awsSecretAccessKey, sign);
},
- __handleResponse : function(res) {
- var ret = new comb.Promise();
+ __handleResponse: function (res) {
+ var ret = new extd.Promise();
var data = '';
//the listener that handles the response chunks
res.on('data', function (chunk) {
data += chunk.toString()
});
- res.on('end', comb.hitch(this, function() {
+ res.on('end', function () {
var parser = new xml2js.Parser();
- parser.parseString(data, comb.hitch(this, function(err, data) {
+ parser.parseString(data, function (err, data) {
if (err) {
ret.errback(err);
} else {
ret.callback(data);
}
- }));
- }));
- res.on("error", comb.hitch(ret, "errback"));
+ }.bind(this));
+ }.bind(this));
+ res.on("error", ret.errback.bind(ret));
return ret;
},
-
- doRequest : function(options) {
- var ret = new comb.Promise();
+ doRequest: function (options) {
+ var ret = new extd.Promise();
try {
var query = this._makeQuery(options);
var body = qs.stringify(query);
var headers = this._makeHeaders(body, options);
- var reqOptions = {host: this.host,path: this.path, method: 'POST',headers: headers};
- var req = (this.useSSL ? https : http).request(reqOptions, comb.hitch(this, function (res) {
+ var reqOptions = {host: this.__host, path: this.__path, method: 'POST', headers: headers};
+ var req = (this.useSSL ? this.https : this.http).request(reqOptions, function (res) {
if (res.statusCode == 200) {
- this.__handleResponse(res).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback", "error"));
+ this.__handleResponse(res).then(ret.callback.bind(ret), ret.errback.bind(this, "error"));
} else {
- this.__handleResponse(res).then(comb.hitch(ret, "errback", "error"), comb.hitch(ret, "errback", "error"));
+ this.__handleResponse(res).then(ret.errback.bind(this, "error"), ret.errback.bind(this, "error"));
}
- }));
- req.on("error", comb.hitch(this, function(e) {
- LOGGER.error(e);
+ }.bind(this));
+ req.on("error", function (e) {
ret.errback("error", e);
- }));
+ }.bind(this));
req.write(body);
req.end();
- } catch(e) {
+ } catch (e) {
ret.errback(e);
}
return ret;
},
- getters : {
- host : function() {
+ getters: {
+ host: function () {
return this.__host;
},
- path : function() {
+ path: function () {
return this.__path;
},
- version : function() {
+ version: function () {
return this._version;
}
},
- setters : {
- host : function(host) {
+ setters: {
+ host: function (host) {
if ("" != host && host != null) {
this.__host = host;
}
},
- path : function(path) {
+ path: function (path) {
if ("" != path && path != null) {
//just as a check to make use easier
path = path.charAt(0) == "/" ? path : "/" + path;
@@ -198,4 +196,6 @@ comb.define(null, {
}
}
}
-}).as(module);
+});
+
+module.exports = BaseService;
View
3  lib/aws/index.js
@@ -1,2 +1,3 @@
exports.SQSClient = require("./sqs");
-exports.SNSClient = require("./sns");
+exports.SNSClient = require("./sns");
+exports.ProductAdvertising = require("./product");
View
42 lib/aws/product.js
@@ -0,0 +1,42 @@
+var extd = require("../extended"),
+ BaseService = require("./baseService");
+
+var ProductService = BaseService.extend({
+
+ instance: {
+ _providers: null,
+
+ _version: "2011-08-01",
+
+ __host: "webservices.amazon.com",
+
+ __path: "/onca/xml",
+
+ _query: null,
+
+ constructor: function (config) {
+ this._super(arguments);
+ if (config.associateTag){
+ this._query = {};
+ extd.merge(this._query, {"Operation": null,
+ "Service": "AWSECommerceService",
+ AssociateTag: config.associateTag,
+ "Region": "US"});
+ } else{
+ throw Error("Must give an associateTag.")
+ }
+ },
+
+ search: function (query) {
+ this._query.Operation = "ItemSearch";
+ this._query = extd.merge(this._query, query);
+ return this.doRequest(this._query);
+ },
+
+ lookup: function(query){
+ this._query.Operation = "ItemLookup";
+ this._query = extd.merge(this._query, query);
+ return this.doRequest(this._query);
+ }
+ }
+}).as(module);
View
104 lib/aws/sns.js
@@ -1,7 +1,7 @@
-var comb = require("comb"),
+var extd = require("../extended"),
BaseService = require("./baseService");
-comb.define(BaseService, {
+BaseService.extend( {
instance : {
@@ -12,145 +12,137 @@ comb.define(BaseService, {
__topicArn : null,
addPermission : function(label, actions) {
- var ret = new comb.Promise();
if (this.topicArn) {
var query = {Action : "AddPermission", TopicArn : this.topicArn, label : label};
if (actions) {
- if (comb.isArray(actions)) {
+ if (extd.isArray(actions)) {
actions.forEach(function(opt, i) {
query["AWSAccountId." + (i + 1)] = opt.accountId;
query["ActionName." + (i + 1)] = opt.actionName;
});
- } else if (comb.isObject(actions)) {
+ } else if (extd.isObject(actions)) {
query["AWSAccountId.1"] = actions.accountId;
query["ActionName.1"] = actions.actionName;
}
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ return this.doRequest(query);
} else {
- ret.errback("Invalid query params.");
+ throw Error("Invalid query params.");
}
} else {
- ret.errback("TopicArc required");
+ throw Error("TopicArc required");
}
- return ret;
},
removePermission : function(label) {
- var ret = new comb.Promise();
if (this.topicArn) {
if (label) {
var query = {Action : "RemovePermission", TopicArn : this.topicArn, label : label};
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ return this.doRequest(query);
} else {
- ret.errback("Invalid query params.");
+ throw Error("Invalid query params.");
}
} else {
- ret.errback("TopicArc required");
+ throw Error("TopicArc required");
}
- return ret;
},
createTopic : function(name) {
- var ret = new comb.Promise();
+ var ret = new extd.Promise();
if (name) {
var query = {Action : "CreateTopic", Name : name};
- this.doRequest(query).then(comb.hitch(this, function(res) {
+ this.doRequest(query).then(function(res) {
var createTopicResult;
- if ((createTopicResult = createTopicResponse.CreateTopicResult) != null) {
- ret.callback(res.TopicArn, res);
@doug-martin Owner

This should be changed to use the chainable .then api

return this.doRequest(query).then(function(res){
     if ((createTopicResult = res.CreateTopicResult) != null) {
        return res.CreateTopicResult.TopicArc[0];
     } else {
        throw new Error("Error" + res);
     }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if ((createTopicResult = res.CreateTopicResult) != null) {
+ ret.callback(res.CreateTopicResult.TopicArn[0], res);
} else {
ret.errback("Error", res);
}
- }), comb.hitch(ret, "errback"));
+ }.bind(this), ret.errback.bind(this));
} else {
- ret.errback("Invalid query params. name required");
+ throw Error("Invalid query params. name required");
}
return ret;
},
deleteTopic : function() {
- var ret = new comb.Promise();
if (this.topicArn) {
- ret = this.doRequest({Action : "DeleteTopic", TopicArn: this.topicArn});
+ return this.doRequest({Action : "DeleteTopic", TopicArn: this.topicArn});
} else {
- ret.errback("TopicArc required");
+ throw Error("TopicArc required");
}
- return ret;
},
getTopicAttributes : function() {
- var ret = new comb.Promise();
+ var ret = new extd.Promise();
if (this.topicArn) {
- this.doRequest({Action : "GetTopicAttributes", TopicArn: this.topicArn}).then(com.hitch(this, function(res) {
+ this.doRequest({Action : "GetTopicAttributes", TopicArn: this.topicArn}).then(function(res) {
@doug-martin Owner

Same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
var getTopicResult, attributes, entry;
- if ((getTopicResult = getTopicResponse.GetTopicAttributesResult) != null && (attributes = getTopicResult.Attributes) && (entry = attributes.entry) != null && comb.isArray(entry)) {
- var ret = {};
+ if ((getTopicResult = res.GetTopicAttributesResponse.GetTopicAttributesResult[0]) != null && (attributes = getTopicResult.Attributes[0]) && (entry = attributes.entry) != null && extd.isArray(entry)) {
+ var retValue = {};
entry.forEach(function(e) {
- ret[e.key] = e.value;
+ retValue[e.key[0]] = e.value[0];
});
- ret.callback(ret, res);
+ ret.callback(retValue, res);
} else {
ret.errback("Error", res);
}
- }), comb.hitch(ret, "errback"));
+ }.bind(this), ret.errback.bind(this));
} else {
- ret.errback("TopicArc required");
+ throw Error("TopicArc required");
}
return ret;
},
publish : function(options) {
- var ret = new comb.Promise();
+ var ret = new extd.Promise();
if (this.topicArn) {
- if (comb.isObject(options) && !comb.isEmpty(options) && options.message) {
- var query = comb.merge({Action : "Publish", TopicArn: this.topicArn}, this._tranformOptions(options));
- this.doRequest(query).then(comb.hitch(this, function(res) {
- var publishResult;
- if ((publishResult = res.PublishResult) != null) {
- ret.callback(publishResult.MessageId, res);
+ if (extd.isObject(options) && !extd.isEmpty(options) && options.message) {
+ var query = extd.merge({Action : "Publish", TopicArn: this.topicArn}, this._tranformOptions(options));
+ this.doRequest(query).then(function(res) {
+ var publishResponse = res.PublishResponse, publishResult;
+ if (publishResponse != null && ((publishResult = publishResponse.PublishResult[0]) != null)) {
+ ret.callback(publishResult.MessageId[0], res);
} else {
ret.errback("Error", res);
}
- }), comb.hitch(ret, "errback"));
+ }.bind(this), ret.errback.bind(this));
} else {
- ret.errback("Invalid query params, message required");
+ throw Error("Invalid query params, message required");
}
} else {
- ret.errback("TopicArc required");
+ throw Error("TopicArc required");
}
return ret;
},
subscribe : function(options) {
- var ret = new comb.Promise();
+ var ret = new extd.Promise();
if (this.topicArn) {
- if (comb.isObject(options) && !comb.isEmpty(options) && options.endpoint && options.protocol) {
- var query = comb.merge({Action : "Subscribe", TopicArn: this.topicArn}, this._tranformOptions(options));
- this.doRequest(query).then(comb.hitch(this, function(res) {
- var subscribeResult;
- if ((subscribeResult = res.SubscribeResult) != null) {
- ret.callback(subscribeResult.SubscriptionArn, res);
+ if (extd.isObject(options) && !extd.isEmpty(options) && options.endpoint && options.protocol) {
+ var query = extd.merge({Action : "Subscribe", TopicArn: this.topicArn}, this._tranformOptions(options));
+ this.doRequest(query).then(function(res) {
+ var subscribeResponse = res.SubscribeResponse;
+ if ((subscribeResult = subscribeResponse.SubscribeResult[0]) != null) {
+ ret.callback(subscribeResult.SubscriptionArn[0], res);
} else {
ret.errback("Error", res);
}
- }), comb.hitch(ret, "errback"));
+ }.bind(this), ret.errback.bind(this));
} else {
- ret.errback("Invalid query params, message required");
+ throw Error("Invalid query params, protocol and endpoint required");
}
} else {
- ret.errback("TopicArc required");
+ throw Error("TopicArc required");
}
return ret;
},
unSubscribe : function() {
- var ret = new comb.Promise();
if (this.topicArn) {
- this.doRequest({Action : "Unsubscribe", SubscriptionArn: this.topicArn}).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ return this.doRequest({Action : "Unsubscribe", SubscriptionArn: this.topicArn});
} else {
- ret.errback("TopicArc required");
+ throw Error("TopicArc required");
}
- return ret;
},
View
72 lib/aws/sqs.js
@@ -1,7 +1,7 @@
-var comb = require("comb"),
+var extd = require("../extended"),
BaseService = require("./baseService");
-comb.define(BaseService, {
+BaseService.extend({
instance : {
@@ -9,7 +9,7 @@ comb.define(BaseService, {
__host : "sqs.us-east-1.amazonaws.com",
- _version : "2009-02-01",
+ _version : "2012-11-05",
constructor : function(options) {
this._super(arguments);
@@ -17,16 +17,16 @@ comb.define(BaseService, {
listQueues : function(queueNamePrefix) {
var opts = {Action : "ListQueues"};
- var ret = new comb.Promise();
+ var ret = new extd.Promise();
queueNamePrefix && (opts.QueueNamePrefix = queueNamePrefix);
- this.doRequest(opts).then(comb.hitch(this, function(result) {
- var res = result.ListQueuesResult;
- var urls = res.QueueUrl;
- if (!comb.isArray(urls)) {
+ this.doRequest(opts).then(function(result) {
+ var res = result.ListQueuesResponse.ListQueuesResult[0];
+ var urls = res.QueueUrl[0];
+ if (!extd.isArray(urls)) {
urls = [urls];
}
ret.callback(urls, result)
- }), comb.hitch(ret, "errback"));
+ }.bind(this), ret.errback.bind(ret));
return ret;
},
@@ -35,21 +35,19 @@ comb.define(BaseService, {
},
deleteMessage : function(receiptHandle) {
- var ret = new comb.Promise();
if (receiptHandle) {
var query = {Action : "DeleteMessage", ReceiptHandle : receiptHandle};
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ return this.doRequest(query);
} else {
- ret.errback("Invalid query params.");
+ throw Error("Invalid query params.");
}
- return ret;
},
receiveMessages : function(options) {
- var ret = new comb.Promise();
+ var ret = new extd.Promise();
var query = {Action : "ReceiveMessage"};
- if (comb.isObject(options) && !comb.isEmpty(options)) {
- comb.merge(query, this._tranformOptions(options));
+ if (extd.isObject(options) && !extd.isEmpty(options)) {
+ extd.merge(query, this._tranformOptions(options));
}
var transformMessage = function(m) {
return {
@@ -61,76 +59,70 @@ comb.define(BaseService, {
})
};
};
- this.doRequest(query).then(comb.hitch(this, function(res) {
+ this.doRequest(query).then(function(res) {
var receiveMessageResult, messages;
if (res && (receiveMessageResult = res.ReceiveMessageResult) != null && (messages = receiveMessageResult.Message) != null) {
- if (comb.isArray(messages)) {
+ if (extd.isArray(messages)) {
ret.callback(messages.map(transformMessage), res);
- } else if (comb.isObject(messages)) {
+ } else if (extd.isObject(messages)) {
ret.callback([transformMessage(messages)]);
}
} else {
ret.callback([], res);
}
- }), comb.hitch(ret, "errback"));
+ }.bind(this), ret.errback.bind(ret));
return ret;
},
addPermission : function(label, actions) {
- var ret = new comb.Promise();
var query = {Action : "AddPermission",label : label};
if (actions) {
- if (comb.isArray(actions)) {
+ if (extd.isArray(actions)) {
actions.forEach(function(opt, i) {
query["AWSAccountId." + (i + 1)] = opt.accountId;
query["ActionName." + (i + 1)] = opt.actionName;
});
- } else if (comb.isObject(actions)) {
+ } else if (extd.isObject(actions)) {
query["AWSAccountId.1"] = actions.accountId;
query["ActionName.1"] = actions.actionName;
}
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ return this.doRequest(query);
} else {
- ret.errback("Invalid query params.");
+ throw Error("Invalid query params.");
}
- return ret;
},
removePermission : function(label) {
- var ret = new comb.Promise();
if (label) {
var query = {Action : "RemovePermission", label : label};
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ return this.doRequest(query);
} else {
- ret.errback("Invalid query params.");
+ throw Error("Invalid query params.");
}
- return ret;
},
sendMessage : function(messageBody) {
- var ret = new comb.Promise();
+ var ret = new extd.Promise();
if (messageBody) {
var query = {Action:"SendMessage", MessageBody : messageBody};
- this.doRequest(query).then(comb.hitch(this, function(res) {
- var result = res.SendMessageResult;
- var r = {md5OfMessageBody : result.MD5OfMessageBody, result : result.MessageId};
+ this.doRequest(query).then(function(res) {
+ var result = res.SendMessageResponse.SendMessageResult[0];
+ var r = {md5OfMessageBody : result.MD5OfMessageBody[0], result : result.MessageId[0]};
ret.callback(r, res);
- }), comb.hitch(ret, "errback"));
+ }.bind(this), ret.errback.bind(ret));
} else {
- ret.errback("Invalid query params.");
+ throw Error("Invalid query params.");
}
return ret;
},
changeMessageVisibility : function(receiptHandle, visibilityTimeout) {
- var ret = new comb.Promise();
if (receiptHandle && !isNaN(visibilityTimeout)) {
var query = {Action : "ChangeMessageVisibility", ReceiptHandle : receiptHandle, VisibilityTimeout : visibilityTimeout};
- this.doRequest(query).then(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
+ return this.doRequest(query);
} else {
- ret.errback("Invalid query params.");
+ throw Error("Invalid query params.");
}
- return ret;
},
getters : {
View
5 lib/extended.js
@@ -0,0 +1,5 @@
+module.exports = require("extended")()
+ .register(require("object-extended"))
+ .register(require("promise-extended"))
+ .register(require("is-extended"))
+ .register("declare", require("declare.js"));
View
13 package.json
@@ -10,8 +10,17 @@
"author": "Doug Martin",
"main": "index.js",
"dependencies" : {
- "comb" : ">=0.0.5",
- "xml2js" : ">=0.1.11"
+ "xml2js" : ">=0.1.11",
+ "extended": "~0.0.3",
+ "declare.js": "~0.0.4",
+ "promise-extended": "~0.0.4",
+ "object-extended": "~0.0.3",
+ "is-extended": "~0.0.4",
+ "it": "~0.2.2",
+ "sandboxed-module": "~0.2.0"
+ },
+ "scripts": {
+ "test": "it -r dot"
},
"directories": {
"lib": "lib"
View
63 test/mock_http.js
@@ -0,0 +1,63 @@
+var extd = require("../lib/extended"),
+ EventEmitter = require('events').EventEmitter;
+
+var MockResponse = extd.declare(EventEmitter, {
+ instance: {
+
+ constructor: function (config) {
+ this._super(arguments);
+ extd.merge(this, config);
+ },
+
+ setEncoding: function () {
+
+ },
+ write: function () {
+
+ },
+ end: function () {
+ // Request module checks against the connection object event emitter
+ this.connection = this;
+ this.pause = this.resume = {apply: function () {
+ }};
+ this.setEncoding = function () {
+ };
+ this.pipe = function (outputStream) {
+ outputStream.write(this.data);
+ outputStream.end();
+ };
+ this.statusCode = this.statusCode;
+ this.headers = {};
+ if (this.contentType) {
+ this.headers['content-type'] = this.contentType;
+ }
+ this.emit('response', this);
+ this.emit('data', this.data);
+ this.emit('end');
+ this.emit('close');
+ }
+ }
+
+});
+
+var MockHttp = extd.declare({
+ instance: {
+ constructor: function (assertOptions, assertBody, xmlData) {
+ var testxml = "<?xml version=\"1.0\" ?><test>test</test>";
+ this.assertOptions = assertOptions;
+ this.assertBody = assertBody;
+ this.xmlData = (xmlData ? xmlData : testxml);
+ },
+ requestCount: 0,
+ request: function (options, cb) {
+ this.requestCount++;
+ var mockResponse = new MockResponse({statusCode: 200, data : this.xmlData, contentType: "xml", write: this.assertBody });
+ cb(mockResponse);
+ mockResponse.end();
+ this.assertOptions(options);
+ return mockResponse;
+ }
+ }
+});
+
+module.exports = MockHttp;
View
86 test/product.test.js
@@ -0,0 +1,86 @@
+var it = require("it"),
+ extd = require("../lib/extended"),
+ assert = require("assert"),
+ qs = require("querystring"),
+ MockHttp = require("./mock_http"),
+ aws = require('../lib/aws');
+
+
+it.describe("Make a call to the amazon product advertising",function (it) {
+
+ var mockHttp, mockHttps,
+ requiredOptions = {
+ associateTag: "associateTag",
+ awsAccessKeyId: "awsAccessKeyId",
+ awsSecretAccessKey: "awsSecretAccessKey"
+ },
+ testSearchOptions = extd.merge({
+ SearchIndex: "SearchIndex",
+ Keyword: "Keyword"
+ }, requiredOptions),
+ testLookupOptions = extd.merge({
+ SearchIndex: "Books",
+ IdItem: "ISBN",
+ ItemId: "2314rwqer3"
+ }, requiredOptions);
+
+ function createMockHttp(assertOptions, assertBody) {
+ mockHttp = new MockHttp(assertOptions, assertBody);
+ mockHttps = new MockHttp(assertOptions, assertBody);
+ mockHttp.requestCount = 0;
+ mockHttps.requestCount = 0;
+ }
+
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ assert.equal(options.host, "webservices.amazon.com");
+ assert.equal(options.path, "/onca/xml");
+ };
+
+ it.should("throw exception if parameters are missing", function (next) {
+ assert.throws(function () {
+ return new aws.ProductAdvertising({http: mockHttp, https: mockHttps})
+ }, Error);
+ next()
+ });
+
+ it.should("query for products", function () {
+
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.SearchIndex, testSearchOptions.SearchIndex);
+ assert.equal(body.Operation, "ItemSearch");
+ assert.equal(body.AssociateTag, testSearchOptions.associateTag);
+ assert.equal(body.Keyword, testSearchOptions.Keyword);
+ assert.equal(body.SearchIndex, testSearchOptions.SearchIndex);
+ };
+ createMockHttp(assertOptions, assertBody);
+
+ var productService = new aws.ProductAdvertising(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return productService.search(testSearchOptions).then(function (results) {
+ assert.equal(results.test, "test");
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("lookup by item id", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.SearchIndex, testLookupOptions.SearchIndex);
+ assert.equal(body.Operation, "ItemLookup");
+ assert.equal(body.AssociateTag, testLookupOptions.associateTag);
+ assert.equal(body.IdItem, testLookupOptions.IdItem);
+ assert.equal(body.ItemId, testLookupOptions.ItemId);
+ };
+ createMockHttp(assertOptions, assertBody);
+ var productService = new aws.ProductAdvertising(extd.merge(testLookupOptions, {http: mockHttp, https: mockHttps}));
+ return productService.lookup(testLookupOptions).then(function (results) {
+ assert.equal(results.test, "test");
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+}).as(module);
+
View
178 test/sns.test.js
@@ -0,0 +1,178 @@
+var it = require("it"),
+ extd = require("../lib/extended"),
+ assert = require("assert"),
+ qs = require("querystring"),
+ MockHttp = require("./mock_http"),
+ aws = require('../lib/aws');
+
+it.describe("Make a call to the amazon sns",function (it) {
+
+ var mockHttp, mockHttps,
+ requiredOptions = {
+ associateTag: "associateTag",
+ awsAccessKeyId: "awsAccessKeyId",
+ awsSecretAccessKey: "awsSecretAccessKey",
+ topicArn: "topicArn"
+ },
+ testSearchOptions = extd.merge({
+ SearchIndex: "SearchIndex",
+ Keyword: "Keyword"
+ }, requiredOptions),
+ testPublishOptions = extd.merge({
+ message: "message"
+ }, requiredOptions),
+ testSubscribeOptions = extd.merge({
+ protocol: "protocol",
+ endpoint: "endpoint"
+ }, requiredOptions);
+ ;
+
+ function createMockHttp(assertOptions, assertBody, xmlData) {
+ mockHttp = new MockHttp(assertOptions, assertBody, xmlData);
+ mockHttps = new MockHttp(assertOptions, assertBody, xmlData);
+ mockHttp.requestCount = 0;
+ mockHttps.requestCount = 0;
+ }
+
+ it.should("throw exception if parameters are missing", function () {
+ assert.throws(function () {
+ return new aws.SNSClient({http: mockHttp, https: mockHttps})
+ }, Error);
+ });
+
+ it.should("add permission", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.TopicArn, testSearchOptions.topicArn);
+ assert.equal(body.Action, "AddPermission");
+ };
+ createMockHttp(assertOptions, assertBody);
+
+ var snsClient = new aws.SNSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.addPermission(testSearchOptions, {}).then(function (results) {
+ assert.equal(results.test, "test");
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("remove permission", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.TopicArn, testSearchOptions.topicArn);
+ assert.equal(body.Action, "RemovePermission");
+ };
+ createMockHttp(assertOptions, assertBody);
+
+ var snsClient = new aws.SNSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.removePermission(testSearchOptions).then(function (results) {
+ assert.equal(results.test, "test");
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("create topic", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "CreateTopic");
+ };
+ createMockHttp(assertOptions, assertBody, "<CreateTopicResult><TopicArn>test</TopicArn></CreateTopicResult><ResponseMetadata><RequestId>test</RequestId></ResponseMetadata>");
+
+ var snsClient = new aws.SNSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.createTopic(testSearchOptions).then(function (results) {
+ assert.equal(results, "test");
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("delete topic", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "DeleteTopic");
+ };
+ createMockHttp(assertOptions, assertBody, "<DeleteTopicResult><ResponseMetadata><RequestId>test</RequestId></ResponseMetadata></DeleteTopicResult>");
+
+ var snsClient = new aws.SNSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.deleteTopic(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ }, console.log)
+ });
+
+
+ it.should("get topic attributes", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "GetTopicAttributes");
+ };
+ createMockHttp(assertOptions, assertBody, '<GetTopicAttributesResponse xmlns=\"http://sns.amazonaws.com/doc/2010-03-31/\"><GetTopicAttributesResult><Attributes><entry><key>Owner</key><value>123456789012</value></entry><entry><key>Policy</key><value>{"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}</value></entry><entry><key>TopicArn</key><value>arn:aws:sns:us-east-1:123456789012:My-Topic</value></entry></Attributes></GetTopicAttributesResult><ResponseMetadata><RequestId>057f074c-33a7-11df-9540-99d0768312d3</RequestId></ResponseMetadata></GetTopicAttributesResponse>');
+
+ var snsClient = new aws.SNSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.getTopicAttributes(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("publish", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "Publish");
+ };
+ createMockHttp(assertOptions, assertBody, '<PublishResponse xmlns=\"http://sns.amazonaws.com/doc/2010-03-31/\"><PublishResult><MessageId>94f20ce6-13c5-43a0-9a9e-ca52d816e90b</MessageId></PublishResult><ResponseMetadata><RequestId>f187a3c1-376f-11df-8963-01868b7c937a</RequestId></ResponseMetadata></PublishResponse>');
+
+ var snsClient = new aws.SNSClient(extd.merge(testPublishOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.publish(testPublishOptions).then(function (res) {
+ assert.equal(res, '94f20ce6-13c5-43a0-9a9e-ca52d816e90b');
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("subscribe", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "Subscribe");
+ };
+ createMockHttp(assertOptions, assertBody, '<SubscribeResponse xmlns=\"http://sns.amazonaws.com/doc/2010-03-31/\"><SubscribeResult><SubscriptionArn>pending confirmation</SubscriptionArn></SubscribeResult><ResponseMetadata><RequestId>a169c740-3766-11df-8963-01868b7c937a</RequestId></ResponseMetadata></SubscribeResponse>');
+
+ var snsClient = new aws.SNSClient(extd.merge(testSubscribeOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.subscribe(testSubscribeOptions).then(function (res) {
+ assert.equal(res, 'pending confirmation');
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("unSubscribe", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "Unsubscribe");
+ };
+ createMockHttp(assertOptions, assertBody, '<UnsubscribeResponse xmlns=\"http://sns.amazonaws.com/doc/2010-03-31/\"><ResponseMetadata><RequestId>18e0ac39-3776-11df-84c0-b93cc1666b84</RequestId></ResponseMetadata></UnsubscribeResponse>');
+
+ var snsClient = new aws.SNSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return snsClient.unSubscribe(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+}).as(module);
View
168 test/sqs.test.js
@@ -0,0 +1,168 @@
+var it = require("it"),
+ extd = require("../lib/extended"),
+ assert = require("assert"),
+ qs = require("querystring"),
+ MockHttp = require("./mock_http"),
+ aws = require('../lib/aws');
+
+it.describe("Make a call to the amazon sqs",function (it) {
+
+ var mockHttp, mockHttps,
+ requiredOptions = {
+ associateTag: "associateTag",
+ awsAccessKeyId: "awsAccessKeyId",
+ awsSecretAccessKey: "awsSecretAccessKey"
+ },
+ testSearchOptions = extd.merge({
+ SearchIndex: "SearchIndex",
+ Keyword: "Keyword"
+ }, requiredOptions),
+ testLookupOptions = extd.merge({
+ SearchIndex: "Books",
+ IdItem: "ISBN",
+ ItemId: "2314rwqer3"
+ }, requiredOptions);
+
+ function createMockHttp(assertOptions, assertBody, xmlData) {
+ mockHttp = new MockHttp(assertOptions, assertBody, xmlData);
+ mockHttps = new MockHttp(assertOptions, assertBody, xmlData);
+ mockHttp.requestCount = 0;
+ mockHttps.requestCount = 0;
+ }
+
+ it.should("throw exception if parameters are missing", function () {
+ assert.throws(function () {
+ return new aws.SQSClient({http: mockHttp, https: mockHttps})
+ }, Error);
+ });
+
+ it.should("list queues", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "ListQueues");
+ };
+ createMockHttp(assertOptions, assertBody, '<ListQueuesResponse><ListQueuesResult><QueueUrl>http://sqs.us-east-1.amazonaws.com/123456789012/testQueue</QueueUrl></ListQueuesResult><ResponseMetadata><RequestId>725275ae-0b9b-4762-b238-436d7c65a1ac</RequestId></ResponseMetadata></ListQueuesResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.listQueues(testSearchOptions).then(function (res) {
+ assert.equal(res, 'http://sqs.us-east-1.amazonaws.com/123456789012/testQueue');
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("delete queue", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "DeleteQueue");
+ };
+ createMockHttp(assertOptions, assertBody, '<DeleteQueueResponse><ResponseMetadata><RequestId>6fde8d1e-52cd-4581-8cd9-c512f4c64223</RequestId></ResponseMetadata></DeleteQueueResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.deleteQueue(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("deleteMessage", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "DeleteMessage");
+ };
+ createMockHttp(assertOptions, assertBody, '<DeleteMessageResponse><ResponseMetadata><RequestId>b5293cb5-d306-4a17-9048-b263635abe42</RequestId></ResponseMetadata></DeleteMessageResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.deleteMessage(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("receive messages", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "ReceiveMessage");
+ };
+ createMockHttp(assertOptions, assertBody, '<ReceiveMessageResponse><ReceiveMessageResult><Message><MessageId>5fea7756-0ea4-451a-a703-a558b933e274</MessageId><ReceiptHandle>MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+CwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0=</ReceiptHandle><MD5OfBody>fafb00f5732ab283681e124bf8747ed1</MD5OfBody><Body>This is a test message</Body><Attribute><Name>SenderId</Name><Value>195004372649</Value></Attribute><Attribute><Name>SentTimestamp</Name><Value>1238099229000</Value></Attribute><Attribute><Name>ApproximateReceiveCount</Name><Value>5</Value></Attribute><Attribute><Name>ApproximateFirstReceiveTimestamp</Name><Value>1250700979248</Value></Attribute></Message></ReceiveMessageResult><ResponseMetadata><RequestId>b6633655-283d-45b4-aee4-4e84e0ae6afa</RequestId></ResponseMetadata></ReceiveMessageResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.receiveMessages(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("add permission", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "AddPermission");
+ };
+ createMockHttp(assertOptions, assertBody, '<AddPermissionResponse><ResponseMetadata><RequestId>9a285199-c8d6-47c2-bdb2-314cb47d599d</RequestId></ResponseMetadata></AddPermissionResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.addPermission(testSearchOptions, {accountId:"test", actionName: 'test'}).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("remove permission", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "RemovePermission");
+ };
+ createMockHttp(assertOptions, assertBody, '<RemovePermissionResponse><ResponseMetadata><RequestId>f8bdb362-6616-42c0-977a-ce9a8bcce3bb</RequestId></ResponseMetadata></RemovePermissionResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.removePermission(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("send message", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "SendMessage");
+ };
+ createMockHttp(assertOptions, assertBody, '<SendMessageResponse><SendMessageResult><MD5OfMessageBody>fafb00f5732ab283681e124bf8747ed1</MD5OfMessageBody><MessageId>5fea7756-0ea4-451a-a703-a558b933e274</MessageId></SendMessageResult><ResponseMetadata><RequestId>27daac76-34dd-47df-bd01-1f6e873584a0</RequestId></ResponseMetadata></SendMessageResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.sendMessage(testSearchOptions).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+ it.should("change message visibility", function () {
+ var assertOptions = function (options) {
+ assert.equal(options.method, "POST");
+ };
+ var assertBody = function (body) {
+ body = qs.parse(body);
+ assert.equal(body.Action, "ChangeMessageVisibility");
+ };
+ createMockHttp(assertOptions, assertBody, '<ChangeMessageVisibilityResponse><ResponseMetadata><RequestId>6a7a282a-d013-4a59-aba9-335b0fa48bed</RequestId></ResponseMetadata></ChangeMessageVisibilityResponse>');
+
+ var sqsClient = new aws.SQSClient(extd.merge(testSearchOptions, {http: mockHttp, https: mockHttps}));
+ return sqsClient.changeMessageVisibility(testSearchOptions, 1).then(function () {
+ assert.equal(mockHttps.requestCount, 1);
+ })
+ });
+
+}).as(module);
Something went wrong with that request. Please try again.