updateProfile static method

dynamic updateProfile({
  1. required String subscribername,
  2. String? dob,
  3. required String profilePin,
  4. String gender = "",
  5. String picture = "",
})

Implementation

static updateProfile({
  required String subscribername,
  String? dob,
  required String profilePin,
  String gender = "",
  String picture = "",
}) async {
  String url = "${AppUrls.baseUrlVSMS}/subscriberv2/v1/subscriber";

  dynamic body;
  if (picture.isNotEmpty) {
    body = {
      "subscribername": subscribername,
      "profilepin": profilePin,
      "dob": dob,
      "gender": gender.isEmpty ? null : gender,
      "picture": picture,
    };
  } else {
    body = {
      "subscribername": subscribername,
      "profilepin": profilePin,
      "dob": dob,
      "gender": gender.isEmpty ? null : gender,
    };
  }

  final response = await _dio!.put(url, data: body);
  if (response.statusCode == 200) {
    return response.data;
  } else {
    throw Exception("failed to update");
  }
}