frapi

package
v0.0.0-...-fb74ee3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package frapi provides the entry points for the graphql fr api. The tests are minimal and simply check the functionality of graphql calls. More extensive tests are performed by higher level client javascript calls.

Example calls:

new property:

mutation NewProperty

{
  createProperty1(input: {name: "newThree", currency: USD, memberrate: 40.00, allownonmembers: false, nonmemberrate: 80.00, timeseconds: 0}) {
    id
    name
  }
}

query properties:

{
  properties1 {
    id
    name
    currency
    memberrate
    nonmemberrate
    allownonmembers
  }
}

new reservation:

mutation NewReservation

{
  createReservation(id: "01a79cdf-668a-4d33-813c-46a9e24e7c60", input: {madefor: "bill", madeby: "sally", startdate: "now", enddate: "later", member: false, rates: [50.0]}) {
    id
  }
}

Index

Constants

This section is empty.

Variables

View Source
var AdminSchema = `
	schema {
		query: Query
		mutation: Mutation
	}
	
	# The query type, represents all of the entry points into our object graph
	type Query {
		# get info about a property
		property(id: String!): Property
	}

	# The mutation type, represents all updates we can make to our data
	type Mutation {
		# create reservation
		createReservation(propertyId: String!, input: NewReservationInput!) : Property
		# cancel reservation
		cancelReservation(propertyId: String!, forVersion: Int!, reservationId: String!, adminRequest: Boolean) : Property
		# create restriction
		createRestriction(propertyId: String!, input: NewRestrictionInput!) : Property
		# create user
		createUser(propertyId: String!, input: NewUserInput!) : Property
		# update user
		updateUser(propertyId: String!, userId: String!, input: UpdateUserInput!) : Property
		# update system user
		updateSystemUser(propertyId: String!, userId: String!, input: UpdateSystemUserInput!) : Property
		# update user balance
		updateBalance(propertyId: String!, input: UpdateBalanceInput!) : Property
		# mark notification read
		notificationRead(propertyId: String!, notificationId: String!) : Property
		# create content
		createContent(propertyId: String!, input: NewContentInput!) : Property
		# accept or reject an invitation to join a property
		acceptInvitation(propertyId: String!, input: AcceptInvitationInput!) : Property
		# update settings
		updateSettings(propertyId: String!, input: UpdateSettingsInput!) : Property
		# update membership
		updateMembershipStatus(propertyId: String!, input: UpdateMembershipInput!) : Property
		export(propertyId: String!) : Property
		deleteProperty(propertyId: String!) : Boolean!
		exportCSV(propertyId: String!) : Property


	}

	# QUERY RESULTS

	# all information about a property
	type Property {
		propertyId: String!
		eventVersion: Int!
		createDateTime: String!
		reservations(userId: String, reservationId: String, order: OrderDirection = ASCENDING): [Reservation]!
		settings(maxVersion: Int): Settings!
		users(userId: String, email: String): [User!]!
		me: User!
		restrictions(restrictionId: String, maxVersion: Int): [RestrictionRecord]!
		ledgers(userId: String, last: Int, reverse: Boolean): [Ledger]!
		notifications(userId: String, reverse: Boolean): [Notification]!
		contents: [Content]!
		updateSettingsConstraints: UpdateSettingsConstraints!
		membershipStatusConstraints(userId: String): [MembershipStatusConstraints]!
		newReservationConstraints(userId: String, userType: ConstraintsUserType!): NewReservationConstraints!
		cancelReservationConstraints(userId: String, userType: ConstraintsUserType!): CancelReservationConstraints!
		updateUserConstraints(userId: String): UpdateUserConstraints!
		updateBalanceConstraints(): UpdateBalanceConstraints!

	}


` + models.NewRestrictionInputGQL + models.BlackoutRestrictionInputGQL + models.MembershipRestrictionInputGQL + models.UpdateSettingsInputGQL + models.AcceptInvitationInputGQL + models.NewReservationInputGQL + settingsGQL + reservationGQL + userGQL + ledgerQueryGQL + membershipStatusConstraintsGQL + restrictionGQL + notificationGQL + contentGQL + reservationConstraintsGQL + settingsConstraintsGQL + updateUserConstraintsGQL + cancelReservationConstraintsGQL + models.LedgerMutationGQL + models.NewUserInputGQL + models.UpdateUserInputGQL + updateBalanceConstraintsGQL + models.NewContentInputGQL + models.UpdateMembershipStatusInputGQL + models.UpdateSystemUserInputGQL

AdminSchema is the gql schema for admin requests

View Source
var EmailSender platform.SendMail

EmailSender is used to send emails

View Source
var FrapiCookies *cookies.AuthCookies

FrapiCookies contains helper functions for setting and getting cookies

View Source
var HomeSchema = `
	schema {
		query: Query
		mutation: Mutation
	}
	
	# The query type, represents all of the entry points into our object graph
	type Query {
		# normal users query which properties they have
		properties(): [Property]!
		# return a login url passing in dest for final destination after the login
		loginURL(dest: String!): String
		# return a logout url passing in dest for final destination after the logout
		logoutURL(dest: String!): String
		# settings constraints for creating a new property
		updateSettingsConstraints: UpdateSettingsConstraints!
		# user constraints for creating a new property
		updateUserConstraints: UpdateUserConstraints!

	}

	# The mutation type, represents all updates we can make to our data
	type Mutation {
		# create a new property
		createProperty(input: NewPropertyInput!): Property
		importProperty(): String!
	}

	# MUTATION INPUT
	input NewPropertyInput {
		propertyName: String!
		currency: Currency!
		memberRate: Int!
		allowNonMembers: Boolean!
		nonMemberRate: Int!
		isMember: Boolean!
		nickname: String!
		timezone: String!
	}
	
	# QUERY RESULTS

	# all information about a property
	type Property {
		propertyId: String!
		eventVersion: Int!
		createDateTime: String!
		settings(maxVersion: Int): Settings!
		me: User!

	}

` + settingsGQL + userGQL + settingsConstraintsGQL + updateUserConstraintsGQL

