Nithanim / gw2api

A library that provides access to the api of Guild Wars 2.
Apache License 2.0
5 stars 1 forks source link

poor implementation of ItemInfo #13

Closed jligeza closed 8 years ago

jligeza commented 8 years ago

I'm trying to fetch all item ids from bank with gw2api.account().bank(apiKey), and then call items.get(ids) to get details of items, like name and icon.

The problem is, there is no handle between details of items and item IDs from bank. Details of items (ItemInfo) have their ID always set to zero, and output of items.get(ids) function is in random sequence.

It is fine when I ask for details one by one item, but it takes too much time. This needs to be fixed.

Nithanim commented 8 years ago

The problem is, there is no handle between details of items and item IDs from bank.

Yes, that is correct. Tht is what the official api gives and so does this java-implementation.

Details of items (ItemInfo) have their ID always set to zero[...]

I am not sure what you mean. When i call

System.out.println(gw2api.account().bank(apikey)[0]);

i get:

me.nithanim.gw2api.v2.common.Item@7fcd72ca[skin=0,upgrades=<null>,infusions=<null>,id=39752,count=120]

And with the additional details

System.out.println(
    gw2api.items().get(
        gw2api.account().bank(apikey)[0].getId()
    )
);

the result is:

me.nithanim.gw2api.v2.api.items.ItemInfo@67cd35c5[name=Bauble,icon=https://render.guildwars2.com/file/AE5AE77B1B291BA6A418B9F80B43CF3D437D0806/561983.png,description=Spend these in shops inside the Super Adventure Box.,chatLink=[&AgFImwAA],type=TROPHY,rarity=BASIC,level=0,vendorValue=0,defaultSkin=-1,flags={AccountBound,NoMysticForge,NoSalvage,NoSell,AccountBindOnUse},gameTypes={ACTIVITY,WVW,DUNGEON,PVE},restrictions={},details=<null>,id=39752,count=1]

In both cases, the item-id is set.

[...] and output of items.get(ids) function is in random sequence.

It is (at least should if gson does not lose it, although I am pretty sure it doesn't) the same order as returned by the official api.

It is fine when I ask for details one by one item, but it takes too much time. This needs to be fixed.

It seems that you have no other choice than building an list of all ids and request that items yourself. This java-api is a simple wrapper that makes the official json-api available as if it would be implemented in java directly. More functionality should be put in another project that provides a more convenient workflow that is based on this thin wrapper.

PS: With items.get() i assume you mean gw2api.items().get().

jligeza commented 8 years ago

Okay, this can be fixed by storing all items in a database. You can close the issue.