sendAdd method

Future<(ServiceState?, String)> sendAdd(
  1. ServiceOfJournal serv,
  2. {String? body}
)

Add service to remote DB.

Create request body and call _commitUrl.

Implementation

Future<(ServiceState?, String)> sendAdd(
  ServiceOfJournal serv, {
  String? body,
}) async {
  //
  // > create body of post request
  //
  // ignore: parameter_assignments
  body ??= AddClientServiceRequest(
    vdate: sqlFormat.format(serv.provDate),
    uuid: serv.uid,
    contracts_id: serv.contractId,
    dep_has_worker_id: serv.workerId,
    serv_id: serv.servId,
  ).toJson();

  //
  // > check: is it in right state (not finished etc...)
  //
  if (ServiceState.added != serv.state) {
    return (serv.state, '');
  }
  //
  // > send Post
  //
  final urlAddress = '${wKey.activeServer}/add';

  return _commitUrl(urlAddress, body: body);
}