AdminReseller.Subscriptions.changeSeats()函数示例...

时间:2016-03-09 08:08:23

标签: google-reseller-api

有任何订阅的changeSeats函数的工作示例吗?

我正致力于为客户自动订购许可证,但我无法让它发挥作用。

我收到subscriptions.list但是在chageSeats中我得到一个警告,我传递的参数数量错误,不幸的是我不知道我应该通过什么,而且无法在docs,只有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, 
          });
        }          

3 个答案:

答案 0 :(得分:0)

我无法找到有关您AdminReseller.Subscriptions.changeSeats的任何引用,但根据changeSeats API参考,我们只能传递2个参数。删除numberOfSeats,因为它应该是请求正文的一部分。您正在使用的命名空间应该能够为这种调用添加请求主体。

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

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

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

谢谢朱利安;)