HomeSchema is the gql schema for choosing a property

View Source
var Logger = logger.New()

Logger is the logger for the platform implementation

View Source
var MemberSchema = `
	schema {
		query: Query
		mutation: Mutation
	}
	
	# The query type, represents all of the entry points into our object graph
	type Query {
		# get info about a property
		property(id: String!): Property
	}

	# The mutation type, represents all updates we can make to our data
	type Mutation {
		# Create a reservation.
		createReservation(propertyId: String!, input: NewReservationInput!) : Property
		cancelReservation(propertyId: String!, forVersion: Int!, reservationId: String!, adminRequest: Boolean) : Property
		# Accept or reject an invitation to join a property.
		acceptInvitation(propertyId: String!, input: AcceptInvitationInput!) : Property
		# update membership status
		updateMembershipStatus(propertyId: String!, input: UpdateMembershipInput!) : Property
	}

	# QUERY RESULTS

	# all information about a property
	type Property {
		propertyId: String!
		eventVersion: Int!
		createDateTime: String!
		reservations(userId: String, reservationId: String, order: OrderDirection = ASCENDING): [Reservation]!
		restrictions(restrictionId: String, maxVersion: Int): [RestrictionRecord]!
		settings(maxVersion: Int): Settings!
		users(userId: String, email: String, maxVersion: Int): [User!]!
		me: User!
		ledgers(userId: String, last: Int, reverse: Boolean): [Ledger]!
		# ranges of dates that are disabled for the calendar view
		notifications(userId: String, reverse: Boolean): [Notification]!
		contents: [Content]!
		membershipStatusConstraints(userId: String): [MembershipStatusConstraints]!
		newReservationConstraints(userId: String, userType: ConstraintsUserType!): NewReservationConstraints!
		cancelReservationConstraints(userId: String, userType: ConstraintsUserType!): CancelReservationConstraints!

	}


` + models.AcceptInvitationInputGQL + models.NewReservationInputGQL + settingsGQL + reservationGQL + restrictionGQL + userGQL + ledgerQueryGQL + notificationGQL + contentGQL + membershipStatusConstraintsGQL + reservationConstraintsGQL + cancelReservationConstraintsGQL + models.UpdateMembershipStatusInputGQL

MemberSchema is the gql schema for member requests

View Source
var PersistedEmailStore platform.PersistedEmailStore

PersistedEmailStore manages the persisted user emails

View Source
var PersistedPropertyList platform.PersistedPropertyList

PersistedPropertyList is the list of persisted properties

View Source
var PersistedVersionedEvents platform.PersistedVersionedEvents

PersistedVersionedEvents is the list of persisted events

Functions

func CreateNewPropertyEvents

func CreateNewPropertyEvents(ctx context.Context, email string, userID string, newProperty *models.NewPropertyInput) ([]platform.VersionedEvent, error)

CreateNewPropertyEvents sets up a new property with its first default events

func DailyCron

func DailyCron(ctx context.Context) error

DailyCron is called by the service once per day

Types

type BlackoutRestrictionResolver

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

BlackoutRestrictionResolver is a blackout resolver

func (*BlackoutRestrictionResolver) EndDate

func (r *BlackoutRestrictionResolver) EndDate() string

EndDate is the last checkout date for a blackout restriction

func (*BlackoutRestrictionResolver) StartDate

func (r *BlackoutRestrictionResolver) StartDate() string

StartDate is the first checkin date for a blackout restriction

type CalendarDisabledRange

type CalendarDisabledRange struct {
	BeforeDate *frdate.Date
	AfterDate  *frdate.Date
	FromDate   *frdate.Date
	ToDate     *frdate.Date
}

CalendarDisabledRange is a range of disabled dates for making reservation, only BeforeDate+AfterDate, or FromDate or ToDate can be set, not any together

func (*CalendarDisabledRange) After

func (r *CalendarDisabledRange) After() *string

After if set (not nil) allows dates that fall after this date, Before is always set if After is set

func (*CalendarDisabledRange) Before

func (r *CalendarDisabledRange) Before() *string

Before if set (not nil) allows dates that fall before this date, After is always set if Before is set

func (*CalendarDisabledRange) From

func (r *CalendarDisabledRange) From() *string

From if set (not nil) allows dates from this date into the future

func (*CalendarDisabledRange) To

func (r *CalendarDisabledRange) To() *string

To if set allows dates before and including this date

type CancelReservationConstraints

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

CancelReservationConstraints are constraints for a canceling reservation

func (*CancelReservationConstraints) CancelReservationAllowed

func (r *CancelReservationConstraints) CancelReservationAllowed() []*string

CancelReservationAllowed returns the reservation ids that the caller is allowed to cancel

type CancelReservationConstraintsArgs

type CancelReservationConstraintsArgs struct {
	UserID   *string
	UserType ConstraintsUserType
}

CancelReservationConstraintsArgs are the arguments for retrieving the constraints

type ConstraintsUserType

type ConstraintsUserType string

ConstraintsUserType is the user type requesting the new or cancel reservation request

const (
	// ADMIN means an admin is making the request
	ADMIN ConstraintsUserType = "ADMIN"
	// MEMBER means a member is making the request
	MEMBER ConstraintsUserType = "MEMBER"
	// NONMEMBER means a member is making the request for a non-member
	NONMEMBER ConstraintsUserType = "NONMEMBER"
)

type ContentResolver

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

ContentResolver resolves a single content string

func (*ContentResolver) Author

func (r *ContentResolver) Author() (*UserResolver, error)

Author is called by the GQL framework, see contentGQL

func (*ContentResolver) Comment

func (r *ContentResolver) Comment() string

Comment is called by the GQL framework, see contentGQL

func (*ContentResolver) CreateDateTime

func (r *ContentResolver) CreateDateTime() string

CreateDateTime is called by the GQL framework, see contentGQL

func (*ContentResolver) Default

func (r *ContentResolver) Default() bool

Default is called by the GQL framework, see contentGQL

func (*ContentResolver) DefaultTemplate

func (r *ContentResolver) DefaultTemplate() string

