legend

package
v0.1.1-0...-4d00150 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2020 License: Unlicense Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenderMale      Gender = 1
	GenderFemale    Gender = 2
	GenderCorporate Gender = 3
	GenderUnknown   Gender = 4

	MembershipProcessTypeNew     MembershipProcessType = 0
	MembershipProcessTypeRenewal MembershipProcessType = 1
)
View Source
const LEGEND_DATE_FORMAT = "2006-01-02"

LEGEND_DATE_FORMAT has the time format used by most Legend dates

Variables

This section is empty.

Functions

This section is empty.

Types

type AgreementChannelEventModel

type AgreementChannelEventModel struct {
	EventCode string
	Prompt    string
}

type ApiClient

type ApiClient struct {
	// contains filtered or unexported fields
}

func NewApiClient

func NewApiClient(config ConnectionConfig) *ApiClient

NewApiClient creates a basic Legend API client with a retry-mechanic It will automatically retry on 5xx errors up to the specified retryMax

func (*ApiClient) GetAllLocations

func (this *ApiClient) GetAllLocations() (target []LocationHierarchy, err error)

GetAllLocations returns all available locations

func (*ApiClient) GetApiRequest

func (this *ApiClient) GetApiRequest(path string, params url.Values, responseTarget interface{}) error

GetApiRequest issues a GET requests and unmarshals JSON response into the provided struct

func (*ApiClient) GetBillDays

func (this *ApiClient) GetBillDays() (target BillDayModel, err error)

GetBillDays

func (*ApiClient) GetContactWithEmail

func (this *ApiClient) GetContactWithEmail(email, firstName, lastName string) (target []ContactWithEmailResultModel, err error)

A prospect is assumed as active if it has not been contacted for last few months. 'Number of months' is a configurable setting in Legend.

func (*ApiClient) GetEmailInUse

func (this *ApiClient) GetEmailInUse(email string) (target bool, err error)

GetEmailInUse checks whether the given email is being used

func (*ApiClient) GetEmployers

func (this *ApiClient) GetEmployers(locationGuid string) (target []EmployerModel, err error)

GetEmployers returns list of active employers at given location

func (*ApiClient) GetHasOnlineProfile

func (this *ApiClient) GetHasOnlineProfile(email string) (target *HasOnlineProfile, err error)

GetHasOnlineProfile checks whether the given email already has an online profile

func (*ApiClient) GetMembershipTypes

func (this *ApiClient) GetMembershipTypes(startDate LegendTime, endDate LegendTime, locationId int64, channelId int64) (target []MembershipTypeReturnModel, err error)

GetMembershipTypes reads available memberships at a given location

func (*ApiClient) GetPriceDetails

func (this *ApiClient) GetPriceDetails(locationId int64, priceTypeId int64, startDate time.Time, promotionCode string) (target MembershipPriceDetailsModel, err error)

GetPriceDetails fetches base price for a given membership price at a location

func (*ApiClient) GetRecurringFee

func (this *ApiClient) GetRecurringFee(facilityGuid string, billingMethodId BillingMethod) (target []RecurringFeeModel, err error)

GetRecurringFee returns List of recurring fees (active only)

func (*ApiClient) GetSalesPersonDetails

func (this *ApiClient) GetSalesPersonDetails(locationId int64) (target []SalesPerson, err error)

GetSalesPersonDetails returns a list of sales-people at location

func (*ApiClient) PostApiRequest

func (this *ApiClient) PostApiRequest(path string, params url.Values, body, responseTarget interface{}) error

PostApiRequest issues a POST requests and unmarshals JSON response into the provided struct

func (*ApiClient) PostApiRequestRawResponse

func (this *ApiClient) PostApiRequestRawResponse(path string, params url.Values, body interface{}) (string, error)

PostApiRequestRawResponse issues a POST requests and returns the raw, unprocessed response as a string Usefull for requests which don't respond with a valid JSON (recurring fee for example)

func (*ApiClient) PostJoiningMembers

func (this *ApiClient) PostJoiningMembers(request *JoiningMembersRequest) (target JoiningMembersResponse, err error)

PostJoiningMembers creates a new member

func (*ApiClient) PostMemberCardRegistration

func (this *ApiClient) PostMemberCardRegistration(request *MemberCardRegistrationRequest) (target string, err error)

