PoiInsert Class
When using Naurt's POI system, it is possible to insert custom POIs. These POIs could be used to keep track of anything; for example, a bench or a lamppost. This data can be sent directly to Naurt's POI API via a PUT request, or if you're using an Android SDK, via the PoiInsert class.
To create an instance of this class, it is required that you use its builder.
Import
import com.naurt.sdk.poi.PoiInsert
import com.naurt.sdk.poi.PoiInsert.Builder
Constructor
The PoiInsert class cannot be directly made with it's constructor. You must build the class via it's Builder. A latitude and longitude must be provided alongside the POI's type (any alphanumerical text) and a valid Naurt key.
class Builder(
apiKey: String,
poiType: String,
latitude: Double,
longitude: Double,
)
The first basic example demonstrates inserting a restaurant location as a POI.
val poiInsert = PoiInsert.Builder(
"<API_KEY_HERE>",
"restaurant",
51.0,
51.0
).build()
This next example demonstrates creating a POI which will later be filterable by the type of restaurant.
val poiInsertWithMeta = PoiInsert.Builder(
"<API_KEY_HERE>",
"restaurant",
51.0,
51.0
).setMetadata(JSONObject(mapOf("type" to "italian"))).build()
And now the POI will be filterable by city.
val poiInsertWithDetailedMeta = PoiInsert.Builder(
"<API_KEY_HERE>",
"restaurant",
51.0,
51.0
).setMetadata(JSONObject(mapOf("type" to "italian", "city" to "London"))).build()
This class conforms to the POI API specification. Please visit the POI API docs for a more in-depth guide.
Once built, the request to insert the POI can be carried out using the .send()
method.
send
This method runs a web request and triggers a callback, so ensure it is correctly spawned off to avoid blocking the main thread.
Signature
poiInsert.send(callback: PoiCallback<JSONObject>)
Parameters
callback
: A Naurt PoiCallback which will receive the result of the web request. If successful a JSON response will be available. If unsuccessful a status code and a JSON containing the error will be present.
Returns
None, but will trigger the callback once the request is done.
Throws
Does not throw.