userApi.jsā¢24 kB
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserApi = exports.UserApiApiKeys = void 0;
const request_1 = __importDefault(require("request"));
const models_1 = require("../model/models");
const models_2 = require("../model/models");
const apis_1 = require("./apis");
let defaultBasePath = 'https://api.brevo.com/v3';
var UserApiApiKeys;
(function (UserApiApiKeys) {
UserApiApiKeys[UserApiApiKeys["apiKey"] = 0] = "apiKey";
UserApiApiKeys[UserApiApiKeys["partnerKey"] = 1] = "partnerKey";
})(UserApiApiKeys = exports.UserApiApiKeys || (exports.UserApiApiKeys = {}));
class UserApi {
constructor(basePathOrUsername, password, basePath) {
this._basePath = defaultBasePath;
this._defaultHeaders = {};
this._useQuerystring = false;
this.authentications = {
'default': new models_1.VoidAuth(),
'apiKey': new models_2.ApiKeyAuth('header', 'api-key'),
'partnerKey': new models_2.ApiKeyAuth('header', 'partner-key'),
};
this.interceptors = [];
if (password) {
if (basePath) {
this.basePath = basePath;
}
}
else {
if (basePathOrUsername) {
this.basePath = basePathOrUsername;
}
}
}
set useQuerystring(value) {
this._useQuerystring = value;
}
set basePath(basePath) {
this._basePath = basePath;
}
set defaultHeaders(defaultHeaders) {
this._defaultHeaders = defaultHeaders;
}
get defaultHeaders() {
return this._defaultHeaders;
}
get basePath() {
return this._basePath;
}
setDefaultAuthentication(auth) {
this.authentications.default = auth;
}
setApiKey(key, value) {
this.authentications[UserApiApiKeys[key]].apiKey = value;
}
addInterceptor(interceptor) {
this.interceptors.push(interceptor);
}
editUserPermission(updatePermissions, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/organization/user/update/permissions';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
}
else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams = {};
if (updatePermissions === null || updatePermissions === undefined) {
throw new Error('Required parameter updatePermissions was null or undefined when calling editUserPermission.');
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'POST',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: models_1.ObjectSerializer.serialize(updatePermissions, "Inviteuser")
};
let authenticationPromise = Promise.resolve();
if (this.authentications.apiKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions));
}
if (this.authentications.partnerKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
localVarRequestOptions.formData = localVarFormParams;
}
else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise((resolve, reject) => {
(0, request_1.default)(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = models_1.ObjectSerializer.deserialize(body, "Inviteuser");
resolve({ response: response, body: body });
}
else {
reject(new apis_1.HttpError(response, body, response.statusCode));
}
}
});
});
});
});
}
getInvitedUsersList(options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/organization/invited/users';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
}
else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams = {};
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
let authenticationPromise = Promise.resolve();
if (this.authentications.apiKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions));
}
if (this.authentications.partnerKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
localVarRequestOptions.formData = localVarFormParams;
}
else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise((resolve, reject) => {
(0, request_1.default)(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = models_1.ObjectSerializer.deserialize(body, "GetInvitedUsersList");
resolve({ response: response, body: body });
}
else {
reject(new apis_1.HttpError(response, body, response.statusCode));
}
}
});
});
});
});
}
getUserPermission(email, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/organization/user/{email}/permissions'
.replace('{' + 'email' + '}', encodeURIComponent(String(email)));
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
}
else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams = {};
if (email === null || email === undefined) {
throw new Error('Required parameter email was null or undefined when calling getUserPermission.');
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
let authenticationPromise = Promise.resolve();
if (this.authentications.apiKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions));
}
if (this.authentications.partnerKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
localVarRequestOptions.formData = localVarFormParams;
}
else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise((resolve, reject) => {
(0, request_1.default)(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = models_1.ObjectSerializer.deserialize(body, "GetUserPermission");
resolve({ response: response, body: body });
}
else {
reject(new apis_1.HttpError(response, body, response.statusCode));
}
}
});
});
});
});
}
inviteuser(sendInvitation, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/organization/user/invitation/send';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
}
else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams = {};
if (sendInvitation === null || sendInvitation === undefined) {
throw new Error('Required parameter sendInvitation was null or undefined when calling inviteuser.');
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'POST',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: models_1.ObjectSerializer.serialize(sendInvitation, "Inviteuser")
};
let authenticationPromise = Promise.resolve();
if (this.authentications.apiKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions));
}
if (this.authentications.partnerKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
localVarRequestOptions.formData = localVarFormParams;
}
else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise((resolve, reject) => {
(0, request_1.default)(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = models_1.ObjectSerializer.deserialize(body, "Inviteuser");
resolve({ response: response, body: body });
}
else {
reject(new apis_1.HttpError(response, body, response.statusCode));
}
}
});
});
});
});
}
putRevokeUserPermission(email, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/organization/user/invitation/revoke/{email}'
.replace('{' + 'email' + '}', encodeURIComponent(String(email)));
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
}
else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams = {};
if (email === null || email === undefined) {
throw new Error('Required parameter email was null or undefined when calling putRevokeUserPermission.');
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'PUT',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
let authenticationPromise = Promise.resolve();
if (this.authentications.apiKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions));
}
if (this.authentications.partnerKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
localVarRequestOptions.formData = localVarFormParams;
}
else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise((resolve, reject) => {
(0, request_1.default)(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = models_1.ObjectSerializer.deserialize(body, "PutRevokeUserPermission");
resolve({ response: response, body: body });
}
else {
reject(new apis_1.HttpError(response, body, response.statusCode));
}
}
});
});
});
});
}
putresendcancelinvitation(action, email, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/organization/user/invitation/{action}/{email}'
.replace('{' + 'action' + '}', encodeURIComponent(String(action)))
.replace('{' + 'email' + '}', encodeURIComponent(String(email)));
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
}
else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams = {};
if (action === null || action === undefined) {
throw new Error('Required parameter action was null or undefined when calling putresendcancelinvitation.');
}
if (email === null || email === undefined) {
throw new Error('Required parameter email was null or undefined when calling putresendcancelinvitation.');
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'PUT',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
let authenticationPromise = Promise.resolve();
if (this.authentications.apiKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions));
}
if (this.authentications.partnerKey.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
localVarRequestOptions.formData = localVarFormParams;
}
else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise((resolve, reject) => {
(0, request_1.default)(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = models_1.ObjectSerializer.deserialize(body, "Putresendcancelinvitation");
resolve({ response: response, body: body });
}
else {
reject(new apis_1.HttpError(response, body, response.statusCode));
}
}
});
});
});
});
}
}
exports.UserApi = UserApi;
//# sourceMappingURL=userApi.js.map