Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. package me.rabrg.imgur;
  2.  
  3. import me.rabrg.imgur.response.Image;
  4. import me.rabrg.imgur.service.ImageService;
  5. import retrofit.RequestInterceptor;
  6. import retrofit.RestAdapter;
  7.  
  8. public class ImgurApi {
  9.  
  10. private final RestAdapter restAdapter;
  11. private final ImageService imageService;
  12.  
  13. public ImgurApi(final String clientId) {
  14. this.restAdapter = new RestAdapter.Builder().setEndpoint("https://api.imgur.com/3").setRequestInterceptor(new RequestInterceptor() {
  15. @Override
  16. public void intercept(final RequestFacade request) {
  17. request.addHeader("Authorization", "Client-ID " + clientId);
  18. }
  19. }).build();
  20.  
  21. this.imageService = restAdapter.create(ImageService.class);
  22. }
  23.  
  24. public Image getImage(final String id) {
  25. return imageService.getImage(id);
  26. }
  27. }
  28.  
  29. package me.rabrg.imgur.service;
  30.  
  31. import me.rabrg.imgur.response.Image;
  32. import retrofit.http.POST;
  33. import retrofit.http.Path;
  34.  
  35. public interface ImageService {
  36.  
  37. @POST("/image/{id}")
  38. Image getImage(@Path("id") String id);
  39. }
  40.  
  41. new ImgurApi(clientId).getImage(id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement