feat: product barcode images
This commit is contained in:
@ -39,6 +39,7 @@ import {
|
||||
deleteDealTag,
|
||||
deleteMarketplace,
|
||||
deleteProduct,
|
||||
deleteProductBarcodeImage,
|
||||
deleteProject,
|
||||
deleteService,
|
||||
deleteServiceCategory,
|
||||
@ -84,6 +85,7 @@ import {
|
||||
updateServiceCategory,
|
||||
updateServicesKit,
|
||||
updateStatus,
|
||||
uploadProductBarcodeImage,
|
||||
uploadProductImage,
|
||||
type Options,
|
||||
} from "../sdk.gen";
|
||||
@ -172,6 +174,9 @@ import type {
|
||||
DeleteMarketplaceData,
|
||||
DeleteMarketplaceError,
|
||||
DeleteMarketplaceResponse2,
|
||||
DeleteProductBarcodeImageData,
|
||||
DeleteProductBarcodeImageError,
|
||||
DeleteProductBarcodeImageResponse,
|
||||
DeleteProductData,
|
||||
DeleteProductError,
|
||||
DeleteProductResponse2,
|
||||
@ -275,6 +280,9 @@ import type {
|
||||
UpdateStatusData,
|
||||
UpdateStatusError,
|
||||
UpdateStatusResponse2,
|
||||
UploadProductBarcodeImageData,
|
||||
UploadProductBarcodeImageError,
|
||||
UploadProductBarcodeImageResponse,
|
||||
UploadProductImageData,
|
||||
UploadProductImageError,
|
||||
UploadProductImageResponse,
|
||||
@ -2292,6 +2300,84 @@ export const getProductBarcodePdfMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const uploadProductBarcodeImageQueryKey = (
|
||||
options: Options<UploadProductBarcodeImageData>
|
||||
) => createQueryKey("uploadProductBarcodeImage", options);
|
||||
|
||||
/**
|
||||
* Upload Product Barcode Image
|
||||
*/
|
||||
export const uploadProductBarcodeImageOptions = (
|
||||
options: Options<UploadProductBarcodeImageData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await uploadProductBarcodeImage({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: uploadProductBarcodeImageQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Upload Product Barcode Image
|
||||
*/
|
||||
export const uploadProductBarcodeImageMutation = (
|
||||
options?: Partial<Options<UploadProductBarcodeImageData>>
|
||||
): UseMutationOptions<
|
||||
UploadProductBarcodeImageResponse,
|
||||
AxiosError<UploadProductBarcodeImageError>,
|
||||
Options<UploadProductBarcodeImageData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UploadProductBarcodeImageResponse,
|
||||
AxiosError<UploadProductBarcodeImageError>,
|
||||
Options<UploadProductBarcodeImageData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await uploadProductBarcodeImage({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Product Barcode Image
|
||||
*/
|
||||
export const deleteProductBarcodeImageMutation = (
|
||||
options?: Partial<Options<DeleteProductBarcodeImageData>>
|
||||
): UseMutationOptions<
|
||||
DeleteProductBarcodeImageResponse,
|
||||
AxiosError<DeleteProductBarcodeImageError>,
|
||||
Options<DeleteProductBarcodeImageData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteProductBarcodeImageResponse,
|
||||
AxiosError<DeleteProductBarcodeImageError>,
|
||||
Options<DeleteProductBarcodeImageData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteProductBarcodeImage({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getServicesQueryKey = (options?: Options<GetServicesData>) =>
|
||||
createQueryKey("getServices", options);
|
||||
|
||||
|
||||
@ -92,6 +92,9 @@ import type {
|
||||
DeleteMarketplaceData,
|
||||
DeleteMarketplaceErrors,
|
||||
DeleteMarketplaceResponses,
|
||||
DeleteProductBarcodeImageData,
|
||||
DeleteProductBarcodeImageErrors,
|
||||
DeleteProductBarcodeImageResponses,
|
||||
DeleteProductData,
|
||||
DeleteProductErrors,
|
||||
DeleteProductResponses,
|
||||
@ -220,6 +223,9 @@ import type {
|
||||
UpdateStatusData,
|
||||
UpdateStatusErrors,
|
||||
UpdateStatusResponses,
|
||||
UploadProductBarcodeImageData,
|
||||
UploadProductBarcodeImageErrors,
|
||||
UploadProductBarcodeImageResponses,
|
||||
UploadProductImageData,
|
||||
UploadProductImageErrors,
|
||||
UploadProductImageResponses,
|
||||
@ -281,6 +287,8 @@ import {
|
||||
zDeleteDealTagResponse2,
|
||||
zDeleteMarketplaceData,
|
||||
zDeleteMarketplaceResponse2,
|
||||
zDeleteProductBarcodeImageData,
|
||||
zDeleteProductBarcodeImageResponse,
|
||||
zDeleteProductData,
|
||||
zDeleteProductResponse2,
|
||||
zDeleteProjectData,
|
||||
@ -373,6 +381,8 @@ import {
|
||||
zUpdateServicesKitResponse2,
|
||||
zUpdateStatusData,
|
||||
zUpdateStatusResponse2,
|
||||
zUploadProductBarcodeImageData,
|
||||
zUploadProductBarcodeImageResponse,
|
||||
zUploadProductImageData,
|
||||
zUploadProductImageResponse,
|
||||
} from "./zod.gen";
|
||||
@ -1719,7 +1729,7 @@ export const uploadProductImage = <ThrowOnError extends boolean = false>(
|
||||
responseValidator: async data => {
|
||||
return await zUploadProductImageResponse.parseAsync(data);
|
||||
},
|
||||
url: "/crm/v1/fulfillment-base/product/images/upload/{productId}",
|
||||
url: "/crm/v1/fulfillment-base/product{pk}/images/upload",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": null,
|
||||
@ -1755,6 +1765,57 @@ export const getProductBarcodePdf = <ThrowOnError extends boolean = false>(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Upload Product Barcode Image
|
||||
*/
|
||||
export const uploadProductBarcodeImage = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UploadProductBarcodeImageData, ThrowOnError>
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).post<
|
||||
UploadProductBarcodeImageResponses,
|
||||
UploadProductBarcodeImageErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
...formDataBodySerializer,
|
||||
requestValidator: async data => {
|
||||
return await zUploadProductBarcodeImageData.parseAsync(data);
|
||||
},
|
||||
responseType: "json",
|
||||
responseValidator: async data => {
|
||||
return await zUploadProductBarcodeImageResponse.parseAsync(data);
|
||||
},
|
||||
url: "/crm/v1/fulfillment-base/product{pk}/barcode/image/upload",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": null,
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Product Barcode Image
|
||||
*/
|
||||
export const deleteProductBarcodeImage = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteProductBarcodeImageData, ThrowOnError>
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).delete<
|
||||
DeleteProductBarcodeImageResponses,
|
||||
DeleteProductBarcodeImageErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
requestValidator: async data => {
|
||||
return await zDeleteProductBarcodeImageData.parseAsync(data);
|
||||
},
|
||||
responseType: "json",
|
||||
responseValidator: async data => {
|
||||
return await zDeleteProductBarcodeImageResponse.parseAsync(data);
|
||||
},
|
||||
url: "/crm/v1/fulfillment-base/product{pk}/barcode/image",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Services
|
||||
*/
|
||||
|
||||
@ -63,6 +63,20 @@ export type BarcodeTemplateSizeSchema = {
|
||||
height: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* BarcodeUploadImageResponse
|
||||
*/
|
||||
export type BarcodeUploadImageResponse = {
|
||||
/**
|
||||
* Message
|
||||
*/
|
||||
message: string;
|
||||
/**
|
||||
* Imageurl
|
||||
*/
|
||||
imageUrl?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* BaseMarketplaceSchema
|
||||
*/
|
||||
@ -103,6 +117,16 @@ export type BoardSchema = {
|
||||
projectId: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Body_upload_product_barcode_image
|
||||
*/
|
||||
export type BodyUploadProductBarcodeImage = {
|
||||
/**
|
||||
* Upload File
|
||||
*/
|
||||
upload_file: Blob | File;
|
||||
};
|
||||
|
||||
/**
|
||||
* Body_upload_product_image
|
||||
*/
|
||||
@ -639,15 +663,7 @@ export type CreateProductSchema = {
|
||||
/**
|
||||
* Barcodes
|
||||
*/
|
||||
barcodes: Array<string>;
|
||||
/**
|
||||
* Imageurl
|
||||
*/
|
||||
imageUrl?: string | null;
|
||||
/**
|
||||
* Images
|
||||
*/
|
||||
images?: Array<ProductImageSchema> | null;
|
||||
barcodes?: Array<string>;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1090,6 +1106,16 @@ export type DealTagSchema = {
|
||||
tagColor: DealTagColorSchema;
|
||||
};
|
||||
|
||||
/**
|
||||
* DeleteBarcodeImageResponse
|
||||
*/
|
||||
export type DeleteBarcodeImageResponse = {
|
||||
/**
|
||||
* Message
|
||||
*/
|
||||
message: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* DeleteBarcodeTemplateResponse
|
||||
*/
|
||||
@ -1538,6 +1564,20 @@ export type PaginationInfoSchema = {
|
||||
totalItems: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* ProductBarcodeImageSchema
|
||||
*/
|
||||
export type ProductBarcodeImageSchema = {
|
||||
/**
|
||||
* Productid
|
||||
*/
|
||||
productId: number;
|
||||
/**
|
||||
* Imageurl
|
||||
*/
|
||||
imageUrl: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* ProductImageSchema
|
||||
*/
|
||||
@ -1603,7 +1643,7 @@ export type ProductSchema = {
|
||||
/**
|
||||
* Barcodes
|
||||
*/
|
||||
barcodes: Array<string>;
|
||||
barcodes?: Array<string>;
|
||||
/**
|
||||
* Imageurl
|
||||
*/
|
||||
@ -1612,6 +1652,11 @@ export type ProductSchema = {
|
||||
* Images
|
||||
*/
|
||||
images?: Array<ProductImageSchema> | null;
|
||||
/**
|
||||
* Barcodeimageurl
|
||||
*/
|
||||
barcodeImageUrl?: string | null;
|
||||
barcodeImage?: ProductBarcodeImageSchema | null;
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
@ -4073,12 +4118,12 @@ export type UploadProductImageData = {
|
||||
body: BodyUploadProductImage;
|
||||
path: {
|
||||
/**
|
||||
* Productid
|
||||
* Pk
|
||||
*/
|
||||
productId: number;
|
||||
pk: number;
|
||||
};
|
||||
query?: never;
|
||||
url: "/crm/v1/fulfillment-base/product/images/upload/{productId}";
|
||||
url: "/crm/v1/fulfillment-base/product{pk}/images/upload";
|
||||
};
|
||||
|
||||
export type UploadProductImageErrors = {
|
||||
@ -4128,6 +4173,70 @@ export type GetProductBarcodePdfResponses = {
|
||||
export type GetProductBarcodePdfResponse2 =
|
||||
GetProductBarcodePdfResponses[keyof GetProductBarcodePdfResponses];
|
||||
|
||||
export type UploadProductBarcodeImageData = {
|
||||
body: BodyUploadProductBarcodeImage;
|
||||
path: {
|
||||
/**
|
||||
* Pk
|
||||
*/
|
||||
pk: number;
|
||||
};
|
||||
query?: never;
|
||||
url: "/crm/v1/fulfillment-base/product{pk}/barcode/image/upload";
|
||||
};
|
||||
|
||||
export type UploadProductBarcodeImageErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type UploadProductBarcodeImageError =
|
||||
UploadProductBarcodeImageErrors[keyof UploadProductBarcodeImageErrors];
|
||||
|
||||
export type UploadProductBarcodeImageResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: BarcodeUploadImageResponse;
|
||||
};
|
||||
|
||||
export type UploadProductBarcodeImageResponse =
|
||||
UploadProductBarcodeImageResponses[keyof UploadProductBarcodeImageResponses];
|
||||
|
||||
export type DeleteProductBarcodeImageData = {
|
||||
body?: never;
|
||||
path: {
|
||||
/**
|
||||
* Pk
|
||||
*/
|
||||
pk: number;
|
||||
};
|
||||
query?: never;
|
||||
url: "/crm/v1/fulfillment-base/product{pk}/barcode/image";
|
||||
};
|
||||
|
||||
export type DeleteProductBarcodeImageErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type DeleteProductBarcodeImageError =
|
||||
DeleteProductBarcodeImageErrors[keyof DeleteProductBarcodeImageErrors];
|
||||
|
||||
export type DeleteProductBarcodeImageResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: DeleteBarcodeImageResponse;
|
||||
};
|
||||
|
||||
export type DeleteProductBarcodeImageResponse =
|
||||
DeleteProductBarcodeImageResponses[keyof DeleteProductBarcodeImageResponses];
|
||||
|
||||
export type GetServicesData = {
|
||||
body?: never;
|
||||
path?: never;
|
||||
|
||||
@ -32,6 +32,14 @@ export const zBarcodeTemplateSchema = z.object({
|
||||
id: z.int(),
|
||||
});
|
||||
|
||||
/**
|
||||
* BarcodeUploadImageResponse
|
||||
*/
|
||||
export const zBarcodeUploadImageResponse = z.object({
|
||||
message: z.string(),
|
||||
imageUrl: z.optional(z.union([z.string(), z.null()])),
|
||||
});
|
||||
|
||||
/**
|
||||
* BaseMarketplaceSchema
|
||||
*/
|
||||
@ -51,6 +59,13 @@ export const zBoardSchema = z.object({
|
||||
projectId: z.int(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Body_upload_product_barcode_image
|
||||
*/
|
||||
export const zBodyUploadProductBarcodeImage = z.object({
|
||||
upload_file: z.any(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Body_upload_product_image
|
||||
*/
|
||||
@ -250,6 +265,14 @@ export const zProductImageSchema = z.object({
|
||||
imageUrl: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* ProductBarcodeImageSchema
|
||||
*/
|
||||
export const zProductBarcodeImageSchema = z.object({
|
||||
productId: z.int(),
|
||||
imageUrl: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* ProductSchema
|
||||
*/
|
||||
@ -264,9 +287,11 @@ export const zProductSchema = z.object({
|
||||
composition: z.union([z.string(), z.null()]),
|
||||
size: z.union([z.string(), z.null()]),
|
||||
additionalInfo: z.union([z.string(), z.null()]),
|
||||
barcodes: z.array(z.string()),
|
||||
barcodes: z.optional(z.array(z.string())).default([]),
|
||||
imageUrl: z.optional(z.union([z.string(), z.null()])),
|
||||
images: z.optional(z.union([z.array(zProductImageSchema), z.null()])),
|
||||
barcodeImageUrl: z.optional(z.union([z.string(), z.null()])),
|
||||
barcodeImage: z.optional(z.union([zProductBarcodeImageSchema, z.null()])),
|
||||
id: z.int(),
|
||||
barcodeTemplate: zBarcodeTemplateSchema,
|
||||
});
|
||||
@ -526,9 +551,7 @@ export const zCreateProductSchema = z.object({
|
||||
composition: z.union([z.string(), z.null()]),
|
||||
size: z.union([z.string(), z.null()]),
|
||||
additionalInfo: z.union([z.string(), z.null()]),
|
||||
barcodes: z.array(z.string()),
|
||||
imageUrl: z.optional(z.union([z.string(), z.null()])),
|
||||
images: z.optional(z.union([z.array(zProductImageSchema), z.null()])),
|
||||
barcodes: z.optional(z.array(z.string())).default([]),
|
||||
});
|
||||
|
||||
/**
|
||||
@ -746,6 +769,13 @@ export const zDealProductAddKitResponse = z.object({
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* DeleteBarcodeImageResponse
|
||||
*/
|
||||
export const zDeleteBarcodeImageResponse = z.object({
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* DeleteBarcodeTemplateResponse
|
||||
*/
|
||||
@ -2161,7 +2191,7 @@ export const zUpdateProductResponse2 = zUpdateProductResponse;
|
||||
export const zUploadProductImageData = z.object({
|
||||
body: zBodyUploadProductImage,
|
||||
path: z.object({
|
||||
productId: z.int(),
|
||||
pk: z.int(),
|
||||
}),
|
||||
query: z.optional(z.never()),
|
||||
});
|
||||
@ -2182,6 +2212,32 @@ export const zGetProductBarcodePdfData = z.object({
|
||||
*/
|
||||
export const zGetProductBarcodePdfResponse2 = zGetProductBarcodePdfResponse;
|
||||
|
||||
export const zUploadProductBarcodeImageData = z.object({
|
||||
body: zBodyUploadProductBarcodeImage,
|
||||
path: z.object({
|
||||
pk: z.int(),
|
||||
}),
|
||||
query: z.optional(z.never()),
|
||||
});
|
||||
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
export const zUploadProductBarcodeImageResponse = zBarcodeUploadImageResponse;
|
||||
|
||||
export const zDeleteProductBarcodeImageData = z.object({
|
||||
body: z.optional(z.never()),
|
||||
path: z.object({
|
||||
pk: z.int(),
|
||||
}),
|
||||
query: z.optional(z.never()),
|
||||
});
|
||||
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
export const zDeleteProductBarcodeImageResponse = zDeleteBarcodeImageResponse;
|
||||
|
||||
export const zGetServicesData = z.object({
|
||||
body: z.optional(z.never()),
|
||||
path: z.optional(z.never()),
|
||||
|
||||
Reference in New Issue
Block a user