|
| 1 | +import { Res } from 'common/types/responses' |
| 2 | +import { Req } from 'common/types/requests' |
| 3 | +import { service } from 'common/service' |
| 4 | + |
| 5 | +export const gitlabIntegrationService = service |
| 6 | + .enhanceEndpoints({ addTagTypes: ['GitlabIntegration'] }) |
| 7 | + .injectEndpoints({ |
| 8 | + endpoints: (builder) => ({ |
| 9 | + createGitlabIntegration: builder.mutation< |
| 10 | + Res['gitlabIntegrations'], |
| 11 | + Req['createGitlabIntegration'] |
| 12 | + >({ |
| 13 | + invalidatesTags: [{ id: 'LIST', type: 'GitlabIntegration' }], |
| 14 | + query: (query: Req['createGitlabIntegration']) => ({ |
| 15 | + body: query.body, |
| 16 | + method: 'POST', |
| 17 | + url: `projects/${query.project_id}/integrations/gitlab/`, |
| 18 | + }), |
| 19 | + }), |
| 20 | + deleteGitlabIntegration: builder.mutation< |
| 21 | + Res['gitlabIntegrations'], |
| 22 | + Req['deleteGitlabIntegration'] |
| 23 | + >({ |
| 24 | + invalidatesTags: [{ id: 'LIST', type: 'GitlabIntegration' }], |
| 25 | + query: (query: Req['deleteGitlabIntegration']) => ({ |
| 26 | + method: 'DELETE', |
| 27 | + url: `projects/${query.project_id}/integrations/gitlab/${query.gitlab_integration_id}/`, |
| 28 | + }), |
| 29 | + }), |
| 30 | + getGitlabIntegration: builder.query< |
| 31 | + Res['gitlabIntegrations'], |
| 32 | + Req['getGitlabIntegration'] |
| 33 | + >({ |
| 34 | + providesTags: [{ id: 'LIST', type: 'GitlabIntegration' }], |
| 35 | + query: (query: Req['getGitlabIntegration']) => ({ |
| 36 | + url: `projects/${query.project_id}/integrations/gitlab/`, |
| 37 | + }), |
| 38 | + }), |
| 39 | + updateGitlabIntegration: builder.mutation< |
| 40 | + Res['gitlabIntegrations'], |
| 41 | + Req['updateGitlabIntegration'] |
| 42 | + >({ |
| 43 | + invalidatesTags: [{ id: 'LIST', type: 'GitlabIntegration' }], |
| 44 | + query: (query: Req['updateGitlabIntegration']) => ({ |
| 45 | + body: query.body, |
| 46 | + method: 'PATCH', |
| 47 | + url: `projects/${query.project_id}/integrations/gitlab/${query.gitlab_integration_id}/`, |
| 48 | + }), |
| 49 | + }), |
| 50 | + // END OF ENDPOINTS |
| 51 | + }), |
| 52 | + }) |
| 53 | + |
| 54 | +export async function createGitlabIntegration( |
| 55 | + store: any, |
| 56 | + data: Req['createGitlabIntegration'], |
| 57 | + options?: Parameters< |
| 58 | + typeof gitlabIntegrationService.endpoints.createGitlabIntegration.initiate |
| 59 | + >[1], |
| 60 | +) { |
| 61 | + return store.dispatch( |
| 62 | + gitlabIntegrationService.endpoints.createGitlabIntegration.initiate( |
| 63 | + data, |
| 64 | + options, |
| 65 | + ), |
| 66 | + ) |
| 67 | +} |
| 68 | +export async function deleteGitlabIntegration( |
| 69 | + store: any, |
| 70 | + data: Req['deleteGitlabIntegration'], |
| 71 | + options?: Parameters< |
| 72 | + typeof gitlabIntegrationService.endpoints.deleteGitlabIntegration.initiate |
| 73 | + >[1], |
| 74 | +) { |
| 75 | + return store.dispatch( |
| 76 | + gitlabIntegrationService.endpoints.deleteGitlabIntegration.initiate( |
| 77 | + data, |
| 78 | + options, |
| 79 | + ), |
| 80 | + ) |
| 81 | +} |
| 82 | +export async function getGitlabIntegration( |
| 83 | + store: any, |
| 84 | + data: Req['getGitlabIntegration'], |
| 85 | + options?: Parameters< |
| 86 | + typeof gitlabIntegrationService.endpoints.getGitlabIntegration.initiate |
| 87 | + >[1], |
| 88 | +) { |
| 89 | + return store.dispatch( |
| 90 | + gitlabIntegrationService.endpoints.getGitlabIntegration.initiate( |
| 91 | + data, |
| 92 | + options, |
| 93 | + ), |
| 94 | + ) |
| 95 | +} |
| 96 | +export async function updateGitlabIntegration( |
| 97 | + store: any, |
| 98 | + data: Req['updateGitlabIntegration'], |
| 99 | + options?: Parameters< |
| 100 | + typeof gitlabIntegrationService.endpoints.updateGitlabIntegration.initiate |
| 101 | + >[1], |
| 102 | +) { |
| 103 | + return store.dispatch( |
| 104 | + gitlabIntegrationService.endpoints.updateGitlabIntegration.initiate( |
| 105 | + data, |
| 106 | + options, |
| 107 | + ), |
| 108 | + ) |
| 109 | +} |
| 110 | +// END OF FUNCTION_EXPORTS |
| 111 | + |
| 112 | +export const { |
| 113 | + useCreateGitlabIntegrationMutation, |
| 114 | + useDeleteGitlabIntegrationMutation, |
| 115 | + useGetGitlabIntegrationQuery, |
| 116 | + useUpdateGitlabIntegrationMutation, |
| 117 | + // END OF EXPORTS |
| 118 | +} = gitlabIntegrationService |
0 commit comments