@dodi-smart/nuki-graphql-api
Version:
Nuki GraphQL API
354 lines • 9.83 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountService = void 0;
class AccountService {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Get an account
* @returns MyAccount successful operation
* @throws ApiError
*/
getAccount() {
return this.httpRequest.request({
method: 'GET',
url: '/account',
errors: {
401: `Not authorized`,
},
});
}
/**
* Create an account
* @param requestBody Account create representation
* @returns void
* @throws ApiError
*/
createAccount(requestBody) {
return this.httpRequest.request({
method: 'PUT',
url: '/account',
body: requestBody,
mediaType: '*/*',
errors: {
400: `Invalid E-Mail address, password or name supplied`,
},
});
}
/**
* Update an account
* @param requestBody Account update representation
* @param deleteApiTokens If false existing API tokens are not deleted if the password is changed
* @returns void
* @throws ApiError
*/
updateAccount(requestBody, deleteApiTokens = true) {
return this.httpRequest.request({
method: 'POST',
url: '/account',
query: {
'deleteApiTokens': deleteApiTokens,
},
body: requestBody,
mediaType: '*/*',
errors: {
400: `Invalid E-Mail address or name supplied`,
401: `Not authorized`,
409: `E-Mail address already exists`,
},
});
}
/**
* Delete an account
* @returns void
* @throws ApiError
*/
deleteAccount() {
return this.httpRequest.request({
method: 'DELETE',
url: '/account',
errors: {
401: `Not authorized`,
},
});
}
/**
* Triggers the email change verification email
* @param requestBody Account email change representation
* @returns void
* @throws ApiError
*/
updateAccountEmailChange(requestBody) {
return this.httpRequest.request({
method: 'POST',
url: '/account/email/change',
body: requestBody,
mediaType: '*/*',
errors: {
400: `Email not in valid format`,
401: `Not authorized`,
409: `Other account is already using the email`,
},
});
}
/**
* Triggers the email change verification email
* @returns void
* @throws ApiError
*/
updateAccountEmailVerify() {
return this.httpRequest.request({
method: 'POST',
url: '/account/email/verify',
errors: {
400: `Email not in valid format`,
401: `Not authorized`,
409: `Other account is already using the email`,
},
});
}
/**
* Get all integrations for this account
* @returns AccountIntegration successful operation
* @throws ApiError
*/
getAccountIntegrations() {
return this.httpRequest.request({
method: 'GET',
url: '/account/integration',
errors: {
401: `Not authorized`,
},
});
}
/**
* Delete an integration
* @param apiKeyId The api key id to delete (this also removes all tokens if no specific tokenId is given)
* @param tokenId The token id if a specific token has to be deleted but not the full api key
* @returns void
* @throws ApiError
*/
deleteAccountIntegration(apiKeyId, tokenId) {
return this.httpRequest.request({
method: 'DELETE',
url: '/account/integration',
query: {
'apiKeyId': apiKeyId,
'tokenId': tokenId,
},
errors: {
401: `Not authorized`,
},
});
}
/**
* Create an one time password secret
* @returns string Ok
* @throws ApiError
*/
createAccountOtp() {
return this.httpRequest.request({
method: 'PUT',
url: '/account/otp',
errors: {
405: `One time password is already enabled`,
},
});
}
/**
* Enables one time password for an account
* @param requestBody Account one time password enable representation
* @returns void
* @throws ApiError
*/
updateAccountOtp(requestBody) {
return this.httpRequest.request({
method: 'POST',
url: '/account/otp',
body: requestBody,
mediaType: '*/*',
errors: {
400: `One time password empty`,
401: `Not authorized or one time password wrong`,
429: `Too many failed attempts`,
},
});
}
/**
* Disables one time password for an account
* @returns void
* @throws ApiError
*/
deleteAccountOtp() {
return this.httpRequest.request({
method: 'DELETE',
url: '/account/otp',
errors: {
401: `Not authorized`,
},
});
}
/**
* Reset account password
* @param requestBody Account password reset representation
* @returns void
* @throws ApiError
*/
updateAccountPasswordReset(requestBody) {
return this.httpRequest.request({
method: 'POST',
url: '/account/password/reset',
body: requestBody,
mediaType: '*/*',
errors: {
401: `Not authorized`,
},
});
}
/**
* Get account setting
* @returns AccountSetting successful operation
* @throws ApiError
*/
getAccountSetting() {
return this.httpRequest.request({
method: 'GET',
url: '/account/setting',
errors: {
401: `Not authorized`,
403: `Forbidden`,
404: `Not found`,
},
});
}
/**
* Create or update account setting
* @param requestBody Account setting representation
* @returns AccountSetting successful operation
* @throws ApiError
*/
createAccountSetting(requestBody) {
return this.httpRequest.request({
method: 'PUT',
url: '/account/setting',
body: requestBody,
mediaType: '*/*',
errors: {
400: `Bad Parameter`,
401: `Not authorized`,
},
});
}
/**
* Delete an account setting
* @returns void
* @throws ApiError
*/
deleteAccountSetting() {
return this.httpRequest.request({
method: 'DELETE',
url: '/account/setting',
errors: {
401: `Not authorized`,
403: `Forbidden`,
},
});
}
/**
* Get an list of sub accounts
* @param email The optional email (regex)
* @returns Account successful operation
* @throws ApiError
*/
getAccountSubs(email) {
return this.httpRequest.request({
method: 'GET',
url: '/account/sub',
query: {
'email': email,
},
errors: {
401: `Not authorized`,
},
});
}
/**
* Create an sub account
* @param requestBody Account sub create representation
* @returns MyAccount Ok
* @throws ApiError
*/
createAccountSub(requestBody) {
return this.httpRequest.request({
method: 'PUT',
url: '/account/sub',
body: requestBody,
mediaType: '*/*',
errors: {
400: `Invalid parameter supplied`,
},
});
}
/**
* Get an sub account
* @param accountId The account id
* @returns Account successful operation
* @throws ApiError
*/
getAccountSub(accountId) {
return this.httpRequest.request({
method: 'GET',
url: '/account/sub/{accountId}',
path: {
'accountId': accountId,
},
errors: {
401: `Not authorized`,
},
});
}
/**
* Update an sub account
* @param accountId The account id
* @param requestBody Account update representation
* @returns void
* @throws ApiError
*/
updateAccountSub(accountId, requestBody) {
return this.httpRequest.request({
method: 'POST',
url: '/account/sub/{accountId}',
path: {
'accountId': accountId,
},
body: requestBody,
mediaType: '*/*',
errors: {
400: `Invalid parameter supplied`,
401: `Not authorized`,
409: `E-Mail address already exists`,
},
});
}
/**
* Delete an sub account
* @param accountId The account id
* @returns void
* @throws ApiError
*/
deleteAccountSub(accountId) {
return this.httpRequest.request({
method: 'DELETE',
url: '/account/sub/{accountId}',
path: {
'accountId': accountId,
},
errors: {
401: `Not authorized`,
},
});
}
}
exports.AccountService = AccountService;
//# sourceMappingURL=AccountService.js.map