/* 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.

   京东云httpdns OpenAPI接口
   京东云httpdns OpenAPI接口

   OpenAPI spec version: v1
   Contact: 

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



import Foundation
import JDCloudSDKCore

public class HttpdnsJDCloudClient:NSObject,JDCloudClient{
    
    private final var httpdnsJDCloudClient:HttpdnsJDCloudClient!


    public convenience init(credential:Credential,sdkEnvironment:SDKEnvironment) {
        self.init()
        self.credential = credential
        self.sdkEnvironment = sdkEnvironment
        httpdnsJDCloudClient = 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: "httpdns.jdcloud-api.com");
        }
        self.credential = GlobalConfig.credential!
        self.sdkEnvironment = sdkEnvironment
        super.init()
        httpdnsJDCloudClient = self
    }
    
    public let userAgent: String = "JdcloudSdkSwift/" + "0.0.1/" + "httpdns/" + "v1"
    
    public let serviceName: String = "httpdns"
    
    public let version: String = "v1"
    
    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 getAccountInfoAsync(request:GetAccountInfoRequest,requestComplation:@escaping ExecuteResult<GetAccountInfoResult>) throws {
        httpdnsJDCloudClient = self
        try GetAccountInfoExecutor(jdCloudClient: httpdnsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func addDomainsAsync(request:AddDomainsRequest,requestComplation:@escaping ExecuteResult<AddDomainsResult>) throws {
        httpdnsJDCloudClient = self
        try AddDomainsExecutor(jdCloudClient: httpdnsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func delDomainsAsync(request:DelDomainsRequest,requestComplation:@escaping ExecuteResult<DelDomainsResult>) throws {
        httpdnsJDCloudClient = self
        try DelDomainsExecutor(jdCloudClient: httpdnsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func createAccountAsync(request:CreateAccountRequest,requestComplation:@escaping ExecuteResult<CreateAccountResult>) throws {
        httpdnsJDCloudClient = self
        try CreateAccountExecutor(jdCloudClient: httpdnsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func getDomainsAsync(request:GetDomainsRequest,requestComplation:@escaping ExecuteResult<GetDomainsResult>) throws {
        httpdnsJDCloudClient = self
        try GetDomainsExecutor(jdCloudClient: httpdnsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func getAccountIdAsync(request:GetAccountIdRequest,requestComplation:@escaping ExecuteResult<GetAccountIdResult>) throws {
        httpdnsJDCloudClient = self
        try GetAccountIdExecutor(jdCloudClient: httpdnsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }

    
    public func operateKeyAsync(request:OperateKeyRequest,requestComplation:@escaping ExecuteResult<OperateKeyResult>) throws {
        httpdnsJDCloudClient = self
        try OperateKeyExecutor(jdCloudClient: httpdnsJDCloudClient).executeAsync(request: request) { (statusCode,result,error,data) in
            requestComplation(statusCode,result,error,data)

        }
    }
    
}


public extension HttpdnsJDCloudClient{

    convenience init(credential: Credential) {

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