diff --git a/bower.json b/bower.json index 1095864..474f5f8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "typetalk-js", - "version": "0.1.2", + "version": "0.1.3", "main": "typetalk.js", "ignore": [ "**/.*", diff --git a/component.json b/component.json deleted file mode 100644 index 01b0d4b..0000000 --- a/component.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "typetalk-js", - "description": "JavaScript library for Typetalk.", - "keywords": [ - "typetalk", - "nulab", - "client", - "javascript", - "library" - ], - "repo": "shoito/typetalk-js", - "main": "typetalk.js", - "scripts": ["typetalk.js"], - "version": "0.1.2", - "license": "MIT" -} \ No newline at end of file diff --git a/example/client.js b/example/client.js index 55e969e..f08e5c2 100644 --- a/example/client.js +++ b/example/client.js @@ -5,7 +5,8 @@ var Promise = require('bluebird'), var typetalk = new Typetalk({ 'client_id': 'YOUR_CLIENT_ID__CLIENT_CREDENTIALS', - 'client_secret': 'YOUR_CLIENT_SECRET__CLIENT_CREDENTIALS' + 'client_secret': 'YOUR_CLIENT_SECRET__CLIENT_CREDENTIALS', + 'scope': 'my' }); typetalk.getAccessTokenUsingClientCredentials().then(function(data) { diff --git a/package.json b/package.json index 7dd2914..7e4f298 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typetalk-js", "title": "typetalk-js", "description": "JavaScript library for Typetalk", - "version": "0.1.2", + "version": "0.1.3", "main": "typetalk.js", "homepage": "https://github.com/shoito/typetalk-js", "author": { diff --git a/typetalk.js b/typetalk.js index 9cca0f4..92a4ac6 100644 --- a/typetalk.js +++ b/typetalk.js @@ -21,16 +21,16 @@ if (typeof window === 'undefined') { clientId, clientSecret, redirectUri, - scope = 'topic.read,topic.post,my'; + scope = 'topic.read'; /** * Typetalk API client * @global * @class Typetalk - * @param {Object} options - API parameters - * @param {String} options.client_id - client id - * @param {String} options.client_secret - client secret - * @param {String} [options.scope=topic.read,topic.post,my] - scope + * @param {Object} [options] - API parameters + * @param {String} [options.client_id] - client id + * @param {String} [options.client_secret] - client secret + * @param {String} [options.scope=topic.read] - scope * @param {String} [options.redirect_uri] - redirect uri * @param {String} [options.access_token] - access token * @param {String} [options.refresh_token] - refresh token @@ -38,13 +38,8 @@ if (typeof window === 'undefined') { * @see {@link http://developers.typetalk.in/oauth.html} */ function Typetalk(options) { - ['client_id', 'client_secret'].forEach(function(field) { - if (typeof options[field] === 'undefined') { - throw new Error(field + ' is required'); - } - }); - self = this; + options = options || {}; self.accessToken = options.access_token; self.refreshToken = options.refresh_token; self.timeout = options.timeout || 3000; @@ -123,18 +118,23 @@ if (typeof window === 'undefined') { * Starts an auth flow at the typetalk oauth2 URL. * @memberof Typetalk * @method + * @param {Object} [options] - oAuth2 parameters + * @param {String} [options.client_id] - client id + * @param {String} [options.scope] - scope + * @param {String} [options.redirect_uri] - redirect uri * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object */ - Typetalk.prototype.authorizeChromeApp = function() { + Typetalk.prototype.authorizeChromeApp = function(options) { + options = options || {}; return new Promise(function(resolve, reject) { if (!(chrome && chrome.identity)) { reject(new Error('chrome.identity API is unsupported')); return; } - var authorizeUrl = Typetalk.OAUTH_BASE_URL + 'authorize?client_id=' + encodeURIComponent(clientId) + - '&redirect_uri=' + encodeURIComponent(redirectUri) + - '&scope=' + encodeURIComponent(scope) + '&response_type=code'; + var authorizeUrl = Typetalk.OAUTH_BASE_URL + 'authorize?client_id=' + encodeURIComponent(clientId || options.client_id) + + '&redirect_uri=' + encodeURIComponent(redirectUri || options.redirect_uri) + + '&scope=' + encodeURIComponent(scope || options.scope) + '&response_type=code'; chrome.identity.launchWebAuthFlow( {'url': authorizeUrl, 'interactive': true}, function(responseUrl) { @@ -193,14 +193,19 @@ if (typeof window === 'undefined') { * Get access token using authorization code * @memberof Typetalk * @method + * @param {Object} [options] - oAuth2 parameters + * @param {String} [options.client_id] - client id + * @param {String} [options.client_secret] - client secret + * @param {String} [options.scope] - scope * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object * @see {@link http://developers.typetalk.in/oauth.html#client} */ - Typetalk.prototype.getAccessTokenUsingClientCredentials = function() { - var param = 'client_id=' + encodeURIComponent(clientId) + - '&client_secret=' + encodeURIComponent(clientSecret) + + Typetalk.prototype.getAccessTokenUsingClientCredentials = function(options) { + options = options || {}; + var param = 'client_id=' + encodeURIComponent(clientId || options.client_id) + + '&client_secret=' + encodeURIComponent(clientSecret || options.client_secret) + '&grant_type=client_credentials' + - '&scope=' + encodeURIComponent(scope); + '&scope=' + encodeURIComponent(scope || options.scope); return requestAccessToken(param); }; @@ -208,12 +213,17 @@ if (typeof window === 'undefined') { * Redirect users to request Typetalk access * @memberof Typetalk * @method + * @param {Object} [options] - oAuth2 parameters + * @param {String} [options.client_id] - client id + * @param {String} [options.scope] - scope + * @param {String} [options.redirect_uri] - redirect uri * @see {@link http://developers.typetalk.in/oauth.html#code} */ - Typetalk.prototype.requestAuthorization = function() { - var param = 'client_id=' + encodeURIComponent(clientId) + - '&redirect_uri=' + encodeURIComponent(redirectUri) + - '&scope=' + encodeURIComponent(scope) + + Typetalk.prototype.requestAuthorization = function(options) { + options = options || {}; + var param = 'client_id=' + encodeURIComponent(clientId || options.client_id) + + '&redirect_uri=' + encodeURIComponent(redirectUri || options.redirect_uri) + + '&scope=' + encodeURIComponent(scope || options.scope) + '&response_type=code'; location.href = Typetalk.OAUTH_BASE_URL + 'authorize?' + param; }; @@ -222,13 +232,18 @@ if (typeof window === 'undefined') { * Get an access token using authorization code * @memberof Typetalk * @method + * @param {Object} [options] - oAuth2 parameters + * @param {String} [options.client_id] - client id + * @param {String} [options.client_secret] - client secret + * @param {String} [options.redirect_uri] - redirect uri * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object * @see {@link http://developers.typetalk.in/oauth.html#code} */ - Typetalk.prototype.getAccessTokenUsingAuthorizationCode = function(code) { - var param = 'client_id=' + encodeURIComponent(clientId) + - '&client_secret=' + encodeURIComponent(clientSecret) + - '&redirect_uri=' + encodeURIComponent(redirectUri) + + Typetalk.prototype.getAccessTokenUsingAuthorizationCode = function(code, options) { + options = options || {}; + var param = 'client_id=' + encodeURIComponent(clientId || options.client_id) + + '&client_secret=' + encodeURIComponent(clientSecret || options.client_secret) + + '&redirect_uri=' + encodeURIComponent(redirectUri || options.redirect_uri) + '&grant_type=authorization_code' + '&code=' + encodeURIComponent(code); return requestAccessToken(param); @@ -238,15 +253,19 @@ if (typeof window === 'undefined') { * Get an access token using authorization code * @memberof Typetalk * @method - * @param {?String} refreshToken - your refresh token + * @param {Object} [options] - oAuth2 parameters and refresh token + * @param {String} [options.client_id] - client id + * @param {String} [options.client_secret] - client secret + * @param {String} [options.refresh_token] - refresh token * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object * @see {@link http://developers.typetalk.in/oauth.html#refresh} */ - Typetalk.prototype.refreshAccessToken = function(refreshToken) { - var param = 'client_id=' + encodeURIComponent(clientId) + - '&client_secret=' + encodeURIComponent(clientSecret) + + Typetalk.prototype.refreshAccessToken = function(options) { + options = options || {}; + var param = 'client_id=' + encodeURIComponent(clientId || options.client_id) + + '&client_secret=' + encodeURIComponent(clientSecret || options.client_secret) + '&grant_type=refresh_token' + - '&refresh_token=' + encodeURIComponent(refreshToken || self.refreshToken); + '&refresh_token=' + encodeURIComponent(self.refreshToken || options.refresh_token); return requestAccessToken(param); }; @@ -277,10 +296,10 @@ if (typeof window === 'undefined') { * @memberof Typetalk * @method * @param {Number} topicId - Topic ID - * @param {?Object} options - Query parameters - * @param {?Number} options.count - default value: 20, maximum: 100 - * @param {?Number} options.from - references Post ID - * @param {?String} options.direction - "backward" or "forward" + * @param {Object} [options] - Query parameters + * @param {Number} [options.count] - default value: 20, maximum: 100 + * @param {Number} [options.from] - references Post ID + * @param {String} [options.direction] - "backward" or "forward" * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object * @see {@link http://developers.typetalk.in/api.html#get-messages} */ @@ -294,10 +313,10 @@ if (typeof window === 'undefined') { * @method * @param {Number} topicId - Topic ID * @param {String} message - your message, maximum length: 4096 - * @param {?Object} options - Form parameters - * @param {?Number} options.replyTo - references Post ID - * @param {?String} options.fileKeys[0-5] - attachment file key, maximum count: 5 - * @param {?Number} options.talkIds[0-5] - Talk IDs that you want to put the message in, maximum count: 5 + * @param {Object} [options] - Form parameters + * @param {Number} [options.replyTo] - references Post ID + * @param {String} [options.fileKeys[0-5]] - attachment file key, maximum count: 5 + * @param {Number} [options.talkIds[0-5]] - Talk IDs that you want to put the message in, maximum count: 5 * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object * @see {@link http://developers.typetalk.in/api.html#post-message} */ @@ -446,8 +465,8 @@ if (typeof window === 'undefined') { * @memberof Typetalk * @method * @param {Number} topicId - Topic ID - * @param {?Object} options - Form parameters - * @param {?Number} options.postId - Post ID ( if no parameter, read all posts ) + * @param {Object} [options] - Form parameters + * @param {Number} [options.postId] - Post ID ( if no parameter, read all posts ) * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object * @see {@link http://developers.typetalk.in/api.html#open-notification} */ @@ -461,9 +480,9 @@ if (typeof window === 'undefined') { * Get mention list * @memberof Typetalk * @method - * @param {?Object} options - Form parameters - * @param {?Number} options.from - Mention ID - * @param {?Boolean} options.unread - true: only unread mentions, false: all mentions + * @param {Object} [options] - Form parameters + * @param {Number} [options.from] - Mention ID + * @param {Boolean} [options.unread] - true: only unread mentions, false: all mentions * @return {Promise} promise object - It will resolve with `response` data or fail with `error` object * @see {@link http://developers.typetalk.in/api.html#get-mentions} */ diff --git a/typetalk.min.js b/typetalk.min.js index 6fd1882..93ca1da 100644 --- a/typetalk.min.js +++ b/typetalk.min.js @@ -1,2 +1,2 @@ -/*! typetalk-js 2014-05-04 */ -"use strict";if("undefined"==typeof window)var Promise=Promise||require("bluebird"),XMLHttpRequest=XMLHttpRequest||require("xmlhttprequest").XMLHttpRequest;(function(){var a=function(){function a(a){["client_id","client_secret"].forEach(function(b){if("undefined"==typeof a[b])throw new Error(b+" is required")}),b=this,b.accessToken=a.access_token,b.refreshToken=a.refresh_token,b.timeout=a.timeout||3e3,c=a.client_id,d=a.client_secret,e=a.redirect_uri,f=a.scope||f}a.API_BASE_URL="https://typetalk.in/api/v1/",a.OAUTH_BASE_URL="https://typetalk.in/oauth2/";var b,c,d,e,f="topic.read,topic.post,my",g=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},h=function(c){return new Promise(function(d,e){var f=new XMLHttpRequest;f.onload=function(){200===f.status?d(JSON.parse(f.responseText)):e(JSON.parse(f.responseText))},f.onerror=e,f.open("POST",a.OAUTH_BASE_URL+"access_token"),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.timeout=b.timeout,f.send(c)})},i=function(a,c,d,e){return new Promise(function(f,g){var h=new XMLHttpRequest;h.onload=function(){if(200===h.status)f(JSON.parse(h.responseText));else if(400===h.status||401===h.status){var a=h.getResponseHeader("WWW-Authenticate")||"",b=a.match(/error="(\w+)"/)||[],c=a.match(/error_description="(\w+)"/)||[],d=b.length>1?b[1]:h.statusText,e=c.length>1?c[1]:"";g({status:h.status,error:d,error_description:e})}else g({status:h.status,error:h.statusText,error_description:"An error has occurred while requesting api"})},h.onerror=g,h.open(c,a),e&&e["Content-Type"]&&h.setRequestHeader("Content-Type",e["Content-Type"]),h.setRequestHeader("Authorization","Bearer "+encodeURIComponent(b.accessToken)),h.timeout=b.timeout,h.send(d)})};return a.prototype.authorizeChromeApp=function(){return new Promise(function(d,g){if(!chrome||!chrome.identity)return void g(new Error("chrome.identity API is unsupported"));var h=a.OAUTH_BASE_URL+"authorize?client_id="+encodeURIComponent(c)+"&redirect_uri="+encodeURIComponent(e)+"&scope="+encodeURIComponent(f)+"&response_type=code";chrome.identity.launchWebAuthFlow({url:h,interactive:!0},function(a){if("undefined"==typeof a)return void g(new Error("response url is required"));var c=a.match(/code=(.+)/)[1];return"undefined"==typeof c?void g(new Error("authorization code is required")):void b.getAccessTokenUsingAuthorizationCode(c).then(function(a){d(a)},function(a){g(a)})})})},a.prototype.hasToken=function(){return!!b.accessToken&&!!b.refreshToken},a.prototype.clearToken=function(){b.accessToken=null,b.refreshToken=null},a.prototype.validateAccessToken=function(){return b.getMyProfile()},a.prototype.getAccessTokenUsingClientCredentials=function(){var a="client_id="+encodeURIComponent(c)+"&client_secret="+encodeURIComponent(d)+"&grant_type=client_credentials&scope="+encodeURIComponent(f);return h(a)},a.prototype.requestAuthorization=function(){var b="client_id="+encodeURIComponent(c)+"&redirect_uri="+encodeURIComponent(e)+"&scope="+encodeURIComponent(f)+"&response_type=code";location.href=a.OAUTH_BASE_URL+"authorize?"+b},a.prototype.getAccessTokenUsingAuthorizationCode=function(a){var b="client_id="+encodeURIComponent(c)+"&client_secret="+encodeURIComponent(d)+"&redirect_uri="+encodeURIComponent(e)+"&grant_type=authorization_code&code="+encodeURIComponent(a);return h(b)},a.prototype.refreshAccessToken=function(a){var e="client_id="+encodeURIComponent(c)+"&client_secret="+encodeURIComponent(d)+"&grant_type=refresh_token&refresh_token="+encodeURIComponent(a||b.refreshToken);return h(e)},a.prototype.getMyProfile=function(){return i(a.API_BASE_URL+"profile","GET",null)},a.prototype.getMyTopics=function(){return i(a.API_BASE_URL+"topics","GET",null)},a.prototype.getTopicMessages=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"?"+g(c),"GET",null)},a.prototype.postMessage=function(b,c,d){return d=d||{},d.message=c,i(a.API_BASE_URL+"topics/"+encodeURIComponent(b),"POST",g(d),{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.uploadAttachmentFile=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b),"POST",{file:c},{"Content-Type":"multipart/form-data"})},a.prototype.getTopicMembers=function(b){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/members/status","GET",null)},a.prototype.getMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c),"GET",null)},a.prototype.removeMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c),"DELETE",null)},a.prototype.likeMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c)+"/like","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.unlikeMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c)+"/like","DELETE",null)},a.prototype.favoriteTopic=function(b){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/favorite","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.unfavoriteTopic=function(b){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/favorite","DELETE",null)},a.prototype.getNotificationList=function(){return i(a.API_BASE_URL+"notifications","GET",null)},a.prototype.getNotificationCount=function(){return i(a.API_BASE_URL+"notifications/status","GET",null)},a.prototype.readNotification=function(){return i(a.API_BASE_URL+"notifications/open","PUT",null)},a.prototype.readMessagesInTopic=function(b,c){return c=c||{},c.topicId=b,i(a.API_BASE_URL+"bookmark/save","POST",g(c),{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.getMentionList=function(b){return b=b||{},i(a.API_BASE_URL+"mentions?"+g(b),"GET",null)},a.prototype.readMention=function(b){return i(a.API_BASE_URL+"mentions/"+encodeURIComponent(b),"PUT",null)},a.prototype.acceptTeamInvitation=function(b,c){return i(a.API_BASE_URL+"teams/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/accept","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.declineTeamInvitation=function(b,c){return i(a.API_BASE_URL+"teams/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/decline","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.acceptTopicInvitation=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/accept","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.declineTopicInvitation=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/decline","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a}();"undefined"!=typeof module?module.exports=a:this.Typetalk=a}).call(this); \ No newline at end of file +/*! typetalk-js 2014-05-06 */ +"use strict";if("undefined"==typeof window)var Promise=Promise||require("bluebird"),XMLHttpRequest=XMLHttpRequest||require("xmlhttprequest").XMLHttpRequest;(function(){var a=function(){function a(a){b=this,a=a||{},b.accessToken=a.access_token,b.refreshToken=a.refresh_token,b.timeout=a.timeout||3e3,c=a.client_id,d=a.client_secret,e=a.redirect_uri,f=a.scope||f}a.API_BASE_URL="https://typetalk.in/api/v1/",a.OAUTH_BASE_URL="https://typetalk.in/oauth2/";var b,c,d,e,f="topic.read",g=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},h=function(c){return new Promise(function(d,e){var f=new XMLHttpRequest;f.onload=function(){200===f.status?d(JSON.parse(f.responseText)):e(JSON.parse(f.responseText))},f.onerror=e,f.open("POST",a.OAUTH_BASE_URL+"access_token"),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.timeout=b.timeout,f.send(c)})},i=function(a,c,d,e){return new Promise(function(f,g){var h=new XMLHttpRequest;h.onload=function(){if(200===h.status)f(JSON.parse(h.responseText));else if(400===h.status||401===h.status){var a=h.getResponseHeader("WWW-Authenticate")||"",b=a.match(/error="(\w+)"/)||[],c=a.match(/error_description="(\w+)"/)||[],d=b.length>1?b[1]:h.statusText,e=c.length>1?c[1]:"";g({status:h.status,error:d,error_description:e})}else g({status:h.status,error:h.statusText,error_description:"An error has occurred while requesting api"})},h.onerror=g,h.open(c,a),e&&e["Content-Type"]&&h.setRequestHeader("Content-Type",e["Content-Type"]),h.setRequestHeader("Authorization","Bearer "+encodeURIComponent(b.accessToken)),h.timeout=b.timeout,h.send(d)})};return a.prototype.authorizeChromeApp=function(d){return d=d||{},new Promise(function(g,h){if(!chrome||!chrome.identity)return void h(new Error("chrome.identity API is unsupported"));var i=a.OAUTH_BASE_URL+"authorize?client_id="+encodeURIComponent(c||d.client_id)+"&redirect_uri="+encodeURIComponent(e||d.redirect_uri)+"&scope="+encodeURIComponent(f||d.scope)+"&response_type=code";chrome.identity.launchWebAuthFlow({url:i,interactive:!0},function(a){if("undefined"==typeof a)return void h(new Error("Cannot get response url"));var c=a.match(/code=(.+)/)[1];return"undefined"==typeof c?void h(new Error("authorization code is required")):void b.getAccessTokenUsingAuthorizationCode(c).then(function(a){g(a)},function(a){h(a)})})})},a.prototype.hasToken=function(){return!!b.accessToken&&!!b.refreshToken},a.prototype.clearToken=function(){b.accessToken=null,b.refreshToken=null},a.prototype.validateAccessToken=function(){return b.getMyProfile()},a.prototype.getAccessTokenUsingClientCredentials=function(a){a=a||{};var b="client_id="+encodeURIComponent(c||a.client_id)+"&client_secret="+encodeURIComponent(d||a.client_secret)+"&grant_type=client_credentials&scope="+encodeURIComponent(f||a.scope);return h(b)},a.prototype.requestAuthorization=function(b){b=b||{};var d="client_id="+encodeURIComponent(c||b.client_id)+"&redirect_uri="+encodeURIComponent(e||b.redirect_uri)+"&scope="+encodeURIComponent(f||b.scope)+"&response_type=code";location.href=a.OAUTH_BASE_URL+"authorize?"+d},a.prototype.getAccessTokenUsingAuthorizationCode=function(a,b){b=b||{};var f="client_id="+encodeURIComponent(c||b.client_id)+"&client_secret="+encodeURIComponent(d||b.client_secret)+"&redirect_uri="+encodeURIComponent(e||b.redirect_uri)+"&grant_type=authorization_code&code="+encodeURIComponent(a);return h(f)},a.prototype.refreshAccessToken=function(a){a=a||{};var e="client_id="+encodeURIComponent(c||a.client_id)+"&client_secret="+encodeURIComponent(d||a.client_secret)+"&grant_type=refresh_token&refresh_token="+encodeURIComponent(b.refreshToken||a.refresh_token);return h(e)},a.prototype.getMyProfile=function(){return i(a.API_BASE_URL+"profile","GET",null)},a.prototype.getMyTopics=function(){return i(a.API_BASE_URL+"topics","GET",null)},a.prototype.getTopicMessages=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"?"+g(c),"GET",null)},a.prototype.postMessage=function(b,c,d){return d=d||{},d.message=c,i(a.API_BASE_URL+"topics/"+encodeURIComponent(b),"POST",g(d),{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.uploadAttachmentFile=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b),"POST",{file:c},{"Content-Type":"multipart/form-data"})},a.prototype.getTopicMembers=function(b){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/members/status","GET",null)},a.prototype.getMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c),"GET",null)},a.prototype.removeMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c),"DELETE",null)},a.prototype.likeMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c)+"/like","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.unlikeMessage=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/posts/"+encodeURIComponent(c)+"/like","DELETE",null)},a.prototype.favoriteTopic=function(b){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/favorite","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.unfavoriteTopic=function(b){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/favorite","DELETE",null)},a.prototype.getNotificationList=function(){return i(a.API_BASE_URL+"notifications","GET",null)},a.prototype.getNotificationCount=function(){return i(a.API_BASE_URL+"notifications/status","GET",null)},a.prototype.readNotification=function(){return i(a.API_BASE_URL+"notifications/open","PUT",null)},a.prototype.readMessagesInTopic=function(b,c){return c=c||{},c.topicId=b,i(a.API_BASE_URL+"bookmark/save","POST",g(c),{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.getMentionList=function(b){return b=b||{},i(a.API_BASE_URL+"mentions?"+g(b),"GET",null)},a.prototype.readMention=function(b){return i(a.API_BASE_URL+"mentions/"+encodeURIComponent(b),"PUT",null)},a.prototype.acceptTeamInvitation=function(b,c){return i(a.API_BASE_URL+"teams/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/accept","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.declineTeamInvitation=function(b,c){return i(a.API_BASE_URL+"teams/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/decline","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.acceptTopicInvitation=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/accept","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a.prototype.declineTopicInvitation=function(b,c){return i(a.API_BASE_URL+"topics/"+encodeURIComponent(b)+"/members/invite/"+encodeURIComponent(c)+"/decline","POST",{"Content-Type":"application/x-www-form-urlencoded"})},a}();"undefined"!=typeof module?module.exports=a:this.Typetalk=a}).call(this); \ No newline at end of file