ClubReady Api

<back to all web services

AgreementAddEndpoint

The following routes are available for this service:
POST/sales/agreement/addSet up a package that will be sold to an existing userSet up a package that will be sold to an existing user. The PaymentMethods property is an array of objects describing how you want ClubReady to take payment while selling the PackageId/InstallmentPlanId. If omitted (or null), the preferred on-file profile will be used. The header `X-Forwarded-For` is required and should be set to the IP address of the end user.
import Foundation
import ServiceStack

// @ApiResponse(Description="", ResponseType=typeof(AddResponse), StatusCode=200)
public class AgreementAddEndpoint : IAddEndpoint, IRestrictedApiRequest, Codable
{
    /**
    * IP address of the end user
    */
    // @ApiMember(Description="IP address of the end user", IsRequired=true, Name="X-Forwarded-For", ParameterType="header")
    public var xForwardedFor:String

    /**
    * Api Authentication Key
    */
    // @ApiMember(Description="Api Authentication Key", IsRequired=true, ParameterType="query")
    public var apiKey:String

    /**
    * Member Id of the user buying the Package
    */
    // @ApiMember(Description="Member Id of the user buying the Package", IsRequired=true, ParameterType="query")
    public var memberId:Int

    public var chainId:Int?
    /**
    * Id of the store for the user
    */
    // @ApiMember(Description="Id of the store for the user", IsRequired=true)
    public var storeId:Int?

    /**
    * Package Id number of the package being purchased
    */
    // @ApiMember(Description="Package Id number of the package being purchased", IsRequired=true)
    public var packageId:Int

    /**
    * Installment Plan Id being purchased. If empty, the default package will be selected.
    */
    // @ApiMember(Description="Installment Plan Id being purchased. If empty, the default package will be selected.")
    public var installmentId:Int?

    /**
    * Date contract takes affect
    */
    // @ApiMember(Description="Date contract takes affect")
    public var startDate:Date?

    /**
    * Promo code to apply a discount.
    */
    // @ApiMember(Description="Promo code to apply a discount.")
    public var promoCode:String

    /**
    * Staff Id of salesperson who sold the agreement.
    */
    // @ApiMember(Description="Staff Id of salesperson who sold the agreement.")
    public var staffId:Int?

    public var restrictedId:Int?
    public var restrictedResourceType:RestrictedResourceType

    required public init(){}
}

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

public class AddResponse : ApiResponse2Base
{
    public var incompleteAgreementToken:String
    public var contractId:Int?

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

    private enum CodingKeys : String, CodingKey {
        case incompleteAgreementToken
        case contractId
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        incompleteAgreementToken = try container.decodeIfPresent(String.self, forKey: .incompleteAgreementToken)
        contractId = try container.decodeIfPresent(Int.self, forKey: .contractId)
    }

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

public class ApiResponse2Base : Codable
{
    public var success:Bool
    public var message:String

    required public init(){}
}


Swift AgreementAddEndpoint DTOs

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

HTTP + JSV

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

POST /sales/agreement/add HTTP/1.1 
Host: www.clubready.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	XForwardedFor: String,
	ApiKey: String,
	MemberId: 0,
	ChainId: 0,
	StoreId: 0,
	PackageId: 0,
	InstallmentId: 0,
	StartDate: 0001-01-01,
	PromoCode: String,
	StaffId: 0,
	RestrictedId: 0,
	RestrictedResourceType: Store
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	incompleteAgreementToken: String,
	contractId: 0,
	success: False,
	message: String
}