// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * Google Workspace Marketplace API Client for Deno * ================================================ * * Lets your Google Workspace Marketplace applications integrate with Google's installtion and licensing services. * * Docs: https://developers.google.com/workspace/marketplace * Source: https://googleapis.deno.dev/v1/appsmarket:v2.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; /** * Lets your Google Workspace Marketplace applications integrate with Google's * installtion and licensing services. */ export class appsmarket { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://appsmarket.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Gets the customer's licensing status to determine if they have access to a * given app. For more information, see [Getting app installation and * licensing * details](https://developers.google.com/workspace/marketplace/example-calls-marketplace-api). * * @param applicationId The ID of the application. * @param customerId The ID of the customer. */ async customerLicenseGet(applicationId: string, customerId: string): Promise { const url = new URL(`${this.#baseUrl}appsmarket/v2/customerLicense/${ applicationId }/${ customerId }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as CustomerLicense; } /** * Gets the user's licensing status to determine if they have permission to * use a given app. For more information, see [Getting app installation and * licensing * details](https://developers.google.com/workspace/marketplace/example-calls-marketplace-api). * * @param applicationId The ID of the application. * @param userId The ID of the user. */ async userLicenseGet(applicationId: string, userId: string): Promise { const url = new URL(`${this.#baseUrl}appsmarket/v2/userLicense/${ applicationId }/${ userId }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as UserLicense; } } export interface CustomerLicense { /** * The ID of the application corresponding to this license query. */ applicationId?: string; /** * The domain name of the customer. */ customerId?: string; /** * (Deprecated) */ editions?: Editions[]; /** * The ID of the customer license. */ id?: string; /** * The type of API resource. This is always `appsmarket#customerLicense`. */ kind?: string; /** * The customer's license status. One of: - `ACTIVE`: The customer has a * valid license. - `UNLICENSED`: There is no license. Either this customer * has never installed your application or has deleted it. */ state?: string; } export interface Editions { /** * (Deprecated) */ assignedSeats?: number; /** * (Deprecated) */ editionId?: string; /** * (Deprecated) */ seatCount?: number; } export interface UserLicense { /** * The ID of the application corresponding to the license query. */ applicationId?: string; /** * The domain name of the user. */ customerId?: string; /** * (Deprecated) */ editionId?: string; /** * The domain administrator has activated the application for this domain. */ enabled?: boolean; /** * The ID of the user license. */ id?: string; /** * The type of API resource. This is always `appsmarket#userLicense`. */ kind?: string; /** * The user's licensing status. One of: - `ACTIVE`: The user has a valid * license and should be permitted to use the application. - `UNLICENSED`: The * administrator of this user's domain never assigned a seat for the * application to this user. - `EXPIRED`: The administrator assigned a seat to * this user, but the license is expired. */ state?: string; /** * The email address of the user. */ userId?: string; }