Total Complexity | 8 |
Complexity/F | 1.14 |
Lines of Code | 56 |
Function Count | 7 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import ApiService from '../api.service'; |
||
2 | |||
3 | export default class AppUrlChangeService extends ApiService { |
||
4 | constructor(httpClient, loginService) { |
||
5 | super(httpClient, loginService, null, 'application/json'); |
||
6 | this.name = 'appUrlChangeService'; |
||
7 | } |
||
8 | |||
9 | /** |
||
10 | * @returns {Promise<Array<{key: string, description: string}>>} |
||
11 | */ |
||
12 | fetchResolverStrategies() { |
||
13 | return this.httpClient.get( |
||
14 | 'app-system/app-url-change/strategies', |
||
15 | { |
||
16 | headers: this.getBasicHeaders() |
||
17 | } |
||
18 | ).then(({ data }) => { |
||
19 | return Object.entries(data).map(([key, description]) => { |
||
20 | return { name: key, description }; |
||
21 | }); |
||
22 | }); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param {{name: string}} strategy |
||
27 | * @returns {*} |
||
28 | */ |
||
29 | resolveUrlChange({ name }) { |
||
30 | return this.httpClient |
||
31 | .post( |
||
32 | 'app-system/app-url-change/resolve', |
||
33 | { strategy: name }, |
||
34 | { |
||
35 | headers: this.getBasicHeaders() |
||
36 | } |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @returns {Promise<{newUrl: string, oldUrl: string} | null>} |
||
42 | */ |
||
43 | getUrlDiff() { |
||
44 | return this.httpClient.get( |
||
45 | 'app-system/app-url-change/url-difference', |
||
46 | { |
||
47 | headers: this.getBasicHeaders() |
||
48 | } |
||
49 | ).then((resp) => { |
||
50 | if (resp.status === 204) { |
||
51 | return null; |
||
52 | } |
||
53 | return resp.data; |
||
54 | }); |
||
55 | } |
||
56 | } |
||
57 |