diff --git a/spec.json b/spec.json index 68f66335ac507eb67b918d2924f79bb38aeedf5d..077195b6cedb85e2cc6e2ab7e8208027bb3a8c37 100644 --- a/spec.json +++ b/spec.json @@ -36,8 +36,8 @@ "required": true }, "responses": { - "200": { - "description": "No accounts associated with a bank user", + "404": { + "description": "Bank profile id does not exist", "content": { "*/*": { "schema": { @@ -46,8 +46,8 @@ } } }, - "404": { - "description": "Bank profile id does not exist", + "200": { + "description": "No accounts associated with a bank user", "content": { "*/*": { "schema": { @@ -78,8 +78,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully created a bank profile", + "400": { + "description": "Could not create profile", "content": { "*/*": { "schema": { @@ -88,8 +88,8 @@ } } }, - "400": { - "description": "Could not create profile", + "200": { + "description": "Successfully created a bank profile", "content": { "*/*": { "schema": { @@ -120,8 +120,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully created account", + "404": { + "description": "Provided bank profile id could not be found", "content": { "*/*": { "schema": { @@ -130,8 +130,8 @@ } } }, - "404": { - "description": "Provided bank profile id could not be found", + "200": { + "description": "Successfully created account", "content": { "*/*": { "schema": { @@ -188,17 +188,17 @@ "required": true }, "responses": { - "204": { - "description": "Password was reset successfully" - }, "403": { "description": "Invalid token" + }, + "204": { + "description": "Password was reset successfully" } }, "security": [] } }, - "/api/image/upload": { + "/api/images": { "post": { "tags": [ "Image" @@ -208,7 +208,7 @@ "operationId": "uploadImage", "requestBody": { "content": { - "application/json": { + "multipart/form-data": { "schema": { "required": [ "file" @@ -225,19 +225,8 @@ } }, "responses": { - "200": { - "description": "Successfully uploaded the image", - "content": { - "*/*": { - "schema": { - "type": "integer", - "format": "int64" - } - } - } - }, "201": { - "description": "Created", + "description": "Successfully uploaded the image", "content": { "*/*": { "schema": { @@ -280,7 +269,7 @@ } } }, - "/api/budget/update": { + "/api/budget/update/{budgetId}": { "post": { "tags": [ "User" @@ -288,19 +277,30 @@ "summary": "Updates a budget", "description": "Updates a budget based on the budget request", "operationId": "updateBudget", + "parameters": [ + { + "name": "budgetId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BudgetResponseDTO" + "$ref": "#/components/schemas/BudgetRequestDTO" } } }, "required": true }, "responses": { - "200": { - "description": "Successfully updated budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -309,8 +309,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully updated budget", "content": { "application/json": { "schema": { @@ -352,8 +352,8 @@ "required": true }, "responses": { - "200": { - "description": "Successfully updated budget", + "500": { + "description": "Error updating expense", "content": { "application/json": { "schema": { @@ -362,8 +362,8 @@ } } }, - "500": { - "description": "Error updating expense", + "200": { + "description": "Successfully updated budget", "content": { "application/json": { "schema": { @@ -426,22 +426,22 @@ } ], "responses": { - "200": { - "description": "Email is valid", + "409": { + "description": "Email already exists", "content": { "*/*": { "schema": { - "type": "object" + "$ref": "#/components/schemas/ExceptionResponse" } } } }, - "409": { - "description": "Email already exists", + "200": { + "description": "Email is valid", "content": { "*/*": { "schema": { - "$ref": "#/components/schemas/ExceptionResponse" + "type": "object" } } } @@ -610,6 +610,38 @@ } } }, + "/api/users/password": { + "patch": { + "tags": [ + "User" + ], + "summary": "Update a password", + "description": "Update the password of the authenticated user", + "operationId": "updatePassword", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PasswordUpdateDTO" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successfully updated password", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/UserDTO" + } + } + } + } + } + } + }, "/bank/v1/account/accounts/ssn/{ssn}": { "get": { "tags": [ @@ -679,8 +711,8 @@ } ], "responses": { - "200": { - "description": "No accounts associated with a bank user", + "404": { + "description": "Bank profile id does not exist", "content": { "*/*": { "schema": { @@ -692,8 +724,8 @@ } } }, - "404": { - "description": "Bank profile id does not exist", + "200": { + "description": "No accounts associated with a bank user", "content": { "*/*": { "schema": { @@ -859,7 +891,7 @@ } } }, - "/api/image/{id}": { + "/api/images/{id}": { "get": { "tags": [ "Image" @@ -884,16 +916,24 @@ "content": { "*/*": { "schema": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } + "type": "string", + "format": "binary" + } + } + } + }, + "404": { + "description": "Image not found", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ExceptionResponse" } } } } - } + }, + "security": [] } }, "/api/goal/getGoals": { @@ -984,8 +1024,8 @@ } ], "responses": { - "200": { - "description": "Successfully got budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -994,8 +1034,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully got budget", "content": { "application/json": { "schema": { @@ -1106,8 +1146,8 @@ } ], "responses": { - "200": { - "description": "Successfully deleted budget", + "500": { + "description": "Budget is not found", "content": { "application/json": { "schema": { @@ -1116,8 +1156,8 @@ } } }, - "500": { - "description": "Budget is not found", + "200": { + "description": "Successfully deleted budget", "content": { "application/json": { "schema": { @@ -1420,13 +1460,9 @@ } } }, - "BudgetResponseDTO": { + "BudgetRequestDTO": { "type": "object", "properties": { - "id": { - "type": "integer", - "format": "int64" - }, "budgetName": { "type": "string" }, @@ -1435,10 +1471,6 @@ }, "expenseAmount": { "type": "number" - }, - "createdAt": { - "type": "string", - "format": "date-time" } } }, @@ -1457,20 +1489,6 @@ } } }, - "BudgetRequestDTO": { - "type": "object", - "properties": { - "budgetName": { - "type": "string" - }, - "budgetAmount": { - "type": "number" - }, - "expenseAmount": { - "type": "number" - } - } - }, "Badge": { "type": "object", "properties": { @@ -1663,6 +1681,10 @@ "email": { "type": "string" }, + "profileImage": { + "type": "integer", + "format": "int64" + }, "checkingAccount": { "$ref": "#/components/schemas/Account" }, @@ -1701,21 +1723,21 @@ "enabled": { "type": "boolean" }, - "accountNonExpired": { - "type": "boolean" - }, - "credentialsNonExpired": { - "type": "boolean" - }, - "username": { - "type": "string" - }, "authorities": { "type": "array", "items": { "$ref": "#/components/schemas/GrantedAuthority" } }, + "username": { + "type": "string" + }, + "accountNonExpired": { + "type": "boolean" + }, + "credentialsNonExpired": { + "type": "boolean" + }, "accountNonLocked": { "type": "boolean" } @@ -1813,8 +1835,9 @@ "email": { "type": "string" }, - "password": { - "type": "string" + "profileImage": { + "type": "integer", + "format": "int64" }, "configuration": { "$ref": "#/components/schemas/ConfigurationDTO" @@ -1834,6 +1857,10 @@ "lastName": { "type": "string" }, + "profileImage": { + "type": "integer", + "format": "int64" + }, "email": { "type": "string" }, @@ -1858,6 +1885,17 @@ } } }, + "PasswordUpdateDTO": { + "type": "object", + "properties": { + "oldPassword": { + "type": "string" + }, + "newPassword": { + "type": "string" + } + } + }, "ProfileDTO": { "type": "object", "properties": { @@ -1871,6 +1909,10 @@ "lastName": { "type": "string" }, + "profileImage": { + "type": "integer", + "format": "int64" + }, "createdAt": { "type": "string", "format": "date-time" @@ -1910,6 +1952,28 @@ } } }, + "BudgetResponseDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "budgetName": { + "type": "string" + }, + "budgetAmount": { + "type": "number" + }, + "expenseAmount": { + "type": "number" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + }, "ExpenseResponseDTO": { "type": "object", "properties": { diff --git a/src/api/index.ts b/src/api/index.ts index a3a2de06404f9a80b4f14a9e08e8857581203498..c2c621ddd2ef1287251a040c2e8e999471704f49 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -37,6 +37,7 @@ export type { LoginRequest } from './models/LoginRequest'; export { ParticipantDTO } from './models/ParticipantDTO'; export type { ParticipantUserDTO } from './models/ParticipantUserDTO'; export type { PasswordResetDTO } from './models/PasswordResetDTO'; +export type { PasswordUpdateDTO } from './models/PasswordUpdateDTO'; export type { Point } from './models/Point'; export type { ProfileDTO } from './models/ProfileDTO'; export type { SignUpRequest } from './models/SignUpRequest'; diff --git a/src/api/models/PasswordUpdateDTO.ts b/src/api/models/PasswordUpdateDTO.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a5085afa9a61c1b1494c034391cb4a758ed7e5d --- /dev/null +++ b/src/api/models/PasswordUpdateDTO.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type PasswordUpdateDTO = { + oldPassword?: string; + newPassword?: string; +}; + diff --git a/src/api/models/ProfileDTO.ts b/src/api/models/ProfileDTO.ts index f3a7d36f290da3dfa38b6143e83b934b427ee47f..4afa17a7faad4191cabd0e5be6450a80507779c1 100644 --- a/src/api/models/ProfileDTO.ts +++ b/src/api/models/ProfileDTO.ts @@ -6,6 +6,7 @@ export type ProfileDTO = { id?: number; firstName?: string; lastName?: string; + profileImage?: number; createdAt?: string; }; diff --git a/src/api/models/User.ts b/src/api/models/User.ts index 0eaf2816d9ef7030fe434d45344fff6068a9e4a5..d6bb1f5767a27a191df1b0297b8ad49b2c7fab44 100644 --- a/src/api/models/User.ts +++ b/src/api/models/User.ts @@ -13,6 +13,7 @@ export type User = { firstName?: string; lastName?: string; email?: string; + profileImage?: number; checkingAccount?: Account; savingsAccount?: Account; password?: string; @@ -23,10 +24,10 @@ export type User = { streak?: Streak; configuration?: Configuration; enabled?: boolean; + authorities?: Array<GrantedAuthority>; + username?: string; accountNonExpired?: boolean; credentialsNonExpired?: boolean; - username?: string; - authorities?: Array<GrantedAuthority>; accountNonLocked?: boolean; }; export namespace User { diff --git a/src/api/models/UserDTO.ts b/src/api/models/UserDTO.ts index 56f00b30d40ee5427b6dce81810255504a11b756..aee3ea036af88cba3a66ffeb071041105d318d8b 100644 --- a/src/api/models/UserDTO.ts +++ b/src/api/models/UserDTO.ts @@ -6,6 +6,7 @@ export type UserDTO = { id?: number; firstName?: string; lastName?: string; + profileImage?: number; email?: string; createdAt?: string; role?: string; diff --git a/src/api/models/UserUpdateDTO.ts b/src/api/models/UserUpdateDTO.ts index 00b3b0a05950d06f960971ef120d217a33202b39..336ccf437745472a97c2c922f3d7ee7f4dc9f4d5 100644 --- a/src/api/models/UserUpdateDTO.ts +++ b/src/api/models/UserUpdateDTO.ts @@ -7,7 +7,7 @@ export type UserUpdateDTO = { firstName?: string; lastName?: string; email?: string; - password?: string; + profileImage?: number; configuration?: ConfigurationDTO; }; diff --git a/src/api/services/ImageService.ts b/src/api/services/ImageService.ts index 672da2fa200bba757b8ad192a39ad131e51aee3c..a673de7d12020130232a9693c0df8a47393ee061 100644 --- a/src/api/services/ImageService.ts +++ b/src/api/services/ImageService.ts @@ -13,36 +13,39 @@ export class ImageService { * @throws ApiError */ public static uploadImage({ - requestBody, + formData, }: { - requestBody?: { + formData?: { file: Blob; }, }): CancelablePromise<number> { return __request(OpenAPI, { method: 'POST', - url: '/api/image/upload', - body: requestBody, - mediaType: 'application/json', + url: '/api/images', + formData: formData, + mediaType: 'multipart/form-data', }); } /** * Retrieve an image * Retrieve an image from the server - * @returns string Successfully retrieved the image + * @returns binary Successfully retrieved the image * @throws ApiError */ public static getImage({ id, }: { id: number, - }): CancelablePromise<Array<string>> { + }): CancelablePromise<Blob> { return __request(OpenAPI, { method: 'GET', - url: '/api/image/{id}', + url: '/api/images/{id}', path: { 'id': id, }, + errors: { + 404: `Image not found`, + }, }); } } diff --git a/src/api/services/UserService.ts b/src/api/services/UserService.ts index 32f920f9b91b3a9bfcabe9764f796d09747942e2..1b05abf91ec94a332c863d9f963260f55feccbe0 100644 --- a/src/api/services/UserService.ts +++ b/src/api/services/UserService.ts @@ -10,6 +10,7 @@ import type { BudgetResponseDTO } from '../models/BudgetResponseDTO'; import type { ExpenseRequestDTO } from '../models/ExpenseRequestDTO'; import type { ExpenseResponseDTO } from '../models/ExpenseResponseDTO'; import type { PasswordResetDTO } from '../models/PasswordResetDTO'; +import type { PasswordUpdateDTO } from '../models/PasswordUpdateDTO'; import type { ProfileDTO } from '../models/ProfileDTO'; import type { UserDTO } from '../models/UserDTO'; import type { UserUpdateDTO } from '../models/UserUpdateDTO'; @@ -63,13 +64,18 @@ export class UserService { * @throws ApiError */ public static updateBudget({ + budgetId, requestBody, }: { - requestBody: BudgetResponseDTO, + budgetId: number, + requestBody: BudgetRequestDTO, }): CancelablePromise<Record<string, any>> { return __request(OpenAPI, { method: 'POST', - url: '/api/budget/update', + url: '/api/budget/update/{budgetId}', + path: { + 'budgetId': budgetId, + }, body: requestBody, mediaType: 'application/json', errors: { @@ -157,6 +163,24 @@ export class UserService { mediaType: 'application/json', }); } + /** + * Update a password + * Update the password of the authenticated user + * @returns UserDTO Successfully updated password + * @throws ApiError + */ + public static updatePassword({ + requestBody, + }: { + requestBody: PasswordUpdateDTO, + }): CancelablePromise<UserDTO> { + return __request(OpenAPI, { + method: 'PATCH', + url: '/api/users/password', + body: requestBody, + mediaType: 'application/json', + }); + } /** * Get a profile * Get the profile of a user diff --git a/src/components/UpdateUserComponents/UpdateUserLayout.vue b/src/components/UpdateUserComponents/UpdateUserLayout.vue index 653d8176eb7306f398d906f927d39ef031ff28ec..42a3dd14b5a2b9d050706567e552ae60559a7790 100644 --- a/src/components/UpdateUserComponents/UpdateUserLayout.vue +++ b/src/components/UpdateUserComponents/UpdateUserLayout.vue @@ -62,8 +62,7 @@ const handleSubmit = async () => { const updateUserPayload: UserUpdateDTO = { firstName: firstNameRef.value, lastName: surnameRef.value, - email: emailRef.value, - password: passwordRef.value + email: emailRef.value };