PostMemberCardRegistration add card token to the user profile

func (*ApiClient) PostRecurringFee

func (this *ApiClient) PostRecurringFee(request *RecurringFeeRequest) (target string, err error)

PostRecurringFee adds a Bolt-on to an existing membership

type BillDayModel

type BillDayModel struct {
	Day int64
}

type BillingMethod

type BillingMethod int64
const (
	BillingMethodUnknown     BillingMethod = 0
	BillingMethodDirectDebit BillingMethod = 1
	BillingMethodCreditCard  BillingMethod = 2
	BillingMethodPayInFull   BillingMethod = 8
)

func BillingMethodFromFeeType

func BillingMethodFromFeeType(feeType FeeType) BillingMethod

BillingMethodFromFeeType converts FeeType into BillingMethod. They are equivalent

func (BillingMethod) String

func (bm BillingMethod) String() string

type ConnectionConfig

type ConnectionConfig struct {
	UserAgent string
	Username  string
	Password  string
	Guid      string
	Endpoint  string

	// How many times should 5xx requests be retried. Defaults to 0 (don't retry)
	MaxRetries int
	// Request timeout (defaults to 120s)
	HttpTimeout time.Duration
	// ProxyUrl allows you to connect through proxies (usefull for local debugging)
	ProxyUrl string
	// Use locally-stored dumps for core-data instead of making GET requests
	// Price calculations & POST requests are still sent externally
	UseMocks bool
	// Persist core-data dumps after making GET requests
	SaveMocks bool
}

ConnectionConfig stores configuration data for Legend ApiClient Credentials MUST be provided at least

type ContactWithEmailResultModel

type ContactWithEmailResultModel struct {
	ContactId int64
	// ExpiryDate DateTime
	FirstName        string
	IsFreeMembership bool
	IsProspect       bool
	LastName         string
	LinkedStatus     string
	MemberNumber     string
	MemberStatus     string
	Mobile           string
	Phone            string
	PostCode         string
	// ProspectCreationDate 	DateTime
	ProspectId     int64
	ProspectStatus string
}

type DiscountPriceDetails

type DiscountPriceDetails struct {
	Amount                    float64
	CycleDiscountActiveMonths int64
	Description               string
	ForProcessType            int64
	ProcessType               int64
	PromoCode                 string
	PromotionID               int64
	PromotionName             string
}

type EmployerModel

type EmployerModel struct {
	Id   int64
	Name string
}

type Fee

type Fee struct {
	Amount              decimal.Decimal
	CardType            string `json:",omitempty"`
	MediaTypeId         int64  `json:",omitempty"`
	PaymentHandlerId    int64  `json:",omitempty"`
	ProcessType         int64
	PromotionCode       string `json:",omitempty"`
	PromotionId         int64  `json:",omitempty"`
	ServerTransactionID string `json:",omitempty"`
	SourceId            int64  `json:",omitempty"`
}

type FeeType

type FeeType int64
const (
	FeeTypeUnknown     FeeType = 0
	FeeTypeDirectDebit FeeType = 1
	FeeTypePayInFull   FeeType = 2
	FeeTypeCreditCard  FeeType = 3
)

func (FeeType) String

func (f FeeType) String() string

type FutureDiscountPriceDetails

type FutureDiscountPriceDetails struct {
	Amount                    float64
	CycleDiscountActiveMonths int64
	Description               string
	ForProcessType            int64
	ProcessType               int64
	PromoCode                 string
	PromotionID               int64
	PromotionName             string
}

type Gender

type Gender int64

type HasOnlineProfile

type HasOnlineProfile struct {
	Id           int64
	DOB          LegendTime
	IsLinked     bool
	LasName      string
	MemberNumber string
	MemberStatus string
}

type JoiningMembersRequest

type JoiningMembersRequest struct {
	ChannelId                int64  `json:",omitempty"`
	ClientIPAddress          string `json:",omitempty"`
	ContactId                int64  `json:",omitempty"`
	DoNotCreateOnlineProfile bool   `json:",omitempty"`
	LocationID               int64  `json:",omitempty"`
	MemberNo                 string `json:",omitempty"`
	MembershipProcessType    MembershipProcessType
	PAndAEligibilities       string        `json:",omitempty"`
	ProspectId               int64         `json:",omitempty"`
	SalesPersonId            int64         `json:",omitempty"`
	SignUpLocation           string        `json:",omitempty"`
	TermsAccepted            bool          `json:",omitempty"`
	Fees                     []Fee         `json:",omitempty"`
	MandateInfo              *MandateInfo  `json:",omitempty"`
	PaymentInfo              *PaymentInfo  `json:",omitempty"`
	PersonalInfo             *PersonalInfo `json:",omitempty"`
	PurchaseInfo             *PurchaseInfo `json:",omitempty"`
}

