Попробуйте следующим образом .. сделать модифицированный объект ..
public class ApiClient {
private final static String BASE_URL = "http://api.cuidadotechnologies.com/NSSPL/";
public static ApiClient apiClient;
private Retrofit retrofit = null;
public static ApiClient getInstance() {
if (apiClient == null) {
apiClient = new ApiClient();
}
return apiClient;
}
//private static Retrofit storeRetrofit = null;
public Retrofit getClient() {
return getClient(null);
}
private Retrofit getClient(final Context context) {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.readTimeout(60, TimeUnit.SECONDS);
client.writeTimeout(60, TimeUnit.SECONDS);
client.connectTimeout(60, TimeUnit.SECONDS);
client.addInterceptor(interceptor);
client.addInterceptor(new Interceptor() {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
Request request = chain.request();
return chain.proceed(request);
}
});
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client.build())
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
}
создать интерфейс для вызова API.
public interface ApiInterface {
@GET("leave_dtls.php")
Call<ResponseData> getData();
}
сделать класс pojo для ответа.
public class ResponseDataItem{
@SerializedName("Status")
private String status;
@SerializedName("uid")
private String uid;
@SerializedName("reason")
private String reason;
@SerializedName("ApprovedDate")
private String approvedDate;
@SerializedName("Remarks")
private String remarks;
@SerializedName("ApprovedBy")
private String approvedBy;
@SerializedName("id")
private String id;
@SerializedName("type")
private String type;
@SerializedName("EndDate")
private String endDate;
@SerializedName("SataDate")
private String sataDate;
public void setStatus(String status){
this.status = status;
}
public String getStatus(){
return status;
}
public void setUid(String uid){
this.uid = uid;
}
public String getUid(){
return uid;
}
public void setReason(String reason){
this.reason = reason;
}
public String getReason(){
return reason;
}
public void setApprovedDate(String approvedDate){
this.approvedDate = approvedDate;
}
public String getApprovedDate(){
return approvedDate;
}
public void setRemarks(String remarks){
this.remarks = remarks;
}
public String getRemarks(){
return remarks;
}
public void setApprovedBy(String approvedBy){
this.approvedBy = approvedBy;
}
public String getApprovedBy(){
return approvedBy;
}
public void setId(String id){
this.id = id;
}
public String getId(){
return id;
}
public void setType(String type){
this.type = type;
}
public String getType(){
return type;
}
public void setEndDate(String endDate){
this.endDate = endDate;
}
public String getEndDate(){
return endDate;
}
public void setSataDate(String sataDate){
this.sataDate = sataDate;
}
public String getSataDate(){
return sataDate;
}
}
окончательный ответ ..
public class ResponseData {
@SerializedName("response_data")
private List<ResponseDataItem> responseData;
@SerializedName("status")
private int status;
public void setResponseData(List<ResponseDataItem> responseData){
this.responseData = responseData;
}
public List<ResponseDataItem> getResponseData(){
return responseData;
}
public void setStatus(int status){
this.status = status;
}
public int getStatus(){
return status;
}
}
вызвал api во фрагмент или активность, подобную этому ..
ApiInterface apiInterface = ApiClient.getInstance().getClient().create(ApiInterface.class);
Call<ResponseData> responseDataCall=apiInterface.getData();
responseDataCall.enqueue(new Callback<ResponseData>() {
@Override
public void onResponse(Call<ResponseData> call, Response<ResponseData> response) {
if (response.isSuccessful() && response.body()!=null && response!=null){
List<ResponseDataItem> data=response.body().getResponseData();
}
}
@Override
public void onFailure(Call<ResponseData> call, Throwable t) {
t.printStackTrace();
}
});