Skip to content

Commit

Permalink
adding updatedSince variable
Browse files Browse the repository at this point in the history
  • Loading branch information
DIDIERRobin committed Jul 31, 2023
1 parent 8995387 commit 116a06e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/demarche/demarche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ export const getDemarcheDossiers = async (
export const getDemarcheDossierWithCustomChamp = async (
client: GraphQLClient,
idDemarche: number,
updatedSince?: Date,
): Promise<getDemarcheWithCustomChampType> => {
const variables = {
demarcheNumber: idDemarche,
};
if (updatedSince) {
variables["updatedSince"] = "2023-07-31T07:31:09.000Z";
}
const result = await graphQlRequest<getDemarcheWithCustomChampType>(
client,
queryDemarcheDossiers,
{
demarcheNumber: idDemarche,
},
variables,
);
result.demarche.dossiers.nodes.forEach((dossier) => {
mergeChampAndChampDescriptor(dossier);
Expand Down
2 changes: 1 addition & 1 deletion src/dossier/custom-champ.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export type CustomChamp = Champ & {
};
export type DossierWithCustomChamp = Dossier & {
champs: Array<CustomChamp>;
};
};
14 changes: 11 additions & 3 deletions src/ds-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { GraphQLClient } from "graphql-request";
import {
getDemarche,
getDemarcheDeletedDossiers,
getDemarcheDossiers, getDemarcheDossierWithCustomChamp,
getDemarcheDossiers,
getDemarcheDossierWithCustomChamp,
} from "./demarche/demarche";
import { getDossier, writeInPrivateAnnotation } from "./dossier/dossier";
import { getGroupInstructeur } from "./groupeInstructeur/groupeInstructeur";
Expand Down Expand Up @@ -34,8 +35,15 @@ export class DsApiClient {
return await getDemarcheDossiers(this.client, idDemarche);
}

async demarcheDossierWithCustomChamp(idDemarche: number) {
return await getDemarcheDossierWithCustomChamp(this.client, idDemarche);
async demarcheDossierWithCustomChamp(
idDemarche: number,
updatedSince?: Date,
) {
return await getDemarcheDossierWithCustomChamp(
this.client,
idDemarche,
updatedSince,
);
}

async demarcheDeletedDossiers(idDemarche: number) {
Expand Down
8 changes: 7 additions & 1 deletion src/graphql/getDemarcheDossiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ export default gql`
$state: DossierState
$order: Order
$after: String
$updatedSince: ISO8601DateTime
) {
demarche(number: $demarcheNumber) {
id
number
title
dossiers(state: $state, order: $order, after: $after) {
dossiers(
state: $state
order: $order
after: $after
updatedSince: $updatedSince
) {
nodes {
...DossierFragment
}
Expand Down

0 comments on commit 116a06e

Please sign in to comment.