sendEventMessage static method

Future<Response> sendEventMessage(
  1. String msgId,
  2. String status
)

Implementation

static Future<Response> sendEventMessage(
    String msgId, String status) async {
  if (kDebugMode) print('📡 sendEventMessage: enviando evento "$status" para messageId $msgId');
  final pref = await SharedPreferences.getInstance();
  MessageRequest request = MessageRequest(
      type: "event",
      messageId: msgId,
      data: MessageRequestData(status: status),
      metadata: MessageRequestMetadata(idTemp: const Uuid().v4()),
      createdAt: DateTime.now().toUtc().millisecondsSinceEpoch,
      senderId: pref.getString(IdentifierType.userId.name),
      sessionUuid: pref.getString(IdentifierType.sessionId.name),
      recipinetId: "HOOK",
      integrationId: pref.getString(IdentifierType.integrationId.name));
  var encoded = request.toJson();
  if (kDebugMode) print('📡 sendEventMessage: payload — ${jsonEncode(encoded)}');
  var response = await ApiManager.post(
      '${SocketUrls.baseBrokerEndpoint}${SocketUrls.sendMessageEndpoint}',
      body: jsonEncode(encoded));
  if (kDebugMode) print('📡 sendEventMessage: respuesta — statusCode: ${response.statusCode}, body: ${response.body}');
  return response;
}