package com.qmth.exam.reserve.weixin;

import com.qmth.exam.reserve.weixin.response.OauthAccessTokenResponseJson;

public class OauthAccessTokenRequest
        extends AbstractRequest<OauthAccessTokenResponseJson, OauthAccessTokenResponseJson, String> {

    private final static String URL = " https://api.weixin.qq.com/sns/oauth2/access_token?";

    private String code;

    private String appId;

    private String appSecret;

    public OauthAccessTokenRequest(String code, String appId, String appSecret) {
        this.code = code;
        this.appId = appId;
        this.appSecret = appSecret;
    }

    @Override
    protected String makeUrl() {
        String accessTokenUrl = URL + "appid=" + this.appId + "&secret=" + this.appSecret + "&code=" + this.code
                + "&grant_type=authorization_code";
        return accessTokenUrl;
    }

}
