Advertisement
Guest User

retrofitHelp

a guest
Sep 2nd, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. package me.danielhartman.retrofitexample;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5.  
  6. import java.util.List;
  7.  
  8. import model.Results;
  9. import retrofit.Call;
  10. import retrofit.Retrofit;
  11. import retrofit.http.GET;
  12. import retrofit.http.Headers;
  13.  
  14. public class MainActivity extends AppCompatActivity {
  15.  
  16. public interface myInterface{
  17. @Headers({
  18. "X-Parse-Application-Id:NNGfkEU1J9i5nWtJGY5EPhVdWAJrr86noDrDheyr",
  19. "X-Parse-REST-API-Key:LiVXTVok9mmWyYcuhd8eHpYpq9VLJZmyk4nJJGGW"
  20. })
  21. @GET("1/classes/Workout")
  22. Call<List<Results>> response();
  23. }
  24.  
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_main);
  29. Retrofit retrofit = new Retrofit.Builder()
  30. .baseUrl("https://api.parse.com")
  31. .build();
  32.  
  33. myInterface service = retrofit.create(myInterface.class);
  34. Call<List<Results>> repos = service.response();
  35. }
  36. }
  37.  
  38.  
  39. package model;
  40.  
  41. /**
  42. * Created by dphart9 on 9/2/2015.
  43. */
  44. public class Results {
  45.  
  46. private String createdAt;
  47. private String objectId;
  48. private String updatedAt;
  49. private String workoutName;
  50.  
  51. public String getCreatedAt() {
  52. return createdAt;
  53. }
  54.  
  55. public void setCreatedAt(String createdAt) {
  56. this.createdAt = createdAt;
  57. }
  58.  
  59. public String getObjectId() {
  60. return objectId;
  61. }
  62.  
  63. public void setObjectId(String objectId) {
  64. this.objectId = objectId;
  65. }
  66.  
  67. public String getUpdatedAt() {
  68. return updatedAt;
  69. }
  70.  
  71. public void setUpdatedAt(String updatedAt) {
  72. this.updatedAt = updatedAt;
  73. }
  74.  
  75. public String getWorkoutName() {
  76. return workoutName;
  77. }
  78.  
  79. public void setWorkoutName(String workoutName) {
  80. this.workoutName = workoutName;
  81. }
  82. }
  83.  
  84.  
  85.  
  86. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  87. What is returned when I do the API Call in python
  88. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  89. {
  90. "results": [
  91. {
  92. "createdAt": "2015-09-02T14:51:46.449Z",
  93. "objectId": "Hm82yMZf1t",
  94. "updatedAt": "2015-09-02T14:51:46.449Z",
  95. "workoutName": "workout One"
  96. }
  97. ]
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement