| Total Complexity | 4 |
| Total Lines | 60 |
| Duplicated Lines | 100 % |
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 | """Script used to define the paystack Customer class.""" |
||
| 6 | View Code Duplication | class Customer(PayStackBase): |
|
|
|
|||
| 7 | """docstring for Customer.""" |
||
| 8 | |||
| 9 | @classmethod |
||
| 10 | def create(cls, **kwargs): |
||
| 11 | """ |
||
| 12 | Function defined to create customer. |
||
| 13 | |||
| 14 | Args: |
||
| 15 | first_name: customer's first name. |
||
| 16 | last_name: customer's last name. |
||
| 17 | email: customer's email address. |
||
| 18 | phone:customer's phone number. |
||
| 19 | |||
| 20 | Returns: |
||
| 21 | Json data from paystack API. |
||
| 22 | """ |
||
| 23 | return cls().requests.post('customer', data=kwargs,) |
||
| 24 | |||
| 25 | @classmethod |
||
| 26 | def get(cls, customer_id): |
||
| 27 | """ |
||
| 28 | Static method defined to get customers by id. |
||
| 29 | |||
| 30 | Args: |
||
| 31 | customer_id: paystack customer id. |
||
| 32 | Returns: |
||
| 33 | Json data from paystack API. |
||
| 34 | """ |
||
| 35 | return cls().requests.get('customer/{customer_id}'.format(**locals())) |
||
| 36 | |||
| 37 | @classmethod |
||
| 38 | def list(cls): |
||
| 39 | """ |
||
| 40 | Static method defined to list paystack customers. |
||
| 41 | |||
| 42 | Args: |
||
| 43 | No argument required. |
||
| 44 | Returns: |
||
| 45 | Json data from paystack API. |
||
| 46 | """ |
||
| 47 | return cls().requests.get('customer') |
||
| 48 | |||
| 49 | @classmethod |
||
| 50 | def update(cls, customer_id, **kwargs): |
||
| 51 | """ |
||
| 52 | Static method defined to update paystack customer data by id. |
||
| 53 | |||
| 54 | Args: |
||
| 55 | customer_id: paystack customer id. |
||
| 56 | first_name: customer's first name(optional). |
||
| 57 | last_name: customer's last name(optional). |
||
| 58 | email: customer's email address(optional). |
||
| 59 | phone:customer's phone number(optional). |
||
| 60 | |||
| 61 | Returns: |
||
| 62 | Json data from paystack API. |
||
| 63 | """ |
||
| 64 | return cls().requests.put('customer/{customer_id}'.format(**locals()), |
||
| 65 | data=kwargs) |
||
| 66 |