Search in sources :

Example 1 with AccountApi

use of com.funstill.kelefun.data.api.AccountApi in project keleFanfou by kelefun.

the class AccountService method getUserInfo.

/**
 * @param auth 用户 Id
 */
public UserInfo getUserInfo(OAuthToken auth) {
    Retrofit retrofit = BaseRetrofit.retrofit(new SignInterceptor());
    AccountApi api = retrofit.create(AccountApi.class);
    Call<ResponseBody> call = api.verifyCred();
    try {
        Response<ResponseBody> response = call.execute();
    // LogHelper.d(response.body().string());
    } catch (Exception e) {
        // TODO handle errors
        e.printStackTrace();
        LogHelper.e(e.getMessage());
    }
    return null;
}
Also used : BaseRetrofit(com.funstill.kelefun.http.BaseRetrofit) Retrofit(retrofit2.Retrofit) AccountApi(com.funstill.kelefun.data.api.AccountApi) SignInterceptor(com.funstill.kelefun.http.SignInterceptor) ResponseBody(okhttp3.ResponseBody)

Example 2 with AccountApi

use of com.funstill.kelefun.data.api.AccountApi in project keleFanfou by kelefun.

the class AccountService method saveUserInfo.

public void saveUserInfo(Context mContext) {
    Retrofit retrofit = BaseRetrofit.retrofit(new SignInterceptor());
    AccountApi api = retrofit.create(AccountApi.class);
    Call<UserInfo> call = api.verifyCred();
    try {
        UserInfo userInfo = call.execute().body();
        new AccountStore(mContext).saveAccount(userInfo);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : BaseRetrofit(com.funstill.kelefun.http.BaseRetrofit) Retrofit(retrofit2.Retrofit) AccountApi(com.funstill.kelefun.data.api.AccountApi) AccountStore(com.funstill.kelefun.config.AccountStore) SignInterceptor(com.funstill.kelefun.http.SignInterceptor) UserInfo(com.funstill.kelefun.data.model.UserInfo) IOException(java.io.IOException)

Aggregations

AccountApi (com.funstill.kelefun.data.api.AccountApi)2 BaseRetrofit (com.funstill.kelefun.http.BaseRetrofit)2 SignInterceptor (com.funstill.kelefun.http.SignInterceptor)2 Retrofit (retrofit2.Retrofit)2 AccountStore (com.funstill.kelefun.config.AccountStore)1 UserInfo (com.funstill.kelefun.data.model.UserInfo)1 IOException (java.io.IOException)1 ResponseBody (okhttp3.ResponseBody)1