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.Response read​(com.google.gson.stream.JsonReader reader)
    Reads in a JSON object to create a Geolocation Response.
    void write​(com.google.gson.stream.JsonWriter out, GeolocationApi.Response value)
    Not supported.

    Methods inherited from class com.google.gson.TypeAdapter

    fromJson, fromJson, fromJsonTree, nullSafe, toJson, toJson, toJsonTree

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • read

      public GeolocationApi.Response read​(com.google.gson.stream.JsonReader reader) throws java.io.IOException
      Reads in a JSON object to create a Geolocation Response. See: https://developers.google.com/maps/documentation/geolocation/intro#responses

      Success 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:
      read in class com.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.IOException
      Not supported.
      Specified by:
      write in class com.google.gson.TypeAdapter<GeolocationApi.Response>
      Throws:
      java.io.IOException