Conditions | 3 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 2 |
CRAP Score | 7.608 |
Changes | 0 |
1 | #!/usr/bin/python |
||
13 | 1 | @staticmethod |
|
14 | 1 | def parse(results: dict) -> APIResponse: |
|
15 | """Parse the sold history model |
||
16 | |||
17 | :type results: dict |
||
18 | :return: |
||
19 | """ |
||
20 | response = SoldHistory(success=results['status'] == 'success') |
||
21 | for item in results['data']['sales']: |
||
22 | wear = item['wear_value'] |
||
23 | if wear is None: |
||
24 | wear = -1.0 |
||
25 | |||
26 | sold_item = SoldItem( |
||
27 | price=int(float(item['price']) * 100), |
||
28 | wear_value=float(wear), |
||
29 | sold_at=int(item['sold_at']) |
||
30 | ) |
||
31 | response.add_sale(sold_item) |
||
32 | return APIResponse(json.dumps(response.__dict__)) |
||
33 |