Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/resources/universes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class Universes {
* @param universeId - The universe ID (numeric string)
* @param userRestrictionId - The user ID (numeric string)
* @param body - The user restriction data to update
* @param placeId - The place ID (optional) (numeric string)
* @returns Promise resolving to the user restriction response
* @throws {AuthError} If API key is invalid
* @throws {OpenCloudError} If an API error occurs
Expand All @@ -180,6 +181,7 @@ export class Universes {
universeId: string,
userRestrictionId: string,
Comment thread
marinofranz marked this conversation as resolved.
Outdated
body: GameJoinRestriction,
placeId?: string,
): Promise<UserRestriction> {
const searchParams = new URLSearchParams();

Expand All @@ -191,14 +193,20 @@ export class Universes {
searchParams.set("idempotencyKey.key", idempotencyKey);
searchParams.set("idempotencyKey.firstSent", firstSent);

return this.http.request<UserRestriction>(
`/cloud/v2/universes/${universeId}/user-restrictions/${userRestrictionId}`,
{
method: "PATCH",
body: JSON.stringify({ gameJoinRestriction: body }),
searchParams,
},
);
let resourcePath = `/cloud/v2/universes/${universeId}`;

// This resource has two different paths, one for universe-level restrictions, and another for place-level restrictions
if (placeId) {
resourcePath += `/places/${placeId}`;
}

resourcePath += `/user-restrictions/${userRestrictionId}`;
Comment thread
marinofranz marked this conversation as resolved.

return this.http.request<UserRestriction>(resourcePath.toString(), {
Comment thread
marinofranz marked this conversation as resolved.
Outdated
method: "PATCH",
body: JSON.stringify({ gameJoinRestriction: body }),
searchParams,
});
}

/**
Expand Down