feat: deal create, update, delete
This commit is contained in:
@ -6,6 +6,9 @@ import type {
|
||||
CreateBoardData,
|
||||
CreateBoardErrors,
|
||||
CreateBoardResponses,
|
||||
CreateDealData,
|
||||
CreateDealErrors,
|
||||
CreateDealResponses,
|
||||
CreateProjectData,
|
||||
CreateProjectErrors,
|
||||
CreateProjectResponses,
|
||||
@ -15,6 +18,9 @@ import type {
|
||||
DeleteBoardData,
|
||||
DeleteBoardErrors,
|
||||
DeleteBoardResponses,
|
||||
DeleteDealData,
|
||||
DeleteDealErrors,
|
||||
DeleteDealResponses,
|
||||
DeleteProjectData,
|
||||
DeleteProjectErrors,
|
||||
DeleteProjectResponses,
|
||||
@ -48,12 +54,16 @@ import type {
|
||||
import {
|
||||
zCreateBoardData,
|
||||
zCreateBoardResponse2,
|
||||
zCreateDealData,
|
||||
zCreateDealResponse2,
|
||||
zCreateProjectData,
|
||||
zCreateProjectResponse2,
|
||||
zCreateStatusData,
|
||||
zCreateStatusResponse2,
|
||||
zDeleteBoardData,
|
||||
zDeleteBoardResponse2,
|
||||
zDeleteDealData,
|
||||
zDeleteDealResponse2,
|
||||
zDeleteProjectData,
|
||||
zDeleteProjectResponse2,
|
||||
zDeleteStatusData,
|
||||
@ -216,6 +226,56 @@ export const getDeals = <ThrowOnError extends boolean = false>(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Deal
|
||||
*/
|
||||
export const createDeal = <ThrowOnError extends boolean = false>(
|
||||
options: Options<CreateDealData, ThrowOnError>
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).post<
|
||||
CreateDealResponses,
|
||||
CreateDealErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
requestValidator: async data => {
|
||||
return await zCreateDealData.parseAsync(data);
|
||||
},
|
||||
responseType: "json",
|
||||
responseValidator: async data => {
|
||||
return await zCreateDealResponse2.parseAsync(data);
|
||||
},
|
||||
url: "/deal/",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Deal
|
||||
*/
|
||||
export const deleteDeal = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteDealData, ThrowOnError>
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).delete<
|
||||
DeleteDealResponses,
|
||||
DeleteDealErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
requestValidator: async data => {
|
||||
return await zDeleteDealData.parseAsync(data);
|
||||
},
|
||||
responseType: "json",
|
||||
responseValidator: async data => {
|
||||
return await zDeleteDealResponse2.parseAsync(data);
|
||||
},
|
||||
url: "/deal/{pk}",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Deal
|
||||
*/
|
||||
@ -234,7 +294,7 @@ export const updateDeal = <ThrowOnError extends boolean = false>(
|
||||
responseValidator: async data => {
|
||||
return await zUpdateDealResponse2.parseAsync(data);
|
||||
},
|
||||
url: "/deal/{dealId}",
|
||||
url: "/deal/{pk}",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
Reference in New Issue
Block a user