now method

Future<DateTime> now()

Get server's current timestamp

Implementation

Future<DateTime> now() async {
  final response =
      await kuzzle.query(KuzzleRequest(controller: name, action: 'now'));

  final result = response.result as Map<String, dynamic>?;

  if (result != null && result.containsKey('now')) {
    if (result['now'] is int) {
      return DateTime.fromMillisecondsSinceEpoch(result['now'] as int);
    }
  }

  throw BadResponseFormatError(
    response.error?.id,
    '$name.now: bad response format',
    response
  );
}