首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google Apps Marketplace api的Maven依赖性

Google Apps Marketplace api的Maven依赖性
EN

Stack Overflow用户
提问于 2015-02-09 12:19:44
回答 1查看 152关注 0票数 2

我正在尝试获取发布在Google Apps for marketplace上的应用程序的许可证通知。

如果我访问下面给出的链接:

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

提供了一个下载jar appsmarket-2010_12_3.jar的链接,这个链接似乎很旧,我担心它不能与新的Google API一起工作。

有没有任何maven可用于市场api的人工制品,它应该与新的谷歌API兼容,如联系api,管理SDK等。

EN

回答 1

Stack Overflow用户

发布于 2015-02-09 18:25:48

我不认为有一个新的库,但不久前我不得不使用这个API。我只是修改了一些旧的类:

代码语言:javascript
复制
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;
  }
}

然后:

代码语言:javascript
复制
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);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28402764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档