setCardLimit static method

Future setCardLimit(
  1. List<Map<String, dynamic>> payload,
  2. String env,
  3. String authToken,
  4. String cardNumber,
)

*********** UPDATE CARD LIMITS FLAGS ***************

Implementation

static Future<dynamic> setCardLimit(List<Map<String, dynamic>> payload, String env, String authToken, String cardNumber) async {
  String url = getBaseUrl(env) +"issuance/v1/cards/$cardNumber/v2/limits";
  try {
    final response = await Card91HttpMethods.putMethods(jsonEncode(payload), url, authToken, "", "")
        .timeout(const Duration(seconds: 70));
    log("response1 update card--->${response.body}");
    if (response.statusCode >= 200 && response.statusCode <= 299) {
      Map<String, dynamic> jsonData = jsonDecode(response.body);
      return card91ResponseBodyToJson(new Card91ResponseBody(success: true, headers: response.headers, data: jsonData));
    } else {
      Map<String, dynamic> jsonData = jsonDecode(response.body);
      Map<String, dynamic> jsonDataHeader = jsonDecode("{}");
      return card91ResponseBodyToJson(new Card91ResponseBody(success: false, headers: jsonDataHeader, data: jsonData));
    }
  } on SocketException {
    Map<String, dynamic> jsonData = jsonDecode('{"message": "Internet or Socket Exception"}');
    Map<String, dynamic> jsonDataHeader = jsonDecode("{}");
    return card91ResponseBodyToJson(new Card91ResponseBody(success: false, headers: jsonDataHeader, data: jsonData));
    throw ('noInternetConnection'.tr);
  } on HandshakeException {
    Map<String, dynamic> jsonData = jsonDecode('{"message":"Handshake Exception"}');
    Map<String, dynamic> jsonDataHeader = jsonDecode("{}");
    return card91ResponseBodyToJson(new Card91ResponseBody(success: false, headers: jsonDataHeader, data: jsonData));
    throw ("No internet");
  }
}