Skip to content

Commit

Permalink
feat(api): add partnerURL handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Mar 31, 2024
1 parent f25fe7e commit 9fb6a28
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/api/user/partnerURL/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { PronoteApiUserPartnerURL, ApiUserPartnerURL } from "./types";

import { PronoteApiFunctions } from "~/constants/functions";
import { PronoteApiOnglets } from "~/constants/onglets";
import { transformDateToPronoteString } from "~/pronote/dates";
import { createPronoteAPICall } from "~/pronote/requestAPI";
import { makeApiHandler } from "~/utils/api";

export const callApiUserPartnerURL = makeApiHandler<ApiUserPartnerURL>(async (fetcher, input) => {
const request_payload = input.session.writePronoteFunctionPayload<PronoteApiUserPartnerURL["request"]>({
_Signature_: {
onglet: PronoteApiOnglets.Presence
},

donnees: {
SSO: {
codePartenaire: input.sso.code,
intituleLien: input.sso.linkLabel,
description: input.sso.description
}
}
});

const response = await createPronoteAPICall(fetcher, PronoteApiFunctions.PartnerURL, {
session_instance: input.session.instance,
payload: request_payload
});

const received = input.session.readPronoteFunctionPayload<PronoteApiUserPartnerURL["response"]>(response.payload);
return { url: received.RapportSaisie.urlSSO.V };
});
46 changes: 46 additions & 0 deletions src/api/user/partnerURL/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { PronoteApiFunctions } from "~/constants/functions";
import { PronoteApiOnglets } from "~/constants/onglets";
import { Session } from "~/session";

export interface PronoteApiUserPartnerURL {
request: {
_Signature_: {
onglet: PronoteApiOnglets.Presence
}

donnees: {
SSO: {
codePartenaire: string
intituleLien: string
description: string
}
}
}

response: {
donnees: {}
nom: PronoteApiFunctions.PartnerURL
RapportSaisie: {
urlSSO: {
_T: 23
V: string
}
}
}
}

export interface ApiUserPartnerURL {
input: {
session: Session

sso: {
code: string
description: string
linkLabel: string
}
}

output: {
url: string
}
}

0 comments on commit 9fb6a28

Please sign in to comment.