(priceMap, fetchTimeout, system=None)
| 50 | |
| 51 | @staticmethod |
| 52 | def fetchPrices(priceMap, fetchTimeout, system=None): |
| 53 | params = {'types': ','.join(str(typeID) for typeID in priceMap)} |
| 54 | for k, v in locations.get(system, {}).items(): |
| 55 | params[k] = v |
| 56 | baseurl = 'https://market.fuzzwork.co.uk/aggregates/' |
| 57 | network = Network.getInstance() |
| 58 | resp = network.get(url=baseurl, type=network.PRICES, params=params, timeout=fetchTimeout) |
| 59 | data = resp.json() |
| 60 | # Cycle through all types we've got from request |
| 61 | for typeID, typeData in data.items(): |
| 62 | try: |
| 63 | typeID = int(typeID) |
| 64 | price = float(typeData['sell']['percentile']) |
| 65 | except (KeyError, TypeError): |
| 66 | continue |
| 67 | # Fuzzworks returns 0 when there's no data for item |
| 68 | if price == 0: |
| 69 | continue |
| 70 | if typeID not in priceMap: |
| 71 | continue |
| 72 | priceMap[typeID].update(PriceStatus.fetchSuccess, price) |
| 73 | del priceMap[typeID] |
| 74 | |
| 75 | |
| 76 | Price.register(FuzzworkMarket) |
no test coverage detected