/* Copyright 2018 JDCLOUD.COM

   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.

   京东云富媒体短信OpenAPI接口
   京东云富媒体短信OpenAPI接口

   OpenAPI spec version: v2
   Contact: 

   NOTE: This class is auto generated by the jdcloud code generator program.
 */



import Foundation
import JDCloudSDKCore

public class RmsJDCloudClient:NSObject,JDCloudClient{
    
    private final var rmsJDCloudClient:RmsJDCloudClient!


    public convenience init(credential:Credential,sdkEnvironment:SDKEnvironment) {
        self.init()
        self.credential = credential
        self.sdkEnvironment = sdkEnvironment
        rmsJDCloudClient = self
    }


    public override init() {

        if(GlobalConfig.credential == nil)
        {
            GlobalConfig.credential = Credential(accessKeyId: "",secretAccessKey: "")
        }
        var sdkEnvironment:SDKEnvironment
        if(GlobalConfig.sdkEnvironment != nil)
        {
            sdkEnvironment = GlobalConfig.sdkEnvironment!
        }else{
            sdkEnvironment = SDKEnvironment(endPoint: "rms.jdcloud-api.com");
        }
        self.credential = GlobalConfig.credential!
        self.sdkEnvironment = sdkEnvironment
        super.init()
        rmsJDCloudClient = self
    }
    
    public let userAgent: String = "JdcloudSdkSwift/" + "0.0.1/" + "rms/" + "v2"
    
    public let serviceName: String = "rms"
    
    public let version: String = "v2"
    
    public let contentType:String = "application/json"
    
    public var credential: Credential
    
    public var sdkEnvironment: SDKEnvironment
    
    public var customHeader: [String : String] = [String:String]()

    public var httpRequestProtocol: String = "https"

    public func addCustomer(key: String, value: String) {
        customHeader[key] = value
    }



    
    public func queryPackageRemainderAsync(request:QueryPackageRemainderRequest,requestComplation:@escaping ExecuteResult<QueryPackageRemainderResult>) throws {
        rmsJDCloudClient = self
        try QueryPackageRemainderExecutor(jdCloudClient: rmsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func addTemplateAsync(request:AddTemplateRequest,requestComplation:@escaping ExecuteResult<AddTemplateResult>) throws {
        rmsJDCloudClient = self
        try AddTemplateExecutor(jdCloudClient: rmsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func sendBatchMsgAsync(request:SendBatchMsgRequest,requestComplation:@escaping ExecuteResult<SendBatchMsgResult>) throws {
        rmsJDCloudClient = self
        try SendBatchMsgExecutor(jdCloudClient: rmsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func queryTemplateByIdAsync(request:QueryTemplateByIdRequest,requestComplation:@escaping ExecuteResult<QueryTemplateByIdResult>) throws {
        rmsJDCloudClient = self
        try QueryTemplateByIdExecutor(jdCloudClient: rmsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func queryTemplateListAsync(request:QueryTemplateListRequest,requestComplation:@escaping ExecuteResult<QueryTemplateListResult>) throws {
        rmsJDCloudClient = self
        try QueryTemplateListExecutor(jdCloudClient: rmsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func querySendStatusAsync(request:QuerySendStatusRequest,requestComplation:@escaping ExecuteResult<QuerySendStatusResult>) throws {
        rmsJDCloudClient = self
        try QuerySendStatusExecutor(jdCloudClient: rmsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }
    
}


public extension RmsJDCloudClient{

    convenience init(credential: Credential) {

        var sdkEnvironment:SDKEnvironment
        if(GlobalConfig.sdkEnvironment != nil)
        {
            sdkEnvironment = GlobalConfig.sdkEnvironment!
        }else{
            sdkEnvironment = SDKEnvironment(endPoint: "rms.jdcloud-api.com");
        }
        self.init(credential: credential,sdkEnvironment: sdkEnvironment)
    }
}
