/*
 * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
 */
package kr.co.zumo.app.lifeplus.network.api;

import com.google.gson.Gson;

import io.reactivex.Single;
import kr.co.zumo.app.lifeplus.bean.api.AuthConfirmRequestBean;
import kr.co.zumo.app.lifeplus.bean.api.AuthRequestBean;
import kr.co.zumo.app.lifeplus.bean.api.FAQResultBean;
import kr.co.zumo.app.lifeplus.bean.api.LifeplusAPIBean;
import kr.co.zumo.app.lifeplus.bean.api.LoginResultBean;
import kr.co.zumo.app.lifeplus.bean.api.MemberJoinRequestBean;
import kr.co.zumo.app.lifeplus.bean.api.MemberJoinResultBean;
import kr.co.zumo.app.lifeplus.bean.api.PolicyConfirmRequestBean;
import kr.co.zumo.app.lifeplus.bean.api.PolicyResultBean;
import kr.co.zumo.app.lifeplus.bean.api.RequestBean;
import kr.co.zumo.app.lifeplus.bean.api.UserNoBean;

/**
 * LifeplusAPIService
 * <pre>
 * </pre>
 *
 * @author 민효동
 * @version 1.0
 * @history 민효동   [2018. 9. 19.]   [최초 작성]
 * @since 2018. 9. 19.
 */
public class LifeplusAPIService implements LifeplusAPI {

  @Override
  public Single<LifeplusAPIBean> requestMobileAuth(AuthRequestBean bean) {
    return Single.fromCallable(() -> new LifeplusAPIBean(LifeplusAPIBean.RETURN_SUCCESS, ""));
  }

  @Override
  public Single<LifeplusAPIBean> confirmMobileAuth(AuthConfirmRequestBean bean) {
    return Single.fromCallable(() -> {
      return new LifeplusAPIBean(LifeplusAPIBean.RETURN_SUCCESS, "");
//      return new LifeplusAPIBean(LifeplusAPIBean.RETURN_MOBILE_AUTH_ERROR_NEED_FOR_30_DAYS, "");
//      return new LifeplusAPIBean(LifeplusAPIBean.RETURN_MOBILE_AUTH_ERROR_ALREADY_MEMBER, "");
//      return new LifeplusAPIBean(LifeplusAPIBean.RETURN_MOBILE_AUTH_ERROR_UNDER_14_YEARS, "");
    });
  }

  @Override
  public Single<PolicyResultBean> getPolicyList(RequestBean bean) {
    return Single.fromCallable(() -> {
      String result = "{\n" +
        "      \"data\": [\n" +
        "        {\n" +
        "          \"isChecked\": false,\n" +
        "          \"mandatory\": true,\n" +
        "          \"title\": \"Lifeplus 서비스 이용약관 동의\",\n" +
        "          \"link_url\": \"http://m.naver.com\",\n" +
        "          \"type_cd\": 1,\n" +
        "          \"version\": 1\n" +
        "        },\n" +
        "        {\n" +
        "          \"isChecked\": false,\n" +
        "          \"mandatory\": true,\n" +
        "          \"title\": \"개인정보 수집 및 활용 동의\",\n" +
        "          \"link_url\": \"http://m.naver.com\",\n" +
        "          \"type_cd\": 2,\n" +
        "          \"version\": 1\n" +
        "        },\n" +
        "        {\n" +
        "          \"isChecked\": false,\n" +
        "          \"mandatory\": false,\n" +
        "          \"title\": \"개인정보 수집 및 활용 동의\",\n" +
        "          \"link_url\": \"http://m.naver.com\",\n" +
        "          \"type_cd\": 3,\n" +
        "          \"version\": 1\n" +
        "        },\n" +
        "        {\n" +
        "          \"isChecked\": false,\n" +
        "          \"mandatory\": false,\n" +
        "          \"title\": \"제휴사 서비스 이용을 위한 개인정보 수집 및 활용 동의\",\n" +
        "          \"link_url\": \"http://m.naver.com\",\n" +
        "          \"type_cd\": 4,\n" +
        "          \"version\": 1\n" +
        "        },\n" +
        "        {\n" +
        "          \"isChecked\": false,\n" +
        "          \"mandatory\": false,\n" +
        "          \"title\": \"위치기반 서비스 이용 동의\",\n" +
        "          \"link_url\": \"http://m.naver.com\",\n" +
        "          \"type_cd\": 5,\n" +
        "          \"version\": 1\n" +
        "        },\n" +
        "        {\n" +
        "          \"isChecked\": false,\n" +
        "          \"mandatory\": false,\n" +
        "          \"title\": \"마케팅 정보 수집 동의\",\n" +
        "          \"link_url\": \"http://m.naver.com\",\n" +
        "          \"type_cd\": 6,\n" +
        "          \"version\": 1\n" +
        "        }\n" +
        "      ],\n" +
        "      \"sp_rtn\": 0\n" +
        "    }\n";

      return new Gson().fromJson(result, PolicyResultBean.class);
    });
  }

  @Override
  public Single<LifeplusAPIBean> confirmPolicy(PolicyConfirmRequestBean bean) {
    return Single.fromCallable(() -> new LifeplusAPIBean(LifeplusAPIBean.RETURN_SUCCESS, ""));
  }