DefaultTemplate is called by the GQL framework, see contentGQL

func (*ContentResolver) Name

Name is called by the GQL framework, see contentGQL

func (*ContentResolver) Rendered

func (r *ContentResolver) Rendered() (string, error)

Rendered is called by the GQL framework, see contentGQL

func (*ContentResolver) Template

func (r *ContentResolver) Template() string

Template is called by the GQL framework, see contentGQL

type ContentRollup

type ContentRollup struct {
	// orginal reservation
	Input        *models.NewContentInput
	EventVersion int32
}

ContentRollup is the rollup record for (html) content, exported for memcache

func (*ContentRollup) GetEventVersion

func (r *ContentRollup) GetEventVersion() int

GetEventVersion returns the version of the rollup record

type DailyRateResolver

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

DailyRateResolver resolves a reservation daily rate

func (*DailyRateResolver) Amount

func (r *DailyRateResolver) Amount() int32

Amount is the cost of the reservation for the date

func (*DailyRateResolver) Date

func (r *DailyRateResolver) Date() string

Date is the date of the reservation

type DuplicateDetectionEvent

type DuplicateDetectionEvent interface {
	GetForVersion() int32
}

DuplicateDetectionEvent must be implemented by all client requests

type LedgerEvent

type LedgerEvent string

LedgerEvent is the ledger record event, exported for GQL

type LedgerRecordResolver

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

LedgerRecordResolver resolves a ledger record

func (*LedgerRecordResolver) Amount

func (r *LedgerRecordResolver) Amount(args *struct{ Format amountFormat }) (string, error)

Amount is the ledger record amount

func (*LedgerRecordResolver) Balance

func (r *LedgerRecordResolver) Balance(args *struct{ Format amountFormat }) (string, error)

Balance is the ledger record balance

func (*LedgerRecordResolver) Event

func (r *LedgerRecordResolver) Event() LedgerEvent

Event is the ledger record event

func (*LedgerRecordResolver) EventDateTime

func (r *LedgerRecordResolver) EventDateTime() string

EventDateTime is the ledger record timestamp

func (*LedgerRecordResolver) GetEventVersion

func (r *LedgerRecordResolver) GetEventVersion() int

GetEventVersion returns the event version for the ledger record

func (*LedgerRecordResolver) UserID

func (r *LedgerRecordResolver) UserID() string

UserID is the ledger record user ID

type LedgerResolver

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

LedgerResolver exported for GQL

func (*LedgerResolver) Records

func (r *LedgerResolver) Records() []*LedgerRecordResolver

Records returns ledger records for a user

func (*LedgerResolver) User

func (r *LedgerResolver) User() *UserResolver

User returns ledger user

type LedgerRollup

type LedgerRollup struct {
	UserID string
	Event  LedgerEvent

	EventDateTime string
	Balance       int32
	Amount        int32

	VersionedEvent *platform.VersionedEvent

	EventVersion int32
}

LedgerRollup is the rollup record for ledgers, exported for memcache

func (*LedgerRollup) GetEventVersion

func (r *LedgerRollup) GetEventVersion() int

GetEventVersion of ledger rollup

type MembershipRecordResolver

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

MembershipRecordResolver resolves one of the memberships for a user

func (*MembershipRecordResolver) Info

Info is called by the GQL framework, see membershipStatusGQL

func (*MembershipRecordResolver) OptOutAllowed

func (r *MembershipRecordResolver) OptOutAllowed() bool

OptOutAllowed is called by the GQL framework, see membershipStatusGQL

func (*MembershipRecordResolver) PurchaseAllowed

func (r *MembershipRecordResolver) PurchaseAllowed() bool

PurchaseAllowed is called by the GQL framework, see membershipStatusGQL

func (*MembershipRecordResolver) ReservationCount

func (r *MembershipRecordResolver) ReservationCount() int32

ReservationCount is called by the GQL framework, see membershipStatusGQL

func (*MembershipRecordResolver) Status

Status is called by the GQL framework, see membershipStatusGQL

type MembershipResolver

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

MembershipResolver exported for GQL

func (*MembershipResolver) Amount

func (r *MembershipResolver) Amount() int32

Amount is membership price, exported for GQL

func (*MembershipResolver) Description

func (r *MembershipResolver) Description() string

Description is membership description, exported for GQL

func (*MembershipResolver) GracePeriodOutDate

func (r *MembershipResolver) GracePeriodOutDate() string

GracePeriodOutDate is membership grace period out date, exported for GQL

func (*MembershipResolver) InDate

func (r *MembershipResolver) InDate() string

InDate is membership start date, exported for GQL

func (*MembershipResolver) MembershipStates

func (r *MembershipResolver) MembershipStates() []*MembershipStateResolver

MembershipStates are the user membership states for the membership, exported for GQL

func (*MembershipResolver) OutDate

func (r *MembershipResolver) OutDate() string

OutDate is membership end date, exported for GQL

func (*MembershipResolver) PrePayStartDate

func (r *MembershipResolver) PrePayStartDate() string

PrePayStartDate is membership pre pay start date, exported for GQL

type MembershipRestrictionResolver

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

MembershipRestrictionResolver is a membership resolver

func (*MembershipRestrictionResolver) Amount

func (r *MembershipRestrictionResolver) Amount(args *struct{ Format amountFormat }) (string, error)

Amount is the price of the membership

func (*MembershipRestrictionResolver) GracePeriodOutDate

func (r *MembershipRestrictionResolver) GracePeriodOutDate(args *struct{ Format string }) (string, error)

GracePeriodOutDate is the last allowed checkout date for membership past the OutDate

func (*MembershipRestrictionResolver) InDate

func (r *MembershipRestrictionResolver) InDate(args *struct{ Format string }) (string, error)

InDate is the first allowed checkin date for a membership

func (*MembershipRestrictionResolver) OutDate

func (r *MembershipRestrictionResolver) OutDate(args *struct{ Format string }) (string, error)

OutDate is the last allowed checkout date for a membership

func (*MembershipRestrictionResolver) PrePayStartDate

