create method

Future<List<QBEvent?>> create(
  1. String type,
  2. String notificationType,
  3. int senderId,
  4. Map<String, Object> payload, {
  5. int? id,
  6. bool? active,
  7. String? name,
  8. int? pushType,
  9. double? date,
  10. int? endDate,
  11. String? period,
  12. int? occuredCount,
  13. List<String>? recipientsIds,
  14. List<String>? recipientsTagsAny,
  15. List<String>? recipientsTagsAll,
  16. List<String>? recipientsTagsExclude,
})

Implementation

Future<List<QBEvent?>> create(String type, String notificationType,
    int senderId, Map<String, Object> payload,
    {int? id,
    bool? active,
    String? name,
    int? pushType,
    double? date,
    int? endDate,
    String? period,
    int? occuredCount,
    List<String>? recipientsIds,
    List<String>? recipientsTagsAny,
    List<String>? recipientsTagsAll,
    List<String>? recipientsTagsExclude}) async {
  Map<String, Object> data = Map();

  data["type"] = type;
  data["notificationType"] = notificationType;
  data["senderId"] = senderId;
  data["payload"] = payload;

  if (id != null) {
    data["id"] = id;
  }
  if (active != null) {
    data["active"] = active;
  }
  if (name != null) {
    data["name"] = name;
  }
  if (pushType != null) {
    data["pushType"] = pushType;
  }
  if (date != null) {
    data["date"] = date;
  }
  if (endDate != null) {
    data["endDate"] = endDate;
  }
  if (period != null) {
    data["period"] = period;
  }
  if (occuredCount != null) {
    data["occuredCount"] = occuredCount;
  }
  if (recipientsIds != null) {
    data["recipientsIds"] = recipientsIds;
  }
  if (recipientsTagsAny != null) {
    data["recipientsTagsAny"] = recipientsTagsAny;
  }
  if (recipientsTagsAll != null) {
    data["recipientsTagsAll"] = recipientsTagsAll;
  }
  if (recipientsTagsExclude != null) {
    data["recipientsTagsExclude"] = recipientsTagsExclude;
  }

  List<Object?> list =
      await _notificationModule.invokeMethod(CREATE_METHOD, data);

  List<QBEvent?> eventsList = [];

  for (final item in list) {
    QBEvent? event =
        QBEventMapper.mapToQBEvent(item as Map<dynamic, dynamic>);
    eventsList.add(event);
  }

  return eventsList;
}