Skip to content

Commit

Permalink
add new endpoint definition
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmanAsh committed Aug 27, 2024
1 parent 08b8dcb commit 3963af9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/api/agreementSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
tagData,
} from "codeforlife/utils/api"

import { type Contributor } from "./contributor"
import api from "."

export type AgreementSignature = Model<
Expand Down Expand Up @@ -48,6 +49,11 @@ export type CreateAgreementSignatureArg = CreateArg<
"contributor" | "agreement_id" | "signed_at"
>

export type CheckSignedAgreementSignatureResult =
| { latest_commit_id: string; status: 404 | 451 }
| { status: 200 }
export type CheckSignedAgreementSignatureArg = Pick<Contributor, "id">

const agreementSignatureApi = api.injectEndpoints({
endpoints: build => ({
retrieveAgreementSignature: build.query<
Expand Down Expand Up @@ -81,6 +87,16 @@ const agreementSignatureApi = api.injectEndpoints({
}),
invalidatesTags: tagData("AgreementSignature", { includeListTag: true }),
}),
checkSignedAgreementSignature: build.mutation<
CheckSignedAgreementSignatureResult,
CheckSignedAgreementSignatureArg
>({
query: ({ id, ...body }) => ({
url: buildUrl(agreementSignatureUrls.detail, { url: { id } }),
method: "PUT",
body,
}),
}),
}),
})

Expand All @@ -91,4 +107,5 @@ export const {
useListAgreementSignaturesQuery,
useLazyListAgreementSignaturesQuery,
useCreateAgreementSignatureMutation,
useCheckSignedAgreementSignatureMutation,
} = agreementSignatureApi

0 comments on commit 3963af9

Please sign in to comment.