func (r *MembershipRestrictionResolver) PrePayStartDate(args *struct{ Format string }) (string, error)

PrePayStartDate is the first date in which a membership can be purchased

type MembershipRollupRecord

type MembershipRollupRecord struct {
	RestrictionID      string
	InDate             string
	OutDate            string
	PrePayStartDate    string
	GracePeriodOutDate string
	Users              map[string]MembershipState
	EventVersion       int32
	Description        string
	Amount             int32
}

MembershipRollupRecord is the rollup record for membership, exported for memcache

func (*MembershipRollupRecord) GetEventVersion

func (r *MembershipRollupRecord) GetEventVersion() int

GetEventVersion returns the version of the rollup record

type MembershipState

type MembershipState string

MembershipState is member's state for a particular membership

const (
	// OPEN means the membership is open for purchase or opt out
	// only one membership can be open at a time
	OPEN MembershipState = "OPEN"
	// PURCHASED means the member has purchased a membership
	// only a purchased membership can have reservations for a member
	PURCHASED MembershipState = "PURCHASED"
	// OPTOUT means the member has opted out, allowing another (future) membership to be open
	// opted out memberships cannot have reservations for a member
	OPTOUT MembershipState = "OPTOUT"
)

type MembershipStateResolver

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

MembershipStateResolver is user membership state, exported for GQL

func (*MembershipStateResolver) State

func (r *MembershipStateResolver) State() string

State is the state component of a membership state, exported for GQL

func (*MembershipStateResolver) User

User is the user component of a membership state, exported for GQL

type MembershipStatusConstraintsResolver

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

MembershipStatusConstraintsResolver resolves the memberships for a user

func (*MembershipStatusConstraintsResolver) Memberships

Memberships is called by the GQL framework, see membershipStatusGQL

func (*MembershipStatusConstraintsResolver) User

User is called by the GQL framework, see membershipStatusGQL

type NewReservationConstraints

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

NewReservationConstraints are constraints for a new reservation

func (*NewReservationConstraints) CheckinDisabled

func (r *NewReservationConstraints) CheckinDisabled() []*CalendarDisabledRange

CheckinDisabled returns the ranges of dates that cannot be a new reservation checkin date

func (*NewReservationConstraints) CheckoutDisabled

func (r *NewReservationConstraints) CheckoutDisabled() []*CalendarDisabledRange

CheckoutDisabled returns the ranges of dates that cannot be a new reservation checkout date

func (*NewReservationConstraints) NewReservationAllowed

func (r *NewReservationConstraints) NewReservationAllowed() bool

NewReservationAllowed is true if the caller is allowed to create a new reservation

func (*NewReservationConstraints) NonMemberInfoMax

func (r *NewReservationConstraints) NonMemberInfoMax() int32

NonMemberInfoMax is the maximum length of non member information

func (*NewReservationConstraints) NonMemberInfoMin

func (r *NewReservationConstraints) NonMemberInfoMin() int32

NonMemberInfoMin is the minimum length of non member information

func (*NewReservationConstraints) NonMemberNameMax

func (r *NewReservationConstraints) NonMemberNameMax() int32

NonMemberNameMax is the maximum length of a non member name

func (*NewReservationConstraints) NonMemberNameMin

func (r *NewReservationConstraints) NonMemberNameMin() int32

NonMemberNameMin is the minimum length of a non member name

type NewReservationConstraintsArgs

type NewReservationConstraintsArgs struct {
	UserID   *string
	UserType ConstraintsUserType
}

NewReservationConstraintsArgs are the arguments for retrieving the constraints

type NotificationResolver

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

NotificationResolver resolves a single notification

func (*NotificationResolver) Author

func (r *NotificationResolver) Author() *UserResolver

Author is called by the GQL framework, see notificationGQL

func (*NotificationResolver) Body

func (r *NotificationResolver) Body() (string, error)

Body is called by the GQL framework, see notificationGQL

func (*NotificationResolver) Cc

Cc is called by the GQL framework, see notificationGQL

func (*NotificationResolver) CreateDateTime

func (r *NotificationResolver) CreateDateTime() string

CreateDateTime is called by the GQL framework, see notificationGQL

func (*NotificationResolver) DefaultTemplate

func (r *NotificationResolver) DefaultTemplate() bool

DefaultTemplate is called by the GQL framework, see notificationGQL

func (*NotificationResolver) EmailSent

func (r *NotificationResolver) EmailSent() bool

EmailSent is called by the GQL framework, see notificationGQL

func (*NotificationResolver) GetEventVersion

func (r *NotificationResolver) GetEventVersion() int

GetEventVersion is called by the GQL framework, see notificationGQL

func (*NotificationResolver) NotificationID

func (r *NotificationResolver) NotificationID() string

NotificationID is the id of the notification

func (*NotificationResolver) Read

func (r *NotificationResolver) Read() bool

Read is called by the GQL framework, see notificationGQL

func (*NotificationResolver) Subject

func (r *NotificationResolver) Subject() (string, error)

Subject is called by the GQL framework, see notificationGQL

func (*NotificationResolver) TemplateName

func (r *NotificationResolver) TemplateName() string

TemplateName is called by the GQL framework, see notificationGQL

func (*NotificationResolver) TemplateVersion

func (r *NotificationResolver) TemplateVersion() int32

TemplateVersion is called by the GQL framework, see notificationGQL

func (*NotificationResolver) To

To is called by the GQL framework, see notificationGQL

type NotificationRollup

type NotificationRollup struct {
	Input            *models.NewNotificationInput
	ReaderUserIdsMap map[string]bool
	EventVersion     int32
	TargetUserIdsMap map[string]bool
}

NotificationRollup is internal structure to hold reservation information for resolvers

func (*NotificationRollup) GetEventVersion

func (r *NotificationRollup) GetEventVersion() int

GetEventVersion returns the version of the rollup record

type OrderDirection

type OrderDirection string

OrderDirection is the sorting order for the reservations by checkin date

const (
	// ASCENDING is oldest to newest reservations by checkin date
	ASCENDING OrderDirection = "ASCENDING"
	// DESCENDING is newest to oldest reservations by checkin date
	DESCENDING OrderDirection = "DESCENDING"
)

