toJson method
Implementation
@override
Map<String, dynamic> toJson() => {
'q': query,
if (types != null && types!.isNotEmpty)
'types': types!.map((e) => e.value).toList(),
if (bbox != null) 'bbox': bbox!.asList,
if (limit != null) 'limit': limit,
if (autocomplete != null) 'autocomplete': autocomplete,
if (permanent != null) 'permanent': permanent,
...switch (proximity) {
(LocationProximity l) => {"proximity": l.asString},
(IpProximity ip) => {"proximity": ip.asString},
// Proximity list for batch is array of coordinates usually?
// Docs say: "proximity": -73.99279,40.719296 or ["-73.99279", "40.719296"]?
// Docs say: "Fields specifying multiple values ... can be passed either as a comma-separated strings or as JSON-formatted arrays"
// Proximity in single request is "long,lat". In JSON it could be string "long,lat" or array [long, lat]?
// Detailed docs for Batch: "Fields which were defined as query parameters ... become fields in the JSON object."
// So "proximity" key with value string "long,lat" should work.
// My Proximity classes have asString property.
(null) || (NoProximity _) => {},
},
if (country != null) 'country': country,
if (language != null) 'language': language,
};