juliarose / backpacktf-api

Interface for backpack.tf API endpoints
MIT License
3 stars 1 forks source link

Handle 'hat' currency #11

Closed carloslbello closed 2 months ago

carloslbello commented 2 months ago

There are existing listings that use the 'hat' currency, which currently result in a parse error. The output from one such listing (using /api/v2/classifieds/listings/440_14613584054) is below.


{"id":"440_14613584054","steamid":"76561199123726690","appid":440,"currencies":{"metal":1.5,"hat":1},"value":{"raw":2.885,"short":"2.89 ref","long":"1.5 ref"},"details":"just wanna get rid of it so just send me an trade offer\n","listedAt":1719728674,"bumpedAt":1720314810,"intent":"sell","count":1,"status":"active","source":"steam","item":{"appid":440,"baseName":"Infernal Impaler","defindex":575,"id":"14613584054","imageUrl":"https:\/\/steamcdn-a.akamaihd.net\/apps\/440\/icons\/infernal_impaler.9259a5b1e57bdce5e4cdec7ac0960e36916d86a2.png","marketName":"The Infernal Impaler","name":"The Infernal Impaler","origin":{"id":0,"name":"Timed Drop"},"originalId":"7080536825","price":{"community":{"value":1,"valueHigh":1,"currency":"hat","raw":1.385,"short":"1.33\u20131.44 ref","long":"Random Craft Hat, 1.39 ref, $0.0291","usd":0.029084999999999996,"updatedAt":1706749449,"difference":0.05500000000000016},"suggested":{"raw":1.385,"short":"1.39 ref","long":"1.39 ref, $0.0291","usd":0.029084999999999996}},"quality":{"id":6,"name":"Unique","color":"#FFD700"},"summary":"Level 13 Headgear","level":13,"class":["Soldier"],"slot":"misc","tradable":true,"craftable":true,"tag":null},"user":{"id":"76561199123726690","name":"Huller","avatar":"https:\/\/avatars.steamstatic.com\/7b59a89a2492730a13b332f3949ed7fdd6700d3c_medium.jpg","avatarFull":"https:\/\/avatars.steamstatic.com\/7b59a89a2492730a13b332f3949ed7fdd6700d3c_full.jpg","premium":false,"online":false,"banned":false,"customNameStyle":"","acceptedSuggestions":0,"class":"","style":"","role":null,"tradeOfferUrl":"https:\/\/steamcommunity.com\/tradeoffer\/new\/?partner=1163460962&token=bLS5T96L","isMarketplaceSeller":false,"flagImpersonated":null,"bans":[]}}```
juliarose commented 2 months ago

Hat currencies shouldn't be around anymore. It's a little annoying that they do show up. I considered just ignoring the hat field, but this might have the potential effect of currencies just being empty which would look odd.

So I added another variant for currencies which includes hats https://github.com/juliarose/backpacktf-api/commit/7fd731802af08d444b99ef8ec0d634a6e236f5bb