type Property

type Property struct {
	// sent back to client
	PropertyID     string
	CreateDateTime string

	// map of email ids to emails
	EmailMap map[string]string

	// reference the events pulled from the database
	Events []platform.VersionedEvent

	// map of rollups for different types of resolvers such as
	// reservations, notifications, etc.
	// each type of resolver is mapped from its id to versions of each id over time
	Rollups map[rollupType]map[string][]versionedRollup
}

Property is the basic structure holding information for rollups The public fields can be cached (for current latest event version)

type PropertyExport

type PropertyExport struct {
	Events   []platform.VersionedEvent
	EmailMap map[string]string
}

PropertyExport defines the contents of an exported property gob

type PropertyResolver

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

PropertyResolver is the resolver for a single property

func (*PropertyResolver) CancelReservationConstraints

CancelReservationConstraints is called to retrieve the cancel reservation constraints

func (*PropertyResolver) Contents

func (r *PropertyResolver) Contents() ([]*ContentResolver, error)

Contents is called by the GQL framework to retrieve all the display content strings

func (*PropertyResolver) CreateDateTime

func (r *PropertyResolver) CreateDateTime() string

CreateDateTime is the time stamp for when the property was created

func (*PropertyResolver) EventVersion

func (r *PropertyResolver) EventVersion() int32

EventVersion is the version of the last property mutation event

func (*PropertyResolver) Ledgers

func (r *PropertyResolver) Ledgers(args *ledgersArgs) ([]*LedgerResolver, error)

Ledgers is called by gql to query user ledgers

func (*PropertyResolver) Me

func (r *PropertyResolver) Me() (*UserResolver, error)

Me is the information for the logged in user

func (*PropertyResolver) MembershipStatusConstraints

func (r *PropertyResolver) MembershipStatusConstraints(args *membershipStatusConstraintsArgs) ([]*MembershipStatusConstraintsResolver, error)

MembershipStatusConstraints is called by the GQL framewor, see contentGQL

func (*PropertyResolver) Memberships

func (r *PropertyResolver) Memberships(args *membershipsArgs) ([]*MembershipResolver, error)

Memberships exported for GQL

func (*PropertyResolver) NewReservationConstraints

NewReservationConstraints is called to retrieve new reservation constraints

func (*PropertyResolver) Notifications

func (r *PropertyResolver) Notifications(args *notificationArgs) ([]*NotificationResolver, error)

Notifications is called to return the list of all past notifications

func (*PropertyResolver) PropertyID

func (r *PropertyResolver) PropertyID() string

PropertyID is the unique id of this property

func (*PropertyResolver) Reservations

func (r *PropertyResolver) Reservations(args *reservationsArgs) ([]*ReservationResolver, error)

Reservations is the gql call to return the list of reservations

func (*PropertyResolver) Restrictions

func (r *PropertyResolver) Restrictions(args *restrictionsArgs) ([]*RestrictionRecordResolver, error)

Restrictions is called to return the list of restrictions

func (*PropertyResolver) Settings

func (r *PropertyResolver) Settings(args *settingsArgs) (*SettingsResolver, error)

Settings method for GQL call

func (*PropertyResolver) UpdateBalanceConstraints

func (r *PropertyResolver) UpdateBalanceConstraints() (*UpdateBalanceConstraints, error)

UpdateBalanceConstraints returns input constraints for updating Balance

func (*PropertyResolver) UpdateSettingsConstraints

func (r *PropertyResolver) UpdateSettingsConstraints(ctx context.Context) (*UpdateSettingsConstraints, error)

UpdateSettingsConstraints returns input constraints for updating settings

func (*PropertyResolver) UpdateUserConstraints

func (r *PropertyResolver) UpdateUserConstraints(ctx context.Context, args *UpdateUserConstraintsArgs) (*UpdateUserConstraints, error)

UpdateUserConstraints returns input constraints for updating user

func (*PropertyResolver) Users

func (r *PropertyResolver) Users(args *usersArgs) []*UserResolver

Users is the gql call to retrieve users for the property

type ReservationResolver

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

ReservationResolver is the reservation resolver receiver

func (*ReservationResolver) Amount

func (r *ReservationResolver) Amount() int32

Amount is the sum of the daily Rates

func (*ReservationResolver) Author

func (r *ReservationResolver) Author() *UserResolver

Author denotes who made the reservation (same as ReservedFor or an admin)

func (*ReservationResolver) Canceled

func (r *ReservationResolver) Canceled() bool

Canceled is true if the reservation has been canceled

func (*ReservationResolver) CreateDateTime

func (r *ReservationResolver) CreateDateTime() string

CreateDateTime returns the reservation create time stamp

func (*ReservationResolver) EndDate

func (r *ReservationResolver) EndDate() string

EndDate is the checkout date

func (*ReservationResolver) Member

func (r *ReservationResolver) Member() bool

Member is true if the reservation is for the ReservedFor member, otherwise the reservation is for a non-member

func (*ReservationResolver) NonMemberInfo

func (r *ReservationResolver) NonMemberInfo() *string

NonMemberInfo is required if the Member flag is false

func (*ReservationResolver) NonMemberName

func (r *ReservationResolver) NonMemberName() *string

NonMemberName is required if the Member flag is false

func (*ReservationResolver) Rate

Rate is a list of the daily price for the reservation

func (*ReservationResolver) ReservationID

func (r *ReservationResolver) ReservationID() string

ReservationID returns the reservation id

func (*ReservationResolver) ReservedFor

func (r *ReservationResolver) ReservedFor() *UserResolver

ReservedFor denotes who will reserve the reservation

func (*ReservationResolver) StartDate

func (r *ReservationResolver) StartDate() string

StartDate is the checkin date

func (*ReservationResolver) UpdateDateTime

func (r *ReservationResolver) UpdateDateTime() string

UpdateDateTime returns the time stamp for an update to the reservation (ex. cancel)

type ReservationRollup

