diff --git a/BackpackTF/account.py b/BackpackTF/account.py index 22a1f40..0bbfcca 100644 --- a/BackpackTF/account.py +++ b/BackpackTF/account.py @@ -26,8 +26,7 @@ def __init__(self, client_id="", client_secret="", api_key=""): # # id - the listing's ID # - - def getListing(self, listing_id=0): + def get_listing(self, listing_id=0): from requests_oauthlib import OAuth2Session from oauthlib.oauth2 import TokenExpiredError @@ -46,12 +45,16 @@ def getListing(self, listing_id=0): return r.text + # alias for compatibility with older versions + # please use the new name, "get_listing" + getListing = get_listing + # # Delete a listing by ID # # id - the listing's ID # - def deleteListing(self, listing_id=0): + def delete_listing(self, listing_id=0): from requests_oauthlib import OAuth2Session from oauthlib.oauth2 import TokenExpiredError @@ -70,6 +73,10 @@ def deleteListing(self, listing_id=0): return r.text + # alias for compatibility with older versions + # please use the new name, "delete_listing" + deleteListing = delete_listing + # # Create a listing # @@ -92,8 +99,7 @@ def deleteListing(self, listing_id=0): # # returns int: 0 or 1, states the success of the listing # - - def createListing(self, intent=0, id=0, quality=6, item_name="Haunted Hat", craftable=1, priceindex=0, offers=0, buyout=1, promoted=0, details="", currencies={"metal": 0}, account_token=""): + def create_listing(self, intent=0, id=0, quality=6, item_name="", craftable=1, priceindex=0, offers=0, buyout=1, promoted=0, details="", currencies={"metal": 0}, account_token=""): from requests_oauthlib import OAuth2Session from oauthlib.oauth2 import BackendApplicationClient from oauthlib.oauth2 import TokenExpiredError @@ -147,6 +153,10 @@ def createListing(self, intent=0, id=0, quality=6, item_name="Haunted Hat", craf except: return jsonResponse + # alias for compatibility with older versions + # please use the new name, "create_listing" + createListing = create_listing + # # This function searches for classified listings # @@ -168,7 +178,7 @@ def createListing(self, intent=0, id=0, quality=6, item_name="Haunted Hat", craf # sheen - 0-7, in order team shine, deadly daffodil, manndarin, mean green, agonizing emerald, villainous violet, hot rod # killstreaker - the id of the killstreaker # - def search_Classifieds(self, intent="dual", page_size=10, fold=1, item_name="Soda Popper", steamid="", tradable="", craftable="", australium="", wear_tier="", quality="", + def search_classifieds(self, intent="dual", page_size=10, fold=1, item_name="", steamid="", tradable="", craftable="", australium="", wear_tier="", quality="", paint="", particle="", killstreak_tier="", sheen="", killstreaker="", page=0, texture_name=""): import requests import urllib.parse @@ -203,6 +213,10 @@ def search_Classifieds(self, intent="dual", page_size=10, fold=1, item_name="Sod return jsondata + # alias for compatibility with older verisions + # please use the new function name, "search_classifieds" (lowercase c) + search_Classifieds = search_classifieds + # # This function extracts the trade url. @@ -239,4 +253,4 @@ def extract_trade_url(self, listingJSON, proxy=None): url = tree.xpath("//li[@id='listing-" + listingJSON['id'] + "']/div[@class='listing-item']/div")[0].get('data-listing_offers_url') return url except: - raise IndexError('List index out of range') \ No newline at end of file + raise IndexError('List index out of range') diff --git a/BackpackTF/currency.py b/BackpackTF/currency.py index 1c3f254..e172d20 100644 --- a/BackpackTF/currency.py +++ b/BackpackTF/currency.py @@ -15,8 +15,7 @@ def __init__(self, apikey=""): # # Function Returns A JSON of the value of currencies # - - def getCurrencies(self): + def get_currencies(self): import requests import json @@ -28,6 +27,10 @@ def getCurrencies(self): else: raise Exception('Your API key is invalid') + # alias for compatibility with older versions + # please use the new name, "get_currencies" + getCurrencies = get_currencies + # # Gets Price History of a specific item in an array of previous values # @@ -42,7 +45,7 @@ def getCurrencies(self): # here's a link to an item http://prntscr.com/pf2s0h # - def priceHistory(self, name="Pyromancer's Mask", quality="Unique", craftable=1, tradable=1, priceIndex=0): + def price_history(self, name="", quality="Unique", craftable=1, tradable=1, priceIndex=0): import requests import urllib.parse import json @@ -70,6 +73,10 @@ def priceHistory(self, name="Pyromancer's Mask", quality="Unique", craftable=1, if success: return jsondata['response']['history'] + + # alias for compatibility with older versions + # please use the new name, "price_history" + priceHistory = price_history # # Gets Price of a specific item @@ -81,7 +88,7 @@ def priceHistory(self, name="Pyromancer's Mask", quality="Unique", craftable=1, # PriceIndex - Not really sure to be honest # - def itemPrice(self, name="Pyromancer's Mask", quality="Unique", craftable=1, tradable=1, priceIndex=0): + def item_price(self, name="", quality="Unique", craftable=1, tradable=1, priceIndex=0): import requests import urllib.parse import json @@ -110,13 +117,17 @@ def itemPrice(self, name="Pyromancer's Mask", quality="Unique", craftable=1, tra if success: return jsondata['response']['history'][len(jsondata['response']['history']) - 1] + # alias for compatibility with older versions + # please use the new name, "item_price" + itemPrice = item_price + # # Gets all prices, requires an elevated API key # # Since - Only prices that have been updated since the unix EPOCH will be shown # - def getAllPrices(self, raw=2, since=0): + def get_all_prices(self, raw=2, since=0): import requests import json @@ -131,3 +142,7 @@ def getAllPrices(self, raw=2, since=0): if success: return jsondata['response'] + + # alias for compatibility with older versions + # please use the new name, "get_all_prices" + getAllPrices = get_all_prices diff --git a/BackpackTF/miscutils.py b/BackpackTF/miscutils.py index 788d8a9..3958d7b 100644 --- a/BackpackTF/miscutils.py +++ b/BackpackTF/miscutils.py @@ -63,105 +63,136 @@ def __init__(self): # # Converts quality string to quality int # - def quality_String_To_Int(self, string): + def quality_string_to_int(self, string): try: return self.qualitiesObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "quality_string_to_int" + quality_String_To_Int = quality_string_to_int + # # Converts particle string to particle int # - def particle_String_To_Int(self, string): + def particle_string_to_int(self, string): try: return self.particleObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "particle_string_to_int" + particle_String_To_Int = particle_string_to_int + # # Converts rarity string to rarity int # - def rarity_String_To_Int(self, string): + def rarity_string_to_int(self, string): try: return self.raritiesObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "rarity_string_to_int" + rarity_String_To_Int = rarity_string_to_int # # Origin quality string to origin int # - def origin_String_To_Int(self, string): + def origin_string_to_int(self, string): try: return self.originsObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "origin_string_to_int" + origin_String_To_Int = origin_string_to_int # # Converts wear_tier string to wear_tier int # - def wear_tier_String_To_Int(self, string): + def wear_tier_string_to_int(self, string): try: return self.wear_tiersObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "wear_tier_string_to_int" + wear_tier_String_To_Int = wear_tier_string_to_int # # Converts killstreaker string to killstreaker int # - def killstreaker_String_To_Int(self, string): + def killstreaker_string_to_int(self, string): try: return self.killstreakers[string.lower()] except: return "" - + # alias for compatibility with older versions + # please use the new name, "killstreaker_string_to_int" + killstreaker_String_To_Int = killstreaker_string_to_int # # Converts sheen string to sheen int # - def sheen_String_To_Int(self, string): + def sheen_string_to_int(self, string): try: return self.sheensObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "sheen_string_to_int" + sheen_String_To_Int = sheen_string_to_int # # Converts killstreak_tier string to killstreak_tier int # - def killstreak_tier_String_To_Int(self, string): + def killstreak_tier_string_to_int(self, string): try: return self.killstreak_tiers[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "killstreak_tier_string_to_int" + killstreak_tier_String_To_Int = killstreak_tier_string_to_int # # Converts strange_part string to strange_part int # - def strange_parts_String_To_Int(self, string): + def strange_parts_string_to_int(self, string): try: return self.strange_partsObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "strange_parts_string_to_int" + strange_parts_String_To_Int = strange_parts_string_to_int # # Converts paint string to paint int # - def paint_String_To_Int(self, string): + def paint_string_to_int(self, string): try: return self.paintsObj[string.lower()] except: return "" + # alias for compatibility with older versions + # please use the new name, "paint_string_to_int" + paint_String_To_Int = paint_string_to_int # # Converts steam ID into the account_id account ID is used in trading requests # def steam_id_to_account_id(self, steam_id): import struct - return str(struct.unpack('>L', int(steam_id).to_bytes(8, byteorder='big')[4:])[0]) \ No newline at end of file + return str(struct.unpack('>L', int(steam_id).to_bytes(8, byteorder='big')[4:])[0]) diff --git a/README.md b/README.md index fd1582f..3f14a6c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ __init__ | api_key | your api key from [here](https://backpack.tf/developer/apikey/view) | -#### createListing - creates a listing / classified on backpack.tf +#### create_listing - creates a listing / classified on backpack.tf | Attributes | Description | @@ -119,7 +119,7 @@ __init__ | apikey | your api key from [here](https://backpack.tf/developer/apikey/view) | -#### getCurrencies - gets currency values +#### get_currencies - gets currency values | Attributes | Description | @@ -129,13 +129,13 @@ __init__ returns a dictonary. [Here's](https://gist.github.com/davidteather/4f9c82f3d224e64c3a187ad28db26d1a) an example json. -#### priceHistory - gets the price history for a given item +#### price_history - gets the price history for a given item | Attributes | Description | | ------------- | ------------- | | name | the name of the item you want to search for | -| quality | the integer of the quality to search by use MiscUtils().qualityStringToInt("unique") to get it | +| quality | the integer of the quality to search by use MiscUtils().qualityStringToInt("Unique") to get it | | craftable | 0/1 | | tradable | 0/1 | | priceindex | complicated, most of the time is 0. [More info](https://image.prntscr.com/image/-zjCD9FiS0ijpGHtG8gNBA.png) | @@ -143,13 +143,13 @@ returns a dictonary. [Here's](https://gist.github.com/davidteather/4f9c82f3d224e returns an array of dictionaries. [Here's](https://gist.github.com/davidteather/db87fbe0bfd7d0ac88cb5412d1bba878) an example. -#### itemPrice - gets the current price for a given item +#### item_price - gets the current price for a given item | Attributes | Description | | ------------- | ------------- | | name | the name of the item you want to search for | -| quality | the integer of the quality to search by use MiscUtils().qualityStringToInt("unique") to get it | +| quality | the integer of the quality to search by use MiscUtils().qualityStringToInt("Unique") to get it | | craftable | 0/1 | | tradable | 0/1 | | priceindex | complicated, most of the time is 0. [More info](https://image.prntscr.com/image/-zjCD9FiS0ijpGHtG8gNBA.png) | @@ -157,7 +157,7 @@ returns an array of dictionaries. [Here's](https://gist.github.com/davidteather/ returns a single dictionary of current value. [Here's](https://gist.github.com/davidteather/a791078ef11d6977d7a9b77d249bd78e) an example. -#### getAllPrices - gets all prices +#### get_all_prices - gets all prices | Attributes | Description | @@ -178,15 +178,15 @@ __init__ | None | None | -#### quality_String_To_Int +#### quality_string_to_int | Attributes | Description | | ------------- | ------------- | -| string | The string of the quality. Ex: "unique" | +| string | The string of the quality. Ex: "Unique" | -#### particle_String_To_Int +#### particle_string_to_int | Attributes | Description | @@ -194,7 +194,7 @@ __init__ | string | The string of the particle effect. | -#### rarity_String_To_Int +#### rarity_string_to_int | Attributes | Description | @@ -202,7 +202,7 @@ __init__ | string | The string of the rarity. | -#### origin_String_To_Int +#### origin_string_to_int | Attributes | Description | @@ -210,7 +210,7 @@ __init__ | string | The string of the origin. | -#### wear_tier_String_To_Int +#### wear_tier_string_to_int | Attributes | Description | @@ -218,7 +218,7 @@ __init__ | string | The string of the wear_tier. | -#### killstreaker_String_To_Int +#### killstreaker_string_to_int | Attributes | Description | @@ -226,7 +226,7 @@ __init__ | string | The string of the killstreaker. | -#### strange_parts_String_To_Int +#### strange_parts_string_to_int | Attributes | Description | diff --git a/setup.py b/setup.py index 58ae985..f607b9b 100644 --- a/setup.py +++ b/setup.py @@ -19,9 +19,9 @@ download_url = 'https://github.com/davidteather/BackpackTf-API/tarball/master', keywords = ['backpacktf', 'python3', 'tf2', 'unofficial', 'backpack.tf', 'trading-bot', 'api'], install_requires=[ - 'requests', 'oauth2', - 'lxml' + 'lxml', + 'requests_oauthlib' ], classifiers=[ 'Development Status :: 3 - Alpha', @@ -33,4 +33,4 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.4' ], -) \ No newline at end of file +)