/*
 * Copyright (c) 2015. Ncomz. All Rights Reserved
 */

package com.ntels.onecable.common.http;

import com.ntels.onecable.R;
import com.ntels.onecable.common.AppConfig;
import com.ntels.onecable.common.Constants;
import com.ntels.onecable.common.c_interface.OnDataSendToReslut;
import com.ntels.onecable.common.c_interface.OnTaskExecutionFinished;
import com.ntels.onecable.common.exception.RequestUnsuccessfulException;
import com.ntels.onecable.common.netatmo.NetatmoHttpClientImpl;
import com.ntels.onecable.common.util.Dlog;
import com.ntels.onecable.common.util.Util;
import com.ntels.onecable.common.widget.CircularProgressBarDrawable;

import android.app.Dialog;
import android.content.Context;
import android.os.AsyncTask;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import static com.ntels.onecable.common.Constants.KEY_UPDATE_FIELD;

/**
 * <pre>
 * 1. ClassName :   HttpSend
 * 2. FileName  :   HttpSend.java
 * 3. Package   :   com.ntels.onecable.common.http
 * 4. Date      :   2016-12-06
 * 5. Author    :   aaron
 * 6. Comment   :   Initialize
 * </pre>
 */
public class HttpSend {

    public static final long DEFAULT_TIMEOUT = 5000;
    public final static int ENC_NOT = 10200;
    public final static int ENC_AES = 10201;
    private static final String TAG = HttpSend.class.getSimpleName();
    protected Context context;
    private AppConfig mAppConfig;
    private Util util = new Util();
    private boolean bDialog = true;
    private boolean bDim = true;
    private OnDataSendToReslut _task_resulted_event;
    private Dialog dialog;

    /**
     * 생성자.
     *
     * @param context 컨텍스트
     */
    public HttpSend(Context context) {

        mAppConfig = (AppConfig) context.getApplicationContext();
        this.context = context;
    }

    /**
     * 생성자.
     *
     * @param context 컨텍스트
     * @param bDialog Dialog 표시 여부
     */
    public HttpSend(Context context, boolean bDialog) {

        mAppConfig = (AppConfig) context.getApplicationContext();
        this.context = context;
        this.bDialog = bDialog;
    }

    /**
     * 생성자.
     *
     * @param context 컨텍스트
     * @param bDialog Dialog 표시 여부
     */
    public HttpSend(Context context, boolean bDialog, boolean bDim) {

        mAppConfig = (AppConfig) context.getApplicationContext();
        this.context = context;
        this.bDialog = bDialog;
        this.bDim = bDim;
    }

