-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change list of webhooks return type (#294)
- Loading branch information
Showing
9 changed files
with
159 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.easypost.model; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParseException; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public final class WebhookDeserializer implements JsonDeserializer<Webhook[]> { | ||
/** | ||
* Deserialize a list of Webhook from a JSON object. | ||
* | ||
* @param json JSON object to deserialize. | ||
* @param typeOfT Type of the object to deserialize. | ||
* @param context Deserialization context. | ||
* @return Deserialized Webhook object. | ||
* @throws JsonParseException if the JSON object is not a valid Webhook. | ||
*/ | ||
@Override | ||
public Webhook[] deserialize(final JsonElement json, final Type typeOfT, | ||
final JsonDeserializationContext context) throws JsonParseException{ | ||
JsonObject jo = json.getAsJsonObject(); | ||
JsonElement results = jo.get("webhooks"); | ||
Gson gson = new Gson(); | ||
|
||
return gson.fromJson(results, Webhook[].class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters