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

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;
import kr.co.zumo.app.lifeplus.config.NetworkConfig;

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

  private static final String AUTH_URL = NetworkConfig.HOST_URL + ":" + NetworkConfig.HOST_PORT + "/";

  private LifeplusAPI api(String url) {
    return retrofit(url, LifeplusAPI.class, 2000);
  }

  /**
   * 모바일 인증 번호 요청
   *
   * @param bean AuthRequestBean
   * @return rx single with LifeplusAPIBean
   */
  @Override
  public Single<LifeplusAPIBean> requestMobileAuth(AuthRequestBean bean) {
    return api(AUTH_URL).requestMobileAuth(bean);
  }

  /**
   * 인증 번호 확인 요청
   *
   * @param bean AuthConfirmRequestBean
   * @return rx single with LifeplusAPIBean
   */
  @Override
  public Single<LifeplusAPIBean> confirmMobileAuth(AuthConfirmRequestBean bean) {
    return api(AUTH_URL).confirmMobileAuth(bean);
  }

  /**
   * 약관 리스트 가져오기
   *
   * @param bean
   * @return
   */
  @Override
  public Single<PolicyResultBean> getPolicyList(RequestBean bean) {
    return api(AUTH_URL).getPolicyList(bean);
  }

  /**
   * 약관 확인
   *
   * @param bean
   * @return
   */
  @Override
  public Single<LifeplusAPIBean> confirmPolicy(PolicyConfirmRequestBean bean) {
    return api(AUTH_URL).confirmPolicy(bean);
  }

  /**
   * 회원 가입
   *
   * @param bean
   * @return
   */
  @Override
  public Single<MemberJoinResultBean> insertMember(MemberJoinRequestBean bean) {
    return api(AUTH_URL).insertMember(bean);
  }

  /**
   * 회원 탈퇴
   *
   * @param bean
   * @return
   */
  @Override
  public Single<LifeplusAPIBean> deleteMember(UserNoBean bean) {
    return api(AUTH_URL).deleteMember(bean);
  }

  /**
   * FAQ 리스트 가져오기
   *
   * @param bean
   * @return
   */
  @Override
  public Single<FAQResultBean> getFaqList(RequestBean bean) {
    return api(AUTH_URL).getFaqList(bean);
  }

  /**
   * 로그인
   *
   * @param bean
   * @return
   */
  @Override
  public Single<LoginResultBean> selectMember(UserNoBean bean) {
    return api(AUTH_URL).selectMember(bean);
  }

  /**
   * 회원 잠금 해제
   *
   * @param bean
   * @return
   */
  @Override
  public Single<LifeplusAPIBean> activeMember(RequestBean bean) {
    return api(AUTH_URL).activeMember(bean);
  }
}
