0

has anybody a working example of the changeSeats function for Subscriptions?

I'm working on automating the ordering of licenses for our customers and i can't get it to work.

i get subscriptions.list but in chageSeats i get a warning that i'm passing the wrong number of parameters, unfortunately i don't know what i should pass and can't find it in the docs, only the http GET requests...

Thanks for any assistance.

Here's what i have...

      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 Answers3

0

I can't find any references regarding your AdminReseller.Subscriptions.changeSeats, but based on the changeSeats API reference, there's only supposed to be 2 parameters to be passed. Remove the numberOfSeats as its supposed to be part of the request body. the namespace you're using should be able to accommodate a way to add the request body for this kind of call.

adjuremods
  • 2,938
  • 2
  • 12
  • 17
  • That's the whole point of my question, As I'm unable to fix it i asked for a working example. If you check the Quickstart (https://developers.google.com/admin-sdk/reseller/v1/quickstart/apps-script) the apps script functions call the whole "path" of the function. `AdminReseller.Subscriptions.changeSeats` – Luca Benelli Mar 11 '16 at 10:50
  • and here is how it works (seats has to be an object): `var seats = { numberOfSeats: totalSeats, } var response = AdminReseller.Subscriptions.changeSeats(seats,sub.customerId,sub.subscriptionId);` - thanks Julian ;) – Luca Benelli Mar 11 '16 at 11:23
0

I have this working on my javascript app using the following code. The below example is for a annual commitment plan

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

mvinayakam
  • 2,808
  • 2
  • 18
  • 20
0

And here is how it works in Apps Script (seats has to be an object):

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

Thanks Julian ;)