reserveIsibookSpace method

Future<IsibookMyReservationResponse?> reserveIsibookSpace({
  1. required int spaceId,
  2. required Jiffy start,
  3. required Jiffy end,
  4. List extras = const [],
  5. required int customers,
  6. bool points = false,
})

Implementation

Future<IsibookMyReservationResponse?> reserveIsibookSpace({
  required int spaceId,
  required Jiffy start,
  required Jiffy end,
  List<dynamic> extras = const [],
  required int customers,
  bool points = false,
}) async {
  final data = {
    "space_id": spaceId,
    "start": start.toUtc().format(pattern: "yyyy-MM-ddTHH:mm:ss.SSS"),
    "end": end.toUtc().format(pattern: "yyyy-MM-ddTHH:mm:ss.SSS"),
    "extras": extras,
    "customers": customers,
    "points": points,
  };

  final intent = HttpIntent("isibook/spaces/reserve", data);

  final req = await HttpRequest().httpRequest(
      intent, context: context, "Prenoto spazio Isibook...",
      method: HttpMethod.post, dialog: dialog);

  _logIsibookCall("reserveIsibookSpace", intent, req);

  if (!elaborateResponse(req)) {
    return null;
  }

  try {
    return IsibookMyReservationResponse.fromJson(
        Map<String, dynamic>.from(req.response));
  } catch (e, stack) {
    _logIsibookException("reserveIsibookSpace", e, stack);
    return null;
  }
}