type JoiningMembersResponse

type JoiningMembersResponse struct {
	Success             bool
	FailureReason       string
	MemberNumber        string
	MandateReference    string
	ExternalId          string
	OnlinePurchaseId    int64
	ContactId           int64
	StatusCode          int64
	ReasonPhrase        string
	RequestMessage      string
	PasswordUrl         string
	IsSuccessStatusCode bool
}

type LegendTime

type LegendTime struct {
	time.Time
}

LegendTime represents the most common datetime format used by Legend API You'll still find other date formats elsewhere in the API (especially when posting data), But this type should cover most GETs

func (LegendTime) FormatShortDate

func (b LegendTime) FormatShortDate() string

FormatShortDate "2006-01-02"

func (LegendTime) MarshalJSON

func (t LegendTime) MarshalJSON() ([]byte, error)

MarshalJSON "Mon Jan _2"

func (*LegendTime) Scan

func (b *LegendTime) Scan(src interface{}) error

func (LegendTime) String

func (b LegendTime) String() string

String "01/02/2006"

func (*LegendTime) UnmarshalJSON

func (b *LegendTime) UnmarshalJSON(src []byte) (err error)

UnmarshalJSON expects either "2006-01-02T15:04:05" or "Mon Jan _2"

func (LegendTime) Value

func (b LegendTime) Value() (driver.Value, error)

type LocationHierarchy

type LocationHierarchy struct {
	Address1     string
	Address2     string
	Address3     string
	Address4     string
	City         string
	Country      string
	FacilityId   int64
	FriendlyName string
	Guid         string
	Latitude     float64
	LocationId   int64
	Longitude    float64
	LongName     string
	Name         string
	ParentGuid   string
	Postcode     string
	Region       string
	ShortName    string
	Type         int64
}

type MandateInfo

type MandateInfo struct {
	AccountName   string `json:",omitempty"`
	AccountNumber string `json:",omitempty"`
	BillDay       int64  `json:",omitempty"`
	Sortcode      string `json:",omitempty"`
}

type MemberCardRegistrationRequest

type MemberCardRegistrationRequest struct {
	ContactExtId string
	ExpiryMonth  int64
	ExpiryYear   int64
	MerchantId   string
	NameOnCard   string
	SecurePan    string
	StartMonth   int64
	StartYear    int64
	Token        string
}

type MembershipPriceDetailsModel

type MembershipPriceDetailsModel struct {
	CycleFee                   decimal.Decimal
	CycleFeeProcessType        int64
	EnrollmentFee              decimal.Decimal
	EnrollmentFeeProcessType   int64
	FirstBillDate              LegendTime
	HasEligibilities           bool
	InductionFee               decimal.Decimal
	InductionFeeProcessType    int64
	MonthInHandFee             decimal.Decimal
	MonthInHandFeeProcessType  int64
	MonthInHandProcessType     int64
	ProrateFee                 decimal.Decimal
	ProrateFeeProcessType      int64
	UpFrontCycleFee            decimal.Decimal
	UpfrontCycleFeeProcessType int64
	WaiveProrateFee            bool
	Discounts                  []DiscountPriceDetails
	FutureDiscounts            []FutureDiscountPriceDetails
}

type MembershipPriceTypeModel

type MembershipPriceTypeModel struct {
	Id                         int64
	ActiveFrom                 LegendTime
	ActiveTo                   LegendTime
	AgreementChannelID         int64
	CycleFee                   float64
	CycleFeeProcessType        int64
	Detail                     string
	DurationInMonths           int64
	EnrollmentFee              float64
	EnrollmentFeeProcessType   int64
	FeeType                    FeeType
	HasEligibilities           bool
	InductionFee               float64
	InductionFeeProcessType    int64
	MembershipDurationInDays   int64
	MonthInHandFee             float64
	MonthInHandFeeProcessType  int64
	MonthInHandProcessType     int64
	MonthsInHand               int64
	Name                       string
	ProrateFee                 float64
	ProrateFeeProcessType      int64
	UpFrontCycleFee            float64
	UpfrontCycleFeeProcessType int64
	WaiveProrateFee            bool
	WebDescription             string
	Discounts                  []DiscountPriceDetails
	Events                     []AgreementChannelEventModel
	FutureDiscounts            []FutureDiscountPriceDetails
}

type MembershipProcessType

type MembershipProcessType int64

type MembershipTypeModel

type MembershipTypeModel struct {
	Id               int64
	Detail           string
	HasEligibilities bool
	Name             string
	WebDescription   string
	Prices           []MembershipPriceTypeModel
}

type MembershipTypeReturnModel

type MembershipTypeReturnModel struct {
	LocationId     int64
	LocationName   string
	MembershipType []MembershipTypeModel
}

type PaymentInfo

type PaymentInfo struct {
	AuthorizationCode string    `json:",omitempty"`
	CardNo            string    `json:",omitempty"`
	DateProcessed     time.Time `json:",omitempty"`
	TransactionId     string    `json:",omitempty"`
}

type PersonalInfo

type PersonalInfo struct {
	AddressCity                string  `json:",omitempty"`
	AddressLine1               string  `json:",omitempty"`
	AddressLine2               string  `json:",omitempty"`
	AddressLine3               string  `json:",omitempty"`
	AddressRegios              string  `json:",omitempty"`
	Birthday                   string  `json:",omitempty"` // 10-01-2010
	CommunicationPreferenceIds []int64 `json:",omitempty"`
	EmailAddress               string  `json:",omitempty"`
	EmergencyContact           string  `json:",omitempty"`
	EmergencyPhone             string  `json:",omitempty"`
	Employer                   string  `json:",omitempty"`
	EthnicOrigin               int64   `json:",omitempty"`
	FirstName                  string  `json:",omitempty"`
	GenderId                   Gender  `json:",omitempty"`
	InductionOptout            bool    `json:",omitempty"`
	MarketingSourceId          int64   `json:",omitempty"`
	MedicalConditionIds        string  `json:",omitempty"`
	MobilePhoneNumber          string  `json:",omitempty"`
	PhoneNumber                string  `json:",omitempty"`
	Postcode                   string  `json:",omitempty"`
	Surname                    string  `json:",omitempty"`
	Title                      string  `json:",omitempty"`
	WorkPhone                  string  `json:",omitempty"`
}

type PurchaseInfo

type PurchaseInfo struct {
	FirstBillDate         time.Time       `json:",omitempty"`
	LocationId            int64           `json:",omitempty"`
	MembershipEndDate     time.Time       `json:",omitempty"`
	MembershipStartDate   time.Time       `json:",omitempty"`
	MembershipTypePriceId int64           `json:",omitempty"`
	PromotionCode         string          `json:",omitempty"`
	PromotionId           int64           `json:",omitempty"`
	TotalFee              decimal.Decimal `json:",omitempty"`
}

type RecurringFeeModel

type RecurringFeeModel struct {
	Id                 int64
	ActiveDate         LegendTime
	AdminFee           decimal.Decimal
	Autobill           bool
	BillingCycleId     int64
	BillingMethodId    BillingMethod
	ClubRestrictionId  int64
	CycleFee           decimal.Decimal
	Description        string
	GroupRestrictionId int64
	InactiveDate       LegendTime
	IsEnterprise       bool
	LocationId         int64
	Name               string
	UsageMonths        int64
	WaiveProrateFee    bool
}

type RecurringFeeRequest

type RecurringFeeRequest struct {
	AdminFee        decimal.Decimal `json:",omitempty"`
	ContactId       int64
	CycleFee        decimal.Decimal `json:",omitempty"`
	FirstBillDate   *time.Time      `json:",omitempty"`
	ProrateFee      decimal.Decimal `json:",omitempty"`
	RecurringFeeId  int64
	RenewalDate     *time.Time `json:",omitempty"`
	SalespersonId   int64
	StartDate       time.Time
	TerminationDate *time.Time `json:",omitempty"`
}

type SalesPerson

type SalesPerson struct {
	Id        int64
	FirstName string
	LastName  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL