ClubReady Api

<back to all web services

CalculatePaymentPlanRequest

The following routes are available for this service:
GET/sales/packages/{PackageId}/installments/calculate/{InstallmentPlanId}Get customer's billing status
import Foundation
import ServiceStack

public class CalculatePaymentPlanRequest : CalculatePaymentPlanRequestDto, IRestrictedApiRequest
{
    /**
    * Api Key - grants access to resources
    */
    // @ApiMember(DataType="string", Description="Api Key - grants access to resources", IsRequired=true, Name="ApiKey", ParameterType="query")
    public var apiKey:String

    /**
    * ID # of store to calculate plan for
    */
    // @ApiMember(DataType="integer", Description="ID # of store to calculate plan for", IsRequired=true, Name="StoreId", ParameterType="query")
    public var storeId:Int?

    /**
    * Installment Plan to calculate a scheduel for
    */
    // @ApiMember(DataType="integer", Description="Installment Plan to calculate a scheduel for", IsRequired=true, Name="InstallmentPlanId", ParameterType="path")
    public var installmentPlanId:Int

    /**
    * The package to calculate for
    */
    // @ApiMember(DataType="integer", Description="The package to calculate for", IsRequired=true, Name="PackageId", ParameterType="path")
    public var packageId:Int

    /**
    * Date to calculate schedule from. If not provided, will use today.
    */
    // @ApiMember(DataType="datetime", Description="Date to calculate schedule from. If not provided, will use today.", Name="StartDate", ParameterType="query")
    public var startDate:Date?

    /**
    * Promo code to apply a discount.
    */
    // @ApiMember(DataType="string", Description="Promo code to apply a discount.", Name="PromoCode", ParameterType="query")
    public var promoCode:String

    public var restrictedId:Int?
    public var restrictedResourceType:RestrictedResourceType

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

    private enum CodingKeys : String, CodingKey {
        case apiKey
        case storeId
        case installmentPlanId
        case packageId
        case startDate
        case promoCode
        case restrictedId
        case restrictedResourceType
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        apiKey = try container.decodeIfPresent(String.self, forKey: .apiKey)
        storeId = try container.decodeIfPresent(Int.self, forKey: .storeId)
        installmentPlanId = try container.decodeIfPresent(Int.self, forKey: .installmentPlanId)
        packageId = try container.decodeIfPresent(Int.self, forKey: .packageId)
        startDate = try container.decodeIfPresent(Date.self, forKey: .startDate)
        promoCode = try container.decodeIfPresent(String.self, forKey: .promoCode)
        restrictedId = try container.decodeIfPresent(Int.self, forKey: .restrictedId)
        restrictedResourceType = try container.decodeIfPresent(RestrictedResourceType.self, forKey: .restrictedResourceType)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if apiKey != nil { try container.encode(apiKey, forKey: .apiKey) }
        if storeId != nil { try container.encode(storeId, forKey: .storeId) }
        if installmentPlanId != nil { try container.encode(installmentPlanId, forKey: .installmentPlanId) }
        if packageId != nil { try container.encode(packageId, forKey: .packageId) }
        if startDate != nil { try container.encode(startDate, forKey: .startDate) }
        if promoCode != nil { try container.encode(promoCode, forKey: .promoCode) }
        if restrictedId != nil { try container.encode(restrictedId, forKey: .restrictedId) }
        if restrictedResourceType != nil { try container.encode(restrictedResourceType, forKey: .restrictedResourceType) }
    }
}

public class CalculatePaymentPlanRequestDto : ApiDtoBase
{
    public var installmentPlanId:Int
    public var packageId:Int
    public var startDate:Date?
    public var promoCode:String

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

    private enum CodingKeys : String, CodingKey {
        case installmentPlanId
        case packageId
        case startDate
        case promoCode
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        installmentPlanId = try container.decodeIfPresent(Int.self, forKey: .installmentPlanId)
        packageId = try container.decodeIfPresent(Int.self, forKey: .packageId)
        startDate = try container.decodeIfPresent(Date.self, forKey: .startDate)
        promoCode = try container.decodeIfPresent(String.self, forKey: .promoCode)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if installmentPlanId != nil { try container.encode(installmentPlanId, forKey: .installmentPlanId) }
        if packageId != nil { try container.encode(packageId, forKey: .packageId) }
        if startDate != nil { try container.encode(startDate, forKey: .startDate) }
        if promoCode != nil { try container.encode(promoCode, forKey: .promoCode) }
    }
}

public class ApiDtoBase : Codable
{
    public var apiKey:String
    public var storeId:Int?
    public var chainId:Int?

    required public init(){}
}

public enum RestrictedResourceType : String, Codable
{
    case Store
    case Chain
    case User
    case Undefined
}

public class CalculatePaymentPlanResultDto : Codable
{
    public var planTotal:String
    public var subTotal:String
    public var taxRate:Float?
    public var enhancementFee:String
    public var enhancementFeeTaxAmount:String
    public var taxEnhFee:Bool
    public var tax:String
    public var totalDueToday:String
    public var payments:[PaymentPlanInstallment] = []
    public var fees:[PaymentPlanInstallment] = []
    public var isEvergreen:Bool
    public var requirePaymentProfile:Bool

    required public init(){}
}

public class PaymentPlanInstallment : Codable
{
    public var payToday:Bool
    public var amount:Double
    public var taxed:Bool
    public var taxRate:Float?
    public var taxAmount:Double?
    public var feeName:String
    public var dueDate:Date
    public var total:String
    public var setupFeeId:Int?

    required public init(){}
}


Swift CalculatePaymentPlanRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /sales/packages/{PackageId}/installments/calculate/{InstallmentPlanId} HTTP/1.1 
Host: clubready.com 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<CalculatePaymentPlanResultDto xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">
  <EnhancementFee>String</EnhancementFee>
  <Fees>
    <PaymentPlanInstallment>
      <Amount>0</Amount>
      <DueDate>0001-01-01T00:00:00</DueDate>
      <FeeName>String</FeeName>
      <PayToday>false</PayToday>
      <SetupFeeId>0</SetupFeeId>
      <TaxRate>0</TaxRate>
      <Taxed>false</Taxed>
    </PaymentPlanInstallment>
  </Fees>
  <IsEvergreen>false</IsEvergreen>
  <Payments>
    <PaymentPlanInstallment>
      <Amount>0</Amount>
      <DueDate>0001-01-01T00:00:00</DueDate>
      <FeeName>String</FeeName>
      <PayToday>false</PayToday>
      <SetupFeeId>0</SetupFeeId>
      <TaxRate>0</TaxRate>
      <Taxed>false</Taxed>
    </PaymentPlanInstallment>
  </Payments>
  <TaxEnhFee>false</TaxEnhFee>
  <TaxRate>0</TaxRate>
</CalculatePaymentPlanResultDto>