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

   Consumption Management APIs
   消费管理API接口

   OpenAPI spec version: v1
   Contact: 

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


import Foundation
import JDCloudSDKCore


///  查询计费价格信息
public class CalculateTotalPriceRequest:JdCloudRequest
{
    /// 操作类型 1:创建 2:续费 3:升配 4:删除
    var cmd:Int

    /// 计算价格的订单
    var orderList:[OrderPriceProtocol?]?

    /// 操作时间，遵循ISO8601标准，使用UTC时间，格式为：YYYY-MM-DDTHH:mm:ssZ
    var operateTime:String?

    /// 1:折扣（不需要传） 2:免费活动3:付费活动 4:推荐码 5:会员价 [{&quot;promotionType&quot;:1,&quot;activityCode&quot;:123},{&quot;promotionType&quot;:2,&quot;activityCode&quot;:}]
    var promotionInfo:String?

    /// 客户端：1.PC端；2.移动端；
    var clientType:Int?

    /// 批量购买时数量
    var packageCount:Int

    /// 临时升配时必传，3-临时升配
    var processType:Int?


    public init(regionId: String,cmd:Int,packageCount:Int){
        self.cmd = cmd
        self.packageCount = packageCount
        super.init(regionId: regionId)
    }


    enum CalculateTotalPriceRequestRequestCodingKeys: String, CodingKey {
        case cmd
        case orderList
        case operateTime
        case promotionInfo
        case clientType
        case packageCount
        case processType
    }

    public override func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: CalculateTotalPriceRequestRequestCodingKeys.self)
        try encoderContainer.encode(cmd, forKey: .cmd)
        try encoderContainer.encode(orderList, forKey: .orderList)
        try encoderContainer.encode(operateTime, forKey: .operateTime)
        try encoderContainer.encode(promotionInfo, forKey: .promotionInfo)
        try encoderContainer.encode(clientType, forKey: .clientType)
        try encoderContainer.encode(packageCount, forKey: .packageCount)
        try encoderContainer.encode(processType, forKey: .processType)

    }
}

public class CalculateTotalPriceResponse:NSObject,Codable
{
    var requestId:String?;

    var error:ServiceError?;

    var result:CalculateTotalPriceResult?;

    enum CalculateTotalPriceResponseCodingKeys: String, CodingKey {
        case requestId
        case error
        case result
    }

    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: CalculateTotalPriceResponseCodingKeys.self)
        self.requestId = try decoderContainer.decodeIfPresent(String?.self, forKey: .requestId) ?? nil
        self.error = try decoderContainer.decodeIfPresent(ServiceError?.self, forKey: .error) ?? nil
        self.result = try decoderContainer.decodeIfPresent(CalculateTotalPriceResult?.self, forKey: .result) ?? nil
    }
}

public extension CalculateTotalPriceResponse{
        func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: CalculateTotalPriceResponseCodingKeys.self)
        try encoderContainer.encode(requestId, forKey: .requestId)
        try encoderContainer.encode(error, forKey: .error)
        try encoderContainer.encode(result, forKey: .result)
    }
}    
/// 查询计费价格信息 
public class CalculateTotalPriceResult:NSObject,JdCloudResult
{
    /// 订单折扣前总价
    var totalPrice:Double?

    /// 订单折扣前总价4位
    var totalPriceScale4:Double?

    /// 折扣后订单价格
    var discountedTotalPrice:Double?

    /// 总折扣金额
    var totalDiscount:Double?

    /// 计算完价格后的详细订单列表
    var list:[OrderPriceDetail?]?

    /// 订单原价 包年时 一年原价为12个月价格，totalPrice为10个月价格
    var totalOriginalPrice:Double?

    /// 参与优惠的明细
    var favorableInfos:String?

    /// 备注
    var remark:String?

    /// 各订单单价总和
    var totalUnitPrice:Double?



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

