From 827033deb3fbd55cabaf65297c0518beee32989e Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Mon, 16 Jun 2014 21:08:22 -0600 Subject: [PATCH] Closes #8. Implemented Posts. Stable Version 0.12.0. --- .jshintrc | 2 +- CHANGELOG.md | 5 + Gruntfile.js | 2 +- README.md | 137 +++++++++- doc.md | 137 +++++++++- lib/api/Posts.js | 530 ++++++++++++++++++++++++++++++++++++ lib/cli/index.js | 11 +- lib/cli/posts.js | 436 +++++++++++++++++++++++++++++ lib/index.js | 6 + package.json | 2 +- test/unit/api/Posts.test.js | 187 +++++++++++++ test/unit/api/index.js | 2 + 12 files changed, 1449 insertions(+), 8 deletions(-) create mode 100644 lib/api/Posts.js create mode 100644 lib/cli/posts.js create mode 100644 test/unit/api/Posts.test.js diff --git a/.jshintrc b/.jshintrc index 3f3cb8b..b442f2a 100644 --- a/.jshintrc +++ b/.jshintrc @@ -71,5 +71,5 @@ "sub": true, "trailing": true, "white": true, - "indent": 4 + "indent": 2 } diff --git a/CHANGELOG.md b/CHANGELOG.md index adabcb7..c3624ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +##### 0.12.0 - 16 June 2014 + +###### Backwards compatible API changes +- #8 - Implemented Posts + ##### 0.11.0 - 15 June 2014 ###### Breaking API changes diff --git a/Gruntfile.js b/Gruntfile.js index 49767e9..daa5da2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,7 +11,7 @@ module.exports = function (grunt) { watch: { dist: { - files: ['lib/**/*.js', 'test/**.*.js', 'README.md'], + files: ['lib/**/*.js', 'test/**.*.js', 'README.md', 'doc.md'], tasks: ['build'] } }, diff --git a/README.md b/README.md index 07dd500..7c4e16a 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,139 @@ Copyright © 2014 Jason Dobry [![Dependency Status](https://gemnasium.com/jmdobry/disqus-node.svg)](https://gemnasium.com/jmdobry/disqus-node) ## Documentation -[API](http://disqus-node.pseudobry.com/lib/index.html) | [CLI](http://disqus-node.pseudobry.com/lib/cli/index.html) +__[Disqus v3.0 API Documentation](https://disqus.com/api/docs/)__ + +
+#### API Client Library +__[API Client Library Documentation](http://disqus-node.pseudobry.com/lib/index.html)__ + +```js +var Disqus = require('disqus-node'); + +var disqus = new Disqus({ + // required + api_secret: 'abcdefgh', + // required when authentication is required + access_token: '12345678', + // defaults shown + logLevel: 'info', + https: true +}); + +// promise-style +disqus.forums.listPosts({ + forum: 'pseudobry', + limit: 3 +}).then(function (response) { + response; // { + "cursor": {...}, + "code": 0, + "response": [ + {...}, + {...}, + {...} + ] + } +}); + +// node-style +disqus.forums.listPosts({ + forum: 'pseudobry', + limit: 3 +}, function (err, response) { + response; // { + "cursor": {...}, + "code": 0, + "response": [ + {...}, + {...}, + {...} + ] + } +}); +``` + +
+#### Command-line Interface +__[CLI Documentation](http://disqus-node.pseudobry.com/lib/cli/index.html)__ + +``` +$ npm install -g disqus-node +``` + +CLI available as `disqus`. `disqus` has a number of available resources: + +``` +$ disqus -h + +Usage: disqus [options] + +Commands: + +applications [options] Execute command for the Applications resource. +blacklists [options] Execute command for the Blacklists resource. +categories [options] Execute command for the Categories resource. +exports [options] Execute command for the Exports resource. +forums [options] Execute command for the Forums resource. +imports [options] Execute command for the Imports resource. +posts [options] Execute command for the Posts resource. +topics [options] Execute command for the Topics resource. +trends [options] Execute command for the Trends resource. +whitelists [options] Execute command for the Whitelists resource. + +Options: + +-h, --help output usage information +-V, --version output the version number +``` + +Each resource has available commands: + +``` +$ disqus forums -h + +Usage: disqus forums [options] + +Commands: + +addModerator [options] Adds a moderator to a forum. +create [options] Creates a new forum. +details [options] Returns forum details. +follow [options] Follow a forum. +installed [options] Returns true if forum has one or more views. +listCategories [options] Returns a list of categories within a forum. +listFollowers [options] Returns a list of users following a forum. +listModerators [options] Returns a list of all moderators on a forum. +listMostActiveUsers [options] Returns a list of users active within a forum ordered by most comments made. +listMostLikedUsers [options] Returns a list of users active within a forum ordered by most likes received. +listPosts [options] Returns a list of posts within a forum. +listThreads [options] Returns a list of threads within a forum sorted by the date created. +listUsers [options] Returns a list of users active within a forum. +removeModerator [options] Removes a moderator from a forum. +unfollow [options] Unfollow a forum. + +Options: + +-h, --help output usage information +``` +
+ +``` +$ disqus forums listPosts -f pseudobry -S '1234abcd' -l 3 + +{ + "cursor": {...}, + "code": 0, + "response": [ + {...}, + {...}, + {...} + ] +} +``` + +
## Functional - Applications - Blacklists @@ -26,14 +157,16 @@ Copyright © 2014 Jason Dobry - Exports - Forums - Imports +- Posts - Topics - Trends - Whitelists +
## Not Yet Implemented -- Posts - Threads - Users +
## License [Apache License Version 2.0](https://github.com/jmdobry/disqus-node/blob/master/LICENSE) diff --git a/doc.md b/doc.md index 3a53e3d..ca79e9d 100644 --- a/doc.md +++ b/doc.md @@ -17,8 +17,139 @@ Copyright © 2014 Jason Dobry [![Dependency Status](https://gemnasium.com/jmdobry/disqus-node.svg)](https://gemnasium.com/jmdobry/disqus-node) ## Documentation -[API](/lib/index.html) | [CLI](/lib/cli/index.html) +__[Disqus v3.0 API Documentation](https://disqus.com/api/docs/)__ + +
+#### API Client Library +__[API Client Library Documentation](/lib/index.html)__ + +```js +var Disqus = require('disqus-node'); + +var disqus = new Disqus({ + // required + api_secret: 'abcdefgh', + // required when authentication is required + access_token: '12345678', + // defaults shown + logLevel: 'info', + https: true +}); + +// promise-style +disqus.forums.listPosts({ + forum: 'pseudobry', + limit: 3 +}).then(function (response) { + response; // { + "cursor": {...}, + "code": 0, + "response": [ + {...}, + {...}, + {...} + ] + } +}); + +// node-style +disqus.forums.listPosts({ + forum: 'pseudobry', + limit: 3 +}, function (err, response) { + response; // { + "cursor": {...}, + "code": 0, + "response": [ + {...}, + {...}, + {...} + ] + } +}); +``` + +
+#### Command-line Interface +__[CLI Documentation](/lib/cli/index.html)__ + +``` +$ npm install -g disqus-node +``` + +CLI available as `disqus`. `disqus` has a number of available resources: + +``` +$ disqus -h + +Usage: disqus [options] + +Commands: + +applications [options] Execute command for the Applications resource. +blacklists [options] Execute command for the Blacklists resource. +categories [options] Execute command for the Categories resource. +exports [options] Execute command for the Exports resource. +forums [options] Execute command for the Forums resource. +imports [options] Execute command for the Imports resource. +posts [options] Execute command for the Posts resource. +topics [options] Execute command for the Topics resource. +trends [options] Execute command for the Trends resource. +whitelists [options] Execute command for the Whitelists resource. + +Options: + +-h, --help output usage information +-V, --version output the version number +``` + +Each resource has available commands: + +``` +$ disqus forums -h + +Usage: disqus forums [options] + +Commands: + +addModerator [options] Adds a moderator to a forum. +create [options] Creates a new forum. +details [options] Returns forum details. +follow [options] Follow a forum. +installed [options] Returns true if forum has one or more views. +listCategories [options] Returns a list of categories within a forum. +listFollowers [options] Returns a list of users following a forum. +listModerators [options] Returns a list of all moderators on a forum. +listMostActiveUsers [options] Returns a list of users active within a forum ordered by most comments made. +listMostLikedUsers [options] Returns a list of users active within a forum ordered by most likes received. +listPosts [options] Returns a list of posts within a forum. +listThreads [options] Returns a list of threads within a forum sorted by the date created. +listUsers [options] Returns a list of users active within a forum. +removeModerator [options] Removes a moderator from a forum. +unfollow [options] Unfollow a forum. + +Options: + +-h, --help output usage information +``` +
+ +``` +$ disqus forums listPosts -f pseudobry -S '1234abcd' -l 3 + +{ + "cursor": {...}, + "code": 0, + "response": [ + {...}, + {...}, + {...} + ] +} +``` + +
## Functional - Applications - Blacklists @@ -26,14 +157,16 @@ Copyright © 2014 Jason Dobry - Exports - Forums - Imports +- Posts - Topics - Trends - Whitelists +
## Not Yet Implemented -- Posts - Threads - Users +
## License [Apache License Version 2.0](https://github.com/jmdobry/disqus-node/blob/master/LICENSE) diff --git a/lib/api/Posts.js b/lib/api/Posts.js new file mode 100644 index 0000000..efdb858 --- /dev/null +++ b/lib/api/Posts.js @@ -0,0 +1,530 @@ +/** + * [Up one level](/lib/index.html) + * ### Posts API + * See the disqus-node [Posts CLI](/lib/cli/posts.html). + * + * See the [Posts API on Disqus.com](https://disqus.com/api/docs/posts/). + */ +var methods = { + approve: { + resource: 'posts', + name: 'approve', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, + create: { + resource: 'posts', + name: 'create', + method: 'POST', + requiredOptions: ['api_secret', 'message'], + availableOptions: ['parent', 'thread', 'author_email', 'author_name', 'state', 'author_url', 'date', 'ip_address'] + }, + details: { + resource: 'posts', + name: 'details', + method: 'GET', + requiredOptions: ['api_secret', 'post'], + availableOptions: ['related'] + }, + getContext: { + resource: 'posts', + name: 'getContext', + method: 'GET', + requiredOptions: ['api_secret', 'post'], + availableOptions: ['depth', 'related'] + }, + list: { + resource: 'posts', + name: 'list', + method: 'GET', + requiredOptions: ['api_secret'], + availableOptions: ['category', 'thread', 'forum', 'since', 'related', 'cursor', 'limit', 'query', 'include', 'order'] + }, + listPopular: { + resource: 'posts', + name: 'listPopular', + method: 'GET', + requiredOptions: ['api_secret'], + availableOptions: ['category', 'interval', 'thread', 'forum', 'related', 'limit', 'offset', 'query', 'include', 'order'] + }, + remove: { + resource: 'posts', + name: 'remove', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, + report: { + resource: 'posts', + name: 'report', + method: 'POST', + requiredOptions: ['api_secret', 'post'], + availableOptions: [] + }, + restore: { + resource: 'posts', + name: 'restore', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, + spam: { + resource: 'posts', + name: 'spam', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, + update: { + resource: 'posts', + name: 'update', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'message', 'post'], + availableOptions: [] + }, + vote: { + resource: 'posts', + name: 'vote', + method: 'POST', + requiredOptions: ['api_secret', 'vote', 'post'], + availableOptions: [] + } +}; + +module.exports = function (util) { + return function Posts(config) { + + /** + * ### approve + * Approves the requested post(s). + * + * Signature: + * ```js + * Disqus#posts.approve(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.approve({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.approve({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.approve = function (options, cb) { + return util.executeAPIMethod(methods.approve, options, config, cb); + }; + + /** + * ### create + * Creates a new post. + * + * Signature: + * ```js + * Disqus#posts.create(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.create({ + * message: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.create({ + * message: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.create = function (options, cb) { + return util.executeAPIMethod(methods.create, options, config, cb); + }; + + /** + * ### details + * Returns information about a post. + * + * Signature: + * ```js + * Disqus#posts.details(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.details({ + * post: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.details({ + * post: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.details = function (options, cb) { + return util.executeAPIMethod(methods.details, options, config, cb); + }; + + /** + * ### getContext + * Returns the hierarchal tree of a post (all parents). + * + * Signature: + * ```js + * Disqus#posts.getContext(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.getContext({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * // optional, defaults shown + * depth: 10, + * related: [] + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.getContext({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * // optional, defaults shown + * depth: 10, + * related: [] + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.getContext = function (options, cb) { + return util.executeAPIMethod(methods.getContext, options, config, cb); + }; + + /** + * ### list + * Returns a list of posts ordered by the date created. + * + * Signature: + * ```js + * Disqus#posts.list(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.list({ + * api_secret: 'asdfghkj', // required, can be set globally + * // optional, defaults shown + * category: null, + * thread: null, + * forum: null, + * since: null, + * related: [], + * cursor: null, + * limit: 25, + * query: null, + * include: ['approved'], + * order: 'desc' + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.list({ + * api_secret: 'asdfghkj', // required, can be set globally + * // optional, defaults shown + * category: null, + * thread: null, + * forum: null, + * since: null, + * related: [], + * cursor: null, + * limit: 25, + * query: null, + * include: ['approved'], + * order: 'desc' + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.list = function (options, cb) { + return util.executeAPIMethod(methods.list, options, config, cb); + }; + + /** + * ### listPopular + * Returns a list of posts ordered by the number of likes recently. + * + * Signature: + * ```js + * Disqus#posts.listPopular(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.listPopular({ + * api_secret: 'asdfghkj', // required, can be set globally + * // optional, defaults shown + * category: null, + * interval: '7d', + * thread: null, + * forum: null, + * related: [], + * limit: 25, + * offset: 0, + * query: null, + * include: ['approved'], + * order: 'desc' + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.listPopular({ + * api_secret: 'asdfghkj', // required, can be set globally + * // optional, defaults shown + * category: null, + * interval: '7d', + * thread: null, + * forum: null, + * related: [], + * limit: 25, + * offset: 0, + * query: null, + * include: ['approved'], + * order: 'desc' + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.listPopular = function (options, cb) { + return util.executeAPIMethod(methods.listPopular, options, config, cb); + }; + + /** + * ### remove + * Deletes the requested post(s). + * + * Signature: + * ```js + * Disqus#posts.remove(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.remove({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.remove({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.remove = function (options, cb) { + return util.executeAPIMethod(methods.remove, options, config, cb); + }; + + /** + * ### report + * Reports a post (flagging). + * + * Signature: + * ```js + * Disqus#posts.report(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.report({ + * post: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.report({ + * post: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.report = function (options, cb) { + return util.executeAPIMethod(methods.report, options, config, cb); + }; + + /** + * ### restore + * Undeletes the requested post(s). + * + * Signature: + * ```js + * Disqus#posts.restore(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.restore({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.restore({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.restore = function (options, cb) { + return util.executeAPIMethod(methods.restore, options, config, cb); + }; + + /** + * ### spam + * Marks the requested post(s) as spam. + * + * Signature: + * ```js + * Disqus#posts.spam(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.spam({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.spam({ + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.spam = function (options, cb) { + return util.executeAPIMethod(methods.spam, options, config, cb); + }; + + /** + * ### update + * Updates information on a post. + * + * Signature: + * ```js + * Disqus#posts.update(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.update({ + * message: '', // required + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.update({ + * message: '', // required + * post: '', // required + * api_secret: 'asdfghkj', // required, can be set globally + * access_token: '12345678' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.update = function (options, cb) { + return util.executeAPIMethod(methods.update, options, config, cb); + }; + + /** + * ### vote + * Register a vote on a post. + * + * Signature: + * ```js + * Disqus#posts.vote(options[, cb]) + * ``` + * + * Usage: + * ```js + * // Node-style + * disqus.posts.vote({ + * vote: '', // required + * post: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }, function (err, result) {...}) + * + * // Promise-style + * disqus.posts.vote({ + * vote: '', // required + * post: '', // required + * api_secret: 'asdfghkj' // required, can be set globally + * }) + * .then(function (result) {...}) + * .catch(function (err) {...}) + * .error(function (err) {...}); + * ``` + */ + this.vote = function (options, cb) { + return util.executeAPIMethod(methods.vote, options, config, cb); + }; + }; +}; diff --git a/lib/cli/index.js b/lib/cli/index.js index ca3b4f0..178d924 100644 --- a/lib/cli/index.js +++ b/lib/cli/index.js @@ -8,7 +8,7 @@ var pkg = require('../../package.json'); npm http GET https://registry.npmjs.org/disqus-node ... - disqus-node@0.11.0 usr/local/lib/node_modules/disqus-node + disqus-node@0.12.0 usr/local/lib/node_modules/disqus-node MBP:~ jason$ disqus -h @@ -22,6 +22,7 @@ var pkg = require('../../package.json'); exports [options] Execute command for the Exports resource. forums [options] Execute command for the Forums resource. imports [options] Execute command for the Imports resource. + posts [options] Execute command for the Posts resource. topics [options] Execute command for the Topics resource. trends [options] Execute command for the Trends resource. whitelists [options] Execute command for the Whitelists resource. @@ -118,6 +119,13 @@ disqus disqus .command('imports [options]') .description('Execute command for the Imports resource.'); +/** + * ###### Posts + * [API](/lib/api/imports.html) | [CLI](/lib/cli/imports.html) | [Disqus](https://disqus.com/api/docs/imports/) + */ +disqus + .command('posts [options]') + .description('Execute command for the Posts resource.'); /** * ###### Topics * [API](/lib/api/topics.html) | [CLI](/lib/cli/topics.html) | [Disqus](https://disqus.com/api/docs/topics/) @@ -150,6 +158,7 @@ exports.parse = function (primaryArgs, secondaryArgs) { case 'exports': case 'forums': case 'imports': + case 'posts': case 'topics': case 'trends': case 'whitelists': diff --git a/lib/cli/posts.js b/lib/cli/posts.js new file mode 100644 index 0000000..09ecfbe --- /dev/null +++ b/lib/cli/posts.js @@ -0,0 +1,436 @@ +/** + * [Up one level](/lib/index.html) + * ### Posts CLI + * See the disqus-node [Posts API](/lib/api/posts.html). + * + * See the [Posts API on Disqus.com](https://disqus.com/api/docs/posts/). + */ +var container = require('../container'); +var Command = container.get('commander').Command; +var posts = new Command('disqus posts'); + +posts + .usage(' [options]'); + +/** + * ### approve + * Approves the requested post(s). + * + * Output of `disqus posts approve --help`: + * ``` + Usage: disqus posts approve [options] + + Options: + + -h, --help output usage information + -A, --access_token Your access token. + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. You must be a moderator on the selected post's forum. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('approve') + .description('Approves the requested post(s).') + .option('-A, --access_token ', 'Your access token.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID. You must be a moderator on the selected post\'s forum.') + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.approve(options, container.get('util').printCliResult); + }); + +/** + * ### create + * Creates a new post. + * + * Output of `disqus posts create --help`: + * ``` + Usage: disqus posts create [options] + + Options: + + -h, --help output usage information + -d, --date [string] Defaults to null. Unix timestamp (or ISO datetime standard). + -e, --author_email [string] Defaults to null. Email address (defined by RFC 5322). + -H, --https [boolean] Whether to use https. Defaults to true. + -i, --ip_address [string] Defaults to null. IP address (defined by RFC 5322). + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -m, --message The content of the post. + -n, --author_name [string] Defaults to null. + -p, --parent_id [string] Looks up a post by ID. + -S, --api_secret Your application's api_secret. + -t, --thread [string] Looks up a thread by ID. + * ``` + */ +posts + .command('create') + .description('Creates a new post.') + .option('-d, --date [string]', 'Defaults to null. Unix timestamp (or ISO datetime standard).', null) + .option('-e, --author_email [string]', 'Defaults to null. Email address (defined by RFC 5322).', null) + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-i, --ip_address [string]', 'Defaults to null. IP address (defined by RFC 5322).', null) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-m, --message ', 'The content of the post.') + .option('-n, --author_name [string]', 'Defaults to null.', null) + .option('-p, --parent_id [string]', 'Looks up a post by ID.', null) + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .option('-t, --thread [string]', 'Looks up a thread by ID.', null) + .action(function (options) { + var Disqus = container.get('Disqus'); + options.parent_id = options.parent; + delete options.parent_id; + new Disqus(options).posts.create(options, container.get('util').printCliResult); + }); + +/** + * ### details + * Returns information about a post. + * + * Output of `disqus posts details --help`: + * ``` + Usage: disqus posts details [options] + + Options: + + -h, --help output usage information + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. + -r, --related [array] You may specify relations to include with your response. Choices: forum, thread. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('details') + .description('Returns information about a post.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID.') + .option('-r, --related [array]', 'You may specify relations to include with your response. Choices: forum, thread.', []) + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.details(options, container.get('util').printCliResult); + }); + +/** + * ### getContext + * Returns the hierarchal tree of a post (all parents). + * + * Output of `disqus posts getContext --help`: + * ``` + Usage: disqus posts getContext [options] + + Options: + + -h, --help output usage information + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. + -r, --related [array] You may specify relations to include with your response. Choices: forum, thread. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('getContext') + .description('Returns the hierarchal tree of a post (all parents).') + .option('-d, --depth [number]', 'Defaults to 10. Minimum value of 1. Maximum value of 10.', 10) + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID.') + .option('-r, --related [array]', 'You may specify relations to include with your response. Choices: forum, thread.', []) + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.getContext(options, container.get('util').printCliResult); + }); + +/** + * ### list + * Returns a list of posts ordered by the date created. + * + * Output of `disqus posts list --help`: + * ``` + Usage: disqus posts list [options] + + Options: + + -h, --help output usage information + -c, --category [string] Defaults to null. Looks up a category by ID. + -C, --cursor [string] Defaults to null. + -f, --forum [string] Defaults to null. Defaults to all forums you moderate. Use :all to retrieve all forums. + -H, --https [boolean] Whether to use https. Defaults to true. + -i, --include [array] Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged, highlighted. + -l, --limit [number] Defaults to 25. Maximum value of 100. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -o, --order [string] Defaults to "desc". Choices: asc, desc. + -q, --query [string] Defaults to null. + -r, --related [array] You may specify relations to include with your response. Choices: forum, thread. + -s, --since [string] Defaults to null. Unix timestamp (or ISO datetime standard). + -S, --api_secret Your application's api_secret. + -r, --thread [string] Defaults to null. Looks up a thread by ID. + * ``` + */ +posts + .command('list') + .description('Returns a list of posts ordered by the date created.') + .option('-c, --category [string]', 'Defaults to null. Looks up a category by ID.', null) + .option('-C, --cursor [string]', 'Defaults to null.', null) + .option('-f, --forum [string]', 'Defaults to null. Defaults to all forums you moderate. Use :all to retrieve all forums.', null) + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-i, --include [array]', 'Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged, highlighted.', ['approved']) + .option('-l, --limit [number]', 'Defaults to 25. Maximum value of 100.', 25) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-o, --order [string]', 'Defaults to "desc". Choices: asc, desc.', 'desc') + .option('-q, --query [string]', 'Defaults to null.', null) + .option('-r, --related [array]', 'You may specify relations to include with your response. Choices: forum, thread.', []) + .option('-s, --since [string]', 'Defaults to null. Unix timestamp (or ISO datetime standard).', null) + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .option('-r, --thread [string]', 'Defaults to null. Looks up a thread by ID.', null) + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.list(options, container.get('util').printCliResult); + }); + +/** + * ### listPopular + * Returns a list of posts ordered by the number of likes recently. + * + * Output of `disqus posts listPopular --help`: + * ``` + Usage: disqus posts listPopular [options] + + Options: + + -h, --help output usage information + -c, --category [string] Defaults to null. Looks up a category by ID. + -f, --forum [string] Defaults to null. Defaults to all forums you moderate. Use :all to retrieve all forums. + -H, --https [boolean] Whether to use https. Defaults to true. + -i, --include [array] Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged, highlighted. + -I, --interval [string] Defaults to "7d". Choices: 1h, 6h, 12h, 1d, 3d, 7d, 30d, 60d, 90d. + -l, --limit [number] Defaults to 25. Maximum value of 100. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -o, --order [string] Defaults to "popular". Choices: popular, best. + -O, --offset [number] Defaults to 0. + -q, --query [string] Defaults to null. + -r, --related [array] You may specify relations to include with your response. Choices: forum, thread. + -S, --api_secret Your application's api_secret. + -r, --thread [string] Defaults to null. Looks up a thread by ID. + * ``` + */ +posts + .command('listPopular') + .description('Returns a list of posts ordered by the number of likes recently.') + .option('-c, --category [string]', 'Defaults to null. Looks up a category by ID.', null) + .option('-f, --forum [string]', 'Defaults to null. Defaults to all forums you moderate. Use :all to retrieve all forums.', null) + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-i, --include [array]', 'Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged, highlighted.', ['approved']) + .option('-I, --interval [string]', 'Defaults to "7d". Choices: 1h, 6h, 12h, 1d, 3d, 7d, 30d, 60d, 90d.', '7d') + .option('-l, --limit [number]', 'Defaults to 25. Maximum value of 100.', 25) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-o, --order [string]', 'Defaults to "popular". Choices: popular, best.', 'popular') + .option('-O, --offset [number]', 'Defaults to 0.', 0) + .option('-q, --query [string]', 'Defaults to null.', null) + .option('-r, --related [array]', 'You may specify relations to include with your response. Choices: forum, thread.', []) + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .option('-r, --thread [string]', 'Defaults to null. Looks up a thread by ID.', null) + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.listPopular(options, container.get('util').printCliResult); + }); + +/** + * ### remove + * Deletes the requested post(s). + * + * Output of `disqus posts remove --help`: + * ``` + Usage: disqus posts remove [options] + + Options: + + -h, --help output usage information + -A, --access_token Your access token. + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('remove') + .description('Deletes the requested post(s).') + .option('-A, --access_token ', 'Your access token.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID.') + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.remove(options, container.get('util').printCliResult); + }); + +/** + * ### restore + * Undeletes the requested post(s). + * + * Output of `disqus posts restore --help`: + * ``` + Usage: disqus posts restore [options] + + Options: + + -h, --help output usage information + -A, --access_token Your access token. + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('restore') + .description('Undeletes the requested post(s).') + .option('-A, --access_token ', 'Your access token.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID.') + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.restore(options, container.get('util').printCliResult); + }); + +/** + * ### restore + * Undeletes the requested post(s). + * + * Output of `disqus posts restore --help`: + * ``` + Usage: disqus posts restore [options] + + Options: + + -h, --help output usage information + -A, --access_token Your access token. + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('restore') + .description('Undeletes the requested post(s).') + .option('-A, --access_token ', 'Your access token.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID.') + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.restore(options, container.get('util').printCliResult); + }); + +/** + * ### spam + * Marks the requested post(s) as spam. + * + * Output of `disqus posts spam --help`: + * ``` + Usage: disqus posts spam [options] + + Options: + + -h, --help output usage information + -A, --access_token Your access token. + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. You must be a moderator on the selected post's forum. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('spam') + .description('Marks the requested post(s) as spam.') + .option('-A, --access_token ', 'Your access token.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID. You must be a moderator on the selected post\'s forum.') + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.spam(options, container.get('util').printCliResult); + }); + +/** + * ### update + * Updates information on a post. + * + * Output of `disqus posts update --help`: + * ``` + Usage: disqus posts update [options] + + Options: + + -h, --help output usage information + -A, --access_token Your access token. + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -m, --message The updated content of the post. + -p, --post Looks up a post by ID. You must be a moderator on the selected post's forum. + -S, --api_secret Your application's api_secret. + * ``` + */ +posts + .command('update') + .description('Updates information on a post.') + .option('-A, --access_token ', 'Your access token.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-m, --message ', 'The updated content of the post.') + .option('-p, --post ', 'Looks up a post by ID. You must be a moderator on the selected post\'s forum.') + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.update(options, container.get('util').printCliResult); + }); + +/** + * ### vote + * Register a vote on a post. + * + * Output of `disqus posts vote --help`: + * ``` + Usage: disqus posts vote [options] + + Options: + + -h, --help output usage information + -A, --access_token Your access token. + -H, --https [boolean] Whether to use https. Defaults to true. + -L, --logLevel [string] Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency. + -p, --post Looks up a post by ID. You must be a moderator on the selected post's forum. + -S, --api_secret Your application's api_secret. + -v, --vote Choices: -1, 0, 1. + * ``` + */ +posts + .command('vote') + .description('Register a vote on a post.') + .option('-A, --access_token ', 'Your access token.') + .option('-H, --https [boolean]', 'Whether to use https. Defaults to true.', true) + .option('-L, --logLevel [string]', 'Output log level. Choices: debug, info, notice, warning, error, critical, alert, emergency.', 'info') + .option('-p, --post ', 'Looks up a post by ID. You must be a moderator on the selected post\'s forum.') + .option('-S, --api_secret ', 'Your application\'s api_secret.') + .option('-v, --vote ', 'Choices: -1, 0, 1.') + .action(function (options) { + var Disqus = container.get('Disqus'); + new Disqus(options).posts.vote(options, container.get('util').printCliResult); + }); + +module.exports = posts; diff --git a/lib/index.js b/lib/index.js index 11ac342..da54028 100644 --- a/lib/index.js +++ b/lib/index.js @@ -35,6 +35,7 @@ function Disqus(options) { var Exports = container.get('Exports'); var Forums = container.get('Forums'); var Imports = container.get('Imports'); + var Posts = container.get('Posts'); var Topics = container.get('Topics'); var Trends = container.get('Trends'); var Whitelists = container.get('Whitelists'); @@ -129,6 +130,11 @@ function Disqus(options) { * [API](/lib/api/imports.html) | [CLI](/lib/cli/imports.html) | [Disqus](https://disqus.com/api/docs/imports/) */ this.imports = new Imports(this.config); + /** + * ###### Posts + * [API](/lib/api/posts.html) | [CLI](/lib/cli/posts.html) | [Disqus](https://disqus.com/api/docs/posts/) + */ + this.posts = new Posts(this.config); /** * ###### Topics * [API](/lib/api/topics.html) | [CLI](/lib/cli/topics.html) | [Disqus](https://disqus.com/api/docs/topics/) diff --git a/package.json b/package.json index 687cb15..bd7b6b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "disqus-node", - "version": "0.11.0", + "version": "0.12.0", "description": "Disqus API bindings and CLI for NodeJS http://disqus.com/api/", "main": "./lib/index.js", "bin": { diff --git a/test/unit/api/Posts.test.js b/test/unit/api/Posts.test.js new file mode 100644 index 0000000..e01b2be --- /dev/null +++ b/test/unit/api/Posts.test.js @@ -0,0 +1,187 @@ +module.exports = function (container, assert, sinon) { + return function () { + var posts; + var Posts; + var config; + var options; + var cb; + var executeApiMethod; + + beforeEach(function () { + config = { + api_secret: '1234' + }; + options = { + stuff: 'stuff' + }; + cb = function () { + }; + + executeApiMethod = sinon.spy(); + + Posts = container.get('Posts', { + util: { + executeAPIMethod: executeApiMethod + } + }); + + posts = new Posts(config); + }); + + describe('approve', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.approve(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'approve', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('create', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.create(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'create', + method: 'POST', + requiredOptions: ['api_secret', 'message'], + availableOptions: ['parent', 'thread', 'author_email', 'author_name', 'state', 'author_url', 'date', 'ip_address'] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('details', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.details(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'details', + method: 'GET', + requiredOptions: ['api_secret', 'post'], + availableOptions: ['related'] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('getContext', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.getContext(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'getContext', + method: 'GET', + requiredOptions: ['api_secret', 'post'], + availableOptions: ['depth', 'related'] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('list', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.list(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'list', + method: 'GET', + requiredOptions: ['api_secret'], + availableOptions: ['category', 'thread', 'forum', 'since', 'related', 'cursor', 'limit', 'query', 'include', 'order'] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('listPopular', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.listPopular(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'listPopular', + method: 'GET', + requiredOptions: ['api_secret'], + availableOptions: ['category', 'interval', 'thread', 'forum', 'related', 'limit', 'offset', 'query', 'include', 'order'] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('remove', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.remove(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'remove', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('report', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.report(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'report', + method: 'POST', + requiredOptions: ['api_secret', 'post'], + availableOptions: [] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('restore', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.restore(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'restore', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('spam', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.spam(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'spam', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'post'], + availableOptions: [] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('update', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.update(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'update', + method: 'POST', + requiredOptions: ['api_secret', 'access_token', 'message', 'post'], + availableOptions: [] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + + describe('vote', function () { + it('should call util.executeApiMethod with the correct arguments', function () { + posts.vote(options, cb); + assert.isTrue(executeApiMethod.calledWithExactly({ + resource: 'posts', + name: 'vote', + method: 'POST', + requiredOptions: ['api_secret', 'vote', 'post'], + availableOptions: [] + }, options, config, cb), 'util.executeApiMethod should have been called with the correct arguments'); + }); + }); + }; +}; diff --git a/test/unit/api/index.js b/test/unit/api/index.js index 05ff681..3703ddb 100644 --- a/test/unit/api/index.js +++ b/test/unit/api/index.js @@ -6,6 +6,7 @@ module.exports = function (container) { container.register('API.Exports.test', require('./Exports.test')); container.register('API.Forums.test', require('./Forums.test')); container.register('API.Imports.test', require('./Imports.test')); + container.register('API.Posts.test', require('./Posts.test')); container.register('API.Topics.test', require('./Topics.test')); container.register('API.Trends.test', require('./Trends.test')); container.register('API.Whitelists.test', require('./Whitelists.test')); @@ -16,6 +17,7 @@ module.exports = function (container) { describe('Exports', container.get('API.Exports.test')); describe('Forums', container.get('API.Forums.test')); describe('Imports', container.get('API.Imports.test')); + describe('Posts', container.get('API.Posts.test')); describe('Topics', container.get('API.Topics.test')); describe('Trends', container.get('API.Trends.test')); describe('Whitelists', container.get('API.Whitelists.test'));