Package ai.nextbillion.maps.internal
Class GeolocationResponseAdapter
java.lang.Object
com.google.gson.TypeAdapter<GeolocationApi.Response>
ai.nextbillion.maps.internal.GeolocationResponseAdapter
public class GeolocationResponseAdapter extends com.google.gson.TypeAdapter<GeolocationApi.Response>
-
Constructor Summary
Constructors Constructor Description GeolocationResponseAdapter() -
Method Summary
Modifier and Type Method Description GeolocationApi.Responseread(com.google.gson.stream.JsonReader reader)Reads in a JSON object to create a Geolocation Response.voidwrite(com.google.gson.stream.JsonWriter out, GeolocationApi.Response value)Not supported.
-
Constructor Details
-
GeolocationResponseAdapter
public GeolocationResponseAdapter()
-
-
Method Details
-
read
public GeolocationApi.Response read(com.google.gson.stream.JsonReader reader) throws java.io.IOExceptionReads in a JSON object to create a Geolocation Response. See: https://developers.google.com/maps/documentation/geolocation/intro#responsesSuccess Case:
{ "location": { "lat": 51.0, "lng": -0.1 }, "accuracy": 1200.4 }Error Case: The response contains an object with a single error object with the following keys:code: This is the same as the HTTP status of the response.
message: A short description of the error.errors: A list of errors which occurred. Each error contains an identifier for the type of error (the reason) and a short description (the message). For example, sending invalid JSON will return the following error:{ "error": { "errors": [ { "domain": "geolocation", "reason": "notFound", "message": "Not Found", "debugInfo": "status: ZERO_RESULTS\ncom.google.api.server.core.Fault: Immu... }], "code": 404, "message": "Not Found" } }- Specified by:
readin classcom.google.gson.TypeAdapter<GeolocationApi.Response>- Throws:
java.io.IOException
-
write
public void write(com.google.gson.stream.JsonWriter out, GeolocationApi.Response value) throws java.io.IOExceptionNot supported.- Specified by:
writein classcom.google.gson.TypeAdapter<GeolocationApi.Response>- Throws:
java.io.IOException
-