Passed
Push — master ( be3abd...2506d1 )
by Steffen
01:21
created

ISales   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 7
Metric Value
dl 0
loc 41
rs 10
c 8
b 0
f 7
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 3 1
A get_sales_info() 0 23 3
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
4
from kuon.bitskins import BitSkins
5
from kuon.bitskins.api.exceptions import *
6
from kuon.common import CommonSteamGames
7
8
9
class ISales(BitSkins):
10
    """Implementation of the API methods related to market sales of 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
        context id:
16
            (2 for Valve games, 6 for Steam Community items, 1 for H1Z1, etc.).
17
            When you right-click on an item in your Steam inventory and copy its URL,
18
            the context ID is the second number after the hash.
19
        market hash name:
20
            The full market name of the item. For example: "AK-47 | Aquamarine Revenge (Field-Tested)"
21
    """
22
23
    def __init__(self, *args, **kwargs):
24
        """Initializing function"""
25
        super().__init__(*args, **kwargs)
26
27
    def get_sales_info(self, market_hash_name: str, page=None, app_id=CommonSteamGames.APP_ID_CSGO):
28
        """GetRecentSaleInfo v1 implementation
29
        https://bitskins.com/api#get_sales_info
30
31
        :param market_hash_name:
32
        :param page:
33
        :param app_id:
34
        :return:
35
        """
36
        api_url = 'https://bitskins.com/api/v1/get_sales_info/'
37
38
        if not app_id:
39
            raise MissingArgumentException('The function get_last_sales requires the argument "app_id"')
40
41
        payload = {
42
            'market_hash_name': market_hash_name,
43
            'app_id': str(app_id),
44
        }
45
46
        if page:
47
            payload['page'] = int(page)
48
49
        return self.api_request(api_url=api_url, params=payload)
50