SlideShare a Scribd company logo
1 of 12
Download to read offline
Retrofit

- REST client abstraction based on OkHttp
(HTTP client for Android)
- by Square (Jake Wharton)
Retrofit
●

Turns yor REST API into a Java interface
Retrofit example
●

Twitter API

●

Obtain token
Twitter – obtain token request
●

Host: https://api.twitter.com

●

POST /oauth2/token

●

Headers
–
–

●

Authorization: base64 encoded consumer key +
consumer secret
Content-Type: application/x-www-form-urlencoded;
charset=UTF-8

Body: “grant_type=client_credentials”
Twitter – obtain token response
{"token_type":"bearer","access_token":"AAAAAAAAAAAAAAAAAAAAA
DryUgAAAAAAzGlUwrr%2B7WL%2FWUvOMLdsQapBr9w
%3DVdxZkBQC1tfFSRFrs8J2AklGAJO9xxuo6tMz0t7wUDo2nV3NIn"}
Retrofit
public interface TwitterService {
@FormUrlEncoded
@POST("/oauth2/token")
TwitterTokenType getToken(
@Header("Authorization") String authorization,
@Field("grant_type") String grantType
);
}
Retrofit - async
@FormUrlEncoded
@POST("/oauth2/token")
void getToken(
@Header("Authorization") String authorization,
@Field("grant_type") String grantType,
Callback<TwitterTokenType> response
);
Retrofit – initialize service
RestAdapter.Log log = new RestAdapter.Log() {
@Override
public void log(String s) {
Log.d("DARIO", s);
}
};
RestAdapter restAdapter = new RestAdapter.Builder()
.setServer(Constants.TWITTER_API_URL)
.setLog(log)
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
service = restAdapter.create(TwitterService.class);
Retrofit – send request

service.getToken("Basic " +
getBase64String(Constants.BEARER_TOKEN_CREDENTIALS),
"client_credentials", callback);
Retrofit - callback
private Callback<TwitterTokenType> callback = new
Callback<TwitterTokenType>() {
@Override
public void success(TwitterTokenType token, Response response) {
Toast.makeText(HomeActivity.this, token.getAccessToken(),
Toast.LENGTH_LONG).show();
}
@Override
public void failure(RetrofitError retrofitError) {
Toast.makeText(HomeActivity.this, "Retrofit error",
Toast.LENGTH_SHORT).show();
}
};
Retrofit - GET
@GET("/1.1/statuses/user_timeline.json")
void getUserTimeline(
@Header("Authorization") String authorization,
@Query("count") int count,
@Query("screen_name") String screenName,
Callback<Object> response
);
Retrofit exampel on Github
●

https://github.com/infinum/RetrofitExample

More Related Content

Viewers also liked

Retrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saberRetrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saberBruno Vieira
 
Retrofit
RetrofitRetrofit
Retrofitbresiu
 
Android word press + woocommerce rest api
Android word press + woocommerce rest apiAndroid word press + woocommerce rest api
Android word press + woocommerce rest apiJose Berna
 
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API 안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API Gosu Ok
 
大鱼架构演进
大鱼架构演进大鱼架构演进
大鱼架构演进Jun Liu
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Andres Almiray
 
Open api개발을 위한 자료1
Open api개발을 위한 자료1Open api개발을 위한 자료1
Open api개발을 위한 자료1도성 김
 
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기Manjong Han
 
[D2 오픈세미나]4.네이티브앱저장통신
[D2 오픈세미나]4.네이티브앱저장통신[D2 오픈세미나]4.네이티브앱저장통신
[D2 오픈세미나]4.네이티브앱저장통신NAVER D2
 
Seismic retrofit methods
Seismic retrofit methodsSeismic retrofit methods
Seismic retrofit methodsPaul McMullin
 
Staying Afloat with Buoy: A High-Performance HTTP Client
Staying Afloat with Buoy: A High-Performance HTTP ClientStaying Afloat with Buoy: A High-Performance HTTP Client
Staying Afloat with Buoy: A High-Performance HTTP Clientlpgauth
 
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...Brian Campbell
 

Viewers also liked (13)

Retrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saberRetrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saber
 
Retrofit
RetrofitRetrofit
Retrofit
 
Android word press + woocommerce rest api
Android word press + woocommerce rest apiAndroid word press + woocommerce rest api
Android word press + woocommerce rest api
 
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API 안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
 
大鱼架构演进
大鱼架构演进大鱼架构演进
大鱼架构演进
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
Open api개발을 위한 자료1
Open api개발을 위한 자료1Open api개발을 위한 자료1
Open api개발을 위한 자료1
 
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
 
[D2 오픈세미나]4.네이티브앱저장통신
[D2 오픈세미나]4.네이티브앱저장통신[D2 오픈세미나]4.네이티브앱저장통신
[D2 오픈세미나]4.네이티브앱저장통신
 
Seismic retrofit methods
Seismic retrofit methodsSeismic retrofit methods
Seismic retrofit methods
 
Staying Afloat with Buoy: A High-Performance HTTP Client
Staying Afloat with Buoy: A High-Performance HTTP ClientStaying Afloat with Buoy: A High-Performance HTTP Client
Staying Afloat with Buoy: A High-Performance HTTP Client
 
OAuth2.0
OAuth2.0OAuth2.0
OAuth2.0
 
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
 

More from Denis_infinum

Infinum Android Talks #04 - Google Maps Android API utility library
Infinum Android Talks #04 - Google Maps Android API utility libraryInfinum Android Talks #04 - Google Maps Android API utility library
Infinum Android Talks #04 - Google Maps Android API utility libraryDenis_infinum
 
Infinum Android Talks #04 - Android Lint
Infinum Android Talks #04 - Android LintInfinum Android Talks #04 - Android Lint
Infinum Android Talks #04 - Android LintDenis_infinum
 
Infinum Android Talks #04 - CouchBase Lite
Infinum Android Talks #04 - CouchBase LiteInfinum Android Talks #04 - CouchBase Lite
Infinum Android Talks #04 - CouchBase LiteDenis_infinum
 
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...Denis_infinum
 
Android Talks #3 Android Design Best Practices - for Designers and Developers
Android Talks #3 Android Design Best Practices - for Designers and DevelopersAndroid Talks #3 Android Design Best Practices - for Designers and Developers
Android Talks #3 Android Design Best Practices - for Designers and DevelopersDenis_infinum
 
Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...
Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...
Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...Denis_infinum
 

More from Denis_infinum (6)

Infinum Android Talks #04 - Google Maps Android API utility library
Infinum Android Talks #04 - Google Maps Android API utility libraryInfinum Android Talks #04 - Google Maps Android API utility library
Infinum Android Talks #04 - Google Maps Android API utility library
 
Infinum Android Talks #04 - Android Lint
Infinum Android Talks #04 - Android LintInfinum Android Talks #04 - Android Lint
Infinum Android Talks #04 - Android Lint
 
Infinum Android Talks #04 - CouchBase Lite
Infinum Android Talks #04 - CouchBase LiteInfinum Android Talks #04 - CouchBase Lite
Infinum Android Talks #04 - CouchBase Lite
 
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
 
Android Talks #3 Android Design Best Practices - for Designers and Developers
Android Talks #3 Android Design Best Practices - for Designers and DevelopersAndroid Talks #3 Android Design Best Practices - for Designers and Developers
Android Talks #3 Android Design Best Practices - for Designers and Developers
 
Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...
Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...
Infinum iOS Talks S01E02 - Things every iOS developer should know about Core ...
 

Recently uploaded

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 

Recently uploaded (20)

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 

Infinum Android talks 2013-11-28 - Retrofit

  • 1. Retrofit - REST client abstraction based on OkHttp (HTTP client for Android) - by Square (Jake Wharton)
  • 2. Retrofit ● Turns yor REST API into a Java interface
  • 4. Twitter – obtain token request ● Host: https://api.twitter.com ● POST /oauth2/token ● Headers – – ● Authorization: base64 encoded consumer key + consumer secret Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Body: “grant_type=client_credentials”
  • 5. Twitter – obtain token response {"token_type":"bearer","access_token":"AAAAAAAAAAAAAAAAAAAAA DryUgAAAAAAzGlUwrr%2B7WL%2FWUvOMLdsQapBr9w %3DVdxZkBQC1tfFSRFrs8J2AklGAJO9xxuo6tMz0t7wUDo2nV3NIn"}
  • 6. Retrofit public interface TwitterService { @FormUrlEncoded @POST("/oauth2/token") TwitterTokenType getToken( @Header("Authorization") String authorization, @Field("grant_type") String grantType ); }
  • 7. Retrofit - async @FormUrlEncoded @POST("/oauth2/token") void getToken( @Header("Authorization") String authorization, @Field("grant_type") String grantType, Callback<TwitterTokenType> response );
  • 8. Retrofit – initialize service RestAdapter.Log log = new RestAdapter.Log() { @Override public void log(String s) { Log.d("DARIO", s); } }; RestAdapter restAdapter = new RestAdapter.Builder() .setServer(Constants.TWITTER_API_URL) .setLog(log) .setLogLevel(RestAdapter.LogLevel.FULL) .build(); service = restAdapter.create(TwitterService.class);
  • 9. Retrofit – send request service.getToken("Basic " + getBase64String(Constants.BEARER_TOKEN_CREDENTIALS), "client_credentials", callback);
  • 10. Retrofit - callback private Callback<TwitterTokenType> callback = new Callback<TwitterTokenType>() { @Override public void success(TwitterTokenType token, Response response) { Toast.makeText(HomeActivity.this, token.getAccessToken(), Toast.LENGTH_LONG).show(); } @Override public void failure(RetrofitError retrofitError) { Toast.makeText(HomeActivity.this, "Retrofit error", Toast.LENGTH_SHORT).show(); } };
  • 11. Retrofit - GET @GET("/1.1/statuses/user_timeline.json") void getUserTimeline( @Header("Authorization") String authorization, @Query("count") int count, @Query("screen_name") String screenName, Callback<Object> response );
  • 12. Retrofit exampel on Github ● https://github.com/infinum/RetrofitExample