type ReservationRollup struct {
	// orginal reservation
	Input *models.NewReservationInput

	// rollup changes
	Canceled       bool
	UpdateDateTime string
	EventVersion   int32
}

ReservationRollup holds a snapshot of a reservation at each event

func (*ReservationRollup) GetEventVersion

func (r *ReservationRollup) GetEventVersion() int

GetEventVersion returns version of rollup item

type Resolver

type Resolver struct{}

Resolver is the basic structure for graphql

func (*Resolver) AcceptInvitation

func (r *Resolver) AcceptInvitation(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.AcceptInvitationInput
}) (*PropertyResolver, error)

AcceptInvitation is called when a user accepts an invitation to participate in a property

func (*Resolver) CancelReservation

func (r *Resolver) CancelReservation(ctx context.Context, args *struct {
	PropertyID    string
	ForVersion    int32
	ReservationID string
	AdminRequest  *bool
}) (*PropertyResolver, error)

CancelReservation is called to cancel a reservation

func (*Resolver) CreateContent

func (r *Resolver) CreateContent(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.NewContentInput
}) (*PropertyResolver, error)

CreateContent is the gql call to create new display content

func (*Resolver) CreateProperty

func (r *Resolver) CreateProperty(ctx context.Context, args *struct{ Input *models.NewPropertyInput }) (*PropertyResolver, error)

CreateProperty is called from gql to create a property

func (*Resolver) CreateReservation

func (r *Resolver) CreateReservation(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.NewReservationInput
}) (*PropertyResolver, error)

CreateReservation is called to create a new reservation

func (*Resolver) CreateRestriction

func (r *Resolver) CreateRestriction(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.NewRestrictionInput
}) (*PropertyResolver, error)

CreateRestriction is called to create a new restriction

func (*Resolver) CreateUser

func (r *Resolver) CreateUser(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.NewUserInput
}) (*PropertyResolver, error)

CreateUser is the gql call to create a new user record

func (*Resolver) DeleteProperty

func (r *Resolver) DeleteProperty(ctx context.Context, args *deletePropertyArgs) (bool, error)

DeleteProperty is called from gql to delete a property

func (*Resolver) Export

func (r *Resolver) Export(ctx context.Context, args *struct {
	PropertyID string
}) (*PropertyResolver, error)

Export is called to export the current property

func (*Resolver) ExportCSV

func (r *Resolver) ExportCSV(ctx context.Context, args *struct {
	PropertyID string
}) (*PropertyResolver, error)

ExportCSV is called to export CSV files for the current property

func (*Resolver) ImportProperty

func (r *Resolver) ImportProperty(ctx context.Context) (string, error)

ImportProperty is called to import a property from a file

func (*Resolver) LoginURL

func (r *Resolver) LoginURL(ctx context.Context, args *struct {
	Dest string
}) (*string, error)

LoginURL returns a URL the client can use to login

func (*Resolver) LogoutURL

func (r *Resolver) LogoutURL(ctx context.Context, args *struct {
	Dest string
}) (*string, error)

LogoutURL returns a url used by the client to logout

func (*Resolver) NotificationRead

func (r *Resolver) NotificationRead(ctx context.Context, args *struct {
	PropertyID     string
	NotificationID string
	ForVersion     int32
}) (*PropertyResolver, error)

NotificationRead marks a notification as having been read

func (*Resolver) Properties

func (r *Resolver) Properties(ctx context.Context) ([]*PropertyResolver, error)

Properties is called to retrieve all the properties for which the caller is a member or admin

func (*Resolver) Property

func (r *Resolver) Property(ctx context.Context, args *struct {
	ID string
}) (*PropertyResolver, error)

Property returns the information for a single property

func (*Resolver) UpdateBalance

func (r *Resolver) UpdateBalance(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.UpdateBalanceInput
}) (*PropertyResolver, error)

UpdateBalance changes the current balance for a user

func (*Resolver) UpdateMembershipStatus

func (r *Resolver) UpdateMembershipStatus(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.UpdateMembershipStatusInput
}) (*PropertyResolver, error)

UpdateMembershipStatus is called to update membership status (ex. payed, opted out, etc.)

func (*Resolver) UpdateSettings

func (r *Resolver) UpdateSettings(ctx context.Context, args *struct {
	PropertyID string
	Input      *models.UpdateSettingsInput
}) (*PropertyResolver, error)

UpdateSettings is called to modify the current settings for a property

func (*Resolver) UpdateSettingsConstraints

func (r *Resolver) UpdateSettingsConstraints(ctx context.Context) (*UpdateSettingsConstraints, error)

UpdateSettingsConstraints returns input constraints for updating settings

func (*Resolver) UpdateSystemUser

func (r *Resolver) UpdateSystemUser(ctx context.Context, args *struct {
	PropertyID string
	UserID     string
	Input      *models.UpdateSystemUserInput
}) (*PropertyResolver, error)

UpdateSystemUser is called to update a system user record

func (*Resolver) UpdateUser

func (r *Resolver) UpdateUser(ctx context.Context, args *struct {
	PropertyID string
	UserID     string
	Input      *models.UpdateUserInput
}) (*PropertyResolver, error)

UpdateUser is called to update a user record

func (*Resolver) UpdateUserConstraints

func (r *Resolver) UpdateUserConstraints() (*UpdateUserConstraints, error)

UpdateUserConstraints returns input constraints for updating user

type RestrictionRecordResolver

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

RestrictionRecordResolver holds underlying information for restriction resolvers

func (*RestrictionRecordResolver) Author

Author is the user that creates the restriction

func (*RestrictionRecordResolver) CreateDateTime

func (r *RestrictionRecordResolver) CreateDateTime() string

CreateDateTime is the create time stamp of the restriction

func (*RestrictionRecordResolver) Description

func (r *RestrictionRecordResolver) Description() string

Description is the description of the restriction

func (*RestrictionRecordResolver) GetEventVersion

func (r *RestrictionRecordResolver) GetEventVersion() int

GetEventVersion is the version of this restriction record

func (*RestrictionRecordResolver) Restriction

Restriction returns a restriction resolver for types of restrictions

func (*RestrictionRecordResolver) RestrictionID

