Passed
Push — master ( 4fbfcc...849c80 )
by Steffen
01:10
created

IInventory.get_inventory_on_sale()   B

Complexity

Conditions 4

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 4
c 2
b 0
f 2
dl 0
loc 34
rs 8.5806
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
from kuon.api_response import APIResponse
4
from kuon.bitskins import BitSkins
5
from kuon.bitskins.common import Sorting, SortingDirection
6
from kuon.common import *
7
8
9
class IInventory(BitSkins):
10
    """Implementation of the API methods related to the inventory of the user on BitSkins
11
12
    common not self explanatory keys:
13
        app id:
14
            The Steam AppID of the game which owns this item (e.g. 730 for CS:GO, 440 for TF2, 570 for Dota 2)
15
    """
16
17
    def __init__(self, *args, **kwargs):
18
        """Initializing function"""
19
        super().__init__(*args, **kwargs)
20
21
    def get_my_inventory(self, app_id=CommonSteamGames.APP_ID_CSGO, page=None) -> APIResponse:
22
        """GetAccountInventory v1 implementation
23
        https://bitskins.com/api/#get_my_inventory
24
25
        Returns the newest 5000 items, use pages to navigate through more
26
27
        :param app_id:
28
        :param page:
29
        :return:
30
        """
31
        api_url = "https://bitskins.com/api/v1/get_my_inventory/"
32
33
        payload = {
34
            'app_id': str(app_id)
35
        }
36
37
        if page:
38
            payload['page'] = int(page)
39
40
        return self.api_request(api_url=api_url, params=payload)
41
42
    def get_inventory_on_sale(self, app_id=CommonSteamGames.APP_ID_CSGO, page=None, sort_by=Sorting.CREATED_AT,
43
                              order=SortingDirection.DESCENDING, market_hash_name=None, min_price=None, max_price=None,
44
                              has_stickers=False, is_stattrak=False, is_souvenir=False, per_page=None) -> APIResponse:
45
        """GetInventoryOnSale v1 implementation
46
        https://bitskins.com/api/#get_inventory_on_sale
47
48
        :param app_id:
49
        :param page:
50
        :param sort_by:
51
        :param order:
52
        :param market_hash_name:
53
        :param min_price:
54
        :param max_price:
55
        :param has_stickers:
56
        :param is_stattrak:
57
        :param is_souvenir:
58
        :param per_page:
59
        :return:
60
        """
61
        arguments = locals()
62
        api_url = "https://bitskins.com/api/v1/get_inventory_on_sale/"
63
64
        payload = {
65
            'app_id': str(app_id)
66
        }
67
68
        for argument in arguments:
69
            if argument == 'self':
70
                continue
71
72
            if arguments[argument] is not None:
73
                payload[argument] = arguments[argument]
74
75
        return self.api_request(api_url=api_url, params=payload)
76