package com.cm.common.wechat.config.pojo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: WechatProperties
 * @Description: 微信配置
 * @Author: WangGeng
 * @Date: 2020/3/1 2:22 下午
 * @Version: 1.0
 **/
@Configuration
@ConfigurationProperties(prefix = "open-platform.wechat.official-account")
public class WechatOfficialAccountProperties {

    private Boolean apiCrossOrigin;
    private Boolean activate;
    private WechatOfficialAccountAuthorizeProperties authorize;
    private String accessTokenUrl;
    private String bindUserUrl;
    private String appId;
    private String appSecret;
    private String grantType;
    private String configToken;

    public Boolean getApiCrossOrigin() {
        return apiCrossOrigin;
    }

    public void setApiCrossOrigin(Boolean apiCrossOrigin) {
        this.apiCrossOrigin = apiCrossOrigin;
    }

    public Boolean getActivate() {
        return activate;
    }

    public void setActivate(Boolean activate) {
        this.activate = activate;
    }

    public WechatOfficialAccountAuthorizeProperties getAuthorize() {
        return authorize;
    }

    public void setAuthorize(WechatOfficialAccountAuthorizeProperties authorize) {
        this.authorize = authorize;
    }

    public String getAccessTokenUrl() {
        return accessTokenUrl == null ? "" : accessTokenUrl.trim();
    }

    public void setAccessTokenUrl(String accessTokenUrl) {
        this.accessTokenUrl = accessTokenUrl;
    }

    public String getBindUserUrl() {
        return bindUserUrl == null ? "" : bindUserUrl.trim();
    }

    public void setBindUserUrl(String bindUserUrl) {
        this.bindUserUrl = bindUserUrl;
    }

    public String getAppId() {
        return appId == null ? "" : appId.trim();
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppSecret() {
        return appSecret == null ? "" : appSecret.trim();
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public String getGrantType() {
        return grantType == null ? "" : grantType.trim();
    }

    public void setGrantType(String grantType) {
        this.grantType = grantType;
    }

    public String getConfigToken() {
        return configToken == null ? "" : configToken.trim();
    }

    public void setConfigToken(String configToken) {
        this.configToken = configToken;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"apiCrossOrigin\":")
                .append(apiCrossOrigin);
        sb.append(",\"activate\":")
                .append(activate);
        sb.append(",\"authorize\":")
                .append(authorize);
        sb.append(",\"accessTokenUrl\":\"")
                .append(accessTokenUrl).append('\"');
        sb.append(",\"bindUserUrl\":\"")
                .append(bindUserUrl).append('\"');
        sb.append(",\"appId\":\"")
                .append(appId).append('\"');
        sb.append(",\"appSecret\":\"")
                .append(appSecret).append('\"');
        sb.append(",\"grantType\":\"")
                .append(grantType).append('\"');
        sb.append(",\"configToken\":\"")
                .append(configToken).append('\"');
        sb.append('}');
        return sb.toString();
    }
}
