submitKwikFormData static method

Future<Result> submitKwikFormData({
  1. required String phone,
  2. required String countryCode,
  3. required String address,
  4. required String name,
  5. required String gender,
  6. required String firstName,
  7. required String lastName,
  8. required String email,
  9. required bool consent,
})

Implementation

static Future<Result<dynamic>> submitKwikFormData({
  required String phone,
  required String countryCode,
  required String address,
  required String name,
  required String gender,
  required String firstName,
  required String lastName,
  required String email,
  required bool consent,
}) async {
  await checkKwikpassHealth();

  try {
    final gokwik = DioClient().getClient();

    gokwik.options.headers[cdnConfigInstance
        .getHeader(APIHeaderKeys.kpIntegrationType)!] = 'PLUGIN';

    final payload = {
      'phone': phone,
      'countryCode': countryCode,
      'address': address,
      'name': name,
      'gender': gender,
      'firstName': firstName,
      'lastName': lastName,
      'email': email,
      'consent': consent,
    };

    final response = await gokwik.post(
      cdnConfigInstance.getEndpoint(APIEndpointKeys.submitKwikFormData)!,
      data: payload,
    );

    return Success(response.data);
  } catch (err) {
    throw handleApiError(err);
  }
}