Skip to content

Commit

Permalink
[TECH] Renommer les params {id} en {campaignId} dans les routes l…
Browse files Browse the repository at this point in the history
…iées aux campagnes (PIX-15425)

 #10629
  • Loading branch information
pix-service-auto-merge authored Nov 26, 2024
2 parents 7a3d154 + e66908d commit c561ebd
Show file tree
Hide file tree
Showing 28 changed files with 97 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const register = async function (server) {
},
{
method: 'PATCH',
path: '/api/campaigns/{id}',
path: '/api/campaigns/{campaignId}',
config: {
pre: [
{
Expand All @@ -37,7 +37,7 @@ const register = async function (server) {
],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
payload: Joi.object({
data: {
Expand Down Expand Up @@ -65,12 +65,12 @@ const register = async function (server) {
},
{
method: 'PUT',
path: '/api/campaigns/{id}/archive',
path: '/api/campaigns/{campaignId}/archive',
config: {
pre: [{ method: securityPreHandlers.checkAuthorizationToManageCampaign }],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignAdministrationController.archiveCampaign,
Expand All @@ -82,12 +82,12 @@ const register = async function (server) {
},
{
method: 'DELETE',
path: '/api/campaigns/{id}/archive',
path: '/api/campaigns/{campaignId}/archive',
config: {
pre: [{ method: securityPreHandlers.checkAuthorizationToManageCampaign }],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignAdministrationController.unarchiveCampaign,
Expand Down Expand Up @@ -132,7 +132,7 @@ const register = async function (server) {
},
{
method: 'PATCH',
path: '/api/admin/campaigns/{id}',
path: '/api/admin/campaigns/{campaignId}',
config: {
pre: [
{
Expand All @@ -147,7 +147,7 @@ const register = async function (server) {
],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
payload: Joi.object({
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const save = async function (request, h, dependencies = { requestResponseUtils,
};

const update = async function (request, _, dependencies = { campaignReportSerializer }) {
const campaignId = request.params.id;
const { campaignId } = request.params;

const result = await usecases.updateCampaign({ campaignId, ...request.deserializedPayload });

Expand All @@ -67,7 +67,7 @@ const swapCampaignCodes = async function (request, h) {
};

const updateCampaignDetails = async function (request, h) {
const campaignId = request.params.id;
const { campaignId } = request.params;
const authenticatedUserId = request.auth.credentials.userId;

const campaignDetails = request.deserializedPayload;
Expand All @@ -92,14 +92,14 @@ const updateCampaignCode = async function (request, h) {

const archiveCampaign = function (request, h, dependencies = { campaignReportSerializer }) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

return usecases.archiveCampaign({ userId, campaignId }).then(dependencies.campaignReportSerializer.serialize);
};

const unarchiveCampaign = function (request, h, dependencies = { campaignReportSerializer }) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

return usecases.unarchiveCampaign({ userId, campaignId }).then(dependencies.campaignReportSerializer.serialize);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const getGroups = async function (request) {

const getAnalysis = async function (request, h, dependencies = { campaignAnalysisSerializer }) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;
const locale = extractLocaleFromRequest(request);
const campaignAnalysis = await usecases.computeCampaignAnalysis({ userId, campaignId, locale });
return dependencies.campaignAnalysisSerializer.serialize(campaignAnalysis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getById = async function (
},
) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const tokenForCampaignResults = dependencies.tokenService.createTokenForCampaignResults({ userId, campaignId });

Expand All @@ -41,13 +41,13 @@ const getById = async function (
};

const getCampaignDetails = async function (request) {
const campaignId = request.params.id;
const { campaignId } = request.params;
const campaign = await usecases.getCampaignManagement({ campaignId });
return campaignDetailsManagementSerializer.serialize(campaign);
};

const findPaginatedFilteredCampaigns = async function (request, _, dependencies = { campaignReportSerializer }) {
const organizationId = request.params.id;
const { organizationId } = request.params;
const options = request.query;
const userId = request.auth.credentials.userId;

Expand All @@ -65,7 +65,7 @@ const findPaginatedFilteredCampaigns = async function (request, _, dependencies
};

const getCsvAssessmentResults = async function (request, h) {
const campaignId = request.params.id;
const { campaignId } = request.params;

const writableStream = new PassThrough();

Expand All @@ -88,7 +88,7 @@ const getCsvAssessmentResults = async function (request, h) {
};

const getCsvProfilesCollectionResults = async function (request, h) {
const campaignId = request.params.id;
const { campaignId } = request.params;

const writableStream = new PassThrough();

Expand All @@ -114,7 +114,7 @@ const findParticipantsActivity = async function (
h,
dependencies = { campaignParticipantsActivitySerializer },
) {
const campaignId = request.params.id;
const { campaignId } = request.params;

const { page, filter: filters } = request.query;
if (filters.divisions && !Array.isArray(filters.divisions)) {
Expand Down
24 changes: 12 additions & 12 deletions api/src/prescription/campaign/application/campaign-detail-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}',
path: '/api/campaigns/{campaignId}',
config: {
pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignDetailController.getById,
Expand All @@ -45,7 +45,7 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/admin/campaigns/{id}',
path: '/api/admin/campaigns/{campaignId}',
config: {
pre: [
{
Expand All @@ -61,7 +61,7 @@ const register = async function (server) {
],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignDetailController.getCampaignDetails,
Expand All @@ -74,12 +74,12 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/organizations/{id}/campaigns',
path: '/api/organizations/{organizationId}/campaigns',
config: {
pre: [{ method: securityPreHandlers.checkUserBelongsToOrganization }],
validate: {
params: Joi.object({
id: identifiersType.organizationId,
organizationId: identifiersType.organizationId,
}),
query: Joi.object({
page: {
Expand All @@ -104,12 +104,12 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/csv-profiles-collection-results',
path: '/api/campaigns/{campaignId}/csv-profiles-collection-results',
config: {
pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignDetailController.getCsvProfilesCollectionResults,
Expand All @@ -123,12 +123,12 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/csv-assessment-results',
path: '/api/campaigns/{campaignId}/csv-assessment-results',
config: {
pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignDetailController.getCsvAssessmentResults,
Expand All @@ -142,11 +142,11 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/participants-activity',
path: '/api/campaigns/{campaignId}/participants-activity',
config: {
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
query: Joi.object({
page: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as campaignCollectiveResultSerializer from '../infrastructure/serialize
import * as campaignProfilesCollectionParticipationSummarySerializer from '../infrastructure/serializers/jsonapi/campaign-profiles-collection-participation-summary-serializer.js';

const findAssessmentParticipationResults = async function (request) {
const campaignId = request.params.id;
const { campaignId } = request.params;
const { page, filter: filters } = request.query;
if (filters.divisions && !Array.isArray(filters.divisions)) {
filters.divisions = [filters.divisions];
Expand All @@ -29,7 +29,7 @@ const findAssessmentParticipationResults = async function (request) {
};

const findProfilesCollectionParticipations = async function (request) {
const campaignId = request.params.id;
const { campaignId } = request.params;
const { page, filter: filters } = request.query;
if (filters.divisions && !Array.isArray(filters.divisions)) {
filters.divisions = [filters.divisions];
Expand All @@ -50,7 +50,7 @@ const findProfilesCollectionParticipations = async function (request) {

const getCollectiveResult = async function (request, h, dependencies = { campaignCollectiveResultSerializer }) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;
const locale = extractLocaleFromRequest(request);

const campaignCollectiveResult = await usecases.computeCampaignCollectiveResult({ userId, campaignId, locale });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const register = async function (server) {
server.route([
{
method: 'GET',
path: '/api/campaigns/{id}/assessment-results',
path: '/api/campaigns/{campaignId}/assessment-results',
config: {
pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
query: Joi.object({
filter: Joi.object({
Expand All @@ -39,12 +39,12 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/profiles-collection-participations',
path: '/api/campaigns/{campaignId}/profiles-collection-participations',
config: {
pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }],
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
query: Joi.object({
filter: Joi.object({
Expand All @@ -69,11 +69,11 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/collective-results',
path: '/api/campaigns/{campaignId}/collective-results',
config: {
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignResultsController.getCollectiveResult,
Expand Down
4 changes: 2 additions & 2 deletions api/src/prescription/campaign/application/campaign-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/analyses',
path: '/api/campaigns/{campaignId}/analyses',
config: {
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignController.getAnalysis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as participationsCountByMasteryRateSerializer from '../infrastructure/s

const getParticipationsByStage = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const participationsByStage = await usecases.getCampaignParticipationsCountByStage({ userId, campaignId });

Expand All @@ -18,7 +18,7 @@ const getParticipationsByStage = async function (request) {

const getParticipationsByStatus = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const participantsCounts = await usecases.getCampaignParticipationsCountsByStatus({ userId, campaignId });

Expand All @@ -29,7 +29,7 @@ const getParticipationsByStatus = async function (request) {
};
const getParticipationsByDay = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const participantsCounts = await usecases.getCampaignParticipationsActivityByDay({ userId, campaignId });

Expand All @@ -41,7 +41,7 @@ const getParticipationsByDay = async function (request) {

const getParticipationsCountByMasteryRate = async function (request) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;

const resultDistribution = await usecases.getParticipationsCountByMasteryRate({ userId, campaignId });

Expand Down
Loading

0 comments on commit c561ebd

Please sign in to comment.