editAddress method

Future editAddress(
  1. AddressModel addressModel
)

Implementation

Future editAddress(AddressModel addressModel) async {
  http.Response response;

  SharedPreferencesService sharedPreferencesService = await SharedPreferencesService.getInstance();

  try {
    final data = addressModel.postData();
    String addressId = addressModel.id!;
    var currentUserId = await sharedPreferencesService.getUserId();
    var token = await sharedPreferencesService.getToken();
    response = await postHttp(
      "/user/$currentUserId/address/$addressId",
      token,
      data,
    );
    if (response.statusCode == 200) {
      return json.decode(response.body);
    }
  } catch (e) {
    throw Exception("Address couldn't be edited");
  }
}