Skip to content

Commit a42c88f

Browse files
authored
Merge pull request #220 from KenEucker/develop
fix(sanity): fixes issues with retrieving the player data from sanity
2 parents 313ef7e + b19f29c commit a42c88f

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

examples/node/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ const getAllGamesAsync = async (pre, client, out = false, opts = {}) => {
128128
return testGameData
129129
}
130130

131+
const get1PlayerAsync = async (pre, client, out = false, opts = {}) => {
132+
opts.limit = opts.limit ? opts.limit : 10
133+
const testPlayerData = await client.getPlayer('player-test', opts).catch(console.error)
134+
log(`${pre} :: success fully retrieved player data`, testPlayerData, out)
135+
136+
return testPlayerData
137+
}
138+
131139
const get10PlayersAsync = async (pre, client, out = false, opts = {}) => {
132140
opts.limit = opts.limit ? opts.limit : 10
133141
const testPlayerData = await client.getPlayers(undefined, opts).catch(console.error)
@@ -199,6 +207,7 @@ const runTests = async (out = false) => {
199207
await getGameAsync("Sanity", bikeTagSanityInstance, out)
200208
// await getAllGamesAsync("Sanity", bikeTagSanityInstance, out)
201209
await get10PlayersAsync("Sanity", bikeTagSanityInstance, out)
210+
await get1PlayerAsync("Sanity", bikeTagSanityInstance, out)
202211
// await get10AmbassadorsAsync("Sanity", bikeTagSanityInstance, out)
203212
// await get10SettingsAsync("Sanity", bikeTagSanityInstance, out)
204213
// await get10AchievementsAsync("Sanity", bikeTagSanityInstance, out)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "biketag",
3-
"version": "3.2.2",
3+
"version": "3.2.3",
44
"description": "The Javascript client API for BikeTag Games",
55
"main": "./biketag.node.js",
66
"browser": "./biketag.js",

src/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ export class BikeTagClient extends EventEmitter {
10811081
/// Else, use the get all and filter method
10821082
return this.getPlayers(
10831083
this.getInitialPayload(
1084-
payload,
1084+
options,
10851085
undefined,
10861086
'getPlayers'
10871087
) as getPlayersPayload,
@@ -1214,7 +1214,7 @@ export class BikeTagClient extends EventEmitter {
12141214
/// Else, use the get all and filter method
12151215
return this.getAmbassadors(
12161216
this.getInitialPayload(
1217-
payload,
1217+
options,
12181218
undefined,
12191219
'getAmbassadors'
12201220
) as getAmbassadorsPayload,
@@ -1311,7 +1311,7 @@ export class BikeTagClient extends EventEmitter {
13111311
/// Else, use the get all and filter method
13121312
return this.getSettings(
13131313
this.getInitialPayload(
1314-
payload,
1314+
options,
13151315
undefined,
13161316
'getSettings'
13171317
) as unknown as getSettingsPayload,
@@ -1401,7 +1401,7 @@ export class BikeTagClient extends EventEmitter {
14011401
/// Else, use the get all and filter method
14021402
return this.getAchievements(
14031403
this.getInitialPayload(
1404-
payload,
1404+
options,
14051405
undefined,
14061406
'getAchievements'
14071407
) as unknown as getAchievementsPayload,

src/common/payloads.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ export type getPlayersPayload = {
7575
hash?: string
7676
limit?: number
7777
account?: string
78-
name?: string
78+
names?: string[]
7979
} & CommonPayloadData
8080

8181
export type getPlayerPayload = {
82+
name?: string
8283
fields?: string[]
8384
slug?: string
8485
hash?: string
@@ -117,6 +118,7 @@ export type getAmbassadorsPayload = {
117118
sort?: SortOptions
118119
slugs?: string[]
119120
} & CommonPayloadData
121+
120122
export type getAmbassadorPayload = {
121123
fields?: string[]
122124
slug?: string

src/sanity/getPlayers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function getPlayers(
2323
DataTypes[DataTypes.player],
2424
/// NOT PASSING IN THE GAME because we are not yet assigning players to games
2525
undefined, // payload.game,
26-
payload.name,
26+
payload.names?.length === 1 ? payload.names[0] : undefined,
2727
payload.slugs,
2828
undefined,
2929
fields

0 commit comments

Comments
 (0)