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
|
|
|
api_url = "https://bitskins.com/api/v1/get_inventory_on_sale/" |
62
|
|
|
|
63
|
|
|
payload = { |
64
|
|
|
'app_id': str(app_id) |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
if page: |
68
|
|
|
payload['page'] = int(page) |
69
|
|
|
if sort_by: |
70
|
|
|
payload['sort_by'] = sort_by |
71
|
|
|
if order: |
72
|
|
|
payload['order'] = order |
73
|
|
|
if market_hash_name: |
74
|
|
|
payload['market_hash_name'] = market_hash_name |
75
|
|
|
if min_price: |
76
|
|
|
payload['min_price'] = float(min_price) |
77
|
|
|
if max_price: |
78
|
|
|
payload['max_price'] = float(max_price) |
79
|
|
|
if has_stickers: |
80
|
|
|
payload['has_stickers'] = int(has_stickers) |
81
|
|
|
if is_stattrak: |
82
|
|
|
payload['is_stattrak'] = int(is_stattrak) |
83
|
|
|
if is_souvenir: |
84
|
|
|
payload['is_souvenir'] = int(is_souvenir) |
85
|
|
|
if per_page: |
86
|
|
|
payload['per_page'] = int(per_page) |
87
|
|
|
|
88
|
|
|
return self.api_request(api_url=api_url, params=payload) |
89
|
|
|
|