psn-api
Version:
A well-tested library that lets you get trophy, user, and game data from the PlayStation Network.
19 lines (18 loc) • 1.22 kB
TypeScript
import type { AuthorizationPayload, UserRegionInfo } from "../models";
/**
* Retrieves the region of a PlayStation Network user based on their username.
*
* This function uses the npId from the user's profile to determine their region.
* The region is extracted from the base64-encoded npId and returned as an object
* containing both the two-letter country code (ISO 3166-1 alpha-2) and the full
* country name.
*
* @param authorization An object containing your access token, typically retrieved with `exchangeAccessCodeForAuthTokens()`.
* @param userName The username for the user whose region you want to determine.
* @param locales Optional. A string with a BCP 47 language tag, or an array of such strings.
* Defaults to ['en'] (English) if not specified.
* @returns A promise that resolves to a RegionInfo object with the country code and name, or null if the region cannot be determined.
*
* @throws Will throw an error if the user cannot be found or if there are any issues accessing the profile.
*/
export declare const getUserRegion: (authorization: AuthorizationPayload, userName: string, locales?: Intl.LocalesArgument) => Promise<UserRegionInfo | null>;