Munish Dhiman
Munish Dhiman

Reputation: 541

Maven dependency for Google Apps Marketplace api

I am trying to fetch license notification for my app published on Google Apps for marketplace.

If I go to the link given below:

https://developers.google.com/google-apps/marketplace/v2/developers_guide

A link to download a jar appsmarket-2010_12_3.jar has been provided which appears to be quite old and I am afraid that it will not work with the new Google APIs.

Is there any maven artifact available for market place api and it should be compatible with new Google API like contact api , Admin SDK etc.

Upvotes: 2

Views: 223

Answers (1)

qtxo
qtxo

Reputation: 1573

Don't think there is a new library, but some time ago I had to use this API. I just end up modifying a bit the old classes:

public class LicenseNotificationList extends GenericJson {
  @Key public ArrayList<LicenseNotification> notifications;
  @Key public String nextPageToken;
}

public class LicenseNotification  extends GenericJson {
  @Key public String id;
  @Key public String applicationId;
  @Key public String customerId;
  // only in customerLicense responses
  @Key public String state;
  @JsonString @Key public Long timestamp;
  // only in licenseNotification responses
  @Key public ArrayList<ProvisionNotification> provisions;
  @Key public ArrayList<ExpiryNotification> expiries;
  @Key public ArrayList<DeleteNotification> deletes;
  @Key public ArrayList<ReassignmentNotification> reassignments;



  public Date getDate() {
      if (timestamp == null) return null;
      return new Date(timestamp);
  }
  /**
   * Notification when licenses are provisioned.
   */
  public static class ProvisionNotification extends GenericJson {
    @Key public String editionId;
    @Key public String seatCount;
    @Key public String type;
  }

  /**
   * Notification when licenses expire. Empty config means all configs have expired.
   */
  public static class ExpiryNotification  extends GenericJson {
    @Key public String editionId;
  }

  /**
   * Notification when licenses are deleted. Empty config means all configs have been deleted.
   */
  public static class DeleteNotification  extends GenericJson {
    @Key public String editionId;
  }

  /**
   * Notification when licenses are assigned/reassigned.
   */
  public static class ReassignmentNotification  extends GenericJson {
    @Key public String editionId;
    @Key public String userId;
    @Key public String type;
  }
}

And then:

String url = LICENSE_URL_BASE + "licenseNotification/" + 
                    appCode + "?alt=json&max-results=200";
            GenericUrl url2 = new GenericUrl(new URL(url));
            if (pageToken != null) {
                url2.put("start-token", pageToken);
            } else // can't have both  params 
                if (timestamp != null) {
                url2.put("timestamp", timestamp);
            }

            HttpRequest req = HTTP_TRANSPORT.createRequestFactory(googleCredential)
            .buildGetRequest(url2); 
            req.setParser(JSON_FACTORY.createJsonObjectParser());

            HttpResponse response = req.execute();

            return response.parseAs(LicenseNotificationList.class);

Upvotes: 2

Related Questions