package com.house365.service.interfaces;

import com.house365.service.impl.WechatClientHystrix;
import net.sf.json.JSONObject;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Date: 2016/12/30</p>
 *
 * @author XN
 * @version 1.0
 */
@FeignClient(value = "wechat-service", fallback = WechatClientHystrix.class)
public interface WechatClient {

    /**
     * 获取access token
     * @param corpID
     * @param secret
     * @return
     */
    @RequestMapping(value = "getAccessToken")
    public String getAccessToken(
        @RequestParam(value = "corpID") String corpID, @RequestParam(value = "secret") String secret
    );

    /**
     * 获取根据code和accesstoken获取用户信息
     * @param code
     * @param accessToken
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/getUserInfo")
    public JSONObject getUserInfo(
        @RequestParam(value = "code") String code, @RequestParam(value = "accessToken") String accessToken
    );

    @RequestMapping(method = RequestMethod.GET, value = "/getOpenId")
    public JSONObject getOpenId(
        @RequestParam(value = "userId") String userId, @RequestParam(value = "agentId") String agentId,
        @RequestParam(value = "accessToken") String accessToken
    );

    @RequestMapping(method = RequestMethod.GET, value = "/getUserId")
    public JSONObject getUserId(
        @RequestParam(value = "openid") String openid,
        @RequestParam(value = "accessToken") String accessToken
    );

    /**
     * 获取access token
     *
     * @param corpID
     * @param secret
     * @return
     */
    @RequestMapping(value = "getJsapiTicket")
    public String getJsapiTicket(
            @RequestParam(value = "corpID") String corpID, @RequestParam(value = "secret") String secret
    );
}
