Skip to content

Commit 0af70e7

Browse files
authored
Merge pull request #819 from AppQuality/renamed-endpoints
🔀 refactor(common/schema.ts): update paths for videos in API schema
2 parents c156b27 + c8042c1 commit 0af70e7

File tree

15 files changed

+111
-108
lines changed

15 files changed

+111
-108
lines changed

src/common/schema.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ export interface paths {
269269
};
270270
};
271271
};
272-
'/campaigns/{cid}/video': {
272+
'/campaigns/{cid}/videos': {
273273
/** Return all published video for a specific campaign */
274-
get: operations['get-campaigns-cid-video'];
274+
get: operations['get-campaigns-cid-videos'];
275275
parameters: {
276276
path: {
277277
cid: string;
@@ -362,30 +362,30 @@ export interface paths {
362362
};
363363
};
364364
};
365-
'/video/{vid}': {
365+
'/videos/{vid}': {
366366
/** Retrive single video data */
367-
get: operations['get-video-vid'];
367+
get: operations['get-videos-vid'];
368368
parameters: {
369369
path: {
370370
vid: string;
371371
};
372372
};
373373
};
374-
'/video/{vid}/observations': {
374+
'/videos/{vid}/observations': {
375375
/** Retrive all observations of a specific video */
376-
get: operations['get-video-vid-observations'];
377-
post: operations['post-video-vid-observations'];
376+
get: operations['get-videos-vid-observations'];
377+
post: operations['post-videos-vid-observations'];
378378
parameters: {
379379
path: {
380380
vid: string;
381381
};
382382
};
383383
};
384-
'/video/{vid}/observations/{oid}': {
384+
'/videos/{vid}/observations/{oid}': {
385385
/** delete an observation */
386-
delete: operations['delete-video-vid-observations-oid'];
386+
delete: operations['delete-videos-vid-observations-oid'];
387387
/** Update partial data of a video observation. */
388-
patch: operations['patch-video-vid-observations-oid'];
388+
patch: operations['patch-videos-vid-observations-oid'];
389389
parameters: {
390390
path: {
391391
vid: string;
@@ -2229,7 +2229,7 @@ export interface operations {
22292229
};
22302230
};
22312231
/** Return all published video for a specific campaign */
2232-
'get-campaigns-cid-video': {
2232+
'get-campaigns-cid-videos': {
22332233
parameters: {
22342234
path: {
22352235
cid: string;
@@ -2644,7 +2644,7 @@ export interface operations {
26442644
};
26452645
};
26462646
/** Retrive single video data */
2647-
'get-video-vid': {
2647+
'get-videos-vid': {
26482648
parameters: {
26492649
path: {
26502650
vid: string;
@@ -2665,7 +2665,7 @@ export interface operations {
26652665
};
26662666
};
26672667
/** Retrive all observations of a specific video */
2668-
'get-video-vid-observations': {
2668+
'get-videos-vid-observations': {
26692669
parameters: {
26702670
path: {
26712671
vid: string;
@@ -2680,7 +2680,7 @@ export interface operations {
26802680
};
26812681
};
26822682
};
2683-
'post-video-vid-observations': {
2683+
'post-videos-vid-observations': {
26842684
parameters: {
26852685
path: {
26862686
vid: string;
@@ -2706,7 +2706,7 @@ export interface operations {
27062706
};
27072707
};
27082708
/** delete an observation */
2709-
'delete-video-vid-observations-oid': {
2709+
'delete-videos-vid-observations-oid': {
27102710
parameters: {
27112711
path: {
27122712
vid: string;
@@ -2719,7 +2719,7 @@ export interface operations {
27192719
};
27202720
};
27212721
/** Update partial data of a video observation. */
2722-
'patch-video-vid-observations-oid': {
2722+
'patch-videos-vid-observations-oid': {
27232723
parameters: {
27242724
path: {
27252725
vid: string;

src/features/api/apiTags.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ unguessApi.enhanceEndpoints({
9595
putUsersMePreferencesByPrefid: {
9696
invalidatesTags: ['Preferences'],
9797
},
98-
getVideoByVidObservations: {
98+
getVideosByVidObservations: {
9999
providesTags: ['Observations'],
100100
},
101-
postVideoByVidObservations: {
101+
postVideosByVidObservations: {
102102
async onQueryStarted({ vid }, { dispatch, queryFulfilled }) {
103103
try {
104104
const { data: updatedPost } = await queryFulfilled;
105105
dispatch(
106106
unguessApi.util.updateQueryData(
107-
'getVideoByVidObservations',
107+
'getVideosByVidObservations',
108108
{ vid },
109109
(draft) => {
110110
draft.push(updatedPost);
@@ -141,13 +141,13 @@ unguessApi.enhanceEndpoints({
141141
postCampaignsByCidVideoTags: {
142142
invalidatesTags: ['VideoTags'],
143143
},
144-
patchVideoByVidObservationsAndOid: {
144+
patchVideosByVidObservationsAndOid: {
145145
async onQueryStarted({ vid, oid }, { dispatch, queryFulfilled }) {
146146
try {
147147
const { data: updatedPatch } = await queryFulfilled;
148148
dispatch(
149149
unguessApi.util.updateQueryData(
150-
'getVideoByVidObservations',
150+
'getVideosByVidObservations',
151151
{ vid },
152152
(draft) => {
153153
const index = draft.findIndex(
@@ -164,13 +164,13 @@ unguessApi.enhanceEndpoints({
164164
}
165165
},
166166
},
167-
deleteVideoByVidObservationsAndOid: {
167+
deleteVideosByVidObservationsAndOid: {
168168
async onQueryStarted({ vid, oid }, { dispatch, queryFulfilled }) {
169169
try {
170170
await queryFulfilled;
171171
dispatch(
172172
unguessApi.util.updateQueryData(
173-
'getVideoByVidObservations',
173+
'getVideosByVidObservations',
174174
{ vid },
175175
(draft) => {
176176
const index = draft.findIndex(

src/features/api/index.ts

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,12 @@ const injectedRtkApi = api.injectEndpoints({
323323
body: queryArg.body,
324324
}),
325325
}),
326-
getCampaignsByCidVideo: build.query<
327-
GetCampaignsByCidVideoApiResponse,
328-
GetCampaignsByCidVideoApiArg
326+
getCampaignsByCidVideos: build.query<
327+
GetCampaignsByCidVideosApiResponse,
328+
GetCampaignsByCidVideosApiArg
329329
>({
330330
query: (queryArg) => ({
331-
url: `/campaigns/${queryArg.cid}/video`,
331+
url: `/campaigns/${queryArg.cid}/videos`,
332332
params: {
333333
limit: queryArg.limit,
334334
start: queryArg.start,
@@ -474,41 +474,44 @@ const injectedRtkApi = api.injectEndpoints({
474474
body: queryArg.body,
475475
}),
476476
}),
477-
getVideoByVid: build.query<GetVideoByVidApiResponse, GetVideoByVidApiArg>({
478-
query: (queryArg) => ({ url: `/video/${queryArg.vid}` }),
477+
getVideosByVid: build.query<
478+
GetVideosByVidApiResponse,
479+
GetVideosByVidApiArg
480+
>({
481+
query: (queryArg) => ({ url: `/videos/${queryArg.vid}` }),
479482
}),
480-
getVideoByVidObservations: build.query<
481-
GetVideoByVidObservationsApiResponse,
482-
GetVideoByVidObservationsApiArg
483+
getVideosByVidObservations: build.query<
484+
GetVideosByVidObservationsApiResponse,
485+
GetVideosByVidObservationsApiArg
483486
>({
484-
query: (queryArg) => ({ url: `/video/${queryArg.vid}/observations` }),
487+
query: (queryArg) => ({ url: `/videos/${queryArg.vid}/observations` }),
485488
}),
486-
postVideoByVidObservations: build.mutation<
487-
PostVideoByVidObservationsApiResponse,
488-
PostVideoByVidObservationsApiArg
489+
postVideosByVidObservations: build.mutation<
490+
PostVideosByVidObservationsApiResponse,
491+
PostVideosByVidObservationsApiArg
489492
>({
490493
query: (queryArg) => ({
491-
url: `/video/${queryArg.vid}/observations`,
494+
url: `/videos/${queryArg.vid}/observations`,
492495
method: 'POST',
493496
body: queryArg.body,
494497
}),
495498
}),
496-
patchVideoByVidObservationsAndOid: build.mutation<
497-
PatchVideoByVidObservationsAndOidApiResponse,
498-
PatchVideoByVidObservationsAndOidApiArg
499+
patchVideosByVidObservationsAndOid: build.mutation<
500+
PatchVideosByVidObservationsAndOidApiResponse,
501+
PatchVideosByVidObservationsAndOidApiArg
499502
>({
500503
query: (queryArg) => ({
501-
url: `/video/${queryArg.vid}/observations/${queryArg.oid}`,
504+
url: `/videos/${queryArg.vid}/observations/${queryArg.oid}`,
502505
method: 'PATCH',
503506
body: queryArg.body,
504507
}),
505508
}),
506-
deleteVideoByVidObservationsAndOid: build.mutation<
507-
DeleteVideoByVidObservationsAndOidApiResponse,
508-
DeleteVideoByVidObservationsAndOidApiArg
509+
deleteVideosByVidObservationsAndOid: build.mutation<
510+
DeleteVideosByVidObservationsAndOidApiResponse,
511+
DeleteVideosByVidObservationsAndOidApiArg
509512
>({
510513
query: (queryArg) => ({
511-
url: `/video/${queryArg.vid}/observations/${queryArg.oid}`,
514+
url: `/videos/${queryArg.vid}/observations/${queryArg.oid}`,
512515
method: 'DELETE',
513516
}),
514517
}),
@@ -1157,7 +1160,7 @@ export type PostCampaignsByCidVideoTagsApiArg = {
11571160
};
11581161
};
11591162
};
1160-
export type GetCampaignsByCidVideoApiResponse = /** status 200 OK */ {
1163+
export type GetCampaignsByCidVideosApiResponse = /** status 200 OK */ {
11611164
items: {
11621165
usecase: {
11631166
id: number;
@@ -1170,7 +1173,7 @@ export type GetCampaignsByCidVideoApiResponse = /** status 200 OK */ {
11701173
})[];
11711174
}[];
11721175
} & PaginationData;
1173-
export type GetCampaignsByCidVideoApiArg = {
1176+
export type GetCampaignsByCidVideosApiArg = {
11741177
cid: string;
11751178
/** Limit pagination parameter */
11761179
limit?: number;
@@ -1340,32 +1343,32 @@ export type PutUsersMePreferencesByPrefidApiArg = {
13401343
value: number;
13411344
};
13421345
};
1343-
export type GetVideoByVidApiResponse = /** status 200 OK */ Video & {
1346+
export type GetVideosByVidApiResponse = /** status 200 OK */ Video & {
13441347
usecase: {
13451348
id: number;
13461349
name: string;
13471350
};
13481351
};
1349-
export type GetVideoByVidApiArg = {
1352+
export type GetVideosByVidApiArg = {
13501353
vid: string;
13511354
};
1352-
export type GetVideoByVidObservationsApiResponse =
1355+
export type GetVideosByVidObservationsApiResponse =
13531356
/** status 200 OK */ Observation[];
1354-
export type GetVideoByVidObservationsApiArg = {
1357+
export type GetVideosByVidObservationsApiArg = {
13551358
vid: string;
13561359
};
1357-
export type PostVideoByVidObservationsApiResponse =
1360+
export type PostVideosByVidObservationsApiResponse =
13581361
/** status 200 OK */ Observation;
1359-
export type PostVideoByVidObservationsApiArg = {
1362+
export type PostVideosByVidObservationsApiArg = {
13601363
vid: string;
13611364
body: {
13621365
start: number;
13631366
end: number;
13641367
};
13651368
};
1366-
export type PatchVideoByVidObservationsAndOidApiResponse =
1369+
export type PatchVideosByVidObservationsAndOidApiResponse =
13671370
/** status 200 OK */ Observation;
1368-
export type PatchVideoByVidObservationsAndOidApiArg = {
1371+
export type PatchVideosByVidObservationsAndOidApiArg = {
13691372
vid: string;
13701373
oid: string;
13711374
body: {
@@ -1376,8 +1379,8 @@ export type PatchVideoByVidObservationsAndOidApiArg = {
13761379
tags?: number[];
13771380
};
13781381
};
1379-
export type DeleteVideoByVidObservationsAndOidApiResponse = unknown;
1380-
export type DeleteVideoByVidObservationsAndOidApiArg = {
1382+
export type DeleteVideosByVidObservationsAndOidApiResponse = unknown;
1383+
export type DeleteVideosByVidObservationsAndOidApiArg = {
13811384
vid: string;
13821385
oid: string;
13831386
};
@@ -2033,7 +2036,7 @@ export const {
20332036
useGetCampaignsByCidUxQuery,
20342037
useGetCampaignsByCidVideoTagsQuery,
20352038
usePostCampaignsByCidVideoTagsMutation,
2036-
useGetCampaignsByCidVideoQuery,
2039+
useGetCampaignsByCidVideosQuery,
20372040
useGetCampaignsByCidWidgetsQuery,
20382041
useGetInsightsByIidQuery,
20392042
useDeleteInsightsByIidMutation,
@@ -2050,11 +2053,11 @@ export const {
20502053
useGetUsersMeQuery,
20512054
useGetUsersMePreferencesQuery,
20522055
usePutUsersMePreferencesByPrefidMutation,
2053-
useGetVideoByVidQuery,
2054-
useGetVideoByVidObservationsQuery,
2055-
usePostVideoByVidObservationsMutation,
2056-
usePatchVideoByVidObservationsAndOidMutation,
2057-
useDeleteVideoByVidObservationsAndOidMutation,
2056+
useGetVideosByVidQuery,
2057+
useGetVideosByVidObservationsQuery,
2058+
usePostVideosByVidObservationsMutation,
2059+
usePatchVideosByVidObservationsAndOidMutation,
2060+
useDeleteVideosByVidObservationsAndOidMutation,
20582061
useGetWorkspacesQuery,
20592062
usePostWorkspacesMutation,
20602063
useGetWorkspacesByWidQuery,

src/pages/Video/Actions.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { LG, Skeleton } from '@appquality/unguess-design-system';
22
import { useTranslation } from 'react-i18next';
33
import { useParams } from 'react-router-dom';
44
import {
5-
useGetVideoByVidObservationsQuery,
6-
useGetVideoByVidQuery,
5+
useGetVideosByVidObservationsQuery,
6+
useGetVideosByVidQuery,
77
} from 'src/features/api';
88
import { Divider } from 'src/common/components/divider';
99
import { appTheme } from 'src/app/theme';
@@ -42,7 +42,7 @@ const Actions = () => {
4242
isFetching: isFetchingVideo,
4343
isLoading: isLoadingVideo,
4444
isError: isErrorVideo,
45-
} = useGetVideoByVidQuery({
45+
} = useGetVideosByVidQuery({
4646
vid: videoId || '',
4747
});
4848

@@ -51,7 +51,7 @@ const Actions = () => {
5151
isFetching: isFetchingObservations,
5252
isLoading: isLoadingObservations,
5353
isError: isErrorObservations,
54-
} = useGetVideoByVidObservationsQuery({
54+
} = useGetVideosByVidObservationsQuery({
5555
vid: videoId || '',
5656
});
5757

src/pages/Video/PageHeader.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { appTheme } from 'src/app/theme';
1111
import { LayoutWrapper } from 'src/common/components/LayoutWrapper';
1212
import {
1313
useGetCampaignsByCidQuery,
14-
useGetVideoByVidObservationsQuery,
15-
useGetVideoByVidQuery,
14+
useGetVideosByVidObservationsQuery,
15+
useGetVideosByVidQuery,
1616
} from 'src/features/api';
1717
import { useLocalizeRoute } from 'src/hooks/useLocalizedRoute';
1818
import { Meta } from 'src/common/components/Meta';
@@ -51,15 +51,15 @@ const VideoPageHeader = () => {
5151
isFetching: isFetchingVideo,
5252
isLoading: isLoadingVideo,
5353
isError: isErrorVideo,
54-
} = useGetVideoByVidQuery({
54+
} = useGetVideosByVidQuery({
5555
vid: videoId || '',
5656
});
5757
const {
5858
data: observations,
5959
isLoading: isLoadingObservations,
6060
isFetching: isFetchingObservations,
6161
isError: isErrorObservations,
62-
} = useGetVideoByVidObservationsQuery({
62+
} = useGetVideosByVidObservationsQuery({
6363
vid: videoId || '',
6464
});
6565

0 commit comments

Comments
 (0)