【问题标题】:Maven dependency for Google Apps Marketplace apiGoogle Apps Marketplace api 的 Maven 依赖项
【发布时间】:2015-02-09 04:19:43
【问题描述】:

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

如果我转到下面给出的链接:

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

提供了一个下载 jar appsmarket-2010_12_3.jar 的链接,该链接似乎很旧,恐怕它不适用于新的 Google API。

是否有任何可用于市场 api 的 maven 工件,它应该与新的 Google API 兼容,如联系人 api、Admin SDK 等。

【问题讨论】:

    标签: java google-contacts-api google-apps-marketplace


    【解决方案1】:

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

    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;
      }
    }
    

    然后:

    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);
    

    【讨论】:

    • 正确,似乎没有它的客户端库。不过很好的解决方案。
    猜你喜欢
    • 2023-04-02
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多