func (r *RestrictionRecordResolver) RestrictionID() string

RestrictionID is the unique restriction id

type RestrictionResolver

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

RestrictionResolver is the receiver for restriction conversion methods

func (*RestrictionResolver) ToBlackoutRestriction

func (r *RestrictionResolver) ToBlackoutRestriction() (*BlackoutRestrictionResolver, bool)

ToBlackoutRestriction check and convert restriction to blackout restriction

func (*RestrictionResolver) ToMembershipRestriction

func (r *RestrictionResolver) ToMembershipRestriction() (*MembershipRestrictionResolver, bool)

ToMembershipRestriction check and convert restriction to membership restriction

type RestrictionRollup

type RestrictionRollup struct {
	Input *models.NewRestrictionInput

	// rollup changes
	Canceled     bool
	EventVersion int32
}

RestrictionRollup is an internal struct used duing rollup of restrictions

func (*RestrictionRollup) GetEventVersion

func (r *RestrictionRollup) GetEventVersion() int

GetEventVersion returns version of rollup item

type SettingsResolver

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

SettingsResolver is the settings resolver receiver

func (*SettingsResolver) AllowNonMembers

func (r *SettingsResolver) AllowNonMembers() bool

AllowNonMembers is true if friends of members can have reservations

func (*SettingsResolver) BalanceReminderIntervalDays

func (r *SettingsResolver) BalanceReminderIntervalDays() int32

BalanceReminderIntervalDays is the minimum interval between reminders for a negative balance

func (*SettingsResolver) Currency

func (r *SettingsResolver) Currency(ctx context.Context, args *struct{ Format currencyFormat }) (string, error)

Currency method for GQL call

func (*SettingsResolver) GetEventVersion

func (r *SettingsResolver) GetEventVersion() int

GetEventVersion returns the version of the settings event

func (*SettingsResolver) MaxOutDays

func (r *SettingsResolver) MaxOutDays() int32

MaxOutDays is the number of days after today after which new reservations are not allowed

func (*SettingsResolver) MemberRate

func (r *SettingsResolver) MemberRate(args *struct{ Format amountFormat }) (string, error)

MemberRate is the daily member rate for reservations

func (*SettingsResolver) MinBalance

func (r *SettingsResolver) MinBalance(args *struct{ Format amountFormat }) (string, error)

MinBalance is the minimum balance required to make new reservations

func (*SettingsResolver) MinInDays

func (r *SettingsResolver) MinInDays() int32

MinInDays is the number of days before the current date when new reservations can be made

func (*SettingsResolver) NonMemberRate

func (r *SettingsResolver) NonMemberRate(args *struct{ Format amountFormat }) (string, error)

NonMemberRate is the daily non-member rate for reservations

func (*SettingsResolver) PropertyName

func (r *SettingsResolver) PropertyName() string

PropertyName is the name of the requested property

func (*SettingsResolver) ReservationReminderDaysBefore

func (r *SettingsResolver) ReservationReminderDaysBefore() int32

ReservationReminderDaysBefore is the number of days before the start of a reservation at which a reminder is sent

func (*SettingsResolver) Timezone

func (r *SettingsResolver) Timezone() string

Timezone is the time zone of the property

type SettingsRollup

type SettingsRollup struct {
	PropertyName                  string
	Currency                      models.Currency
	MemberRate                    int32
	AllowNonMembers               bool
	NonMemberRate                 int32
	Timezone                      string
	MinBalance                    int32
	MaxOutDays                    int32
	MinInDays                     int32
	EventVersion                  int32
	ReservationReminderDaysBefore int32
	BalanceReminderIntervalDays   int32
}

SettingsRollup is an internal struct used duing rollup of settings

func (*SettingsRollup) GetEventVersion

func (r *SettingsRollup) GetEventVersion() int

GetEventVersion returns version of rollup item

type UpdateBalanceConstraints

type UpdateBalanceConstraints struct {
}

UpdateBalanceConstraints provides the retriever for contraint methods

func (*UpdateBalanceConstraints) AmountMax

func (r *UpdateBalanceConstraints) AmountMax() int32

AmountMax returns the maximum amount

func (*UpdateBalanceConstraints) AmountMin

func (r *UpdateBalanceConstraints) AmountMin() int32

AmountMin returns the minimum amount

func (*UpdateBalanceConstraints) DescriptionMax

func (r *UpdateBalanceConstraints) DescriptionMax() int32

DescriptionMax returns the maximum description length

func (*UpdateBalanceConstraints) DescriptionMin

func (r *UpdateBalanceConstraints) DescriptionMin() int32

DescriptionMin returns the minimum description length

type UpdateSettingsConstraints

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

UpdateSettingsConstraints provides the retriever for constraint methods

func (*UpdateSettingsConstraints) AllowNewProperty

func (r *UpdateSettingsConstraints) AllowNewProperty() bool

AllowNewProperty is true if a new property creation is allowed

func (*UpdateSettingsConstraints) AllowPropertyDelete

func (r *UpdateSettingsConstraints) AllowPropertyDelete() bool

AllowPropertyDelete is true if a the property can be deleted

func (*UpdateSettingsConstraints) AllowPropertyExportBackup

func (r *UpdateSettingsConstraints) AllowPropertyExportBackup() bool

AllowPropertyExportBackup is true if export of property backup is allowed

func (*UpdateSettingsConstraints) AllowPropertyExportCSV

func (r *UpdateSettingsConstraints) AllowPropertyExportCSV() bool

AllowPropertyExportCSV is true if export of property data is allowed

func (*UpdateSettingsConstraints) AllowPropertyImport

func (r *UpdateSettingsConstraints) AllowPropertyImport() bool

AllowPropertyImport is true if import of a property is allowed

func (*UpdateSettingsConstraints) BalanceReminderIntervalDaysMax

func (r *UpdateSettingsConstraints) BalanceReminderIntervalDaysMax() int32

BalanceReminderIntervalDaysMax returns min value

func (*UpdateSettingsConstraints) BalanceReminderIntervalDaysMin

