POST | /sales/agreement/add | Set up a package that will be sold to an existing user | Set 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 datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
class RestrictedResourceType(str, Enum):
STORE = 'Store'
CHAIN = 'Chain'
USER = 'User'
UNDEFINED = 'Undefined'
# @ApiResponse(Description="", ResponseType=typeof(AddResponse), StatusCode=200)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AgreementAddEndpoint(IAddEndpoint, IRestrictedApiRequest):
# @ApiMember(Description="IP address of the end user", IsRequired=true, Name="X-Forwarded-For", ParameterType="header")
x_forwarded_for: Optional[str] = None
"""
IP address of the end user
"""
# @ApiMember(Description="Api Authentication Key", IsRequired=true, ParameterType="query")
api_key: Optional[str] = None
"""
Api Authentication Key
"""
# @ApiMember(Description="Member Id of the user buying the Package", IsRequired=true, ParameterType="query")
member_id: int = 0
"""
Member Id of the user buying the Package
"""
chain_id: Optional[int] = None
# @ApiMember(Description="Id of the store for the user", IsRequired=true)
store_id: Optional[int] = None
"""
Id of the store for the user
"""
# @ApiMember(Description="Package Id number of the package being purchased", IsRequired=true)
package_id: int = 0
"""
Package Id number of the package being purchased
"""
# @ApiMember(Description="Installment Plan Id being purchased. If empty, the default package will be selected.")
installment_id: Optional[int] = None
"""
Installment Plan Id being purchased. If empty, the default package will be selected.
"""
# @ApiMember(Description="Date contract takes affect")
start_date: Optional[datetime.datetime] = None
"""
Date contract takes affect
"""
# @ApiMember(Description="Promo code to apply a discount.")
promo_code: Optional[str] = None
"""
Promo code to apply a discount.
"""
# @ApiMember(Description="Staff Id of salesperson who sold the agreement.")
staff_id: Optional[int] = None
"""
Staff Id of salesperson who sold the agreement.
"""
restricted_id: Optional[int] = None
restricted_resource_type: Optional[RestrictedResourceType] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ApiResponse2Base:
success: bool = False
message: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AddResponse(ApiResponse2Base):
incomplete_agreement_token: Optional[str] = None
contract_id: Optional[int] = None
Python AgreementAddEndpoint DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
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/csv
Content-Type: text/csv
Content-Length: length
{"XForwardedFor":"String","ApiKey":"String","MemberId":0,"ChainId":0,"StoreId":0,"PackageId":0,"InstallmentId":0,"StartDate":"0001-01-01T00:00:00.0000000","PromoCode":"String","StaffId":0,"RestrictedId":0,"RestrictedResourceType":"Store"}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"incompleteAgreementToken":"String","contractId":0,"success":false,"message":"String"}