diff --git a/.istanbul.yml b/.istanbul.yml index 72047a7..9b86037 100644 --- a/.istanbul.yml +++ b/.istanbul.yml @@ -1,3 +1,2 @@ instrumentation: - default-excludes: false - excludes: ["gulpfile.js", "**/test/**", "**/node_modules/!(lib)/**"] \ No newline at end of file + excludes: ["gulpfile.js", "**/lib/api/**"] \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 570b375..15cf6c0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,12 +17,12 @@ gulp.task('quality', function () { .pipe(jshint.reporter('default')); }); gulp.task('test', function () { - return gulp.src('./test/*.js') + return gulp.src('./test/**/*test.js') .pipe(mocha({reporter: 'mocha-better-spec-reporter', timeout: '20s'})); }); gulp.task('cover', function () { - return gulp.src('./test/*.js') + return gulp.src('./test/**/*test.js') .pipe(mocha({reporter: 'mocha-lcov-reporter', timeout: '120s'})); }); diff --git a/lib/auth.js b/lib/api/auth.js similarity index 98% rename from lib/auth.js rename to lib/api/auth.js index 96554fb..c48c057 100644 --- a/lib/auth.js +++ b/lib/api/auth.js @@ -5,8 +5,8 @@ // Dependencies: -var api = require('./api'); -var utility = require('./utility'); +var api = require('../api'); +var utility = require('../utility'); // *** diff --git a/lib/contacts.js b/lib/api/contacts.js similarity index 94% rename from lib/contacts.js rename to lib/api/contacts.js index 2637a23..d9ca544 100644 --- a/lib/contacts.js +++ b/lib/api/contacts.js @@ -5,8 +5,8 @@ // Dependencies: -var api = require('./api'); -var utility = require('./utility'); +var api = require('../api'); +var utility = require('../utility'); // *** diff --git a/lib/messages.js b/lib/api/messages.js similarity index 85% rename from lib/messages.js rename to lib/api/messages.js index 2766776..51d0e3e 100644 --- a/lib/messages.js +++ b/lib/api/messages.js @@ -5,8 +5,8 @@ // Dependencies: -var api = require('./api'); -var utility = require('./utility'); +var api = require('../api'); +var utility = require('../utility'); // *** @@ -73,6 +73,19 @@ Messages.prototype.getHistory = function (peer, offset, max_id, limit, callback) return utility.callService(api.service.messages.getHistory, this.client, this.client._channel, callback, arguments); }; +// *** +// messages.**readHistory(peer, offset, max_id, limit, [callback])** + +// Returns a Promise to mark message history as read.. + +// [Click here for more details](https://core.telegram.org/method/messages.readHistory) + + +// The code: +Messages.prototype.readHistory = function (peer, offset, max_id, limit, callback) { + return utility.callService(api.service.messages.readHistory, this.client, this.client._channel, callback, arguments); +}; + // *** // messages.**sendMessage(peer, message, random_id, [callback])** diff --git a/lib/updates.js b/lib/api/updates.js similarity index 65% rename from lib/updates.js rename to lib/api/updates.js index 3730082..86e74c0 100644 --- a/lib/updates.js +++ b/lib/api/updates.js @@ -5,8 +5,8 @@ // Dependencies: -var api = require('./api'); -var utility = require('./utility'); +var api = require('../api'); +var utility = require('../utility'); // *** @@ -41,5 +41,18 @@ Updates.prototype.getState = function (callback) { return utility.callService(api.service.updates.getState, this.client, this.client._channel, callback, arguments); }; + +// *** +// updates.**getDifference(pts, date, qts, [callback])** + +// Returns a Promise for get the difference between the current state of updates and transmitted. + +// [Click here for more details](https://core.telegram.org/method/updates.getDifference) + +// The code: +Updates.prototype.getDifference = function (pts, date, qts, callback) { + return utility.callService(api.service.updates.getDifference, this.client, this.client._channel, callback, arguments); +}; + // Exports the class module.exports = exports = Updates; \ No newline at end of file diff --git a/lib/telegram.link.js b/lib/telegram.link.js index b038155..264c4a6 100644 --- a/lib/telegram.link.js +++ b/lib/telegram.link.js @@ -126,15 +126,16 @@ function Client(app, dataCenter) { this._channel = createEncryptedChannel(this._connection, app, app.authKey, NULL_SERVER_SALT); } - // creates the authorization modules bound with the client to call all the API methods - // user authorization - this.auth = new (require('./auth'))(this); - // user contacts - this.contacts = new (require('./contacts'))(this); - // session updates - this.updates = new (require('./updates'))(this); - // chat messages - this.messages = new (require('./messages'))(this); + // User authorization + this.auth = new (require('./api/auth'))(this); + // User contacts + this.contacts = new (require('./api/contacts'))(this); + // Session updates + this.updates = new (require('./api/updates'))(this); + // Chat messages + this.messages = new (require('./api/messages'))(this); + // Notifications and settings + this.account = new (require('./api/account'))(this); } // Extend the `events.EventEmitter` class require('util').inherits(Client, require('events').EventEmitter); diff --git a/test/auth.test.js b/test/api/auth.test.js similarity index 100% rename from test/auth.test.js rename to test/api/auth.test.js