UNPKG

@wireapp/api-client

Version:

Wire API Client to send and receive data.

201 lines (200 loc) • 7.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var UserAPI = (function () { function UserAPI(client) { this.client = client; } Object.defineProperty(UserAPI, "URL", { get: function () { return { ACTIVATE: '/activate', CALLS: '/calls', CLIENTS: 'clients', CONTACTS: 'contacts', DELETE: '/delete', HANDLES: 'handles', PASSWORDRESET: '/password-reset', PRE_KEYS: 'prekeys', PROPERTIES: '/properties', SEARCH: '/search', SEND: 'send', USERS: '/users', }; }, enumerable: true, configurable: true }); UserAPI.prototype.deleteProperties = function () { var config = { method: 'delete', url: UserAPI.URL.PROPERTIES, }; return this.client.sendJSON(config).then(function () { return ({}); }); }; UserAPI.prototype.deleteProperty = function (propertyKey) { var config = { method: 'delete', url: UserAPI.URL.PROPERTIES + "/" + propertyKey, }; return this.client.sendJSON(config).then(function () { return ({}); }); }; UserAPI.prototype.getActivation = function (activationCode, activationKey) { var config = { params: { code: activationCode, key: activationKey, }, method: 'get', url: UserAPI.URL.ACTIVATE, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getCallsConfiguration = function () { var config = { method: 'get', url: UserAPI.URL.CALLS + "/config", }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getClient = function (userId, clientId) { var config = { method: 'get', url: UserAPI.URL.USERS + "/" + userId + "/" + UserAPI.URL.CLIENTS + "/" + clientId, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getClientPreKey = function (userId, clientId) { var config = { method: 'get', url: UserAPI.URL.USERS + "/" + userId + "/" + UserAPI.URL.PRE_KEYS + "/" + clientId, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getClients = function (userId) { var config = { method: 'get', url: UserAPI.URL.USERS + "/" + userId + "/" + UserAPI.URL.CLIENTS, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getHandle = function (handle) { var config = { method: 'get', url: UserAPI.URL.USERS + "/" + UserAPI.URL.HANDLES + "/" + handle, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getProperties = function () { var config = { method: 'get', url: UserAPI.URL.PROPERTIES, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getProperty = function (propertyKey) { var config = { method: 'get', url: UserAPI.URL.PROPERTIES + "/" + propertyKey, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getSearchContacts = function (query, limit) { var config = { params: { q: query, }, method: 'get', url: UserAPI.URL.SEARCH + "/" + UserAPI.URL.CONTACTS, }; if (limit) { config.params.size = limit; } return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getUser = function (userId) { var config = { method: 'get', url: UserAPI.URL.USERS + "/" + userId, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getUserPreKeys = function (userId) { var config = { method: 'get', url: UserAPI.URL.USERS + "/" + userId + "/" + UserAPI.URL.PRE_KEYS, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.getUsers = function (parameters) { var config = { method: 'get', params: {}, url: UserAPI.URL.USERS, }; if (parameters.handles) { config.params.handles = parameters.handles.join(','); } else if (parameters.ids) { config.params.ids = parameters.ids.join(','); } return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.postActivation = function (activationData) { var config = { data: activationData, method: 'post', url: UserAPI.URL.ACTIVATE, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.postActivationCode = function (activationCodeData) { var config = { data: activationCodeData, method: 'post', url: UserAPI.URL.ACTIVATE + "/" + UserAPI.URL.SEND, }; return this.client.sendJSON(config).then(function () { return ({}); }); }; UserAPI.prototype.postDelete = function (verificationData) { var config = { data: verificationData, method: 'post', url: UserAPI.URL.DELETE, }; return this.client.sendJSON(config).then(function () { return ({}); }); }; UserAPI.prototype.postHandles = function (handles) { var config = { data: handles, method: 'post', url: UserAPI.URL.USERS + "/" + UserAPI.URL.HANDLES, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.postMultiPreKeyBundles = function (userClientMap) { var config = { data: userClientMap, method: 'post', url: UserAPI.URL.USERS + "/" + UserAPI.URL.PRE_KEYS, }; return this.client.sendJSON(config).then(function (response) { return response.data; }); }; UserAPI.prototype.postPasswordReset = function (resetData) { var config = { data: resetData, method: 'post', url: UserAPI.URL.PASSWORDRESET, }; return this.client.sendJSON(config).then(function () { return ({}); }); }; UserAPI.prototype.putProperty = function (propertyKey, propertyData) { var config = { data: propertyData, method: 'put', url: UserAPI.URL.PROPERTIES + "/" + propertyKey, }; return this.client.sendJSON(config).then(function () { return ({}); }); }; return UserAPI; }()); exports.UserAPI = UserAPI;