Total Complexity | 5 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 55.56% |
Changes | 0 |
1 | #!/usr/bin/python |
||
2 | # -*- coding: utf-8 -*- |
||
3 | 1 | from kuon.api_response import APIResponse |
|
4 | 1 | from kuon.bitskins.api.interfaces import ISales |
|
5 | 1 | from kuon.watcher.adapters import SalesAdapterBase |
|
6 | 1 | from kuon.watcher.adapters.bitskins.parser import SearchResponseParser, SoldHistoryParser |
|
7 | |||
8 | |||
9 | 1 | class BitSkinsSalesAdapter(SalesAdapterBase): |
|
10 | """Adapter for the Sales Interface of BitSkins""" |
||
11 | |||
12 | 1 | def __init__(self, *args, **kwargs) -> None: |
|
13 | """Initializing function |
||
14 | |||
15 | :type args: list |
||
16 | :type kwargs: dict |
||
17 | """ |
||
18 | super().__init__(*args, **kwargs) |
||
19 | self.sales_interface = ISales(*args, **kwargs) |
||
20 | |||
21 | 1 | def search(self, market_name, no_delay=False) -> APIResponse: |
|
22 | """Implementation of the search function |
||
23 | |||
24 | :type market_name: str |
||
25 | :type no_delay: bool |
||
26 | :return: |
||
27 | """ |
||
28 | return SearchResponseParser.parse(self.sales_interface.get_inventory_on_sale(market_hash_name=market_name)) |
||
29 | |||
30 | 1 | def get_sold_history(self, market_name, no_delay=False) -> APIResponse: |
|
31 | """Implementation of get sold history function |
||
32 | |||
33 | :type market_name: str |
||
34 | :type no_delay: bool |
||
35 | :return: |
||
36 | """ |
||
37 | search_results = self.search(market_name=market_name).data.market_items |
||
38 | if search_results: |
||
39 | market_name = search_results[0].market_name |
||
40 | |||
41 | return SoldHistoryParser.parse(self.sales_interface.get_sales_info(market_hash_name=market_name)) |
||
42 | |||
43 | 1 | @staticmethod |
|
44 | 1 | def get_item_link(item_id: str) -> str: |
|
45 | """Generate the item link from the item id |
||
46 | |||
47 | :type item_id: str |
||
48 | :return: |
||
49 | """ |
||
50 | return "https://bitskins.com/view_item?item_id={0:s}".format(item_id) |
||
51 |