Skip to content

Commit

Permalink
Move all the api modules under the api sub-folder
Browse files Browse the repository at this point in the history
  • Loading branch information
enricostara committed Aug 16, 2015
1 parent 4deab54 commit cc029c6
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .istanbul.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
instrumentation:
default-excludes: false
excludes: ["gulpfile.js", "**/test/**", "**/node_modules/!(lib)/**"]
excludes: ["gulpfile.js", "**/lib/api/**"]
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}));
});

Expand Down
4 changes: 2 additions & 2 deletions lib/auth.js → lib/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


// Dependencies:
var api = require('./api');
var utility = require('./utility');
var api = require('../api');
var utility = require('../utility');


// ***
Expand Down
4 changes: 2 additions & 2 deletions lib/contacts.js → lib/api/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


// Dependencies:
var api = require('./api');
var utility = require('./utility');
var api = require('../api');
var utility = require('../utility');


// ***
Expand Down
17 changes: 15 additions & 2 deletions lib/messages.js → lib/api/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


// Dependencies:
var api = require('./api');
var utility = require('./utility');
var api = require('../api');
var utility = require('../utility');


// ***
Expand Down Expand Up @@ -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])**

Expand Down
17 changes: 15 additions & 2 deletions lib/updates.js → lib/api/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


// Dependencies:
var api = require('./api');
var utility = require('./utility');
var api = require('../api');
var utility = require('../utility');


// ***
Expand Down Expand Up @@ -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;
19 changes: 10 additions & 9 deletions lib/telegram.link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
File renamed without changes.

0 comments on commit cc029c6

Please sign in to comment.