Skip to content

Commit

Permalink
[TECH] Migrer la route GET /api/certification-point-of-contacts/me da…
Browse files Browse the repository at this point in the history
…ns src (PIX-15543)

 #10732
  • Loading branch information
pix-service-auto-merge authored Dec 9, 2024
2 parents 173b177 + e1cd82c commit 14fafae
Show file tree
Hide file tree
Showing 19 changed files with 324 additions and 348 deletions.

This file was deleted.

21 changes: 0 additions & 21 deletions api/lib/application/certification-point-of-contacts/index.js

This file was deleted.

2 changes: 0 additions & 2 deletions api/lib/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ import * as campaignParticipationRepository from '../../infrastructure/repositor
import { campaignParticipationResultRepository } from '../../infrastructure/repositories/campaign-participation-result-repository.js';
import * as campaignRepository from '../../infrastructure/repositories/campaign-repository.js';
import * as certifiableProfileForLearningContentRepository from '../../infrastructure/repositories/certifiable-profile-for-learning-content-repository.js';
import * as certificationPointOfContactRepository from '../../infrastructure/repositories/certification-point-of-contact-repository.js';
import * as certificationRepository from '../../infrastructure/repositories/certification-repository.js';
import * as complementaryCertificationCourseResultRepository from '../../infrastructure/repositories/complementary-certification-course-result-repository.js';
import * as flashAssessmentResultRepository from '../../infrastructure/repositories/flash-assessment-result-repository.js';
Expand Down Expand Up @@ -239,7 +238,6 @@ const dependencies = {
certificationCourseRepository,
certificationCpfCityRepository,
certificationOfficerRepository,
certificationPointOfContactRepository,
certificationRepository,
challengeRepository,
codeGenerator,
Expand Down
2 changes: 0 additions & 2 deletions api/lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as campaignParticipations from './application/campaign-participations/i
import * as certificationCenterInvitations from './application/certification-center-invitations/index.js';
import * as certificationCenterMemberships from './application/certification-center-memberships/index.js';
import * as certificationCenters from './application/certification-centers/index.js';
import * as certificationPointOfContacts from './application/certification-point-of-contacts/index.js';
import * as certifications from './application/certifications/index.js';
import * as frameworks from './application/frameworks/index.js';
import * as memberships from './application/memberships/index.js';
Expand All @@ -23,7 +22,6 @@ const routes = [
certificationCenters,
certificationCenterInvitations,
certificationCenterMemberships,
certificationPointOfContacts,
certifications,
healthcheck,
memberships,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as userSerializer from '../../../shared/infrastructure/serializers/json
import { requestResponseUtils } from '../../../shared/infrastructure/utils/request-response-utils.js';
import { usecases } from '../../domain/usecases/index.js';
import { authenticationMethodsSerializer } from '../../infrastructure/serializers/jsonapi/authentication-methods.serializer.js';
import * as certificationPointOfContactSerializer from '../../infrastructure/serializers/jsonapi/certification-point-of-contact.serializer.js';
import { emailVerificationSerializer } from '../../infrastructure/serializers/jsonapi/email-verification.serializer.js';
import * as updateEmailSerializer from '../../infrastructure/serializers/jsonapi/update-email.serializer.js';
import { userAccountInfoSerializer } from '../../infrastructure/serializers/jsonapi/user-account-info.serializer.js';
Expand Down Expand Up @@ -234,11 +235,18 @@ const validateUserAccountEmail = async function (request, h) {
return h.redirect(location);
};

const getCertificationPointOfContact = async function (request) {
const authenticatedUserId = request.auth.credentials.userId;
const certificationPointOfContact = await usecases.getCertificationPointOfContact({ userId: authenticatedUserId });
return certificationPointOfContactSerializer.serialize(certificationPointOfContact);
};

export const userController = {
acceptPixCertifTermsOfService,
acceptPixLastTermsOfService,
acceptPixOrgaTermsOfService,
changeUserLanguage,
getCertificationPointOfContact,
getCurrentUser,
getCurrentUserAccountInfo,
getUserAuthenticationMethods,
Expand Down
12 changes: 12 additions & 0 deletions api/src/identity-access-management/application/user/user.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,16 @@ export const userRoutes = [
tags: ['api', 'user', 'update-email'],
},
},
{
method: 'GET',
path: '/api/certification-point-of-contacts/me',
config: {
handler: (request, h) => userController.getCertificationPointOfContact(request, h),
notes: [
'- **Cette route est restreinte aux utilisateurs authentifiés*' * '\n' +
'- Récupération d’un référent de certification.',
],
tags: ['api', 'identity-access-management', 'user', 'certification', 'certification-point-of-contact'],
},
},
];
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/**
* @typedef {import('./index.js').CenterRepository} CenterRepository
* @typedef {import('../../../src/certification/enrolment/domain/models/Center.js').Center} Center
* @typedef {import('../../../certification/enrolment/infrastructure/repositories/center-repository.js').CenterRepository} CenterRepository
* @typedef {import('../../infrastructure/repositories/certification-point-of-contact-repository.js').CertificationPointOfContactRepository} CertificationPointOfContactRepository
* @typedef {import('../../../certification/enrolment/domain/models/Center.js').Center} Center
*/
import { CONCURRENCY_HEAVY_OPERATIONS } from '../../../src/shared/infrastructure/constants.js';
import { PromiseUtils } from '../../../src/shared/infrastructure/utils/promise-utils.js';
import { CONCURRENCY_HEAVY_OPERATIONS } from '../../../shared/infrastructure/constants.js';
import { PromiseUtils } from '../../../shared/infrastructure/utils/promise-utils.js';

/**
* @param {Object} params
* @param {string} params.userId
* @param {CenterRepository} params.centerRepository
* @param {CertificationPointOfContactRepository} params.certificationPointOfContactRepository
*/
const getCertificationPointOfContact = async function ({
userId,
Expand Down
4 changes: 4 additions & 0 deletions api/src/identity-access-management/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { oidcAuthenticationServiceRegistry } from '../../../../lib/domain/usecas
import * as campaignParticipationRepository from '../../../../lib/infrastructure/repositories/campaign-participation-repository.js';
import * as campaignRepository from '../../../../lib/infrastructure/repositories/campaign-repository.js';
import * as organizationLearnerRepository from '../../../../lib/infrastructure/repositories/organization-learner-repository.js';
import * as centerRepository from '../../../certification/enrolment/infrastructure/repositories/center-repository.js';
import * as userRecommendedTrainingRepository from '../../../devcomp/infrastructure/repositories/user-recommended-training-repository.js';
import { repositories as campaignRepositories } from '../../../prescription/campaign/infrastructure/repositories/index.js';
import * as prescriptionOrganizationLearnerRepository from '../../../prescription/learner-management/infrastructure/repositories/organization-learner-repository.js';
Expand All @@ -27,6 +28,7 @@ import { certificationCenterMembershipRepository } from '../../../team/infrastru
import * as membershipRepository from '../../../team/infrastructure/repositories/membership.repository.js';
import { accountRecoveryDemandRepository } from '../../infrastructure/repositories/account-recovery-demand.repository.js';
import * as authenticationMethodRepository from '../../infrastructure/repositories/authentication-method.repository.js';
import * as certificationPointOfContactRepository from '../../infrastructure/repositories/certification-point-of-contact.repository.js';
import { emailValidationDemandRepository } from '../../infrastructure/repositories/email-validation-demand.repository.js';
import { eventLoggingJobRepository } from '../../infrastructure/repositories/jobs/event-logging-job.repository.js';
import { garAnonymizedBatchEventsLoggingJobRepository } from '../../infrastructure/repositories/jobs/gar-anonymized-batch-events-logging-job-repository.js';
Expand All @@ -53,7 +55,9 @@ const repositories = {
campaignParticipationRepository,
campaignRepository,
campaignToJoinRepository: campaignRepositories.campaignToJoinRepository,
centerRepository,
certificationCenterMembershipRepository,
certificationPointOfContactRepository,
emailValidationDemandRepository,
emailRepository,
eventLoggingJobRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import _ from 'lodash';

import { knex } from '../../../db/knex-database-connection.js';
import { NotFoundError } from '../../../src/shared/domain/errors.js';
import { AllowedCertificationCenterAccess } from '../../../src/shared/domain/read-models/AllowedCertificationCenterAccess.js';
import { CertificationPointOfContact } from '../../../src/shared/domain/read-models/CertificationPointOfContact.js';
import { knex } from '../../../../db/knex-database-connection.js';
import { NotFoundError } from '../../../shared/domain/errors.js';
import { AllowedCertificationCenterAccess } from '../../../shared/domain/read-models/AllowedCertificationCenterAccess.js';
import { CertificationPointOfContact } from '../../../shared/domain/read-models/CertificationPointOfContact.js';

const CERTIFICATION_CENTER_MEMBERSHIPS_TABLE_NAME = 'certification-center-memberships';

Expand Down

This file was deleted.

Loading

0 comments on commit 14fafae

Please sign in to comment.