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