putGeofence method

Future<PutGeofenceResponse> putGeofence({
  1. required String collectionName,
  2. required String geofenceId,
  3. required GeofenceGeometry geometry,
  4. Map<String, String>? geofenceProperties,
})

Stores a geofence geometry in a given geofence collection, or updates the geometry of an existing geofence if a geofence ID is included in the request.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter collectionName : The geofence collection to store the geofence in.

Parameter geofenceId : An identifier for the geofence. For example, ExampleGeofence-1.

Parameter geometry : Contains the details to specify the position of the geofence. Can be a circle, a polygon, or a multipolygon. Polygon and MultiPolygon geometries can be defined using their respective parameters, or encoded in Geobuf format using the Geobuf parameter. Including multiple geometry types in the same request will return a validation error.

Parameter geofenceProperties : Associates one of more properties with the geofence. A property is a key-value pair stored with the geofence and added to any geofence event triggered with that geofence.

Format: "key" : "value"

Implementation

Future<PutGeofenceResponse> putGeofence({
  required String collectionName,
  required String geofenceId,
  required GeofenceGeometry geometry,
  Map<String, String>? geofenceProperties,
}) async {
  final $payload = <String, dynamic>{
    'Geometry': geometry,
    if (geofenceProperties != null) 'GeofenceProperties': geofenceProperties,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/geofencing/v0/collections/${Uri.encodeComponent(collectionName)}/geofences/${Uri.encodeComponent(geofenceId)}',
    exceptionFnMap: _exceptionFns,
  );
  return PutGeofenceResponse.fromJson(response);
}