Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 10 additions & 2 deletions src/interface/model/FTTHClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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<typeof FTTHClientSchema>;
type CreateFTTHClientDTO = z.infer<typeof CreateFTTHClientDTOSchema>;
type UpdateFTTHClientDTO = z.infer<typeof UpdateFTTHClientDTOSchema>;
type BatchUpdateFTTHClientDTO = z.infer<typeof BatchUpdateFTTHClientDTOSchema>;

export {
FTTHClientStatus,
Expand All @@ -57,4 +63,6 @@ export {
CreateFTTHClientDTO,
UpdateFTTHClientDTOSchema,
UpdateFTTHClientDTO,
BatchUpdateFTTHClientDTOSchema,
BatchUpdateFTTHClientDTO,
};
9 changes: 8 additions & 1 deletion src/interface/model/Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof PropertySchema>;
type CreatePropertyDTO = z.infer<typeof CreatePropertyDTOSchema>;
type UpdatePropertyDTO = z.infer<typeof UpdatePropertyDTOSchema>;
type BatchUpdatePropertyDTO = z.infer<typeof BatchUpdatePropertyDTOSchema>;

export {
PropertySchema,
Expand All @@ -97,4 +102,6 @@ export {
CreatePropertyDTO,
UpdatePropertyDTOSchema,
UpdatePropertyDTO,
BatchUpdatePropertyDTOSchema,
BatchUpdatePropertyDTO,
};
25 changes: 24 additions & 1 deletion src/proxy/entities/FTTHClient.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -17,6 +25,21 @@ class FTTHClientProxy extends UpdatableProxy<FTTHClient, UpdateFTTHClientDTO> {
return super.updateById(id, parsedData, options);
}

public async batchUpdate(
filter: ApiFilter[] | ApiFilter[][] | Array<ApiFilter | ApiFilter[]>,
data: BatchUpdateFTTHClientDTO,
options?: Parameters<Api['post']>[0]['options'],
): Promise<void> {
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<Api['delete']>[0]['options']): Promise<void> {
return this.apiInstance.delete({
route: `${this._route}/${id}`,
Expand Down
19 changes: 19 additions & 0 deletions src/proxy/entities/Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {
CreatePropertyDTOSchema,
UpdatePropertyDTO,
UpdatePropertyDTOSchema,
ApiFilter,
ApiFilterSchema,
BatchUpdatePropertyDTO,
BatchUpdatePropertyDTOSchema,
} from '../../interface';

import WritableProxy from '../WritableProxy';
Expand All @@ -20,6 +24,21 @@ class PropertyProxy extends WritableProxy<Property, CreatePropertyDTO, UpdatePro
return super.create(parsedData, options);
}

public async batchUpdate(
filter: ApiFilter[] | ApiFilter[][] | Array<ApiFilter | ApiFilter[]>,
data: BatchUpdatePropertyDTO,
options?: Parameters<Api['post']>[0]['options'],
): Promise<void> {
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,
Expand Down
Loading