github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/java/libraries/okhttp-gson/ApiCallback.mustache (about) 1 {{>licenseInfo}} 2 3 package {{invokerPackage}}; 4 5 import java.io.IOException; 6 7 import java.util.Map; 8 import java.util.List; 9 10 /** 11 * Callback for asynchronous API call. 12 * 13 * @param <T> The return type 14 */ 15 public interface ApiCallback<T> { 16 /** 17 * This is called when the API call fails. 18 * 19 * @param e The exception causing the failure 20 * @param statusCode Status code of the response if available, otherwise it would be 0 21 * @param responseHeaders Headers of the response if available, otherwise it would be null 22 */ 23 void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders); 24 25 /** 26 * This is called when the API call succeeded. 27 * 28 * @param result The result deserialized from response 29 * @param statusCode Status code of the response 30 * @param responseHeaders Headers of the response 31 */ 32 void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders); 33 34 /** 35 * This is called when the API upload processing. 36 * 37 * @param bytesWritten bytes Written 38 * @param contentLength content length of request body 39 * @param done write end 40 */ 41 void onUploadProgress(long bytesWritten, long contentLength, boolean done); 42 43 /** 44 * This is called when the API downlond processing. 45 * 46 * @param bytesRead bytes Read 47 * @param contentLength content lenngth of the response 48 * @param done Read end 49 */ 50 void onDownloadProgress(long bytesRead, long contentLength, boolean done); 51 }