buildGraphQLInlineObject method

String buildGraphQLInlineObject(
  1. List<CollectPaymentModeList>? value
)

Implementation

String buildGraphQLInlineObject(List<submit.CollectPaymentModeList>? value) {
  if (value == null || value.isEmpty) return '[]';

  final items = value.map((mode) {
    final collections = mode.collection?.map((outerList) {
      final payments = outerList.map((payment) {
        return '''{
        id: "${payment.id}",
        value: "${payment.value}",
        amount: ${payment.amount},
        formatAmount: ${payment.formatAmount},
        label: "${payment.label}",
        fieldMappingKey: "${payment.fieldMappingKey}",
        fieldType: "${payment.fieldType}"
      }''';
      }).join(',');

      return '[$payments]';
    }).join(',');

    return '''{
    id: "${mode.id}",
    collection: [$collections]
  }''';
  }).join(',');

  return '[$items]';
}