put static method
Implementation
static Future<Map<String, dynamic>> put(String url, Object body, {Duration? timeout}) async {
var headers = {'Content-Type': "application/json"};
var requestUrl = _mBaseUrl + url;
if (getSessionToken() != null) {
headers["Authorization"] = "Bearer ${getSessionToken()}";
}
if (getAppId() != null) {
headers["app-id"] = getAppId()!;
}
try {
final effectiveTimeout = timeout ?? const Duration(seconds: 15);
final response = await Dio(BaseOptions(connectTimeout: const Duration(seconds: 10), receiveTimeout: effectiveTimeout)).put(requestUrl,
options: Options(headers: headers, receiveDataWhenStatusError: true),
data: jsonEncode(body));
if (response.statusCode! >= 200 && response.statusCode! < 300) {
return response.data;
}
throw HttpUtil.makeTPException(response);
} on DioException catch (e) {
if (e.response != null) {
throw HttpUtil.makeTPException(e.response);
}
throw TPException()..setCode(-1)..setMessage(e.message ?? e.type.name);
} catch(e){
rethrow;
}
}