TRON -> TRON_MAINNET
This commit is contained in:
@@ -163,3 +163,49 @@ Future<FileUploaded?> getFileUploadResponse(String service, String url, String f
|
||||
final streamedResponse = await _fileUploadRequest(service, url, fileName, fileType, mediaType, bytes, authToken: authToken);
|
||||
return FileUploaded.fromJson(await _handleResponse(http.Response.fromStream(streamedResponse)));
|
||||
}
|
||||
|
||||
class BinaryResponse {
|
||||
final List<int> bytes;
|
||||
final Map<String, String> headers;
|
||||
final int statusCode;
|
||||
|
||||
const BinaryResponse({
|
||||
required this.bytes,
|
||||
required this.headers,
|
||||
required this.statusCode,
|
||||
});
|
||||
|
||||
String? header(String key) => headers[key.toLowerCase()];
|
||||
}
|
||||
|
||||
Future<BinaryResponse> getBinaryGETResponse(String service, String url, {String? authToken}) async {
|
||||
late http.Response response;
|
||||
try {
|
||||
response = await getRequest(service, url, authToken: authToken);
|
||||
} catch (e) {
|
||||
throw ConnectivityError(message: e.toString());
|
||||
}
|
||||
|
||||
if (response.statusCode < 200 || response.statusCode >= 300) {
|
||||
late HTTPMessage message;
|
||||
try {
|
||||
message = HTTPMessage.fromJson(json.decode(response.body));
|
||||
} catch (e) {
|
||||
_throwConnectivityError(response, e);
|
||||
}
|
||||
|
||||
late ErrorResponse error;
|
||||
try {
|
||||
error = ErrorResponse.fromJson(message.data);
|
||||
} catch (e) {
|
||||
_throwConnectivityError(response, e);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
return BinaryResponse(
|
||||
bytes: response.bodyBytes,
|
||||
headers: response.headers,
|
||||
statusCode: response.statusCode,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user