Admin SDK Google Workspace 經銷商服務

Admin SDK Google Workspace 經銷商服務可讓您在 Apps Script 中使用 Admin SDK Reseller API。這個 API 可讓授權經銷商管理員下訂客戶訂單,並管理 Google Workspace 每月後付的訂閱項目。

參考資料

如要進一步瞭解這項服務,請參閱 Admin SDK Google Workspace Reseller API 的參考說明文件。如同 Apps Script 的所有進階服務,Admin SDKGoogle Workspace 經銷商服務會使用與公用 API 相同的物件、方法和參數。詳情請參閱「如何判定方法簽章」一文。

如要回報問題及尋找其他支援,請參閱 Admin SDK 經銷商支援指南

程式碼範例

下方程式碼範例使用第 1 版的 API。

取得訂閱項目清單

這個範例記錄了訂閱清單,包括客戶 ID、建立日期、方案名稱和 SKU ID。請注意,使用頁面權杖來存取完整的結果清單。

advanced/adminSDK.gs
/**
 * Logs the list of subscriptions, including the customer ID, date created, plan
 * name, and the sku ID. Notice the use of page tokens to access the full list
 * of results.
 * @see https://developers.google.com/admin-sdk/reseller/reference/rest/v1/subscriptions/list
 */
function getSubscriptions() {
  let result;
  let pageToken;
  do {
    result = AdminReseller.Subscriptions.list({
      pageToken: pageToken
    });
    for (const sub of result.subscriptions) {
      const creationDate = new Date();
      creationDate.setUTCSeconds(sub.creationTime);
      console.log('customer ID: %s, date created: %s, plan name: %s, sku id: %s',
          sub.customerId, creationDate.toDateString(), sub.plan.planName,
          sub.skuId);
    }
    pageToken = result.nextPageToken;
  } while (pageToken);
}