  @Override
  public Single<MemberJoinResultBean> insertMember(MemberJoinRequestBean bean) {
    return Single.fromCallable(() -> {
      String result = "{\n" +
        "  \"sp_rtn\":0,\n" +
        "  \"rtn_message\":\"성공\",\n" +
        "  \"data\": [{\"user_no\": \"201810050000000007\",\n" +
        "            \"user_name\": \"나나나\",\n" +
        "            \"mail_id\": \"naananan@gmail.com\",\n" +
        "            \"memr_stat_cd\": \"000\",\n" +
        "            \"lock_stat_cd\": \"000\"}]\n" +
        "}";

      return new Gson().fromJson(result, MemberJoinResultBean.class);
    });
  }

  @Override
  public Single<LifeplusAPIBean> deleteMember(UserNoBean bean) {
    return Single.fromCallable(() -> new LifeplusAPIBean(LifeplusAPIBean.RETURN_SUCCESS, ""));
  }

  @Override
  public Single<FAQResultBean> getFaqList(RequestBean bean) {
    return Single.fromCallable(() -> {
      String result = "{\n" +
        "      \"data\": [\n" +
        "        {\n" +
        "          \"cate\": \"기타\",\n" +
        "          \"faq_contents\": \"Transportation, especially to medical appointments and procedures, is a popular home care service. It can often be arranged in a few hours, but the more notice given is always better. A regular planned schedule can be set up, or the caregiver can be used on an “as needed” basis.\",\n" +
        "          \"reg_dt\": \"2018-09-28\",\n" +
        "          \"id\": 6,\n" +
        "          \"faq_title\": \"Will Washington Senior Home Care Send Someone To Cook And Clean Or Help Around The House?\"\n" +
        "        },\n" +
        "        {\n" +
        "          \"cate\": \"혜택\",\n" +
        "          \"faq_contents\": \"Home health is covered 100% by Medicare, and we accept most forms of insurance. Part of the admission process includes verification of insurance. We can help answer your financial and insurance questions.\",\n" +
        "          \"reg_dt\": \"2018-09-28\",\n" +
        "          \"id\": 5,\n" +
        "          \"faq_title\": \"Will My Insurance Cover Home Health Services?\"\n" +
        "        },\n" +
        "        {\n" +
        "          \"cate\": \"회원\",\n" +
        "          \"faq_contents\": \"Your state’s Medicaid program or your private insurance may cover home health care. Check with your state Medicaid program or insurance company to learn about their specific eligibility requirements.\",\n" +
        "          \"reg_dt\": \"2018-09-28\",\n" +
        "          \"id\": 4,\n" +
        "          \"faq_title\": \"Who pays for Home Health care services?\"\n" +
        "        },\n" +
        "        {\n" +
        "          \"cate\": \"회원\",\n" +
        "          \"faq_contents\": \"On the first visit, a nurse or therapist will conduct an initial assessment. At Washington Senior Home Care, this thorough interview and professional assessment is part of our coordinated approach to managing your overall health status. Our assessment focuses on identifying areas where you may benefit from education in self-care management and partners with your doctor to promote disease prevention, in addition, to providing hands-on intervention – which includes the family or caregivers.\",\n" +
        "          \"reg_dt\": \"2018-09-28\",\n" +
        "          \"id\": 3,\n" +
        "          \"faq_title\": \"What can I expect on the first Home Health care visit?\"\n" +
        "        },\n" +
        "        {\n" +
        "          \"cate\": \"회원\",\n" +
        "          \"faq_contents\": \"The difference between home health and personal home care assistance is the necessity for skilled services. Home health care requires skilled services that would come from a physician’s order. This includes things like registered nurses, physical therapy and occupational therapy.\",\n" +
        "          \"reg_dt\": \"2018-09-28\",\n" +
        "          \"id\": 2,\n" +
        "          \"faq_title\": \"What Is The Difference Between Home Health And Personal Home Care Assistance?\"\n" +
        "        },\n" +
        "        {\n" +
        "          \"cate\": \"회원\",\n" +
        "          \"faq_contents\": \"Home health is designed to help you recover in the comfort of your home through rehabilitation and skilled nursing services. Home health must be ordered by your physician when he or she determines your condition requires you to remain in the home for rehab and recovery.\",\n" +
        "          \"reg_dt\": \"2018-09-28\",\n" +
        "          \"id\": 1,\n" +
        "          \"faq_title\": \"What Is Home Health Care?\"\n" +
        "        }\n" +
        "      ],\n" +
        "    \"sp_rtn\": 0\n" +
        "}";

      return new Gson().fromJson(result, FAQResultBean.class);
    });
  }

  @Override
  public Single<LoginResultBean> selectMember(UserNoBean bean) {
    return Single.fromCallable(() -> {
      String result = "{\n" +
        "  \"data\": [{\"user_no\": \"12345678900\",\n" +
        "            \"user_name\": \"나나나\",\n" +
        "            \"mail_id\": \"naananan@gmail.com\",\n" +
        "            \"memr_stat_cd\": \"000\",\n" +                // 000: 정상, 200:휴면, 탈퇴:900
        "            \"lock_stat_cd\": \"000\", \n" +               // 정상: 000, 잠김 회원: 999
        "            \"ci_value\":\"5555555555\"}],\n" +
        "    \"sp_rtn\": 0\n" +
        " }";

      return new Gson().fromJson(result, LoginResultBean.class);
    });
  }

  @Override
  public Single<LifeplusAPIBean> activeMember(RequestBean bean) {
    return Single.fromCallable(() -> new LifeplusAPIBean(LifeplusAPIBean.RETURN_SUCCESS, ""));
//    return Single.fromCallable(() -> new LifeplusAPIBean(LifeplusAPIBean.RETURN_PARAMETER_ERROR, "RETURN_PARAMETER_ERROR"));
  }
}
