Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Response error -> Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
- import com.google.gson.annotations.Expose;
- import com.google.gson.annotations.SerializedName;
- import com.orm.SugarRecord;
- public class Repayment extends SugarRecord {
- @SerializedName("repaymentId")
- @Expose
- private Integer repaymentId;
- @SerializedName("loanId")
- @Expose
- private String loanId;
- @SerializedName("borrowerId")
- @Expose
- private String borrowerId;
- @SerializedName("amount_paid")
- @Expose
- private String amountPaid;
- @SerializedName("balanceOfLoan")
- @Expose
- private String balanceOfLoan;
- @SerializedName("created_at")
- @Expose
- private String createdAt;
- @SerializedName("updated_at")
- @Expose
- private String updatedAt;
- public Integer getRepaymentId() {
- return repaymentId;
- }
- public void setId(Integer repaymentId) {
- this.repaymentId = repaymentId;
- }
- public String getLoanId() {
- return loanId;
- }
- public void setLoanId(String loanId) {
- this.loanId = loanId;
- }
- public String getBorrowerId() {
- return borrowerId;
- }
- public void setBorrowerId(String borrowerId) {
- this.borrowerId = borrowerId;
- }
- public String getAmountPaid() {
- return amountPaid;
- }
- public void setAmountPaid(String amountPaid) {
- this.amountPaid = amountPaid;
- }
- public String getBalanceOfLoan() {
- return balanceOfLoan;
- }
- public void setBalanceOfLoan(String balanceOfLoan) {
- this.balanceOfLoan = balanceOfLoan;
- }
- public String getCreatedAt() {
- return createdAt;
- }
- public void setCreatedAt(String createdAt) {
- this.createdAt = createdAt;
- }
- public String getUpdatedAt() {
- return updatedAt;
- }
- public void setUpdatedAt(String updatedAt) {
- this.updatedAt = updatedAt;
- }
- }
- @GET("loan_balance")
- Call<Repayment> getCurrentLoanBalance();
- public void getBalance(){
- APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
- Call<Repayment> call = apiInterface.getCurrentLoanBalance();
- call.enqueue(new Callback<Repayment>() {
- @Override
- public void onResponse(Call<Repayment> call, Response<Repayment> response) {
- try {
- Utils.log("Response -> " + response.message());
- Repayment repayment = response.body();
- aQuery.id(R.id.loan_limit).text(repayment.getBalanceOfLoan());
- } catch (Exception e){
- Utils.log("Error retrieving repayment -> " + e.getMessage());
- }
- }
- @Override
- public void onFailure(Call<Repayment> call, Throwable t) {
- Utils.log("Response error -> " + t.getMessage());
- }
- });
- }
- implementation 'com.google.code.gson:gson:2.8.5'
- implementation 'com.squareup.okhttp:okhttp:1.3.0'
- implementation 'com.squareup.retrofit2:retrofit:2.3.0'
- implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement