Passed
Push — master ( 7e874c...f67e1e )
by Christian
14:45 queued 02:54
created

PromotionCodeApiService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 22
loc 22
rs 10
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A constructor 4 4 1
A generateCodeFixed 12 12 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
const ApiService = Shopware.Classes.ApiService;
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2
3
/**
4
 * Gateway for the API endpoint "promotion codes"
5
 * @class
6
 * @extends ApiService
7
 */
8 View Code Duplication
export default class PromotionCodeApiService extends ApiService {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9
    constructor(httpClient, loginService, apiEndpoint = 'promotion') {
10
        super(httpClient, loginService, apiEndpoint);
11
        this.name = 'promotionCodeApiService';
12
    }
13
14
    /**
15
     * @returns {Promise<T>}
16
     */
17
    generateCodeFixed() {
18
        const headers = this.getBasicHeaders();
19
20
        return this.httpClient.get(
21
            `/_action/${this.getApiBasePath()}/codes/generate-fixed`,
22
            {
23
                headers
24
            }
25
        ).then((response) => {
26
            return ApiService.handleResponse(response);
27
        });
28
    }
29
}
30