/* 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账户接口

   OpenAPI spec version: v1
   Contact: 

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


import Foundation
///  domain
public class Domain:NSObject,Codable{
    /// 索引ID
    var id:Int?
    /// 账户ID
    var accountId:String?
    /// 服务的域名
    var domainName:String?
    /// 域名创建时间
    var createTime:Int64?
    /// 从本月1号开始到现在的httpdns总查询次数
    var queryCount:Int64?
    /// 是否删除
    var isDelete:Int?



    public override init(){
            super.init()
    }

    enum DomainCodingKeys: String, CodingKey {
        case id
        case accountId
        case domainName
        case createTime
        case queryCount
        case isDelete
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: DomainCodingKeys.self)
        if decoderContainer.contains(.id)
        {
            self.id = try decoderContainer.decode(Int?.self, forKey: .id)
        }
        if decoderContainer.contains(.accountId)
        {
            self.accountId = try decoderContainer.decode(String?.self, forKey: .accountId)
        }
        if decoderContainer.contains(.domainName)
        {
            self.domainName = try decoderContainer.decode(String?.self, forKey: .domainName)
        }
        if decoderContainer.contains(.createTime)
        {
            self.createTime = try decoderContainer.decode(Int64?.self, forKey: .createTime)
        }
        if decoderContainer.contains(.queryCount)
        {
            self.queryCount = try decoderContainer.decode(Int64?.self, forKey: .queryCount)
        }
        if decoderContainer.contains(.isDelete)
        {
            self.isDelete = try decoderContainer.decode(Int?.self, forKey: .isDelete)
        }
    }
}
public extension Domain{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: DomainCodingKeys.self)
         try encoderContainer.encode(id, forKey: .id)
         try encoderContainer.encode(accountId, forKey: .accountId)
         try encoderContainer.encode(domainName, forKey: .domainName)
         try encoderContainer.encode(createTime, forKey: .createTime)
         try encoderContainer.encode(queryCount, forKey: .queryCount)
         try encoderContainer.encode(isDelete, forKey: .isDelete)
    }
}
///  domainData
public class DomainData:NSObject,Codable{
    /// 域名数组
    var dataList:[Domain?]?
    /// 当前页的个数
    var currentCount:Int?
    /// 域名的总数
    var totalCount:Int?
    /// 域名的总页数
    var totalPage:Int?



    public override init(){
            super.init()
    }

    enum DomainDataCodingKeys: String, CodingKey {
        case dataList
        case currentCount
        case totalCount
        case totalPage
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: DomainDataCodingKeys.self)
        if decoderContainer.contains(.dataList)
        {
            self.dataList = try decoderContainer.decode([Domain?]?.self, forKey: .dataList)
        }
        if decoderContainer.contains(.currentCount)
        {
            self.currentCount = try decoderContainer.decode(Int?.self, forKey: .currentCount)
        }
        if decoderContainer.contains(.totalCount)
        {
            self.totalCount = try decoderContainer.decode(Int?.self, forKey: .totalCount)
        }
        if decoderContainer.contains(.totalPage)
        {
            self.totalPage = try decoderContainer.decode(Int?.self, forKey: .totalPage)
        }
    }
}
public extension DomainData{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: DomainDataCodingKeys.self)
         try encoderContainer.encode(dataList, forKey: .dataList)
         try encoderContainer.encode(currentCount, forKey: .currentCount)
         try encoderContainer.encode(totalCount, forKey: .totalCount)
         try encoderContainer.encode(totalPage, forKey: .totalPage)
    }
}
///  countData
public class CountData:NSObject,Codable{
    /// 时间序列
    var time:[Int64?]?
    /// 数据序列
    var count:[Count?]?



    public override init(){
            super.init()
    }

    enum CountDataCodingKeys: String, CodingKey {
        case time
        case count
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: CountDataCodingKeys.self)
        if decoderContainer.contains(.time)
        {
            self.time = try decoderContainer.decode([Int64?]?.self, forKey: .time)
        }
        if decoderContainer.contains(.count)
        {
            self.count = try decoderContainer.decode([Count?]?.self, forKey: .count)
        }
    }
}
public extension CountData{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: CountDataCodingKeys.self)
         try encoderContainer.encode(time, forKey: .time)
         try encoderContainer.encode(count, forKey: .count)
    }
}
///  count
public class Count:NSObject,Codable{
    /// 类型，&quot;http_auth&quot;,&quot;http_non_auth&quot;,&quot;https_auth&quot;,&quot;https_non_auth&quot;,&quot;all&quot;5种
    var name:String?
    /// 此类型的数据。&lt;br&gt;
      /// &quot;all&quot;类型的data是&quot;http_auth&quot;,&quot;http_noauth&quot;,&quot;https_auth&quot;,&quot;https_noauth&quot;四个类型的data之和。
      /// 
    var data:[Int64?]?



    public override init(){
            super.init()
    }

    enum CountCodingKeys: String, CodingKey {
        case name
        case data
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: CountCodingKeys.self)
        if decoderContainer.contains(.name)
        {
            self.name = try decoderContainer.decode(String?.self, forKey: .name)
        }
        if decoderContainer.contains(.data)
        {
            self.data = try decoderContainer.decode([Int64?]?.self, forKey: .data)
        }
    }
}
public extension Count{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: CountCodingKeys.self)
         try encoderContainer.encode(name, forKey: .name)
         try encoderContainer.encode(data, forKey: .data)
    }
}
///  totalcount
public class Totalcount:NSObject,Codable{
    /// 域名
    var domain:String?
    /// 域名的查询总数
    var count:Int64?



    public override init(){
            super.init()
    }

    enum TotalcountCodingKeys: String, CodingKey {
        case domain
        case count
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: TotalcountCodingKeys.self)
        if decoderContainer.contains(.domain)
        {
            self.domain = try decoderContainer.decode(String?.self, forKey: .domain)
        }
        if decoderContainer.contains(.count)
        {
            self.count = try decoderContainer.decode(Int64?.self, forKey: .count)
        }
    }
}
public extension Totalcount{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: TotalcountCodingKeys.self)
         try encoderContainer.encode(domain, forKey: .domain)
         try encoderContainer.encode(count, forKey: .count)
    }
}
///  totalcountData
public class TotalcountData:NSObject,Codable{
    /// 域名查询次数数组
    var dataList:[Totalcount?]?
    /// 当前页的个数
    var currentCount:Int?
    /// 总数
    var totalCount:Int?
    /// 总页数
    var totalPage:Int?



    public override init(){
            super.init()
    }

    enum TotalcountDataCodingKeys: String, CodingKey {
        case dataList
        case currentCount
        case totalCount
        case totalPage
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: TotalcountDataCodingKeys.self)
        if decoderContainer.contains(.dataList)
        {
            self.dataList = try decoderContainer.decode([Totalcount?]?.self, forKey: .dataList)
        }
        if decoderContainer.contains(.currentCount)
        {
            self.currentCount = try decoderContainer.decode(Int?.self, forKey: .currentCount)
        }
        if decoderContainer.contains(.totalCount)
        {
            self.totalCount = try decoderContainer.decode(Int?.self, forKey: .totalCount)
        }
        if decoderContainer.contains(.totalPage)
        {
            self.totalPage = try decoderContainer.decode(Int?.self, forKey: .totalPage)
        }
    }
}
public extension TotalcountData{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: TotalcountDataCodingKeys.self)
         try encoderContainer.encode(dataList, forKey: .dataList)
         try encoderContainer.encode(currentCount, forKey: .currentCount)
         try encoderContainer.encode(totalCount, forKey: .totalCount)
         try encoderContainer.encode(totalPage, forKey: .totalPage)
    }
}
///  dataplan
public class Dataplan:NSObject,Codable{
    /// 流量包索引ID
    var id:Int?
    /// 账户ID
    var accountId:String?
    /// 这个流量包的总数
    var number:Double?
    /// 这个流量包的单位
    var unit:Int?
    /// 这个流量包的起始时间
    var startTime:Int64?
    /// 这个流量包的过期时间
    var expireTime:Int64?
    /// 这个流量包使用过了的数量
    var usedNumber:Double?
    /// 流量包的类型，1:免费流量包 2:收费包
    var type:Int?
    /// 是否过期，0:未过期 1:过期了
    var isExpired:Int?



    public override init(){
            super.init()
    }

    enum DataplanCodingKeys: String, CodingKey {
        case id
        case accountId
        case number
        case unit
        case startTime
        case expireTime
        case usedNumber
        case type
        case isExpired
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: DataplanCodingKeys.self)
        if decoderContainer.contains(.id)
        {
            self.id = try decoderContainer.decode(Int?.self, forKey: .id)
        }
        if decoderContainer.contains(.accountId)
        {
            self.accountId = try decoderContainer.decode(String?.self, forKey: .accountId)
        }
        if decoderContainer.contains(.number)
        {
            self.number = try decoderContainer.decode(Double?.self, forKey: .number)
        }
        if decoderContainer.contains(.unit)
        {
            self.unit = try decoderContainer.decode(Int?.self, forKey: .unit)
        }
        if decoderContainer.contains(.startTime)
        {
            self.startTime = try decoderContainer.decode(Int64?.self, forKey: .startTime)
        }
        if decoderContainer.contains(.expireTime)
        {
            self.expireTime = try decoderContainer.decode(Int64?.self, forKey: .expireTime)
        }
        if decoderContainer.contains(.usedNumber)
        {
            self.usedNumber = try decoderContainer.decode(Double?.self, forKey: .usedNumber)
        }
        if decoderContainer.contains(.type)
        {
            self.type = try decoderContainer.decode(Int?.self, forKey: .type)
        }
        if decoderContainer.contains(.isExpired)
        {
            self.isExpired = try decoderContainer.decode(Int?.self, forKey: .isExpired)
        }
    }
}
public extension Dataplan{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: DataplanCodingKeys.self)
         try encoderContainer.encode(id, forKey: .id)
         try encoderContainer.encode(accountId, forKey: .accountId)
         try encoderContainer.encode(number, forKey: .number)
         try encoderContainer.encode(unit, forKey: .unit)
         try encoderContainer.encode(startTime, forKey: .startTime)
         try encoderContainer.encode(expireTime, forKey: .expireTime)
         try encoderContainer.encode(usedNumber, forKey: .usedNumber)
         try encoderContainer.encode(type, forKey: .type)
         try encoderContainer.encode(isExpired, forKey: .isExpired)
    }
}
///  dataplanInfo
public class DataplanInfo:NSObject,Codable{
    /// 使用过的额度
    var usedNumber:Int64?
    /// 剩余的额度
    var excessNumber:Int64?



    public override init(){
            super.init()
    }

    enum DataplanInfoCodingKeys: String, CodingKey {
        case usedNumber
        case excessNumber
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: DataplanInfoCodingKeys.self)
        if decoderContainer.contains(.usedNumber)
        {
            self.usedNumber = try decoderContainer.decode(Int64?.self, forKey: .usedNumber)
        }
        if decoderContainer.contains(.excessNumber)
        {
            self.excessNumber = try decoderContainer.decode(Int64?.self, forKey: .excessNumber)
        }
    }
}
public extension DataplanInfo{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: DataplanInfoCodingKeys.self)
         try encoderContainer.encode(usedNumber, forKey: .usedNumber)
         try encoderContainer.encode(excessNumber, forKey: .excessNumber)
    }
}
///  accountId
public class AccountId:NSObject,Codable{
    /// 用户名
    var userPin:String?
    /// 账户ID
    var accountIdValue:String?



    public override init(){
            super.init()
    }

    enum AccountIdCodingKeys: String, CodingKey {
        case userPin
        case accountIdValue = "accountId"
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: AccountIdCodingKeys.self)
        if decoderContainer.contains(.userPin)
        {
            self.userPin = try decoderContainer.decode(String?.self, forKey: .userPin)
        }
        if decoderContainer.contains(.accountIdValue)
        {
            self.accountIdValue = try decoderContainer.decode(String?.self, forKey: .accountIdValue)
        }
    }
}
public extension AccountId{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: AccountIdCodingKeys.self)
         try encoderContainer.encode(userPin, forKey: .userPin)
         try encoderContainer.encode(accountIdValue, forKey: .accountIdValue)
    }
}
///  account
public class Account:NSObject,Codable{
    /// 索引id
    var id:Int?
    /// 用户名
    var userPin:String?
    /// 账户ID
    var accountId:String?
    /// 提供httpdns服务的IP
    var serviceIp:[String?]?
    /// httpdns服务的密钥
    var key:[String?]?
    /// httpdns服务的密钥的状态，同key的序号对应
    var keyStatus:[Int?]?
    /// 账户创建时间
    var createTime:Int64?
    /// 账户更新时间
    var updateTime:Int64?
    /// 非鉴权方式是否可以访问httpdns服务，0:不可以，1:可以
    var noauthAccess:Int?
    /// 账户最多可以创建的域名
    var domainLimit:Int?
    /// 账户状态，0:正常 1:使用80%流量，2:欠费 3:停服
    var accountStatus:Int?



    public override init(){
            super.init()
    }

    enum AccountCodingKeys: String, CodingKey {
        case id
        case userPin
        case accountId
        case serviceIp
        case key
        case keyStatus
        case createTime
        case updateTime
        case noauthAccess
        case domainLimit
        case accountStatus
    }


    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: AccountCodingKeys.self)
        if decoderContainer.contains(.id)
        {
            self.id = try decoderContainer.decode(Int?.self, forKey: .id)
        }
        if decoderContainer.contains(.userPin)
        {
            self.userPin = try decoderContainer.decode(String?.self, forKey: .userPin)
        }
        if decoderContainer.contains(.accountId)
        {
            self.accountId = try decoderContainer.decode(String?.self, forKey: .accountId)
        }
        if decoderContainer.contains(.serviceIp)
        {
            self.serviceIp = try decoderContainer.decode([String?]?.self, forKey: .serviceIp)
        }
        if decoderContainer.contains(.key)
        {
            self.key = try decoderContainer.decode([String?]?.self, forKey: .key)
        }
        if decoderContainer.contains(.keyStatus)
        {
            self.keyStatus = try decoderContainer.decode([Int?]?.self, forKey: .keyStatus)
        }
        if decoderContainer.contains(.createTime)
        {
            self.createTime = try decoderContainer.decode(Int64?.self, forKey: .createTime)
        }
        if decoderContainer.contains(.updateTime)
        {
            self.updateTime = try decoderContainer.decode(Int64?.self, forKey: .updateTime)
        }
        if decoderContainer.contains(.noauthAccess)
        {
            self.noauthAccess = try decoderContainer.decode(Int?.self, forKey: .noauthAccess)
        }
        if decoderContainer.contains(.domainLimit)
        {
            self.domainLimit = try decoderContainer.decode(Int?.self, forKey: .domainLimit)
        }
        if decoderContainer.contains(.accountStatus)
        {
            self.accountStatus = try decoderContainer.decode(Int?.self, forKey: .accountStatus)
        }
    }
}
public extension Account{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: AccountCodingKeys.self)
         try encoderContainer.encode(id, forKey: .id)
         try encoderContainer.encode(userPin, forKey: .userPin)
         try encoderContainer.encode(accountId, forKey: .accountId)
         try encoderContainer.encode(serviceIp, forKey: .serviceIp)
         try encoderContainer.encode(key, forKey: .key)
         try encoderContainer.encode(keyStatus, forKey: .keyStatus)
         try encoderContainer.encode(createTime, forKey: .createTime)
         try encoderContainer.encode(updateTime, forKey: .updateTime)
         try encoderContainer.encode(noauthAccess, forKey: .noauthAccess)
         try encoderContainer.encode(domainLimit, forKey: .domainLimit)
         try encoderContainer.encode(accountStatus, forKey: .accountStatus)
    }
}