    /**
     * [POST]회원 가입 등록(회원 가입 정보를 입력 완료 후 인증 이메일을 발송한다.)
     *
     * @param keyNickname      사용자 이름
     * @param keyEmailId       사용자 email id
     * @param keyPassword      사용자 password
     * @param keyServiceId     서비스 ID (30001 : AoT@Home 3.0)
     * @param keyOsType        OS 유형 (MA : 안드로이드, MI : IOS)
     * @param keyCountryCode   국가 코드 (default : KR)
     * @param keyTimezoneName  타임존 아이디 (default : 210)
     * @param keyImageFile     사용자 프로필 이미지 파일 이름
     * @param keyImageFilePath 사용자 프로필 이미지 파일 경로
     */
    public void P_member(String keyNickname, String keyEmailId, String keyPassword, String keyServiceId, String keyOsType, String
            keyCountryCode, String keyTimezoneName, String keyImageFile, String keyImageFilePath) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_member);
            //            sendType = Constants.SEND_TYPE_POST;
            sendType = Constants.SEND_TYPE_MULTIPART;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            /* 이름 */
            addParameter(alPost, Constants.KEY_NICKNAME, keyNickname);
            /* 이메일 ID */
            addParameter(alPost, Constants.KEY_EMAIL_ID, keyEmailId);
            /* 패스워드 */
            addParameter(alPost, Constants.KEY_PASSWORD, keyPassword);
            /* 서비스 ID (30001 : AoT@Home 3.0) */
            addParameter(alPost, Constants.KEY_SERVICE_ID, keyServiceId);
            /* OS 유형 (MA : 안드로이드, MI : IOS) */
            addParameter(alPost, Constants.KEY_OS_TYPE, keyOsType);
            /* 국가 코드 (default : KR) */
            addParameter(alPost, Constants.KEY_COUNTRY_CODE, keyCountryCode);
            /* 타임존 아이디 (default : 210) */
            addParameter(alPost, Constants.KEY_TIMEZONE_NAME, keyTimezoneName);

            fileParamName = keyImageFile;
            filePath = keyImageFilePath;
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]회원 로그인(회원 로그인을 처리한다.)
     *
     * @param keyEmailId        사용자 email id
     * @param keyPassword       사용자 password
     * @param keyServiceId      서비스 ID (30001 : AoT@Home 3.0)
     * @param keyOsType         OS 유형 (MA : 안드로이드, MI : IOS)
     * @param keyDeviceSn       단말 일련번호 (애플 기기 : UUID / 안드로이드 기기 : IMEI or Mac Address)
     * @param keyDeviceToken    푸시노티 토큰 (애플 기기 : device token / 안드로이드 기기 : reg id)
     * @param keyDeviceName     사용자 단말기 이름
     * @param keyDeviceHostname 사용자 단말기 네트워크 호스트 이름
     */
    public void P_member_login(String keyEmailId, String keyPassword, String keyServiceId, String keyOsType, String keyDeviceSn,
                               String keyDeviceToken, String keyDeviceName, String keyDeviceHostname) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_member_login);
            sendType = Constants.SEND_TYPE_POST;
            /* 이메일 ID */
            addParameter(alPost, Constants.KEY_EMAIL_ID, keyEmailId);
            /* 패스워드 */
            addParameter(alPost, Constants.KEY_PASSWORD, keyPassword);
            /* 서비스 ID (30001 : AoT@Home 3.0) */
            addParameter(alPost, Constants.KEY_SERVICE_ID, keyServiceId);
            /* OS 유형 (MA : 안드로이드, MI : IOS) */
            addParameter(alPost, Constants.KEY_OS_TYPE, keyOsType);
            addParameter(alPost, Constants.KEY_DEVICE_SN, keyDeviceSn);
            addParameter(alPost, Constants.KEY_DEVICE_TOKEN, keyDeviceToken);
            addParameter(alPost, Constants.KEY_DEVICE_NAME, keyDeviceName);
            addParameter(alPost, Constants.KEY_DEVICE_HOSTNAME, keyDeviceHostname);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST] (홈그룹에 속해 있지 않은 회원이 마스터가 되는) 홈그룹을 새로 생성한다.
     */
    public void P_homegrp() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_homegrp);
            sendType = Constants.SEND_TYPE_POST;

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST] 등록하려는 홈허브에 device_id, device_key 정보를 전달한다.
     *
     * @param keyHostAddress 홈허브 IP address
     * @param keyDeviceId    홈허브 ID
     * @param keyDeviceKey   홈허브 key
     */
    public void P_deviceinfo(String keyHostAddress, String keyDeviceId, String keyDeviceKey) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            url = context.getString(R.string.SEND_P_deviceinfo, keyHostAddress);
            addParameter(alPost, Constants.KEY_DEVICE_ID, keyDeviceId);
            addParameter(alPost, Constants.KEY_DEVICE_KEY, keyDeviceKey);
            sendType = Constants.SEND_TYPE_POST;

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]새 단말(장치) 인증(새로운 단말로 로그인 시 단말(장치) 인증 번호를 확인하고, 단말(장치)을 등록 처리한다. (기존 단말(장치)을 대체할 경우의 처리도
     * 포함))
     *
     * @param keyKey            이메일로 전달되는 인증 번호
     * @param keyEmailId        사용자 email id
     * @param keyServiceId      서비스 ID (30001 : AoT@Home 3.0)
     * @param keyOsType         OS 유형 (MA : 안드로이드, MI : IOS)
     * @param keyDeviceSn       단말 일련번호 (애플 기기 : UUID / 안드로이드 기기 : IMEI or Mac Address)
     * @param keyDeviceToken    푸시노티 토큰 (애플 기기 : device token / 안드로이드 기기 : reg id)
     * @param keyDeviceName     사용자 단말기 이름
     * @param keyDeviceHostname 사용자 단말기 네트워크 호스트 이름
     */
    public void P_member_new_mobile_device(String keyKey, String keyEmailId, String keyServiceId, String keyOsType, String
            keyDeviceSn, String keyDeviceToken, String keyDeviceName, String keyDeviceHostname) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_member_new_mobile_device);
            sendType = Constants.SEND_TYPE_POST;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            /* ket */
            addParameter(alPost, Constants.KEY_KEY, keyKey);
            /* 이메일 ID */
            addParameter(alPost, Constants.KEY_EMAIL_ID, keyEmailId);
            /* 서비스 ID (30001 : AoT@Home 3.0) */
            addParameter(alPost, Constants.KEY_SERVICE_ID, keyServiceId);
            /* OS 유형 (MA : 안드로이드, MI : IOS) */
            addParameter(alPost, Constants.KEY_OS_TYPE, keyOsType);
            addParameter(alPost, Constants.KEY_DEVICE_SN, keyDeviceSn);
            addParameter(alPost, Constants.KEY_DEVICE_TOKEN, keyDeviceToken);
            addParameter(alPost, Constants.KEY_DEVICE_NAME, keyDeviceName);
            addParameter(alPost, Constants.KEY_DEVICE_HOSTNAME, keyDeviceHostname);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]비밀번호 찾기(재설정)(입력된 이메일 ID 정보로 비밀번호 찾기를 위한 메일 발송을 처리한다.)
     *
     * @param keyEmailId   사용자 email id
     * @param keyServiceId 서비스 ID (30001 : AoT@Home 3.0)
     */
    public void P_member_password(String keyEmailId, String keyServiceId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_member_password);
            sendType = Constants.SEND_TYPE_POST;
            /* 이메일 ID */
            addParameter(alPost, Constants.KEY_EMAIL_ID, keyEmailId);
            addParameter(alPost, Constants.KEY_SERVICE_ID, keyServiceId);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]회원 로그아웃(회원 로그아웃을 처리한다. (인증 토큰 무효화))
     */
    public void G_member_logout() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_member_logout);
            sendType = Constants.SEND_TYPE_GET;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT]회원 로그인 정보 조회 및 푸시 토큰 등록/수정(인증 토큰을 기준으로 회원의 로그인 정보를 조회하고 푸시 토큰을 등록/수정한다.)
     *
     * @param keyDeviceSn       단말 일련번호 (애플 기기 : UUID / 안드로이드 기기 : IMEI or Mac Address)
     * @param keyDeviceToken    푸시노티 토큰 (애플 기기 : device token / 안드로이드 기기 : reg id)
     * @param keyOsType         OS 유형 (MA : 안드로이드, MI : IOS)
     * @param keyDeviceHostname 사용자 단말기 네트워크 호스트 이름
     */
    public void P_member(String keyDeviceSn, String keyDeviceToken, String keyOsType, String keyDeviceHostname) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_member);
            sendType = Constants.SEND_TYPE_PUT;
            /* 단말 일련번호 (애플 기기 : UUID / 안드로이드 기기 : IMEI or Mac Address) */
            addParameter(alPost, Constants.KEY_DEVICE_SN, keyDeviceSn);
            /* 푸시노티 토큰 (애플 기기 : device token / 안드로이드 기기 : reg id) */
            addParameter(alPost, Constants.KEY_DEVICE_TOKEN, keyDeviceToken);
            addParameter(alPost, Constants.KEY_OS_TYPE, keyOsType);
            addParameter(alPost, Constants.KEY_DEVICE_HOSTNAME, keyDeviceHostname);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT][REST]회원 정보 수정(가입된 이메일, 비밀번호, 이름 정보에 대해 변경 처리한다.)
     *
     * @param keyMemberId        멤버 ID(정수)
     * @param keyUpdateField     수정할 필드명(ex> name, password, email...)
     * @param keyNewEmailId      신규 이메일 ID(변경구분 : email 일때 필수)
     * @param keyOldPassword     현재 비밀번호(변경구분 : password 일때 필수)
     * @param keyNewPassword     새 비밀번호(변경구분 : password 일때 필수)
     * @param keyConfirmPassword 비밀번호 확인(변경구분 : password 일때 필수)
     * @param keyNickname        이름(변경구분 : name 일때 필수)
     */
    public void P_member_member_id_update_field(String keyMemberId, String keyUpdateField, String keyNewEmailId, String
            keyOldPassword, String keyNewPassword, String keyConfirmPassword, String keyNickname, String keyImageFileName) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_member_member_id_update_field);
            sendType = Constants.SEND_TYPE_PUT;
            interface_Id = util.convGetRestReplace(interface_Id, KEY_UPDATE_FIELD, keyUpdateField);
            if (KEY_UPDATE_FIELD.equals("email")) {
                /* 신규 이메일 ID(변경구분 : email 일때 필수) */
                addParameter(alPost, Constants.KEY_NEW_EMAIL_ID, keyNewEmailId);
            } else if (KEY_UPDATE_FIELD.equals("password")) {
                /* 현재 비밀번호(변경구분 : password 일때 필수) */
                addParameter(alPost, Constants.KEY_OLD_PASSWORD, keyOldPassword);
                /* 새 비밀번호(변경구분 : password 일때 필수) */
                addParameter(alPost, Constants.KEY_NEW_PASSWORD, keyNewPassword);
                /* 비밀번호 확인(변경구분 : password 일때 필수) */
                addParameter(alPost, Constants.KEY_CONFIRM_PASSWORD, keyConfirmPassword);
            } else if (KEY_UPDATE_FIELD.equals("name")) {
                /* 이름(변경구분 : name 일때 필수) */
                addParameter(alPost, Constants.KEY_NICKNAME, keyNickname);
            } else if (KEY_UPDATE_FIELD.equals("profile")) {
                /* 이름(변경구분 : name 일때 필수) */
                addParameter(alPost, Constants.KEY_IMAGE_FILE_NAME, keyImageFileName);
            }
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET][REST](기존)비밀번호 확인(비밀번호 정보를 확인한다.)
     *
     * @param keyMemberId 멤버 ID(정수)
     * @param keyPassword 사용자 password
     */
    public void G_member_member_id(String keyMemberId, String keyPassword) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_member_member_id);
            sendType = Constants.SEND_TYPE_GET;
            /* 비밀번호 */
            addParameter(alPost, Constants.KEY_PASSWORD, keyPassword);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [DELETE][REST]회원 탈퇴 (계정삭제)(회원의 계정을 삭제 처리한다.)
     */
    public void D_member() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_D_member);
            sendType = Constants.SEND_TYPE_DELETE;
            //interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, key_device_id);
            //interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            /* 비밀번호 */
            //addParameter(alPost, Constants.KEY_password, key_password);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]홈그룹 멤버 목록조회(홈그룹의 멤버 목록을 조회한다.)
     */
    public void getHomeGroupMembers() {

        String url = "";
        String interfaceId = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interfaceId = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_homegrp_members,
                    mAppConfig.getCustId(),
                    mAppConfig.getCtrtGroupId());
            sendType = Constants.SEND_TYPE_GET;
            //            /* 이름 */
            //            interfaceId = util.convGetRestReplace(interfaceId, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            setHttp(url, interfaceId, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]홈그룹 멤버초대(홈그룹의 멤버를 초대한다.)
     *
     * @param bodyVal Request body string
     */
    public void P_homegrp_members(String bodyVal) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_homegrp_members);
            sendType = Constants.SEND_TYPE_POST1;
            body = bodyVal;
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [DELETE]홈그룹 멤버 강퇴/초대 취소(홈그룹으로 초대받은 멤버의 정보를 변경한다.)
     *
     * @param keyMemberIds 멤버 ID 목록(','로 구분됨)
     * @param keyNicknames 초대 멤버 핸드폰 번호 목록(','로 구분됨)
     */
    public void deleteHomegrpMembers(String keyMemberIds, String keyNicknames) {

        String url = "";
        String interfaceId = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interfaceId = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_D_homegrp_members, mAppConfig.getCustId(),
                    mAppConfig.getCtrtGroupId());
            sendType = Constants.SEND_TYPE_DELETE;
            addParameter(alPost, Constants.KEY_MEMBER_IDS, keyMemberIds);
            addParameter(alPost, Constants.KEY_RECEIVE_PHONES, keyNicknames);
            setHttp(url, interfaceId, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]홈그룹 초대 알림(홈초대 알림 화면에서 승락/거절 처리를 한다. (+ 초대 수락 처리 후에 나머지 요청은 거절한다.))
     *
     * @param keyHomegrpId          홈그룹 ID
     * @param keyStatusCode         (응답) 상태 코드 (Y : 참여 / N : 거절)
     * @param keyAuthorizationReply 인증 답변 (년-월-일,  ex : "2015-10-01")
     */
    public void P_homegrp_members_invitations(String keyHomegrpId, String keyStatusCode, String keyAuthorizationReply) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_homegrp_members_invitations);
            sendType = Constants.SEND_TYPE_POST;
            addParameter(alPost, Constants.KEY_HOMEGRP_ID, keyHomegrpId);
            addParameter(alPost, Constants.KEY_STATUS_CODE, keyStatusCode);
            if (!Constants.KEY_AUTHORIZATION_REPLY.equals("")) {
                addParameter(alPost, Constants.KEY_AUTHORIZATION_REPLY, keyAuthorizationReply);
            }
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]홈그룹 멤버 초대 유효성 체크(초대 대상자의 유효성을 체크한다. (홈허브가 없는 홈의 회원 또는 홈이 없는 회원/비회원만 가능))
     *
     * @param keyTargetEmail 초대할 email
     */
    public void P_homegrp_members_validation(String keyTargetEmail) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_homegrp_members_validation);
            sendType = Constants.SEND_TYPE_GET;
            addParameter(alPost, Constants.KEY_TARGET_EMAIL, keyTargetEmail);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [DELETE][REST]홈그룹 (자진) 탈퇴(일반 등급의 홈그룹 멤버를 홈그룹에서 자진 탈퇴 처리한다.)
     */
    public void D_homegrp_members_member_id() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_D_homegrp_members_member_id);
            sendType = Constants.SEND_TYPE_DELETE;
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]멤버 이미지 변경(멤버의 프로필 이미지를 수정.)
     *
     * @param keyImageFile     프로필 이미지 파일명
     * @param keyImageFilePath 프로필 이미지 파일 path
     */
    public void P_member_profile_image(String keyImageFile, String keyImageFilePath) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_member_profile_image);
            sendType = Constants.SEND_TYPE_MULTIPART;
            /* 이메일 ID */
            fileParamName = keyImageFile;
            filePath = keyImageFilePath;

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]홈그룹 이미지 변경(홈그룹의 프로필 이미지를 수정.)
     *
     * @param keyImageFile     프로필 이미지 파일명
     * @param keyImageFilePath 프로필 이미지 파일 path
     */
    public void P_homegrp_profile_image(String keyImageFile, String keyImageFilePath) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_homegrp_profile_image);
            sendType = Constants.SEND_TYPE_MULTIPART;
            /* 이메일 ID */
            fileParamName = keyImageFile;
            filePath = keyImageFilePath;

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]홈그룹 초대 목록(초대받은 홈그룹 목록을 호출)
     */
    public void G_homegrp_members_invitations() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_G_homegrp_members_invitations);
            sendType = Constants.SEND_TYPE_GET;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]홈모드 조회(홈그룹의 홈모드 목록을 불러온다.)
     */
    public void G_modes() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_modes);
            sendType = Constants.SEND_TYPE_GET;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT][REST]현재 홈모드 변경(현재 홈모드를 변경한다.)
     *
     * @param keyModeId 홈모드 ID(ex> HOME, AWAY, MORNING, NIGHT)
     */
    public void P_modes_mode_id_current_mode(String keyModeId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_modes_mode_id_current_mode);
            sendType = Constants.SEND_TYPE_PUT;
            addParameter(alPost, Constants.KEY_MODE_ID, keyModeId);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]대시보드 정보 조회(홈그룹 모드 조회, 공지, 알림 갯수 조회 등)
     *
     * @param keyReadDatetime 공지사항 최종 확인 일시 (년월일시분초, ex : 20150101151515)
     */
    public void G_dashboard(String keyReadDatetime) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_dashboard);
            sendType = Constants.SEND_TYPE_GET;
            /* 이메일 ID */
            addParameter(alPost, Constants.KEY_READ_DATETIME, keyReadDatetime);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]알림 조회(알림 목록을 조회한다.)
     *
     * @param keyPushNotiHistId (페이징 기준) 푸시 노티 이력 ID
     * @param keyPagingType     페이징 방향 (U:Upward, D:Downward)
     */
    public void G_notices_personal(String keyPushNotiHistId, String keyPagingType) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_notices_personal);
            sendType = Constants.SEND_TYPE_GET;
            /* 이메일 인증키 */
            addParameter(alPost, Constants.KEY_PUSH_NOTI_HIST_ID, keyPushNotiHistId);
            addParameter(alPost, Constants.KEY_PAGING_TYPE, keyPagingType);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]공지사항 조회(공지사항 목록을 조회한다.)
     *
     * @param keyNoticeId     (페이징 기준) 공지사항 ID
     * @param keyPagingType   페이징 방향 (U:Upward, D:Downward)
     * @param keyReadDatetime 공지사항 최종 확인 일시 (년월일시분초, ex : 20150101151515)
     */
    public void G_notices(String keyNoticeId, String keyPagingType, String keyReadDatetime) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_notices);
            sendType = Constants.SEND_TYPE_GET;
            /* 이메일 인증키 */
            addParameter(alPost, Constants.KEY_NOTICE_ID, keyNoticeId);
            addParameter(alPost, Constants.KEY_PAGING_TYPE, keyPagingType);
            addParameter(alPost, Constants.KEY_READ_DATETIME, keyReadDatetime);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET][REST]홈모드 변경 결과 조회(현재 홈모드 변경으로 장치를 제어한 결과를 조회한다.)
     *
     * @param keyModeId 홈모드 ID(ex> HOME, AWAY, MORNING, NIGHT)
     */
    public void G_modes_mode_id_status(String keyModeId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_modes_mode_id_status);
            sendType = Constants.SEND_TYPE_GET;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_MODE_ID, keyModeId);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]장치 리스트 조회(회원의 장치 목록을 조회한다.)
     */
    public void getDevices() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_devices
                    , mAppConfig.getCustId()
                    , mAppConfig.getCtrtGroupId());
            sendType = Constants.SEND_TYPE_GET;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET][REST]노드 상세 조회(해당 장치의 상세 정보를 조회한다.
     *
     * @param keyDeviceId 홈허브 ID
     * @param keyNodeId   노드 ID
     */
    public void getNodeDetail(String keyDeviceId, String keyNodeId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_node
                    , mAppConfig.getCustId()
                    , mAppConfig.getCtrtGroupId()
                    , keyDeviceId
                    , keyNodeId);
            sendType = Constants.SEND_TYPE_GET;
//            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, keyDeviceId);
//            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_NODE_ID, keyNodeId);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT][REST]장치 명/아이콘 변경(장치 이름 또는 아이콘을 변경한다.)
     *
     * @param keyDeviceId   홈허브 ID
     * @param keyNodeId     노드 ID
     * @param keyDeviceName 새 장치명명
     */
    public void P_devices_property_device_id(String keyDeviceId, String keyNodeId, String keyDeviceName) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_devices_property_device_id);
            sendType = Constants.SEND_TYPE_PUT;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, keyDeviceId);
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_NODE_ID, keyNodeId);
            addParameter(alPost, Constants.KEY_DEVICE_NAME, keyDeviceName);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT]기존 디바이스의 비밀번호를 확인하여 일치하면 소유권을 변경 처리한다.
     *
     * @param keyDeviceId          홈허브 ID
     * @param keyOwnerAuthPassword 홈허브 password
     */
    public void P_devices_device_id_ownership(String keyDeviceId, String keyOwnerAuthPassword) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_devices_device_id_ownership);
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, keyDeviceId);
            sendType = Constants.SEND_TYPE_PUT;
            addParameter(alPost, Constants.KEY_OWNER_AUTH_PASSWORD, keyOwnerAuthPassword);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT](소유권을 확인할 때 사용하는) 디바이스 비밀번호를 변경한다.)
     *
     * @param keyDeviceId             홈허브 ID
     * @param keyNewOwnerAuthPassword (새) 소유자 인증 비밀번호
     */
    public void P_devices_device_id_password(String keyDeviceId, String keyNewOwnerAuthPassword) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_devices_device_id_password);
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, keyDeviceId);
            sendType = Constants.SEND_TYPE_PUT;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_user_device_password, key_user_device_password);
            addParameter(alPost, Constants.KEY_NEW_OWNER_AUTH_PASSWORD, keyNewOwnerAuthPassword);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET](외출 상태시) 경고 필요한 장치 조회((외출 상태시) 경고가 필요한 장치 노드 목록을 조회한다.)
     */
    public void G_devices_warning_nodes() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_devices_warning_nodes);
            sendType = Constants.SEND_TYPE_GET;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]홈 규칙 목록 조회(홈의 규칙 목록을 조회한다.)
     *
     * @param keyRuleId     페이징 기준 규칙 ID
     * @param keyPagingType 페이징 유형 (U : Upward, D : Downward)
     */
    public void G_rules(String keyRuleId, String keyPagingType) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_rules);
            sendType = Constants.SEND_TYPE_GET;

            addParameter(alPost, Constants.KEY_RULE_ID, keyRuleId);
            addParameter(alPost, Constants.KEY_PAGING_TYPE, keyPagingType);

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET][REST]홈 규칙 상세 조회(해당 규칙의 정보를 상세 조회한다.)
     *
     * @param keyHomegrpRuleId 홈그룹 규칙 ID
     */
    public void G_rules_homegrp_rule_id(String keyHomegrpRuleId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_rules_homegrp_rule_id);
            sendType = Constants.SEND_TYPE_GET;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_HOMEGRP_RULE_ID, keyHomegrpRuleId);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT][REST]홈 규칙 상태 변경(해당 규칙의 상태를 변경한다.)
     *
     * @param key_homegrp_rule_id 홈그룹 규칙 ID
     * @param key_status_code     (변경할) 상태 코드 (02 : 실행 / 03 : 중지)
     */
    public void P_rules_homegrp_rule_id_status(String key_homegrp_rule_id, String key_status_code) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_P_rules_homegrp_rule_id_status);
            sendType = Constants.SEND_TYPE_PUT;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_HOMEGRP_RULE_ID, key_homegrp_rule_id);
            addParameter(alPost, Constants.KEY_STATUS_CODE, key_status_code);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST]홈 규칙 등록(규칙을 등록한다.)
     *
     * @param bodyVal Request body string
     */
    public void P_rules(String bodyVal) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_rules);
            sendType = Constants.SEND_TYPE_POST1;
            body = bodyVal;
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT][REST]홈 규칙 수정(해당 규칙을 수정한다.)
     *
     * @param keyHomegrpRuleId 홈그룹 규칙 ID
     * @param bodyVal          Request body string
     */
    public void P_rules_homegrp_rule_id(String keyHomegrpRuleId, String bodyVal) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_rules_homegrp_rule_id);
            sendType = Constants.SEND_TYPE_PUT1;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_HOMEGRP_RULE_ID, keyHomegrpRuleId);
            body = bodyVal;
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [DELETE][REST]홈 규칙 삭제(해당 규칙을 삭제한다.)
     *
     * @param keyHomegrpRuleId 홈그룹 규칙 ID
     */
    public void D_rules_homegrp_rule_id(String keyHomegrpRuleId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_D_rules_homegrp_rule_id);
            sendType = Constants.SEND_TYPE_DELETE;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_HOMEGRP_RULE_ID, keyHomegrpRuleId);

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET][REST]액션 장치의 목록 조회(규칙 아이템(조건,액션)으로 사용할 장치를 조회)
     *
     * @param keyItemTypeCode 항목 유형 코드 (01 : trigger, 02 : action)
     */
    public void G_rules_item_devices_item_type_code(String keyItemTypeCode) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_G_rules_item_devices_item_type_code);
            sendType = Constants.SEND_TYPE_GET;
            addParameter(alPost, Constants.KEY_ITEM_TYPE_CODE, keyItemTypeCode);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET][REST]홈그룹 모드의 멀티제어 상세 조회(해당 홈모드 멀티제어의 정보를 상세 조회한다.)
     *
     * @param keyModeId 홈모드 ID(ex> HOME, AWAY, MORNING, NIGHT)
     */
    public void G_mode_scenes_mode_id(String keyModeId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_G_mode_scenes_mode_id);
            sendType = Constants.SEND_TYPE_GET;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_MODE_ID, keyModeId);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST][REST]홈그룹 모드의 멀티제어 등록&수정(멀티제어를 등록&수정한다.)
     *
     * @param keyModeId 홈모드 ID(ex> HOME, AWAY, MORNING, NIGHT)
     * @param bodyVal   Request body string
     */
    public void P_mode_scenes_mode_id(String keyModeId, String bodyVal) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_mode_scenes_mode_id);
            sendType = Constants.SEND_TYPE_POST1;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_MODE_ID, keyModeId);
            body = bodyVal;
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [DELETE][REST]홈그룹 모드의 규칙 삭제
     *
     * @param keyModeId 홈모드 ID(ex> HOME, AWAY, MORNING, NIGHT)
     */
    public void D_modes_mode_id_rule(String keyModeId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_D_modes_mode_id_rule);
            sendType = Constants.SEND_TYPE_DELETE;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_MODE_ID, keyModeId);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]앱 버전 정보 조회(서비스 이용이 가능한 앱 버전 정보를 조회한다.)
     *
     * @param keyOsType     OS 유형 (MA : 안드로이드, MI : IOS)
     * @param keyAppVersion (현재 접속한) 앱 버전
     */
    public void P_app_version(String keyOsType, String keyAppVersion) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_app_version);
            sendType = Constants.SEND_TYPE_POST;
            addParameter(alPost, Constants.KEY_OS_TYPE, keyOsType);
            addParameter(alPost, Constants.KEY_APP_VERSION, keyAppVersion);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET]야후날씨 지역코드 목록 조회(야후 날씨에 사용할 지역코드목록을 조회한다.)
     */
    public void G_common_weather_location_codes() {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_G_common_weather_location_codes);
            sendType = Constants.SEND_TYPE_GET;
            //            /* 이름 */
            //            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_member_id, key_member_id);
            //            /* 이름 */
            //            addParameter(alPost, Constants.KEY_, key_);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [PUT]알림 수신 여부 설정(알림 수신 여부를 설정 한다. (예 : 홈모드가 바뀔 때, 집이 빌 때))
     *
     * @param keyPushTypeModeChgYn  모드가 바뀔 때 알림 설정 여부 (Y : 받음, N : 안받음)
     * @param keyPushTypePrsncChgYn 집이 빌때 알림 설정 여부 (Y : 받음, N : 안받음)
     */
    public void P_member_push_noti(String keyPushTypeModeChgYn, String keyPushTypePrsncChgYn) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string.SEND_P_member_push_noti);
            sendType = Constants.SEND_TYPE_PUT;
            /* 이메일 ID */
            addParameter(alPost, Constants.KEY_PUSH_TYPE_MODE_CHG_YN, keyPushTypeModeChgYn);
            addParameter(alPost, Constants.KEY_PUSH_TYPE_PRSNC_CHG_YN, keyPushTypePrsncChgYn);
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET](등록 진행하기 전) 해당 디바이스의 기 등록여부를 조회한다.
     *
     * @param keyMfId    홈허브 제조사 ID
     * @param keyModelId 홈허브 모델 ID
     * @param keySn      홈허브 시리얼번호
     */
    public void G_devices_mf_id_model_id_sn(String keyMfId, String keyModelId, String keySn) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            interface_Id = util.getString(context, R.string.API_VERSION) + util.getString(context, R.string
                    .SEND_G_devices_mf_id_model_id_sn);
            sendType = Constants.SEND_TYPE_GET;

            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_MF_ID, keyMfId);
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_MODEL_ID, keyModelId);
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_SN, keySn);

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST] Cloud to Cloud 연동 Node 등록
     *
     * @param keyDeviceId 홈허브 ID
     * @param bodyVal     Request body string
     */
    public void P_cloud_devices_device_id_nodes(String keyDeviceId, String bodyVal) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            url = mAppConfig.getCloudGatewayUrl();
            interface_Id = util.getString(context, R.string.CLOUD_API_VERSION) + util.getString(context, R.string
                    .SEND_P_cloud_devices_device_id_nodes);
            sendType = Constants.SEND_TYPE_POST1;
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, keyDeviceId);
            body = bodyVal;

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [DELETE] Cloud to Cloud 연동 Node 삭제
     *
     * @param keyDeviceId    홈허브 ID
     * @param keyNodeId      노드 ID
     * @param keyHomegroupId 홈그룹 ID
     * @param keyMemberId    멤버 ID
     */
    public void D_cloud_devices_device_id_nodes_node_id(String keyDeviceId, String keyNodeId,
                                                        String keyHomegroupId, String keyMemberId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            url = mAppConfig.getCloudGatewayUrl();
            interface_Id = util.getString(context, R.string.CLOUD_API_VERSION) + util.getString(context, R.string
                    .SEND_D_cloud_devices_device_id_nodes_node_id);
            sendType = Constants.SEND_TYPE_DELETE;

            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, keyDeviceId);
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_NODE_ID, keyNodeId);
            addParameter(alPost, Constants.KEY_HOMEGROUP_ID, keyHomegroupId);
            addParameter(alPost, Constants.KEY_MEMBER_ID, keyMemberId);

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [GET][REST]네타모 카메라의 로컬 IP Address를 조회한다.
     *
     * @param keyVpnUrl 넷타모 영상 스트리밍 URL
     */
    public void G_cloud_netatmo_command_ping(String keyVpnUrl) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            url = keyVpnUrl + "/command/ping";
            sendType = Constants.SEND_TYPE_GET;
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [DELETE] 서비스허브 REST API를 사용하여 노드 삭제(Inclusion과정이 필요없는 장치용)
     *
     * @param keyDeviceId    홈허브 ID
     * @param keyNodeId      노드 ID
     * @param keyHomegroupId 홈그룹 ID
     * @param keyMemberId    멤버 ID
     */
    public void D_servicehub_devices_device_id_nodes_node_id(String keyDeviceId, String keyNodeId,
                                                             String keyHomegroupId, String keyMemberId) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            url = mAppConfig.getServicehubRestUrl();
            interface_Id = util.getString(context, R.string.SERVICEHUB_API_VERSION) + util.getString(context, R.string
                    .SEND_D_servicehub_devices_device_id_nodes_node_id);
            sendType = Constants.SEND_TYPE_DELETE;

            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_DEVICE_ID, keyDeviceId);
            interface_Id = util.convGetRestReplace(interface_Id, Constants.KEY_NODE_ID, keyNodeId);
            addParameter(alPost, Constants.KEY_HOMEGROUP_ID, keyHomegroupId);
            addParameter(alPost, Constants.KEY_MEMBER_ID, keyMemberId);

            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * [POST][REST]넷타모 로그인
     *
     * @param netatmoHttpClientImpl 넷타모 정보를 포함한 인스턴스
     * @param email                 넷타모 로그인 email
     * @param password              넷타모 로그인 password
     */
    public void P_cloud_netatmo_login(NetatmoHttpClientImpl netatmoHttpClientImpl, String email, String password) {

        String url = "";
        String interface_Id = "";
        String sendType = "";
        String body = "";
        String fileParamName = "";
        String filePath = "";
        ArrayList<HashMap<String, Object>> alPost = new ArrayList<HashMap<String, Object>>();
        ArrayList<String> alFilePath = new ArrayList<String>();
        try {
            url = "https://api.netatmo.net/oauth2/token";
            sendType = Constants.SEND_TYPE_POST;
            addParameter(alPost, "grant_type", "password");
            addParameter(alPost, "client_id", netatmoHttpClientImpl.getClientId());
            addParameter(alPost, "client_secret", netatmoHttpClientImpl.getClientSecret());
            addParameter(alPost, "username", email);
            addParameter(alPost, "password", password);
            addParameter(alPost, "scope", netatmoHttpClientImpl.getAppScope());
            setHttp(url, interface_Id, sendType, alPost, body, fileParamName, filePath, alFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Http 정보 셋팅 및 요청
     *
     * @param url           요청 URL
     * @param interfaceId   Path parameter
     * @param sendType      HTTP method
     * @param alPost        Request parameter list
     * @param body          Request parameter string
     * @param fileParamName 업로드 파일 명
     * @param filePath      업로드 파일 경로
     * @param alFilePath    업로드 파일 경로 list
     */
    void setHttp(String url, String interfaceId, String sendType, ArrayList<HashMap<String, Object>> alPost, String body, String
            fileParamName, String filePath, ArrayList<String> alFilePath) {

        try {
            String urlVal = "";
            String uriVal = "";
            String sendTypeVal = "";
            if (url.equals("")) {
                urlVal = mAppConfig.getUrl();
            } else {
                urlVal = url;
            }

            String sParam = util.convGetParam(alPost);
            if (sendType.equals(Constants.SEND_TYPE_POST)) {
                uriVal = urlVal + interfaceId;
                sendTypeVal = CustomRequest.HTTP_METHOD_POST;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), alPost,
                        CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
            } else if (sendType.equals(Constants.SEND_TYPE_POST1)) {
                uriVal = urlVal + interfaceId;
                sendTypeVal = CustomRequest.HTTP_METHOD_POST;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), body,
                        CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
            } else if (sendType.equals(Constants.SEND_TYPE_MULTIPART)) {
                uriVal = urlVal + interfaceId;
                sendTypeVal = CustomRequest.HTTP_METHOD_MULTIPART;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), alPost,
                        fileParamName, filePath, CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
            } else if (sendType.equals(Constants.SEND_TYPE_MULTIPART1)) {
                uriVal = urlVal + interfaceId;
                sendTypeVal = CustomRequest.HTTP_METHOD_MULTIPART;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), alPost,
                        fileParamName, alFilePath, CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
            } else if (sendType.equals(Constants.SEND_TYPE_DELETE)) {
                uriVal = urlVal + interfaceId + sParam;
                sendTypeVal = CustomRequest.HTTP_METHOD_DELETE;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), "",
                        CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
                //            } else if ( sendType.equals(Constants.SEND_TYPE_DELETE1) ) {
                //                uriVal = urlVal + interfaceId + body;
                //                sendTypeVal = CustomRequest.HTTP_METHOD_DELETE;
                //                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig
                // .getAuthToken(), "", CustomRequest.SEND_METHOD);
                //                executeRequest(customRequest);
            } else if (sendType.equals(Constants.SEND_TYPE_GET)) {
                uriVal = urlVal + interfaceId + sParam;
                sendTypeVal = CustomRequest.HTTP_METHOD_GET;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), "",
                        CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
            } else if (sendType.equals(Constants.SEND_TYPE_PUT)) {
                uriVal = urlVal + interfaceId + sParam;
                sendTypeVal = CustomRequest.HTTP_METHOD_PUT;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), alPost,
                        CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
            } else if (sendType.equals(Constants.SEND_TYPE_PUT1)) {
                uriVal = urlVal + interfaceId + sParam;
                sendTypeVal = CustomRequest.HTTP_METHOD_PUT;
                CustomRequest customRequest = new CustomRequest(bDialog, sendTypeVal, uriVal, mAppConfig.getAuthorization(), body,
                        CustomRequest.SEND_METHOD);
                executeRequest(customRequest);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Request parameter 추가.
     *
     * @param paramListPost  Parameter 추가 될 list
     * @param parameterName  Parameter key
     * @param parameterValue Parameter value
     */
    void addParameter(List<HashMap<String, Object>> paramListPost, String parameterName, String parameterValue) {

        if (parameterName == null) {
            return;
        }
        HashMap<String, Object> hmTemp = new HashMap<String, Object>();
        if (parameterValue == null) {
            hmTemp.put(parameterName, "");
        } else {
            Dlog.v(parameterName + ": " + parameterValue);
            hmTemp.put(parameterName, parameterValue);
        }
        paramListPost.add(hmTemp);
    }

    /**
     * HTTP 요청
     *
     * @param customRequest HTTP request 정보 instance
     */
    private void executeRequest(CustomRequest customRequest) {

        if (!bDialog) {
            if (dialog != null) {
                dialog.dismiss();
                dialog = null;
            }
        } else {
            if (dialog != null) {
                dialog.cancel();
                dialog = null;
            }
            if (bDialog) {
                dialog = new Dialog(context, R.style.NTLES_Dialog1);
            } else {
                dialog = new Dialog(context, R.style.NTLES_Dialog2);
            }
//            dialog.addContentView(new ProgressBar(context, null, android.R.attr.progressBarStyleInverse), new LayoutParams(LayoutParams
//                    .WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

            ProgressBar progressBar = new ProgressBar(context);

            CircularProgressBarDrawable drawable = new CircularProgressBarDrawable();
//            drawable.setColorSchemeResources(context, android.R.color.holo_red_light,
//                    android.R.color.holo_green_light, android.R.color.holo_blue_bright,
//                    android.R.color.holo_orange_light);
            drawable.setColors(new int[]{0xffff0000, 0xffff00a8, 0xffb400ff, 0xff2400ff, 0xff008aff,
                    0xff00ffe4, 0xff00ff60, 0xff0cff00, 0xffa8ff00, 0xffffc600, 0xffff3600, 0xffff0000});
            progressBar.setProgressDrawable(drawable);
            progressBar.setMax(100);
            progressBar.setProgress(100);
            dialog.addContentView(progressBar, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams
                    .WRAP_CONTENT));

            dialog.show();
        }
        AsyncTask<CustomRequest, Integer, Response[]> task = null;
        try {
            task = new HttpTask(context);
            ((HttpTask) task).setOnTaskFinishedEvent(new OnTaskExecutionFinished() {
                @Override
                public void OnTaskFihishedEvent(Response[] result) {

                    try {
                        if (dialog != null && dialog.isShowing()) {
                            dialog.dismiss();
                            dialog = null;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    if (_task_resulted_event != null) {
                        _task_resulted_event.resultResponse(result != null ? result[0] : null);
                    }
                }
            });
            task.execute(customRequest);
        } catch (RequestUnsuccessfulException e) {
            String msg1 = "Unable to execute request";
            Dlog.w(msg1, e);
            _task_resulted_event.resultResponse(ResponseHelper.writeException(msg1, e));
        } catch (Exception ex) {
            ex.printStackTrace();
            String msg1 = "Unable to execute request";
            Dlog.w(msg1, ex);
            _task_resulted_event.resultResponse(ResponseHelper.writeException(msg1, ex));
        }
    }

    /**
     * HTTP response listener setting.
     *
     * @param _event Response listener
     */
    public void setOnDataSendToReslutEvent(OnDataSendToReslut _event) {

        if (_event != null) {
            this._task_resulted_event = _event;
        }
    }
}
