Completed
Push — master ( c9bcca...639448 )
by Messense
05:52
created

BaseWeChatPayAPI   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Test Coverage

Coverage 76.47%

Importance

Changes 0
Metric Value
dl 26
loc 26
ccs 13
cts 17
cp 0.7647
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A _get() 4 4 2
A __init__() 2 2 1
A _post() 4 4 2
A mch_id() 3 3 1
A appid() 3 3 1
A sub_mch_id() 3 3 1

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
# -*- coding: utf-8 -*-
2 10
from __future__ import absolute_import, unicode_literals
3
4
5 10 View Code Duplication
class BaseWeChatPayAPI(object):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6
    """ WeChat Pay API base class """
7 10
    def __init__(self, client=None):
8 10
        self._client = client
9
10 10
    def _get(self, url, **kwargs):
11
        if getattr(self, 'API_BASE_URL', None):
12
            kwargs['api_base_url'] = self.API_BASE_URL
13
        return self._client.get(url, **kwargs)
14
15 10
    def _post(self, url, **kwargs):
16 10
        if getattr(self, 'API_BASE_URL', None):
17
            kwargs['api_base_url'] = self.API_BASE_URL
18 10
        return self._client.post(url, **kwargs)
19
20 10
    @property
21
    def appid(self):
22 10
        return self._client.appid
23
24 10
    @property
25
    def mch_id(self):
26 10
        return self._client.mch_id
27
28 10
    @property
29
    def sub_mch_id(self):
30
        return self._client.sub_mch_id
31