    enum CalculateTotalPriceResultCodingKeys: String, CodingKey {
        case totalPrice
        case totalPriceScale4
        case discountedTotalPrice
        case totalDiscount
        case list
        case totalOriginalPrice
        case favorableInfos
        case remark
        case totalUnitPrice
    }

    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: CalculateTotalPriceResultCodingKeys.self)
        if decoderContainer.contains(.totalPrice)
        {
            self.totalPrice = try decoderContainer.decode(Double?.self, forKey: .totalPrice)
        }
        if decoderContainer.contains(.totalPriceScale4)
        {
            self.totalPriceScale4 = try decoderContainer.decode(Double?.self, forKey: .totalPriceScale4)
        }
        if decoderContainer.contains(.discountedTotalPrice)
        {
            self.discountedTotalPrice = try decoderContainer.decode(Double?.self, forKey: .discountedTotalPrice)
        }
        if decoderContainer.contains(.totalDiscount)
        {
            self.totalDiscount = try decoderContainer.decode(Double?.self, forKey: .totalDiscount)
        }
        if decoderContainer.contains(.list)
        {
            self.list = try decoderContainer.decode([OrderPriceDetail?]?.self, forKey: .list)
        }
        if decoderContainer.contains(.totalOriginalPrice)
        {
            self.totalOriginalPrice = try decoderContainer.decode(Double?.self, forKey: .totalOriginalPrice)
        }
        if decoderContainer.contains(.favorableInfos)
        {
            self.favorableInfos = try decoderContainer.decode(String?.self, forKey: .favorableInfos)
        }
        if decoderContainer.contains(.remark)
        {
            self.remark = try decoderContainer.decode(String?.self, forKey: .remark)
        }
        if decoderContainer.contains(.totalUnitPrice)
        {
            self.totalUnitPrice = try decoderContainer.decode(Double?.self, forKey: .totalUnitPrice)
        }
    }
}
public extension CalculateTotalPriceResult{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: CalculateTotalPriceResultCodingKeys.self)
        try encoderContainer.encode(totalPrice, forKey: .totalPrice)
        try encoderContainer.encode(totalPriceScale4, forKey: .totalPriceScale4)
        try encoderContainer.encode(discountedTotalPrice, forKey: .discountedTotalPrice)
        try encoderContainer.encode(totalDiscount, forKey: .totalDiscount)
        try encoderContainer.encode(list, forKey: .list)
        try encoderContainer.encode(totalOriginalPrice, forKey: .totalOriginalPrice)
        try encoderContainer.encode(favorableInfos, forKey: .favorableInfos)
        try encoderContainer.encode(remark, forKey: .remark)
        try encoderContainer.encode(totalUnitPrice, forKey: .totalUnitPrice)
    }
}
/// 查询账单资源汇总数据 
public class QueryBillSummaryResult:NSObject,JdCloudResult
{
    /// Pagination
    var pagination:Pagination?

    /// Result
    var result:[BillSummary?]?



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

    enum QueryBillSummaryResultCodingKeys: String, CodingKey {
        case pagination
        case result
    }

    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: QueryBillSummaryResultCodingKeys.self)
        if decoderContainer.contains(.pagination)
        {
            self.pagination = try decoderContainer.decode(Pagination?.self, forKey: .pagination)
        }
        if decoderContainer.contains(.result)
        {
            self.result = try decoderContainer.decode([BillSummary?]?.self, forKey: .result)
        }
    }
}
public extension QueryBillSummaryResult{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: QueryBillSummaryResultCodingKeys.self)
        try encoderContainer.encode(pagination, forKey: .pagination)
        try encoderContainer.encode(result, forKey: .result)
    }
}
/// 查询账单明细数据 
public class QueryBillDetailResult:NSObject,JdCloudResult
{
    /// Pagination
    var pagination:Pagination?

    /// Result
    var result:[BillSummary?]?



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

    enum QueryBillDetailResultCodingKeys: String, CodingKey {
        case pagination
        case result
    }

    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: QueryBillDetailResultCodingKeys.self)
        if decoderContainer.contains(.pagination)
        {
            self.pagination = try decoderContainer.decode(Pagination?.self, forKey: .pagination)
        }
        if decoderContainer.contains(.result)
        {
            self.result = try decoderContainer.decode([BillSummary?]?.self, forKey: .result)
        }
    }
}
public extension QueryBillDetailResult{
    func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: QueryBillDetailResultCodingKeys.self)
        try encoderContainer.encode(pagination, forKey: .pagination)
        try encoderContainer.encode(result, forKey: .result)
    }
}

///  查询账单资源汇总数据
public class QueryBillSummaryRequest:JdCloudRequest
{
    /// 计费开始时间
    var startTime:String

    /// 计费结束时间
    var endTime:String

    /// 产品线代码
    var appCode:String?

    /// 产品代码
    var serviceCode:String?

    /// 资源单id列表
    var resourceIds:[String?]?

    /// 标签
    var tags:[Tags?]?

    /// pageIndex
    var pageIndex:Int?

    /// pageSize
    var pageSize:Int?


    public init(regionId: String,startTime:String,endTime:String){
        self.startTime = startTime
        self.endTime = endTime
        super.init(regionId: regionId)
    }


    enum QueryBillSummaryRequestRequestCodingKeys: String, CodingKey {
        case startTime
        case endTime
        case appCode
        case serviceCode
        case resourceIds
        case tags
        case pageIndex
        case pageSize
    }

