Passed
Push — trunk ( f1db29...787632 )
by Christian
12:08 queued 12s
created

ConfigApiService.getConfig   A

Complexity

Conditions 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
dl 0
loc 20
rs 9.8
c 0
b 0
f 0
1
/**
2
 * @package admin
3
 */
4
5
import type { AxiosInstance } from 'axios';
6
import ApiService from '../api.service';
7
import type { LoginService } from '../login.service';
8
9
/**
10
 * Gateway for the API end point "config"
11
 * @class
12
 * @extends ApiService
13
 * @package system-settings
14
 */
15
class ConfigApiService extends ApiService {
16
    constructor(httpClient: AxiosInstance, loginService: LoginService, apiEndpoint = 'config') {
17
        super(httpClient, loginService, apiEndpoint);
18
        this.name = 'configService';
19
    }
20
21
    /**
22
     * Get information of the logged in user
23
     *
24
     * @param {Object} [additionalParams = {}]
25
     * @param {Object} [additionalHeaders = {}]
26
     * @returns {Promise<T>}
27
     */
28
    getConfig(additionalParams = {}, additionalHeaders = {}) {
29
        const params = additionalParams;
30
        const headers = this.getBasicHeaders(additionalHeaders);
31
32
        return new Promise((resolve) => {
33
            void this.httpClient
34
                .get('/_info/config', {
35
                    params,
36
                    headers,
37
                })
38
                .then((response) => {
39
                    resolve(ApiService.handleResponse(response));
40
                });
41
        });
42
    }
43
}
44
45
// eslint-disable-next-line sw-deprecation-rules/private-feature-declarations
46
export default ConfigApiService;
47