Skip to content

Commit 1fd20eb

Browse files
committed
ResourceBase removed. One more toJson() method added to Base
1 parent c607fc9 commit 1fd20eb

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

libs/sparkpost-lib/src/main/java/com/sparkpost/model/Base.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,13 @@ public String toJson(boolean prettyPrint) {
3737

3838
return gson.toJson(this);
3939
}
40+
41+
/**
42+
* Generate JSON from this object for required type.
43+
* @param tClass - target Class.
44+
* @return json of object.
45+
*/
46+
public String toJson(Class tClass) {
47+
return GSON_BUILDER.setPrettyPrinting().create().toJson(this, tClass);
48+
}
4049
}

libs/sparkpost-lib/src/main/java/com/sparkpost/resources/ResourceBase.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

libs/sparkpost-lib/src/main/java/com/sparkpost/resources/ResourceWebhooks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @author grava
2020
*/
21-
public class ResourceWebhooks extends ResourceBase {
21+
public class ResourceWebhooks {
2222

2323
private static final String DEFAULT_TIMEZONE = "UTC";
2424

@@ -74,7 +74,7 @@ public static WebhookDescribeResponse describe(RestConnection conn, String id, S
7474

7575
public static WebhookIdContainerResponse update(RestConnection conn, String id, WebhookDescription webhookDescription) throws SparkPostException {
7676

77-
String json = getObjectAsJsonForClass(webhookDescription, WebhookDescription.class);
77+
String json = webhookDescription.toJson(WebhookDescription.class);
7878
Response response = conn.put("webhooks/" + id, json);
7979
WebhookIdContainerResponse webhookIdContainerResponse = WebhookIdContainerResponse.decode(
8080
response,

0 commit comments

Comments
 (0)