Directly getting a specific resource


I seem only find an api call to get all player resources instead of a specific one. Since I do not want to rely on the current order I receive them in and just use the array index, I have to search the array with the "find" function.

const playerCurrencies = await currencies.getPlayerCurrencies(projectId, playerId);
  const currentWood = => x.currencyId == 'WOOD').balance;
  const currentLoyality = => x.currencyId == 'LOYALITY').balance;

Is this the best way to do so or am I missing something?
I would have expected something like['WOOD'];
This does not work since the id is part of the object instead of beeing a pointer to it.

     {'LOYALITY': {
      balance: 0,
      writeLock: '1',
      created: { date: '2022-05-26T23:24:47Z' },
      modified: { date: '2022-05-26T23:24:47Z' }

Something like this, you would lose the explicit stating of currencyId but would gain the ability to directly point to the resource by name.
But maybe using the index is the better way for performance since its not a string comparison.
Usability wise I just missed the option to the resource by name via the api.
Just thoughts..

Side node:
I really start to love the unity game services. The amount of complexity economy specially takes away is awesome. Thanks!

1 Like

I found this in client documentation now so I assume it will also work in the cloud code version (js).

public async Task<CurrencyDefinition> GetCurrencyAsync(string id)

How ever this would result in multiple calls which isnt really the solution for the usability issue above.
But a good solution where we only have to check a single resource.