-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from Automattic/add/me-endpoints
Add `me` endpoints
- Loading branch information
Showing
30 changed files
with
1,665 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
var _createClass = require('babel-runtime/helpers/create-class')['default']; | ||
|
||
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default']; | ||
|
||
var root = '/me/connected-applications/'; | ||
|
||
var MeConnectedApp = (function () { | ||
|
||
/** | ||
* `MeConnectedApp` constructor. | ||
* | ||
* @param {String} appId - application identifier | ||
* @param {WPCOM} wpcom - wpcom instance | ||
* @return {Null} null | ||
*/ | ||
|
||
function MeConnectedApp(appId, wpcom) { | ||
_classCallCheck(this, MeConnectedApp); | ||
|
||
if (!(this instanceof MeConnectedApp)) { | ||
return new MeConnectedApp(appId, wpcom); | ||
} | ||
this._id = appId; | ||
this.wpcom = wpcom; | ||
} | ||
|
||
/** | ||
* Expose `MeConnectedApp` module | ||
*/ | ||
|
||
/** | ||
* Get one of current user's connected applications. | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
|
||
_createClass(MeConnectedApp, [{ | ||
key: 'get', | ||
value: function get(query, fn) { | ||
return this.wpcom.req.get(root + this._id, query, fn); | ||
} | ||
|
||
/** | ||
* Delete the app of the current user | ||
* through of the given appId | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
}, { | ||
key: 'delete', | ||
value: function _delete(query, fn) { | ||
return this.wpcom.req.del(root + this._id + '/delete', query, fn); | ||
} | ||
}]); | ||
|
||
return MeConnectedApp; | ||
})(); | ||
|
||
module.exports = MeConnectedApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
var _createClass = require('babel-runtime/helpers/create-class')['default']; | ||
|
||
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default']; | ||
|
||
var root = '/me/keyring-connections/'; | ||
|
||
var KeyringConnection = (function () { | ||
|
||
/** | ||
* `KeyringConnection` constructor. | ||
* | ||
* @param {String} keyId - the connection ID to take action on. | ||
* @param {WPCOM} wpcom - wpcom instance | ||
* @return {Null} null | ||
*/ | ||
|
||
function KeyringConnection(keyId, wpcom) { | ||
_classCallCheck(this, KeyringConnection); | ||
|
||
if (!(this instanceof KeyringConnection)) { | ||
return new KeyringConnection(keyId, wpcom); | ||
} | ||
this._id = keyId; | ||
this.wpcom = wpcom; | ||
} | ||
|
||
/** | ||
* Expose `KeyringConnection` module | ||
*/ | ||
|
||
/** | ||
* Get a single Keyring connection that the current user has setup. | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
|
||
_createClass(KeyringConnection, [{ | ||
key: 'get', | ||
value: function get(query, fn) { | ||
return this.wpcom.req.get(root + this._id, query, fn); | ||
} | ||
|
||
/** | ||
* Delete the Keyring connection (and associated token) with the | ||
* provided ID. Also deletes all associated publicize connections. | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
}, { | ||
key: 'delete', | ||
value: function _delete(query, fn) { | ||
return this.wpcom.req.del(root + this._id + '/delete', query, fn); | ||
} | ||
}]); | ||
|
||
return KeyringConnection; | ||
})(); | ||
|
||
module.exports = KeyringConnection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
var _createClass = require('babel-runtime/helpers/create-class')['default']; | ||
|
||
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default']; | ||
|
||
var root = '/me/publicize-connections/'; | ||
|
||
var PublicizeConnection = (function () { | ||
/** | ||
* `PublicizeConnection` constructor. | ||
* | ||
* @param {String} connectionId - application identifier | ||
* @param {WPCOM} wpcom - wpcom instance | ||
* @return {Null} null | ||
*/ | ||
|
||
function PublicizeConnection(connectionId, wpcom) { | ||
_classCallCheck(this, PublicizeConnection); | ||
|
||
if (!(this instanceof PublicizeConnection)) { | ||
return new PublicizeConnection(connectionId, wpcom); | ||
} | ||
this._id = connectionId; | ||
this.wpcom = wpcom; | ||
} | ||
|
||
/** | ||
* Expose `PublicizeConnection` module | ||
*/ | ||
|
||
/** | ||
* Get a single publicize connection that the current user has set up. | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
|
||
_createClass(PublicizeConnection, [{ | ||
key: 'get', | ||
value: function get(query, fn) { | ||
return this.wpcom.req.get(root + this._id, query, fn); | ||
} | ||
|
||
/** | ||
* Add a publicize connection belonging to the current user. | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Object} body - body object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
}, { | ||
key: 'add', | ||
value: function add(query, body, fn) { | ||
return this.wpcom.req.post(root + 'new', query, body, fn); | ||
} | ||
|
||
/** | ||
* Update a publicize connection belonging to the current user. | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Object} body - body object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
}, { | ||
key: 'update', | ||
value: function update(query, body, fn) { | ||
return this.wpcom.req.put(root + this._id, query, body, fn); | ||
} | ||
|
||
/** | ||
* Delete the app of the current user | ||
* through of the given connectionId | ||
* | ||
* @param {Object} [query] - query object parameter | ||
* @param {Function} fn - callback function | ||
* @return {Function} request handler | ||
*/ | ||
}, { | ||
key: 'delete', | ||
value: function _delete(query, fn) { | ||
return this.wpcom.req.del(root + this._id + '/delete', query, fn); | ||
} | ||
}]); | ||
|
||
return PublicizeConnection; | ||
})(); | ||
|
||
module.exports = PublicizeConnection; |
Oops, something went wrong.