// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * Google Play Grouping API Client for Deno * ======================================== * * playgrouping.googleapis.com API. * * Docs: https://cloud.google.com/playgrouping/ * Source: https://googleapis.deno.dev/v1/playgrouping:v1alpha1.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; /** * playgrouping.googleapis.com API. */ export class PlayGrouping { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://playgrouping.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Create or update tags for the user and app that are represented by the * given token. * * @param appPackage Required. App whose tags are being manipulated. Format: apps/{package_name} * @param token Required. Token for which the tags are being inserted or updated. Format: tokens/{token} */ async appsTokensTagsCreateOrUpdate(appPackage: string, token: string, req: CreateOrUpdateTagsRequest): Promise { req = serializeCreateOrUpdateTagsRequest(req); const url = new URL(`${this.#baseUrl}v1alpha1/${ appPackage }/${ token }/tags:createOrUpdate`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeCreateOrUpdateTagsResponse(data); } /** * Verify an API token by asserting the app and persona it belongs to. The * verification is a protection against client-side attacks and will fail if * the contents of the token don't match the provided values. A token must be * verified before it can be used to manipulate user tags. * * @param appPackage Required. App the token belongs to. Format: apps/{package_name} * @param token Required. The token to be verified. Format: tokens/{token} */ async appsTokensVerify(appPackage: string, token: string, req: VerifyTokenRequest): Promise { const url = new URL(`${this.#baseUrl}v1alpha1/${ appPackage }/${ token }:verify`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as VerifyTokenResponse; } } /** * Request message for CreateOrUpdateTags. VerifyToken. */ export interface CreateOrUpdateTagsRequest { /** * Tags to be inserted or updated. */ tags?: Tag[]; } function serializeCreateOrUpdateTagsRequest(data: any): CreateOrUpdateTagsRequest { return { ...data, tags: data["tags"] !== undefined ? data["tags"].map((item: any) => (serializeTag(item))) : undefined, }; } function deserializeCreateOrUpdateTagsRequest(data: any): CreateOrUpdateTagsRequest { return { ...data, tags: data["tags"] !== undefined ? data["tags"].map((item: any) => (deserializeTag(item))) : undefined, }; } /** * Response message for CreateOrUpdateTags. */ export interface CreateOrUpdateTagsResponse { /** * All requested tags are returned, including pre-existing ones. */ tags?: Tag[]; } function serializeCreateOrUpdateTagsResponse(data: any): CreateOrUpdateTagsResponse { return { ...data, tags: data["tags"] !== undefined ? data["tags"].map((item: any) => (serializeTag(item))) : undefined, }; } function deserializeCreateOrUpdateTagsResponse(data: any): CreateOrUpdateTagsResponse { return { ...data, tags: data["tags"] !== undefined ? data["tags"].map((item: any) => (deserializeTag(item))) : undefined, }; } /** * A tag is associated with exactly one package name and user. */ export interface Tag { /** * A boolean value of the tag. */ booleanValue?: boolean; /** * A signed 64-bit integer value of the tag. */ int64Value?: bigint; /** * Required. Key for the tag. */ key?: string; /** * A string value of the tag. */ stringValue?: string; /** * A time value of the tag. */ timeValue?: Date; } function serializeTag(data: any): Tag { return { ...data, int64Value: data["int64Value"] !== undefined ? String(data["int64Value"]) : undefined, timeValue: data["timeValue"] !== undefined ? data["timeValue"].toISOString() : undefined, }; } function deserializeTag(data: any): Tag { return { ...data, int64Value: data["int64Value"] !== undefined ? BigInt(data["int64Value"]) : undefined, timeValue: data["timeValue"] !== undefined ? new Date(data["timeValue"]) : undefined, }; } /** * Request message for VerifyToken. */ export interface VerifyTokenRequest { /** * Required. Persona represented by the token. Format: personas/{persona} */ persona?: string; } /** * Response message for VerifyToken. */ export interface VerifyTokenResponse { }