2015-02-09 99 views
1

我正在嘗試爲Google Apps for marketplace上發佈的我的應用獲取許可證通知。Google Apps Marketplace API的Maven依賴關係

如果我去下面給出的鏈接:

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

下載JAR appsmarket-2010_12_3.jar已經提供了似乎是很老,我很害怕的鏈接,它不會使用新的Google API。

是否有任何可用的Maven構件對市場的API,它應該是新的谷歌API等接觸API,SDK管理等兼容

回答

2

不要認爲這是一個新的圖書館,但我前一段時間必須使用這個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); 
+0

正確似乎沒有成爲它的客戶端庫。雖然很好的解 – soitof 2015-02-18 18:45:36