diff --git a/package.json b/package.json index 355dd62..e79c497 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ozmap/ozmap-sdk", - "version": "1.1.2", + "version": "1.1.3", "description": "Use this sdk to access ozmap plataform and connect it to your own systems. ", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/interface/model/FTTHClient.ts b/src/interface/model/FTTHClient.ts index 2af4152..7745103 100644 --- a/src/interface/model/FTTHClient.ts +++ b/src/interface/model/FTTHClient.ts @@ -3,8 +3,8 @@ import { BaseModelSchema, stringOrObjectId } from './BaseModel'; import { TagSchema } from './Tag'; enum FTTHClientStatus { - OK = 'OK', - ERROR = 'ERROR', + OK = 0, + ERROR = 1, } const FTTHClientDataSchema = z.object({ @@ -44,10 +44,16 @@ const CreateFTTHClientDTOSchema = FTTHClientDataSchema.partial({ cpe: true, }).merge(z.object({ external_id: z.any().optional() })); const UpdateFTTHClientDTOSchema = FTTHClientDataSchema.merge(z.object({ external_id: z.any().optional() })).partial(); +const BatchUpdateFTTHClientDTOSchema = FTTHClientDataSchema.pick({ + certified: true, + implanted: true, + status: true, +}); type FTTHClient = z.infer; type CreateFTTHClientDTO = z.infer; type UpdateFTTHClientDTO = z.infer; +type BatchUpdateFTTHClientDTO = z.infer; export { FTTHClientStatus, @@ -57,4 +63,6 @@ export { CreateFTTHClientDTO, UpdateFTTHClientDTOSchema, UpdateFTTHClientDTO, + BatchUpdateFTTHClientDTOSchema, + BatchUpdateFTTHClientDTO, }; diff --git a/src/interface/model/Property.ts b/src/interface/model/Property.ts index c2c4526..4fcd01f 100644 --- a/src/interface/model/Property.ts +++ b/src/interface/model/Property.ts @@ -81,14 +81,19 @@ const UpdatePropertyDTOSchema = PropertyDataSchema.merge(z.object({ external_id: auto_connect: z.boolean().optional(), force: z.boolean().optional(), connector: stringOrObjectId.nullish(), - port: z.number().optional() + port: z.number().optional(), }), ) .partial(); +const BatchUpdatePropertyDTOSchema = PropertyDataSchema.pick({ + potencyRead: true, +}); + type Property = z.infer; type CreatePropertyDTO = z.infer; type UpdatePropertyDTO = z.infer; +type BatchUpdatePropertyDTO = z.infer; export { PropertySchema, @@ -97,4 +102,6 @@ export { CreatePropertyDTO, UpdatePropertyDTOSchema, UpdatePropertyDTO, + BatchUpdatePropertyDTOSchema, + BatchUpdatePropertyDTO, }; diff --git a/src/proxy/entities/FTTHClient.ts b/src/proxy/entities/FTTHClient.ts index 0ab2959..5479aa6 100644 --- a/src/proxy/entities/FTTHClient.ts +++ b/src/proxy/entities/FTTHClient.ts @@ -1,4 +1,12 @@ -import { FTTHClient, UpdateFTTHClientDTO, UpdateFTTHClientDTOSchema } from '../../interface'; +import { + ApiFilter, + ApiFilterSchema, + BatchUpdateFTTHClientDTO, + BatchUpdateFTTHClientDTOSchema, + FTTHClient, + UpdateFTTHClientDTO, + UpdateFTTHClientDTOSchema, +} from '../../interface'; import UpdatableProxy from '../UpdatableProxy'; import Api from '../../util/Api'; @@ -17,6 +25,21 @@ class FTTHClientProxy extends UpdatableProxy { return super.updateById(id, parsedData, options); } + public async batchUpdate( + filter: ApiFilter[] | ApiFilter[][] | Array, + data: BatchUpdateFTTHClientDTO, + options?: Parameters[0]['options'], + ): Promise { + const parsedFilter = ApiFilterSchema.parse(filter); + const parsedData = BatchUpdateFTTHClientDTOSchema.parse(data); + + return this.apiInstance.post({ + route: `${this._route}/batch-update`, + inputData: { filter: parsedFilter, update: parsedData }, + options, + }); + } + public async deleteById(id: FTTHClient['id'], options?: Parameters[0]['options']): Promise { return this.apiInstance.delete({ route: `${this._route}/${id}`, diff --git a/src/proxy/entities/Property.ts b/src/proxy/entities/Property.ts index 78f489e..4fd5767 100644 --- a/src/proxy/entities/Property.ts +++ b/src/proxy/entities/Property.ts @@ -4,6 +4,10 @@ import { CreatePropertyDTOSchema, UpdatePropertyDTO, UpdatePropertyDTOSchema, + ApiFilter, + ApiFilterSchema, + BatchUpdatePropertyDTO, + BatchUpdatePropertyDTOSchema, } from '../../interface'; import WritableProxy from '../WritableProxy'; @@ -20,6 +24,21 @@ class PropertyProxy extends WritableProxy, + data: BatchUpdatePropertyDTO, + options?: Parameters[0]['options'], + ): Promise { + const parsedFilter = ApiFilterSchema.parse(filter); + const parsedData = BatchUpdatePropertyDTOSchema.parse(data); + + return this.apiInstance.post({ + route: `${this._route}/batch-update`, + inputData: { filter: parsedFilter, data: parsedData }, + options, + }); + } + public async updateById( id: Property['id'], data: UpdatePropertyDTO,