package cn.com.countrygarden.bi.main.sms.client;
/*
* Copyright 2017 Alibaba Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import com.alibaba.cloudapi.sdk.core.BaseApiClient;
import com.alibaba.cloudapi.sdk.core.BaseApiClientBuilder;
import com.alibaba.cloudapi.sdk.core.annotation.NotThreadSafe;
import com.alibaba.cloudapi.sdk.core.annotation.ThreadSafe;
import com.alibaba.cloudapi.sdk.core.enums.Method;
import com.alibaba.cloudapi.sdk.core.enums.ParamPosition;
import com.alibaba.cloudapi.sdk.core.enums.Scheme;
import com.alibaba.cloudapi.sdk.core.model.ApiRequest;
import com.alibaba.cloudapi.sdk.core.model.ApiResponse;
import com.alibaba.cloudapi.sdk.core.model.BuilderParams;

@ThreadSafe
public final class SyncApiClientSmsService extends BaseApiClient {
    public final static String GROUP_HOST = "sms-service-ag.bgyfw.com";

    private SyncApiClientSmsService(BuilderParams builderParams) {
        super(builderParams);
    }

    @NotThreadSafe
    public static class Builder extends BaseApiClientBuilder<Builder, SyncApiClientSmsService>{

        @Override
        protected SyncApiClientSmsService build(BuilderParams params) {
            return new SyncApiClientSmsService(params);
        }
    }

    public static Builder newBuilder(){
        return new Builder();
    }

    public static SyncApiClientSmsService getInstance(){
        return getApiClassInstance(SyncApiClientSmsService.class);
    }

    public ApiResponse postSms(String SpanId, String ParentSpanId, String Sampled, String Flags, String TraceId, String CorpId, String mobile, String content, String type, String Fingerprint) {
        String _apiPath = "/sms";

        ApiRequest _apiRequest = new ApiRequest(Scheme.HTTP, Method.POST_FORM, GROUP_HOST, _apiPath);
        _apiRequest.addParam("X-Proxy-BGY-Service-Fingerprint", Fingerprint, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-SpanId", SpanId, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-ParentSpanId", ParentSpanId, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-Sampled", Sampled, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-Flags", Flags, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-TraceId", TraceId, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-Proxy-BGY-CorpId", CorpId, ParamPosition.HEADER, false);
        _apiRequest.addParam("mobile", mobile, ParamPosition.FORM, true);
        _apiRequest.addParam("content", content, ParamPosition.FORM, true);
        _apiRequest.addParam("type", type, ParamPosition.FORM, true);

        return syncInvoke(_apiRequest);
    }

    public ApiResponse getSms(String SpanId, String TraceId, String Flags, String Sampled, String ParentSpanId, String CorpId, Integer id) {
        String _apiPath = "/sms";

        ApiRequest _apiRequest = new ApiRequest(Scheme.HTTP, Method.GET, GROUP_HOST, _apiPath);

        _apiRequest.addParam("X-B3-SpanId", SpanId, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-TraceId", TraceId, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-Flags", Flags, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-Sampled", Sampled, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-B3-ParentSpanId", ParentSpanId, ParamPosition.HEADER, false);
        _apiRequest.addParam("X-Proxy-BGY-CorpId", CorpId, ParamPosition.HEADER, false);
        _apiRequest.addParam("id", id, ParamPosition.QUERY, true);

        return syncInvoke(_apiRequest);
    }

}

