Skip to content

Commit

Permalink
feat(wedof): updating cfsurveys classes
Browse files Browse the repository at this point in the history
  • Loading branch information
obenazouz-wedof committed Aug 12, 2024
1 parent 525852b commit bb03413
Show file tree
Hide file tree
Showing 10 changed files with 485 additions and 20 deletions.
5 changes: 5 additions & 0 deletions packages/pieces/community/wedof/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import { certificationFolderSurveyLongTermExperienceAnswered } from './lib/trigg
import { certificationFolderSurveyLongTermExperienceAvailable } from './lib/triggers/certification-folder-survey/certification-folder-survey-long-experience-available';
import { certificationFolderSurveySixMonthExperienceAnswered } from './lib/triggers/certification-folder-survey/certification-folder-survey-six-month-experience-answered';
import { certificationFolderSurveySixMonthExperienceAvailable } from './lib/triggers/certification-folder-survey/certification-folder-survey-six-month-experience-available';
import { getCertificationFolderSurvey } from './lib/actions/certification-folder-survey/get-certification-folder-survey';
import { listCertificationFolderSurveys } from './lib/actions/certification-folder-survey/list-certification-folder-surveys';

export const wedofAuth = PieceAuth.SecretText({
displayName: 'Clé API',
Expand Down Expand Up @@ -123,6 +125,9 @@ export const wedof = createPiece({
createTask,
createActivitie,
sendFile,
///////////// certificationFoldersSurvey ///////
getCertificationFolderSurvey,
listCertificationFolderSurveys
],
triggers: [
////////////// registrationFolders ////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
import { wedofAuth } from '../../..';
import {
createAction,
Property,
} from '@activepieces/pieces-framework';
import { wedofCommon } from '../../common/wedof';

export const getCertificationFolderSurvey = createAction({
auth: wedofAuth,
name: 'getCertificationFolderSurvey',
displayName: "Récupération d'une enquête",
description: "Permet de récupérer une enquête associée à un dossier de certification",
props: {
certificationFolderExternalId: Property.ShortText({
displayName: 'N° de dossier de certification',
description: "Sélectionner la propriété {externalId} du dossier de certification",
required: true,
}),
},

async run(context) {
return (
await httpClient.sendRequest({
method: HttpMethod.GET,
url: wedofCommon.baseUrl + '/surveys/'+ context.propsValue.certificationFolderExternalId,
headers: {
'Content-Type': 'application/json',
'X-Api-Key': context.auth as string,
},
})
).body;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { HttpMethod, QueryParams, httpClient } from '@activepieces/pieces-common';
import { wedofAuth } from '../../..';
import {
createAction,
Property,
} from '@activepieces/pieces-framework';
import { wedofCommon } from '../../common/wedof';

export const listCertificationFolderSurveys = createAction({
auth: wedofAuth,
name: 'listCertificationFolderSurveys',
displayName: 'Liste les enquêtes selon des critères',
description: "Récupérer l'ensemble des enquêtes de l'organisme de l'utilisateur connecté",
props: {
certifInfo: Property.ShortText({
displayName: 'N° certifInfo',
description: "Permet de n'obtenir que les enquêtes liées à la certification considérée",
required: false,
}),
limit: Property.ShortText({
displayName: "Nombre d'enquêtes",
description: "Nombre d'éléments retourné par requête - par défaut 100",
required: false,
}),
order: Property.StaticDropdown({
displayName: "Ordre",
description: "Tri les résultats par ordre ascendant ou descendant",
required: false,
options: {
options: [
{
value: 'asc',
label: 'Ascendant',
},
{
value: 'desc',
label: 'Descendant',
},
],
disabled: false,
},
}),
page: Property.Number({
displayName: 'N° de page de la requête',
description: 'Par défaut : 1',
defaultValue: 1,
required: false,
}),
state: Property.StaticDropdown({
displayName: "Etat",
description: "Permet de n'obtenir que les enquêtes en fonction de l'état considéré",
required: false,
options: {
options: [
{
value: 'all',
label: 'Tous',
},
{
value: 'created',
label: 'Créé',
},
{
value: 'beforeCertificationSuccess',
label: 'Avant la réussite de la certification',
},
{
value: 'afterSixMonthsCertificationSuccess',
label: 'Six mois après la réussite de la certification',
},
{
value: 'finished',
label: 'Terminé',
},
],
disabled: false,
},
}),
},

async run(context) {
const params = {
certifInfo: context.propsValue.certifInfo ?? null,
limit: context.propsValue.limit ?? null,
page: context.propsValue.page ?? null,
state: context.propsValue.state ?? null,
order:context.propsValue.order ?? null,
};
const queryParams: QueryParams = {};
Object.keys(params).forEach((value) => {
const key = value as keyof typeof params;
if (params[key] != null && params[key] != undefined) {
queryParams[value] = params[key] as string;
}
});
return (
await httpClient.sendRequest({
method: HttpMethod.GET,
queryParams: queryParams,
url: wedofCommon.baseUrl + '/surveys',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': context.auth as string,
},
})
).body;
},
});
4 changes: 2 additions & 2 deletions packages/pieces/community/wedof/src/lib/common/wedof.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Property } from '@activepieces/pieces-framework';

export const wedofCommon = {
baseUrl: 'https://www.wedof.fr/api',
host: 'https://www.wedof.fr/api',
baseUrl: 'https://staging.wedof.fr/api',
host: 'https://staging.wedof.fr/api',


state: Property.StaticMultiSelectDropdown({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,64 @@ import { wedofCommon } from '../../common/wedof';
export const certificationFolderSurveyInitialExperienceAnswered = createTrigger({
auth: wedofAuth,
name: 'certificationFolderSurveyInitialExperienceAnswered',
displayName: 'Enquéte "Situation professionnelle en début de cursus" répondue',
description: "Se déclenche lorsqu'un une enquéte de début de cursus est répondue",
displayName: 'Enquête "Situation professionnelle en début de cursus" répondue',
description: "Se déclenche lorsqu'un une enquête de début de cursus est répondue",
type: TriggerStrategy.WEBHOOK,
props: {},
sampleData: {},
sampleData: {
"id": 0,
"initialExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"initialExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"sixMonthExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"sixMonthExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"sixMonthExperienceStartDate": "2019-08-24T14:15:22Z",
"longTermExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"longTermExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"longTermExperienceStartDate": "2019-08-24T14:15:22Z",
"state": "created"
},

async onEnable(context) {
const url = context.webhookUrl as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,64 @@ import { wedofCommon } from '../../common/wedof';
export const certificationFolderSurveyInitialExperienceAvailable = createTrigger({
auth: wedofAuth,
name: 'certificationFolderSurveyInitialExperienceAvailable',
displayName: 'Questionnaire "Situation professionnelle en début de cursus" disponible',
description: "Se déclenche lorsqu'un une enquéte de début de cursus est disponible",
displayName: 'Enquête "Situation professionnelle en début de cursus" disponible',
description: "Se déclenche lorsqu'un une enquête de début de cursus est disponible",
type: TriggerStrategy.WEBHOOK,
props: {},
sampleData: {},
sampleData: {
"id": 0,
"initialExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"initialExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"sixMonthExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"sixMonthExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"sixMonthExperienceStartDate": "2019-08-24T14:15:22Z",
"longTermExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"longTermExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"longTermExperienceStartDate": "2019-08-24T14:15:22Z",
"state": "created"
},

async onEnable(context) {
const url = context.webhookUrl as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,64 @@ import { wedofCommon } from '../../common/wedof';
export const certificationFolderSurveyLongTermExperienceAnswered = createTrigger({
auth: wedofAuth,
name: 'certificationFolderSurveyLongTermExperienceAnswered',
displayName: 'Enquéte "Situation professionnelle au moins un an" répondue',
description: "Se déclenche lorsqu'un une enquéte de au moins un an de cursus est répondue",
displayName: 'Enquête "Situation professionnelle au moins un an" répondue',
description: "Se déclenche lorsqu'un une enquête de au moins un an de cursus est répondue",
type: TriggerStrategy.WEBHOOK,
props: {},
sampleData: {},
sampleData: {
"id": 0,
"initialExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"initialExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"sixMonthExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"sixMonthExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"sixMonthExperienceStartDate": "2019-08-24T14:15:22Z",
"longTermExperience": {
"id": 0,
"qualification": 0,
"certificationName": "string",
"job": "string",
"companyName": "string",
"salaryYearly": 0,
"situation": "string",
"contractType": "string",
"executiveStatus": true,
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"createdOn": "2019-08-24T14:15:22Z",
"updatedOn": "2019-08-24T14:15:22Z"
},
"longTermExperienceAnsweredDate": "2019-08-24T14:15:22Z",
"longTermExperienceStartDate": "2019-08-24T14:15:22Z",
"state": "created"
},

async onEnable(context) {
const url = context.webhookUrl as string;
Expand Down
Loading

0 comments on commit bb03413

Please sign in to comment.