storeSensieRequest method

Future<Map<String, dynamic>> storeSensieRequest({
  1. required int whipCount,
  2. required bool flow,
})

Implementation

Future<Map<String, dynamic>> storeSensieRequest({
  required int whipCount,
  required bool flow,
}) async {
  final path = '/session/$id/sensie';

  final body = {
    'accelerometerX': sensorData.accelX,
    'accelerometerY': sensorData.accelY,
    'accelerometerZ': sensorData.accelZ,
    'gyroscopeX': sensorData.gyroX,
    'gyroscopeY': sensorData.gyroY,
    'gyroscopeZ': sensorData.gyroZ,
    'whips': whipCount,
    'flowing': flow ? 1 : -1,
    'agreement': 1,
  };

  final headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'X-api-key': accessToken,
  };

  final response = await http.post(
    Uri.parse(BASE_URL + path),
    body: json.encode(body),
    headers: headers,
  );

  return json.decode(response.body) as Map<String, dynamic>;
}