Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. Response error -> Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
  2.  
  3. import com.google.gson.annotations.Expose;
  4. import com.google.gson.annotations.SerializedName;
  5. import com.orm.SugarRecord;
  6.  
  7. public class Repayment extends SugarRecord {
  8.  
  9. @SerializedName("repaymentId")
  10. @Expose
  11. private Integer repaymentId;
  12. @SerializedName("loanId")
  13. @Expose
  14. private String loanId;
  15. @SerializedName("borrowerId")
  16. @Expose
  17. private String borrowerId;
  18. @SerializedName("amount_paid")
  19. @Expose
  20. private String amountPaid;
  21. @SerializedName("balanceOfLoan")
  22. @Expose
  23. private String balanceOfLoan;
  24. @SerializedName("created_at")
  25. @Expose
  26. private String createdAt;
  27. @SerializedName("updated_at")
  28. @Expose
  29. private String updatedAt;
  30.  
  31. public Integer getRepaymentId() {
  32. return repaymentId;
  33. }
  34.  
  35. public void setId(Integer repaymentId) {
  36. this.repaymentId = repaymentId;
  37. }
  38.  
  39. public String getLoanId() {
  40. return loanId;
  41. }
  42.  
  43. public void setLoanId(String loanId) {
  44. this.loanId = loanId;
  45. }
  46.  
  47. public String getBorrowerId() {
  48. return borrowerId;
  49. }
  50.  
  51. public void setBorrowerId(String borrowerId) {
  52. this.borrowerId = borrowerId;
  53. }
  54.  
  55. public String getAmountPaid() {
  56. return amountPaid;
  57. }
  58.  
  59. public void setAmountPaid(String amountPaid) {
  60. this.amountPaid = amountPaid;
  61. }
  62.  
  63. public String getBalanceOfLoan() {
  64. return balanceOfLoan;
  65. }
  66.  
  67. public void setBalanceOfLoan(String balanceOfLoan) {
  68. this.balanceOfLoan = balanceOfLoan;
  69. }
  70.  
  71. public String getCreatedAt() {
  72. return createdAt;
  73. }
  74.  
  75. public void setCreatedAt(String createdAt) {
  76. this.createdAt = createdAt;
  77. }
  78.  
  79. public String getUpdatedAt() {
  80. return updatedAt;
  81. }
  82.  
  83. public void setUpdatedAt(String updatedAt) {
  84. this.updatedAt = updatedAt;
  85. }
  86. }
  87.  
  88. @GET("loan_balance")
  89. Call<Repayment> getCurrentLoanBalance();
  90.  
  91. public void getBalance(){
  92.  
  93. APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
  94. Call<Repayment> call = apiInterface.getCurrentLoanBalance();
  95. call.enqueue(new Callback<Repayment>() {
  96. @Override
  97. public void onResponse(Call<Repayment> call, Response<Repayment> response) {
  98. try {
  99. Utils.log("Response -> " + response.message());
  100. Repayment repayment = response.body();
  101. aQuery.id(R.id.loan_limit).text(repayment.getBalanceOfLoan());
  102.  
  103. } catch (Exception e){
  104. Utils.log("Error retrieving repayment -> " + e.getMessage());
  105. }
  106. }
  107.  
  108. @Override
  109. public void onFailure(Call<Repayment> call, Throwable t) {
  110. Utils.log("Response error -> " + t.getMessage());
  111. }
  112. });
  113. }
  114.  
  115. implementation 'com.google.code.gson:gson:2.8.5'
  116. implementation 'com.squareup.okhttp:okhttp:1.3.0'
  117. implementation 'com.squareup.retrofit2:retrofit:2.3.0'
  118. implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement