0

有没有人为 Subscriptions 提供 changeSeats 函数的工作示例?

我正在为我们的客户自动订购许可证,但我无法让它工作。

我得到了subscriptions.list 但在chageSeats 中我得到一个警告,我传递了错误数量的参数,不幸的是我不知道我应该传递什么并且在文档中找不到它,只有http GET 请求.. .

感谢您的任何帮助。

这就是我所拥有的...

      result = AdminReseller.Subscriptions.list({
        //have an email address take the domain part (this is already a valid customer of my reseller, checks have been earlier on)
        customerId: sheet.getRange(row,2).getValue().split('@')[1],
        pageToken: pageToken,
      });
      for (var i = 0; i < result.subscriptions.length; i++) {
        var sub = result.subscriptions[i];
        var creationDate = new Date();
        creationDate.setUTCSeconds(sub.creationTime);
        Logger.log('customer ID: %s, date created: %s, plan name: %s, sku id: %s, subscriptionId: %s, seats: %s, licensed seats: %s',sub.customerId, creationDate.toDateString(), sub.plan.planName,sub.skuId, sub.subscriptionId, sub.seats.numberOfSeats, sub.seats.licensedNumberOfSeats);

        //GOOGLE APPS ANNUAL
        //If the customer requested apps licenses, we have the SKU and payment plan we expect... 
        if ((apps) && (sub.skuId=="Google-Apps-For-Business") && (sub.plan.planName=='ANNUAL')){
          var totalSeats=apps+sub.seats.numberOfSeats;
          var appsReturn = "Buying "+apps+" apps licenses, subID: "+sub.subscriptionId + " in addition to "+sub.seats.numberOfSeats+" total Seats: "+totalSeats+"\n"; 
          //Up to here it works.... 
          var response = AdminReseller.Subscriptions.changeSeats({
            customerId: sub.customerId,
            subscriptionId: sub.subscriptionId,
            numberOfSeats: totalSeats, 
          });
        }          
4

3 回答 3

0

以下是它在 Apps 脚本中的工作方式(座位必须是一个对象):

var seats = { numberOfSeats: totalSeats, } 
var response = AdminReseller.Subscriptions.changeSeats(seats,sub.customerId,sub.subscriptionId)‌​; 

谢谢朱利安;)

于 2016-03-15T14:29:55.603 回答
0

我找不到任何关于您的参考资料AdminReseller.Subscriptions.changeSeats,但根据changeSeatsAPI 参考资料,应该只传递 2 个参数。删除numberOfSeats它应该是请求正文的一部分。您正在使用的命名空间应该能够提供一种为此类调用添加请求正文的方法。

于 2016-03-10T05:53:09.397 回答
0

我使用以下代码在我的 javascript 应用程序上工作。以下示例适用于年度承诺计划

var restRequest = gapi.client.request({ 'path': ' https://content.googleapis.com/apps/reseller/v1/customers/domainname /subscriptions/subscriptionId/changeSeats', body: { "numberOfSeats": customerdetails [key].totalSeats }, '方法': 'POST' });

于 2016-03-15T12:00:14.970 回答