package org.ntlab.acanthus_client.views.main_menu_ui.mypage.model;

import android.text.method.ReplacementTransformationMethod;

import androidx.lifecycle.MutableLiveData;

import org.ntlab.acanthus_client.Acanthus;
import org.ntlab.acanthus_client.databinding.ActivityAnimationBinding;
import org.ntlab.acanthus_client.entities.Account;
import org.ntlab.acanthus_client.resources.accounts.AccountsRest;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

//-----------------------------------------------------------------
// マイページ情報の通信API (Follow, Followerの取得時に本格的に使うかも)
public class MyPageInfoConnectionModel {

    private Acanthus acanthus;
    private Retrofit retrofit;

    //-----------------------------------------------------------------
    //-----------------------------------------------------------------
    //
    public MyPageInfoConnectionModel(Acanthus acanthus) {
        init(acanthus);
    }

    //-----------------------------------------------------------------
    //-----------------------------------------------------------------
    // アカウント情報の取得API
    public void getAccountByUid(MutableLiveData<String> mUidText) {
        final AccountsRest accountsRest = retrofit.create(AccountsRest.class);
        mUidText.setValue(acanthus.getPreferenceUid().toString());


        //Todo:　なんもわからん
//        String uid = acanthus.getPreferenceUid().toString();
//        String token = acanthus.getPreferenceToken();
//
//        Call<Account> call = accountsRest.getAccountByUid(uid, token);
//
//        call.enqueue(new Callback<Account>() {
//            @Override
//            public void onResponse(Call<Account> call, Response<Account> response) {
//                if (response.isSuccessful()) {
//                    Account resAccount = response.body();
//                    mUidText.setValue(acanthus.getPreferenceUid().toString());
//                }
//            }
//
//            @Override
//            public void onFailure(Call<Account> call, Throwable t) {
//
//            }
//        });
    }

    //-----------------------------------------------------------------
    //-----------------------------------------------------------------
    // init
    private void init(Acanthus acanthus) {
        this.acanthus = acanthus;
        this.retrofit = new Retrofit.Builder()
                .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/")
                .addConverterFactory(ScalarsConverterFactory.create())
                .addConverterFactory(JacksonConverterFactory.create())
                .build();
    }
    //-----------------------------------------------------------------


}