    public override func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: QueryBillSummaryRequestRequestCodingKeys.self)
        try encoderContainer.encode(startTime, forKey: .startTime)
        try encoderContainer.encode(endTime, forKey: .endTime)
        try encoderContainer.encode(appCode, forKey: .appCode)
        try encoderContainer.encode(serviceCode, forKey: .serviceCode)
        try encoderContainer.encode(resourceIds, forKey: .resourceIds)
        try encoderContainer.encode(tags, forKey: .tags)
        try encoderContainer.encode(pageIndex, forKey: .pageIndex)
        try encoderContainer.encode(pageSize, forKey: .pageSize)

    }
}

public class QueryBillSummaryResponse:NSObject,Codable
{
    var requestId:String?;

    var error:ServiceError?;

    var result:QueryBillSummaryResult?;

    enum QueryBillSummaryResponseCodingKeys: String, CodingKey {
        case requestId
        case error
        case result
    }

    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: QueryBillSummaryResponseCodingKeys.self)
        self.requestId = try decoderContainer.decodeIfPresent(String?.self, forKey: .requestId) ?? nil
        self.error = try decoderContainer.decodeIfPresent(ServiceError?.self, forKey: .error) ?? nil
        self.result = try decoderContainer.decodeIfPresent(QueryBillSummaryResult?.self, forKey: .result) ?? nil
    }
}

public extension QueryBillSummaryResponse{
        func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: QueryBillSummaryResponseCodingKeys.self)
        try encoderContainer.encode(requestId, forKey: .requestId)
        try encoderContainer.encode(error, forKey: .error)
        try encoderContainer.encode(result, forKey: .result)
    }
}    
public class QueryBillDetailResponse:NSObject,Codable
{
    var requestId:String?;

    var error:ServiceError?;

    var result:QueryBillDetailResult?;

    enum QueryBillDetailResponseCodingKeys: String, CodingKey {
        case requestId
        case error
        case result
    }

    required public init(from decoder: Decoder) throws {
        let decoderContainer = try decoder.container(keyedBy: QueryBillDetailResponseCodingKeys.self)
        self.requestId = try decoderContainer.decodeIfPresent(String?.self, forKey: .requestId) ?? nil
        self.error = try decoderContainer.decodeIfPresent(ServiceError?.self, forKey: .error) ?? nil
        self.result = try decoderContainer.decodeIfPresent(QueryBillDetailResult?.self, forKey: .result) ?? nil
    }
}

public extension QueryBillDetailResponse{
        func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: QueryBillDetailResponseCodingKeys.self)
        try encoderContainer.encode(requestId, forKey: .requestId)
        try encoderContainer.encode(error, forKey: .error)
        try encoderContainer.encode(result, forKey: .result)
    }
}    

///  查询账单明细数据
public class QueryBillDetailRequest:JdCloudRequest
{
    /// 计费开始时间
    var startTime:String

    /// 计费结束时间
    var endTime:String

    /// 产品线代码
    var appCode:String?

    /// 产品代码
    var serviceCode:String?

    /// 计费类型 1、按配置 2、按用量 3、包年包月 4、按次
    var billingType:Int?

    /// 资源单id列表
    var resourceIds:[String?]?

    /// 标签
    var tags:[Tags?]?

    /// pageIndex
    var pageIndex:Int?

    /// pageSize
    var pageSize:Int?


    public init(regionId: String,startTime:String,endTime:String){
        self.startTime = startTime
        self.endTime = endTime
        super.init(regionId: regionId)
    }


    enum QueryBillDetailRequestRequestCodingKeys: String, CodingKey {
        case startTime
        case endTime
        case appCode
        case serviceCode
        case billingType
        case resourceIds
        case tags
        case pageIndex
        case pageSize
    }

    public override func encode(to encoder: Encoder) throws {
        var encoderContainer = encoder.container(keyedBy: QueryBillDetailRequestRequestCodingKeys.self)
        try encoderContainer.encode(startTime, forKey: .startTime)
        try encoderContainer.encode(endTime, forKey: .endTime)
        try encoderContainer.encode(appCode, forKey: .appCode)
        try encoderContainer.encode(serviceCode, forKey: .serviceCode)
        try encoderContainer.encode(billingType, forKey: .billingType)
        try encoderContainer.encode(resourceIds, forKey: .resourceIds)
        try encoderContainer.encode(tags, forKey: .tags)
        try encoderContainer.encode(pageIndex, forKey: .pageIndex)
        try encoderContainer.encode(pageSize, forKey: .pageSize)

    }
}

