diff --git a/mobile/lib/modules/backup/services/backup.service.dart b/mobile/lib/modules/backup/services/backup.service.dart index 325e1cbea..02b0a6863 100644 --- a/mobile/lib/modules/backup/services/backup.service.dart +++ b/mobile/lib/modules/backup/services/backup.service.dart @@ -376,8 +376,8 @@ class BackupService { DeviceTypeEnum deviceType, ) async { try { - var updatedDeviceInfo = await _apiService.deviceInfoApi.updateDeviceInfo( - UpdateDeviceInfoDto( + var updatedDeviceInfo = await _apiService.deviceInfoApi.upsertDeviceInfo( + UpsertDeviceInfoDto( deviceId: deviceId, deviceType: deviceType, isAutoBackup: status, diff --git a/mobile/lib/modules/login/providers/authentication.provider.dart b/mobile/lib/modules/login/providers/authentication.provider.dart index db1c2343c..9bf7d53eb 100644 --- a/mobile/lib/modules/login/providers/authentication.provider.dart +++ b/mobile/lib/modules/login/providers/authentication.provider.dart @@ -210,8 +210,8 @@ class AuthenticationNotifier extends StateNotifier { // Register device info try { DeviceInfoResponseDto? deviceInfo = - await _apiService.deviceInfoApi.createDeviceInfo( - CreateDeviceInfoDto( + await _apiService.deviceInfoApi.upsertDeviceInfo( + UpsertDeviceInfoDto( deviceId: state.deviceId, deviceType: state.deviceType, ), diff --git a/mobile/openapi/.openapi-generator/FILES b/mobile/openapi/.openapi-generator/FILES index 20453107c..15fce354b 100644 --- a/mobile/openapi/.openapi-generator/FILES +++ b/mobile/openapi/.openapi-generator/FILES @@ -24,7 +24,6 @@ doc/CheckDuplicateAssetResponseDto.md doc/CheckExistingAssetsDto.md doc/CheckExistingAssetsResponseDto.md doc/CreateAlbumDto.md -doc/CreateDeviceInfoDto.md doc/CreateProfileImageResponseDto.md doc/CreateTagDto.md doc/CreateUserDto.md @@ -72,9 +71,9 @@ doc/ThumbnailFormat.md doc/TimeGroupEnum.md doc/UpdateAlbumDto.md doc/UpdateAssetDto.md -doc/UpdateDeviceInfoDto.md doc/UpdateTagDto.md doc/UpdateUserDto.md +doc/UpsertDeviceInfoDto.md doc/UsageByUserDto.md doc/UserApi.md doc/UserCountResponseDto.md @@ -118,7 +117,6 @@ lib/model/check_duplicate_asset_response_dto.dart lib/model/check_existing_assets_dto.dart lib/model/check_existing_assets_response_dto.dart lib/model/create_album_dto.dart -lib/model/create_device_info_dto.dart lib/model/create_profile_image_response_dto.dart lib/model/create_tag_dto.dart lib/model/create_user_dto.dart @@ -160,9 +158,9 @@ lib/model/thumbnail_format.dart lib/model/time_group_enum.dart lib/model/update_album_dto.dart lib/model/update_asset_dto.dart -lib/model/update_device_info_dto.dart lib/model/update_tag_dto.dart lib/model/update_user_dto.dart +lib/model/upsert_device_info_dto.dart lib/model/usage_by_user_dto.dart lib/model/user_count_response_dto.dart lib/model/user_response_dto.dart @@ -189,7 +187,6 @@ test/check_duplicate_asset_response_dto_test.dart test/check_existing_assets_dto_test.dart test/check_existing_assets_response_dto_test.dart test/create_album_dto_test.dart -test/create_device_info_dto_test.dart test/create_profile_image_response_dto_test.dart test/create_tag_dto_test.dart test/create_user_dto_test.dart @@ -237,9 +234,9 @@ test/thumbnail_format_test.dart test/time_group_enum_test.dart test/update_album_dto_test.dart test/update_asset_dto_test.dart -test/update_device_info_dto_test.dart test/update_tag_dto_test.dart test/update_user_dto_test.dart +test/upsert_device_info_dto_test.dart test/usage_by_user_dto_test.dart test/user_api_test.dart test/user_count_response_dto_test.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 3f71fdba5..a0482b3e0 100644 Binary files a/mobile/openapi/README.md and b/mobile/openapi/README.md differ diff --git a/mobile/openapi/doc/DeviceInfoApi.md b/mobile/openapi/doc/DeviceInfoApi.md index d1c032e65..b4dcdb255 100644 Binary files a/mobile/openapi/doc/DeviceInfoApi.md and b/mobile/openapi/doc/DeviceInfoApi.md differ diff --git a/mobile/openapi/doc/UpdateDeviceInfoDto.md b/mobile/openapi/doc/UpdateDeviceInfoDto.md deleted file mode 100644 index 75c98bf1b..000000000 Binary files a/mobile/openapi/doc/UpdateDeviceInfoDto.md and /dev/null differ diff --git a/mobile/openapi/doc/CreateDeviceInfoDto.md b/mobile/openapi/doc/UpsertDeviceInfoDto.md similarity index 93% rename from mobile/openapi/doc/CreateDeviceInfoDto.md rename to mobile/openapi/doc/UpsertDeviceInfoDto.md index d0629bb2d..29c67d0ab 100644 Binary files a/mobile/openapi/doc/CreateDeviceInfoDto.md and b/mobile/openapi/doc/UpsertDeviceInfoDto.md differ diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index 7d403fe59..69efb7a30 100644 Binary files a/mobile/openapi/lib/api.dart and b/mobile/openapi/lib/api.dart differ diff --git a/mobile/openapi/lib/api/device_info_api.dart b/mobile/openapi/lib/api/device_info_api.dart index c365ac60d..054f1872f 100644 Binary files a/mobile/openapi/lib/api/device_info_api.dart and b/mobile/openapi/lib/api/device_info_api.dart differ diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index b65d7d7a1..5057f6950 100644 Binary files a/mobile/openapi/lib/api_client.dart and b/mobile/openapi/lib/api_client.dart differ diff --git a/mobile/openapi/lib/model/create_device_info_dto.dart b/mobile/openapi/lib/model/create_device_info_dto.dart deleted file mode 100644 index 1c2cf46e1..000000000 Binary files a/mobile/openapi/lib/model/create_device_info_dto.dart and /dev/null differ diff --git a/mobile/openapi/lib/model/update_device_info_dto.dart b/mobile/openapi/lib/model/upsert_device_info_dto.dart similarity index 76% rename from mobile/openapi/lib/model/update_device_info_dto.dart rename to mobile/openapi/lib/model/upsert_device_info_dto.dart index c11a2df56..7d642d28c 100644 Binary files a/mobile/openapi/lib/model/update_device_info_dto.dart and b/mobile/openapi/lib/model/upsert_device_info_dto.dart differ diff --git a/mobile/openapi/test/device_info_api_test.dart b/mobile/openapi/test/device_info_api_test.dart index 4e8a35e35..280f9a3e6 100644 Binary files a/mobile/openapi/test/device_info_api_test.dart and b/mobile/openapi/test/device_info_api_test.dart differ diff --git a/mobile/openapi/test/update_device_info_dto_test.dart b/mobile/openapi/test/update_device_info_dto_test.dart deleted file mode 100644 index 46aefee1b..000000000 Binary files a/mobile/openapi/test/update_device_info_dto_test.dart and /dev/null differ diff --git a/mobile/openapi/test/create_device_info_dto_test.dart b/mobile/openapi/test/upsert_device_info_dto_test.dart similarity index 85% rename from mobile/openapi/test/create_device_info_dto_test.dart rename to mobile/openapi/test/upsert_device_info_dto_test.dart index 777faf11a..9c1dd0fbc 100644 Binary files a/mobile/openapi/test/create_device_info_dto_test.dart and b/mobile/openapi/test/upsert_device_info_dto_test.dart differ diff --git a/server/apps/immich/src/api-v1/device-info/device-info.controller.ts b/server/apps/immich/src/api-v1/device-info/device-info.controller.ts index f2865d219..3e57f47e5 100644 --- a/server/apps/immich/src/api-v1/device-info/device-info.controller.ts +++ b/server/apps/immich/src/api-v1/device-info/device-info.controller.ts @@ -1,11 +1,10 @@ -import { Controller, Post, Body, Patch, ValidationPipe } from '@nestjs/common'; +import { Body, Controller, Patch, Post, Put, ValidationPipe } from '@nestjs/common'; import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { AuthUserDto, GetAuthUser } from '../../decorators/auth-user.decorator'; import { Authenticated } from '../../decorators/authenticated.decorator'; import { DeviceInfoService } from './device-info.service'; -import { CreateDeviceInfoDto } from './dto/create-device-info.dto'; -import { UpdateDeviceInfoDto } from './dto/update-device-info.dto'; -import { DeviceInfoResponseDto } from './response-dto/create-device-info-response.dto'; +import { UpsertDeviceInfoDto } from './dto/upsert-device-info.dto'; +import { DeviceInfoResponseDto, mapDeviceInfoResponse } from './response-dto/device-info-response.dto'; @Authenticated() @ApiBearerAuth() @@ -14,19 +13,30 @@ import { DeviceInfoResponseDto } from './response-dto/create-device-info-respons export class DeviceInfoController { constructor(private readonly deviceInfoService: DeviceInfoService) {} + /** @deprecated */ @Post() - async createDeviceInfo( - @Body(ValidationPipe) createDeviceInfoDto: CreateDeviceInfoDto, - @GetAuthUser() authUser: AuthUserDto, + public async createDeviceInfo( + @GetAuthUser() user: AuthUserDto, + @Body(ValidationPipe) dto: UpsertDeviceInfoDto, ): Promise { - return this.deviceInfoService.create(createDeviceInfoDto, authUser); + return this.upsertDeviceInfo(user, dto); } + /** @deprecated */ @Patch() - async updateDeviceInfo( - @Body(ValidationPipe) updateDeviceInfoDto: UpdateDeviceInfoDto, - @GetAuthUser() authUser: AuthUserDto, + public async updateDeviceInfo( + @GetAuthUser() user: AuthUserDto, + @Body(ValidationPipe) dto: UpsertDeviceInfoDto, ): Promise { - return this.deviceInfoService.update(authUser.id, updateDeviceInfoDto); + return this.upsertDeviceInfo(user, dto); + } + + @Put() + public async upsertDeviceInfo( + @GetAuthUser() user: AuthUserDto, + @Body(ValidationPipe) dto: UpsertDeviceInfoDto, + ): Promise { + const deviceInfo = await this.deviceInfoService.upsert({ ...dto, userId: user.id }); + return mapDeviceInfoResponse(deviceInfo); } } diff --git a/server/apps/immich/src/api-v1/device-info/device-info.service.spec.ts b/server/apps/immich/src/api-v1/device-info/device-info.service.spec.ts new file mode 100644 index 000000000..60f39c2a4 --- /dev/null +++ b/server/apps/immich/src/api-v1/device-info/device-info.service.spec.ts @@ -0,0 +1,65 @@ +import { DeviceInfoEntity, DeviceType } from '@app/database/entities/device-info.entity'; +import { Repository } from 'typeorm'; +import { DeviceInfoService } from './device-info.service'; + +const deviceId = 'device-123'; +const userId = 'user-123'; + +describe('DeviceInfoService', () => { + let sut: DeviceInfoService; + let repositoryMock: jest.Mocked>; + + beforeEach(async () => { + repositoryMock = { + findOne: jest.fn(), + save: jest.fn(), + } as unknown as jest.Mocked>; + + sut = new DeviceInfoService(repositoryMock); + }); + + it('should be defined', () => { + expect(sut).toBeDefined(); + }); + + describe('upsert', () => { + it('should create a new record', async () => { + const request = { deviceId, userId, deviceType: DeviceType.IOS } as DeviceInfoEntity; + const response = { ...request, id: 1 } as DeviceInfoEntity; + + repositoryMock.findOne.mockResolvedValue(null); + repositoryMock.save.mockResolvedValue(response); + + await expect(sut.upsert(request)).resolves.toEqual(response); + + expect(repositoryMock.findOne).toHaveBeenCalledTimes(1); + expect(repositoryMock.save).toHaveBeenCalledTimes(1); + }); + + it('should update an existing record', async () => { + const request = { deviceId, userId, deviceType: DeviceType.IOS, isAutoBackup: true } as DeviceInfoEntity; + const response = { ...request, id: 1 } as DeviceInfoEntity; + + repositoryMock.findOne.mockResolvedValue(response); + repositoryMock.save.mockResolvedValue(response); + + await expect(sut.upsert(request)).resolves.toEqual(response); + + expect(repositoryMock.findOne).toHaveBeenCalledTimes(1); + expect(repositoryMock.save).toHaveBeenCalledTimes(1); + }); + + it('should keep properties that were not updated', async () => { + const request = { deviceId, userId } as DeviceInfoEntity; + const response = { id: 1, isAutoBackup: true, deviceId, userId, deviceType: DeviceType.WEB } as DeviceInfoEntity; + + repositoryMock.findOne.mockResolvedValue(response); + repositoryMock.save.mockResolvedValue(response); + + await expect(sut.upsert(request)).resolves.toEqual(response); + + expect(repositoryMock.findOne).toHaveBeenCalledTimes(1); + expect(repositoryMock.save).toHaveBeenCalledTimes(1); + }); + }); +}); diff --git a/server/apps/immich/src/api-v1/device-info/device-info.service.ts b/server/apps/immich/src/api-v1/device-info/device-info.service.ts index 76a546fbc..b5f3facec 100644 --- a/server/apps/immich/src/api-v1/device-info/device-info.service.ts +++ b/server/apps/immich/src/api-v1/device-info/device-info.service.ts @@ -1,70 +1,29 @@ -import { BadRequestException, Injectable, Logger, NotFoundException } from '@nestjs/common'; +import { DeviceInfoEntity } from '@app/database/entities/device-info.entity'; +import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; -import { AuthUserDto } from '../../decorators/auth-user.decorator'; -import { CreateDeviceInfoDto } from './dto/create-device-info.dto'; -import { UpdateDeviceInfoDto } from './dto/update-device-info.dto'; -import { DeviceInfoEntity } from '@app/database/entities/device-info.entity'; -import { DeviceInfoResponseDto, mapDeviceInfoResponse } from './response-dto/create-device-info-response.dto'; + +type EntityKeys = Pick; +type Entity = EntityKeys & Partial; @Injectable() export class DeviceInfoService { constructor( @InjectRepository(DeviceInfoEntity) - private deviceRepository: Repository, + private repository: Repository, ) {} - async create(createDeviceInfoDto: CreateDeviceInfoDto, authUser: AuthUserDto): Promise { - const res = await this.deviceRepository.findOne({ - where: { - deviceId: createDeviceInfoDto.deviceId, - userId: authUser.id, - }, - }); + public async upsert(entity: Entity): Promise { + const { deviceId, userId } = entity; + const exists = await this.repository.findOne({ where: { userId, deviceId } }); - if (res) { - Logger.log('Device Info Exist', 'createDeviceInfo'); - return mapDeviceInfoResponse(res); + if (!exists) { + return await this.repository.save(entity); } - const deviceInfo = new DeviceInfoEntity(); - deviceInfo.deviceId = createDeviceInfoDto.deviceId; - deviceInfo.deviceType = createDeviceInfoDto.deviceType; - deviceInfo.userId = authUser.id; + exists.isAutoBackup = entity.isAutoBackup ?? exists.isAutoBackup; + exists.deviceType = entity.deviceType ?? exists.deviceType; - const newDeviceInfo = await this.deviceRepository.save(deviceInfo); - - return mapDeviceInfoResponse(newDeviceInfo); - } - - async update(userId: string, updateDeviceInfoDto: UpdateDeviceInfoDto): Promise { - const deviceInfo = await this.deviceRepository.findOne({ - where: { deviceId: updateDeviceInfoDto.deviceId, userId: userId }, - }); - - if (!deviceInfo) { - throw new NotFoundException('Device Not Found'); - } - - const res = await this.deviceRepository.update( - { - id: deviceInfo.id, - }, - updateDeviceInfoDto, - ); - - if (res.affected == 1) { - const updatedDeviceInfo = await this.deviceRepository.findOne({ - where: { deviceId: updateDeviceInfoDto.deviceId, userId: userId }, - }); - - if (!updatedDeviceInfo) { - throw new NotFoundException('Device Not Found'); - } - - return mapDeviceInfoResponse(updatedDeviceInfo); - } else { - throw new BadRequestException('Bad Request'); - } + return await this.repository.save(exists); } } diff --git a/server/apps/immich/src/api-v1/device-info/dto/update-device-info.dto.ts b/server/apps/immich/src/api-v1/device-info/dto/update-device-info.dto.ts deleted file mode 100644 index f267d9036..000000000 --- a/server/apps/immich/src/api-v1/device-info/dto/update-device-info.dto.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { DeviceType } from '@app/database/entities/device-info.entity'; -import { ApiProperty } from '@nestjs/swagger'; -import { IsNotEmpty, IsOptional } from 'class-validator'; - -export class UpdateDeviceInfoDto { - @IsNotEmpty() - deviceId!: string; - - @IsNotEmpty() - @ApiProperty({ enumName: 'DeviceTypeEnum', enum: DeviceType }) - deviceType!: DeviceType; - - @IsOptional() - isAutoBackup?: boolean; -} diff --git a/server/apps/immich/src/api-v1/device-info/dto/create-device-info.dto.ts b/server/apps/immich/src/api-v1/device-info/dto/upsert-device-info.dto.ts similarity index 91% rename from server/apps/immich/src/api-v1/device-info/dto/create-device-info.dto.ts rename to server/apps/immich/src/api-v1/device-info/dto/upsert-device-info.dto.ts index 29dddea81..e4233bc45 100644 --- a/server/apps/immich/src/api-v1/device-info/dto/create-device-info.dto.ts +++ b/server/apps/immich/src/api-v1/device-info/dto/upsert-device-info.dto.ts @@ -2,7 +2,7 @@ import { IsNotEmpty, IsOptional } from 'class-validator'; import { DeviceType } from '@app/database/entities/device-info.entity'; import { ApiProperty } from '@nestjs/swagger'; -export class CreateDeviceInfoDto { +export class UpsertDeviceInfoDto { @IsNotEmpty() deviceId!: string; diff --git a/server/apps/immich/src/api-v1/device-info/response-dto/create-device-info-response.dto.ts b/server/apps/immich/src/api-v1/device-info/response-dto/device-info-response.dto.ts similarity index 100% rename from server/apps/immich/src/api-v1/device-info/response-dto/create-device-info-response.dto.ts rename to server/apps/immich/src/api-v1/device-info/response-dto/device-info-response.dto.ts diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index 23f921e5c..29533a036 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -1783,13 +1783,15 @@ "/device-info": { "post": { "operationId": "createDeviceInfo", + "summary": "", + "description": "@deprecated", "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateDeviceInfoDto" + "$ref": "#/components/schemas/UpsertDeviceInfoDto" } } } @@ -1817,13 +1819,49 @@ }, "patch": { "operationId": "updateDeviceInfo", + "summary": "", + "description": "@deprecated", "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UpdateDeviceInfoDto" + "$ref": "#/components/schemas/UpsertDeviceInfoDto" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeviceInfoResponseDto" + } + } + } + } + }, + "tags": [ + "Device Info" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "put": { + "operationId": "upsertDeviceInfo", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpsertDeviceInfoDto" } } } @@ -3227,7 +3265,7 @@ "WEB" ] }, - "CreateDeviceInfoDto": { + "UpsertDeviceInfoDto": { "type": "object", "properties": { "deviceType": { @@ -3276,24 +3314,6 @@ "isAutoBackup" ] }, - "UpdateDeviceInfoDto": { - "type": "object", - "properties": { - "deviceType": { - "$ref": "#/components/schemas/DeviceTypeEnum" - }, - "deviceId": { - "type": "string" - }, - "isAutoBackup": { - "type": "boolean" - } - }, - "required": [ - "deviceType", - "deviceId" - ] - }, "ServerInfoResponseDto": { "type": "object", "properties": { diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 4cdf22ac2..7e126a44b 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -564,31 +564,6 @@ export interface CreateAlbumDto { */ 'assetIds'?: Array; } -/** - * - * @export - * @interface CreateDeviceInfoDto - */ -export interface CreateDeviceInfoDto { - /** - * - * @type {DeviceTypeEnum} - * @memberof CreateDeviceInfoDto - */ - 'deviceType': DeviceTypeEnum; - /** - * - * @type {string} - * @memberof CreateDeviceInfoDto - */ - 'deviceId': string; - /** - * - * @type {boolean} - * @memberof CreateDeviceInfoDto - */ - 'isAutoBackup'?: boolean; -} /** * * @export @@ -1629,31 +1604,6 @@ export interface UpdateAssetDto { */ 'isFavorite'?: boolean; } -/** - * - * @export - * @interface UpdateDeviceInfoDto - */ -export interface UpdateDeviceInfoDto { - /** - * - * @type {DeviceTypeEnum} - * @memberof UpdateDeviceInfoDto - */ - 'deviceType': DeviceTypeEnum; - /** - * - * @type {string} - * @memberof UpdateDeviceInfoDto - */ - 'deviceId': string; - /** - * - * @type {boolean} - * @memberof UpdateDeviceInfoDto - */ - 'isAutoBackup'?: boolean; -} /** * * @export @@ -1722,6 +1672,31 @@ export interface UpdateUserDto { */ 'profileImagePath'?: string; } +/** + * + * @export + * @interface UpsertDeviceInfoDto + */ +export interface UpsertDeviceInfoDto { + /** + * + * @type {DeviceTypeEnum} + * @memberof UpsertDeviceInfoDto + */ + 'deviceType': DeviceTypeEnum; + /** + * + * @type {string} + * @memberof UpsertDeviceInfoDto + */ + 'deviceId': string; + /** + * + * @type {boolean} + * @memberof UpsertDeviceInfoDto + */ + 'isAutoBackup'?: boolean; +} /** * * @export @@ -4321,14 +4296,15 @@ export class AuthenticationApi extends BaseAPI { export const DeviceInfoApiAxiosParamCreator = function (configuration?: Configuration) { return { /** - * - * @param {CreateDeviceInfoDto} createDeviceInfoDto + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createDeviceInfo: async (createDeviceInfoDto: CreateDeviceInfoDto, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'createDeviceInfoDto' is not null or undefined - assertParamExists('createDeviceInfo', 'createDeviceInfoDto', createDeviceInfoDto) + createDeviceInfo: async (upsertDeviceInfoDto: UpsertDeviceInfoDto, options: AxiosRequestConfig = {}): Promise => { + // verify required parameter 'upsertDeviceInfoDto' is not null or undefined + assertParamExists('createDeviceInfo', 'upsertDeviceInfoDto', upsertDeviceInfoDto) const localVarPath = `/device-info`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); @@ -4352,7 +4328,7 @@ export const DeviceInfoApiAxiosParamCreator = function (configuration?: Configur setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(createDeviceInfoDto, localVarRequestOptions, configuration) + localVarRequestOptions.data = serializeDataIfNeeded(upsertDeviceInfoDto, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), @@ -4360,14 +4336,15 @@ export const DeviceInfoApiAxiosParamCreator = function (configuration?: Configur }; }, /** - * - * @param {UpdateDeviceInfoDto} updateDeviceInfoDto + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateDeviceInfo: async (updateDeviceInfoDto: UpdateDeviceInfoDto, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'updateDeviceInfoDto' is not null or undefined - assertParamExists('updateDeviceInfo', 'updateDeviceInfoDto', updateDeviceInfoDto) + updateDeviceInfo: async (upsertDeviceInfoDto: UpsertDeviceInfoDto, options: AxiosRequestConfig = {}): Promise => { + // verify required parameter 'upsertDeviceInfoDto' is not null or undefined + assertParamExists('updateDeviceInfo', 'upsertDeviceInfoDto', upsertDeviceInfoDto) const localVarPath = `/device-info`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); @@ -4391,7 +4368,46 @@ export const DeviceInfoApiAxiosParamCreator = function (configuration?: Configur setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(updateDeviceInfoDto, localVarRequestOptions, configuration) + localVarRequestOptions.data = serializeDataIfNeeded(upsertDeviceInfoDto, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + upsertDeviceInfo: async (upsertDeviceInfoDto: UpsertDeviceInfoDto, options: AxiosRequestConfig = {}): Promise => { + // verify required parameter 'upsertDeviceInfoDto' is not null or undefined + assertParamExists('upsertDeviceInfo', 'upsertDeviceInfoDto', upsertDeviceInfoDto) + const localVarPath = `/device-info`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication bearer required + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(upsertDeviceInfoDto, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), @@ -4409,23 +4425,35 @@ export const DeviceInfoApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = DeviceInfoApiAxiosParamCreator(configuration) return { /** - * - * @param {CreateDeviceInfoDto} createDeviceInfoDto + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async createDeviceInfo(createDeviceInfoDto: CreateDeviceInfoDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.createDeviceInfo(createDeviceInfoDto, options); + async createDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createDeviceInfo(upsertDeviceInfoDto, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async updateDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.updateDeviceInfo(upsertDeviceInfoDto, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** * - * @param {UpdateDeviceInfoDto} updateDeviceInfoDto + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async updateDeviceInfo(updateDeviceInfoDto: UpdateDeviceInfoDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.updateDeviceInfo(updateDeviceInfoDto, options); + async upsertDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.upsertDeviceInfo(upsertDeviceInfoDto, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, } @@ -4439,22 +4467,33 @@ export const DeviceInfoApiFactory = function (configuration?: Configuration, bas const localVarFp = DeviceInfoApiFp(configuration) return { /** - * - * @param {CreateDeviceInfoDto} createDeviceInfoDto + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createDeviceInfo(createDeviceInfoDto: CreateDeviceInfoDto, options?: any): AxiosPromise { - return localVarFp.createDeviceInfo(createDeviceInfoDto, options).then((request) => request(axios, basePath)); + createDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: any): AxiosPromise { + return localVarFp.createDeviceInfo(upsertDeviceInfoDto, options).then((request) => request(axios, basePath)); + }, + /** + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: any): AxiosPromise { + return localVarFp.updateDeviceInfo(upsertDeviceInfoDto, options).then((request) => request(axios, basePath)); }, /** * - * @param {UpdateDeviceInfoDto} updateDeviceInfoDto + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateDeviceInfo(updateDeviceInfoDto: UpdateDeviceInfoDto, options?: any): AxiosPromise { - return localVarFp.updateDeviceInfo(updateDeviceInfoDto, options).then((request) => request(axios, basePath)); + upsertDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: any): AxiosPromise { + return localVarFp.upsertDeviceInfo(upsertDeviceInfoDto, options).then((request) => request(axios, basePath)); }, }; }; @@ -4467,25 +4506,38 @@ export const DeviceInfoApiFactory = function (configuration?: Configuration, bas */ export class DeviceInfoApi extends BaseAPI { /** - * - * @param {CreateDeviceInfoDto} createDeviceInfoDto + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DeviceInfoApi */ - public createDeviceInfo(createDeviceInfoDto: CreateDeviceInfoDto, options?: AxiosRequestConfig) { - return DeviceInfoApiFp(this.configuration).createDeviceInfo(createDeviceInfoDto, options).then((request) => request(this.axios, this.basePath)); + public createDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: AxiosRequestConfig) { + return DeviceInfoApiFp(this.configuration).createDeviceInfo(upsertDeviceInfoDto, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * @deprecated + * @summary + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceInfoApi + */ + public updateDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: AxiosRequestConfig) { + return DeviceInfoApiFp(this.configuration).updateDeviceInfo(upsertDeviceInfoDto, options).then((request) => request(this.axios, this.basePath)); } /** * - * @param {UpdateDeviceInfoDto} updateDeviceInfoDto + * @param {UpsertDeviceInfoDto} upsertDeviceInfoDto * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DeviceInfoApi */ - public updateDeviceInfo(updateDeviceInfoDto: UpdateDeviceInfoDto, options?: AxiosRequestConfig) { - return DeviceInfoApiFp(this.configuration).updateDeviceInfo(updateDeviceInfoDto, options).then((request) => request(this.axios, this.basePath)); + public upsertDeviceInfo(upsertDeviceInfoDto: UpsertDeviceInfoDto, options?: AxiosRequestConfig) { + return DeviceInfoApiFp(this.configuration).upsertDeviceInfo(upsertDeviceInfoDto, options).then((request) => request(this.axios, this.basePath)); } }