func (r *UpdateSettingsConstraints) BalanceReminderIntervalDaysMin() int32

BalanceReminderIntervalDaysMin returns min value

func (*UpdateSettingsConstraints) MaxOutDaysMax

func (r *UpdateSettingsConstraints) MaxOutDaysMax() int32

MaxOutDaysMax returns max value

func (*UpdateSettingsConstraints) MaxOutDaysMin

func (r *UpdateSettingsConstraints) MaxOutDaysMin() int32

MaxOutDaysMin returns min value

func (*UpdateSettingsConstraints) MemberRateMax

func (r *UpdateSettingsConstraints) MemberRateMax() int32

MemberRateMax returns max value

func (*UpdateSettingsConstraints) MemberRateMin

func (r *UpdateSettingsConstraints) MemberRateMin() int32

MemberRateMin returns min value

func (*UpdateSettingsConstraints) MinBalanceMax

func (r *UpdateSettingsConstraints) MinBalanceMax() int32

MinBalanceMax returns min value

func (*UpdateSettingsConstraints) MinBalanceMin

func (r *UpdateSettingsConstraints) MinBalanceMin() int32

MinBalanceMin returns min value

func (*UpdateSettingsConstraints) MinInDaysMax

func (r *UpdateSettingsConstraints) MinInDaysMax() int32

MinInDaysMax returns min value

func (*UpdateSettingsConstraints) MinInDaysMin

func (r *UpdateSettingsConstraints) MinInDaysMin() int32

MinInDaysMin returns min value

func (*UpdateSettingsConstraints) NonMemberRateMax

func (r *UpdateSettingsConstraints) NonMemberRateMax() int32

NonMemberRateMax returns max value

func (*UpdateSettingsConstraints) NonMemberRateMin

func (r *UpdateSettingsConstraints) NonMemberRateMin() int32

NonMemberRateMin returns min value

func (*UpdateSettingsConstraints) PropertyNameMax

func (r *UpdateSettingsConstraints) PropertyNameMax() int32

PropertyNameMax returns max length

func (*UpdateSettingsConstraints) PropertyNameMin

func (r *UpdateSettingsConstraints) PropertyNameMin() int32

PropertyNameMin returns min length

func (*UpdateSettingsConstraints) ReservationReminderDaysBeforeMax

func (r *UpdateSettingsConstraints) ReservationReminderDaysBeforeMax() int32

ReservationReminderDaysBeforeMax returns min value

func (*UpdateSettingsConstraints) ReservationReminderDaysBeforeMin

func (r *UpdateSettingsConstraints) ReservationReminderDaysBeforeMin() int32

ReservationReminderDaysBeforeMin returns min value

func (*UpdateSettingsConstraints) TrialDays

func (r *UpdateSettingsConstraints) TrialDays() int32

TrialDays returns the days at which a property will be deleted during a trial

func (*UpdateSettingsConstraints) TrialOn

func (r *UpdateSettingsConstraints) TrialOn() bool

TrialOn is true if the site is setup for trial properties only

type UpdateUserConstraints

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

UpdateUserConstraints provides the retriever for contraint methods

func (*UpdateUserConstraints) EmailMax

func (r *UpdateUserConstraints) EmailMax() int32

EmailMax returns max length of email string

func (*UpdateUserConstraints) EmailMin

func (r *UpdateUserConstraints) EmailMin() int32

EmailMin returns min length of email string

func (*UpdateUserConstraints) InvalidEmails

func (r *UpdateUserConstraints) InvalidEmails() []*string

InvalidEmails is the list of emails that cannot be used

func (*UpdateUserConstraints) InvalidNicknames

func (r *UpdateUserConstraints) InvalidNicknames() []*string

InvalidNicknames is a list of all the nicknames that cannot be used

func (*UpdateUserConstraints) NicknameMax

func (r *UpdateUserConstraints) NicknameMax() int32

NicknameMax returns max length of nickname

func (*UpdateUserConstraints) NicknameMin

func (r *UpdateUserConstraints) NicknameMin() int32

NicknameMin returns min length of nickname

type UpdateUserConstraintsArgs

type UpdateUserConstraintsArgs struct {
	UserID *string
}

UpdateUserConstraintsArgs holds the arguments for the UpdateUserConstraints GQL call

type User

type User struct {
	Email string
}

User represents a user of the application.

func GetUser

func GetUser(ctx context.Context) *User

GetUser retrieves the email address of the logged in user

type UserMembershipRecord

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

UserMembershipRecord contains the information for resolving a user membership

type UserResolver

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

UserResolver is the receiver for user resolver calls

func (*UserResolver) Email

func (r *UserResolver) Email() string

Email is the email of the user

func (*UserResolver) GetEventVersion

func (r *UserResolver) GetEventVersion() int

GetEventVersion returns the version of this user record

func (*UserResolver) IsAdmin

func (r *UserResolver) IsAdmin() bool

IsAdmin is true if the user is an admin

func (*UserResolver) IsMember

func (r *UserResolver) IsMember() bool

IsMember is true if the user is a member, i.e. can make reservations

func (*UserResolver) IsSystem

func (r *UserResolver) IsSystem() bool

IsSystem is true if the user is a system user

func (*UserResolver) Nickname

func (r *UserResolver) Nickname() string

Nickname is the user nickname

func (*UserResolver) State

func (r *UserResolver) State() models.UserState

State is the user state

func (*UserResolver) UserID

func (r *UserResolver) UserID() string

UserID is the id of the user

type UserRollup

type UserRollup struct {
	UserID       string
	IsAdmin      bool
	IsMember     bool
	IsSystem     bool
	State        models.UserState
	Nickname     string
	EmailID      string
	EventVersion int32
}

UserRollup is the user event rollup structure

func (*UserRollup) GetEventVersion

func (r *UserRollup) GetEventVersion() int

GetEventVersion returns the version of the rollup record

type VersionedInput

type VersionedInput interface {
	GetForVersion() int32
}

VersionedInput is an input based on the client view of the current version

Notes

Bugs

  • consider having separate create author and cancel author

Jump to

Keyboard shortcuts

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