Class ApiResponse<T>
- java.lang.Object
-
- com.cadiducho.telegrambotapi.util.ApiResponse<T>
-
- Type Parameters:
T
- Type of the result
public class ApiResponse<T> extends Object
A container that parse an API response- Author:
- Cadiducho
-
-
Constructor Summary
Constructors Constructor Description ApiResponse()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> ApiResponse<T>
from(String source, Type resultType)
Create an ApiResponse object from a Stringstatic <T> ApiResponse<T>
from(okio.BufferedSource source, Type resultType)
Create an ApiResponse object from a BufferedSourceString
toJson()
Serialize this response to json
-
-
-
Method Detail
-
toJson
public String toJson()
Serialize this response to json- Returns:
- String that contains the serialized response
-
from
public static <T> ApiResponse<T> from(String source, Type resultType) throws IOException
Create an ApiResponse object from a String- Type Parameters:
T
- Type of the result- Parameters:
source
- String fetched from the APIresultType
- Class of the result- Returns:
- An ApiResponse object with that data
- Throws:
IOException
- If Moshi fails
-
from
public static <T> ApiResponse<T> from(okio.BufferedSource source, Type resultType) throws IOException
Create an ApiResponse object from a BufferedSource- Type Parameters:
T
- Type of the result- Parameters:
source
- String fetched from the APIresultType
- Class of the result- Returns:
- An ApiResponse object with that data
- Throws:
IOException
- If Moshi fails
-
-