Documentation
¶
Index ¶
- type CompleteRegistrationEndpoint
- type CompleteRegistrationRequest
- type ConfirmPaymentEndpoint
- type ConfirmPaymentRequest
- type CreateRegistrationSessionRequest
- type CreateSessionEndpoint
- type CreateUserEndpoint
- type CreateUserRequest
- type ListSessionsEndpoint
- type RegistrationSessionSvc
- type RegistrationSessionSvcConfig
- type ResendEmailEndpoint
- type ResendEmailRequest
- type RetrieveSessionEndpoint
- type RetrieveSessionRequest
- type SetupBillingEndpoint
- type SetupBillingRequest
- type UpdateSessionDataRequest
- type UpdateSessionEndpoint
- type UpdateSessionRequest
- type VerifyTokenEndpoint
- type VerifyTokenRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompleteRegistrationEndpoint ¶
type CompleteRegistrationEndpoint struct{}
Completes a registration session by creating the account the registrant signed up for.
The registering user becomes an administrator of the new account, and a paired sandbox account is provisioned alongside it. Requires a user to have been created for the session and an account name to have been supplied; paid plans additionally require confirmed payment, and their subscription starts here. If the selected plan has reached its signup capacity the request fails and the registration is added to a waiting list. Returns the ID of the new account.
func (*CompleteRegistrationEndpoint) Materialize ¶
func (e *CompleteRegistrationEndpoint) Materialize() *apiendpoint.APIEndpoint[*CompleteRegistrationRequest, *apiresource.CompleteRegistrationResponse]
type CompleteRegistrationRequest ¶
type CompleteRegistrationRequest struct {
// Session ID.
SessionID string `json:"-" path:"session_id" validate:"required"`
}
Request to complete registration for a session.
type ConfirmPaymentEndpoint ¶
type ConfirmPaymentEndpoint struct{}
Verifies that a Stripe Setup Intent succeeded and marks the registration session's payment as completed.
A registration on a paid plan cannot be completed until this succeeds. Confirming a session whose payment is already recorded returns success without re-checking Stripe.
func (*ConfirmPaymentEndpoint) Materialize ¶
func (e *ConfirmPaymentEndpoint) Materialize() *apiendpoint.APIEndpoint[*ConfirmPaymentRequest, *apiresource.ConfirmPaymentResponse]
type ConfirmPaymentRequest ¶
type ConfirmPaymentRequest struct {
// Session ID.
SessionID string `json:"-" path:"session_id" validate:"required"`
// ID of the Stripe Setup Intent to verify.
//
// Must be the Setup Intent most recently created for this session by Setup Registration Billing, and its status must be `succeeded`.
SetupIntentID string `json:"setup_intent_id" validate:"required"`
}
Request to confirm payment for a registration session.
func (*ConfirmPaymentRequest) SchemaExample ¶
func (*ConfirmPaymentRequest) SchemaExample() any
type CreateRegistrationSessionRequest ¶
type CreateRegistrationSessionRequest struct {
// Email address of the registering user.
//
// A verification email is sent to this address to start the registration.
Email string `json:"email" validate:"required,custom_email,max=255"`
// Code of the pricing plan to register for.
//
// Free plans skip the payment step; paid plans require a payment method to be collected and confirmed before the registration can complete.
PlanCode constants.PublicPlanCode `json:"plan_code" validate:"required"`
}
Request to create a registration session.
func (*CreateRegistrationSessionRequest) SchemaExample ¶
func (*CreateRegistrationSessionRequest) SchemaExample() any
type CreateSessionEndpoint ¶
type CreateSessionEndpoint struct{}
Starts a self-serve registration session and emails a verification link to the registrant.
If a session started for the same email within the last seven days is still in progress, its ID is returned instead of a new one, its plan is switched to `plan_code`, and the verification email is sent again.
If the email already belongs to a user, the message sent directs them to sign in rather than carrying a verification link, since an existing account cannot be registered again.
func (*CreateSessionEndpoint) Materialize ¶
func (e *CreateSessionEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateRegistrationSessionRequest, *apiresource.CreateSessionResponse]
type CreateUserEndpoint ¶
type CreateUserEndpoint struct{}
Creates the user for a registration session and signs the registrant in.
The session's email must already be verified, and no user may exist for that email yet; someone who already has an account must sign in instead of registering again. On success the session advances to the `account_details` step and the response sets authentication cookies, so the remaining registration calls are made as the new user. Repeating the call on a session that already has a user re-issues cookies for that user instead of creating another.
func (*CreateUserEndpoint) Materialize ¶
func (e *CreateUserEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateUserRequest, *apiresource.CreateUserResponse]
type CreateUserRequest ¶
type CreateUserRequest struct {
// Session ID.
SessionID string `json:"-" path:"session_id" validate:"required"`
// The user's display name.
Name string `json:"name" validate:"required,max=255"`
// Password for the new user.
//
// Must be 8–72 characters and contain at least one lowercase letter, one uppercase letter, one digit, and one special character.
Password string `json:"password" validate:"required,password" sensitive:"true"` // #nosec G117 - Struct field, not a hardcoded credential
}
Request to create a user for a registration session.
func (*CreateUserRequest) SchemaExample ¶
func (*CreateUserRequest) SchemaExample() any
type ListSessionsEndpoint ¶
type ListSessionsEndpoint struct{}
Returns a paginated list of the authenticated user's registration sessions that are still in progress, newest first.
The list is empty once the user has finished registering.
func (*ListSessionsEndpoint) Materialize ¶
func (e *ListSessionsEndpoint) Materialize() *apiendpoint.APIEndpoint[*apiresource.PaginationRequest, *apiresource.List[apiresource.RegistrationSession]]
type RegistrationSessionSvc ¶
type RegistrationSessionSvc interface {
CreateSession(ctx context.Context, req *CreateRegistrationSessionRequest) (*apiresource.CreateSessionResponse, *apierror.APIError)
ResendVerificationEmail(ctx context.Context, req *ResendEmailRequest) (*apiresource.EmptyResource, *apierror.APIError)
VerifyToken(ctx context.Context, req *VerifyTokenRequest) (*apiresource.RegistrationSession, *apierror.APIError)
GetSession(ctx context.Context, req *RetrieveSessionRequest) (*apiresource.RegistrationSession, *apierror.APIError)
CreateUser(ctx context.Context, req *CreateUserRequest) (*apiresource.CreateUserResponse, *apierror.APIError)
UpdateSession(ctx context.Context, req *UpdateSessionRequest) (*apiresource.RegistrationSession, *apierror.APIError)
ListSessions(ctx context.Context, req *apiresource.PaginationRequest) (*apiresource.List[apiresource.RegistrationSession], *apierror.APIError)
SetupBilling(ctx context.Context, req *SetupBillingRequest) (*apiresource.SetupBillingResponse, *apierror.APIError)
ConfirmPayment(ctx context.Context, req *ConfirmPaymentRequest) (*apiresource.ConfirmPaymentResponse, *apierror.APIError)
CompleteRegistration(ctx context.Context, req *CompleteRegistrationRequest) (*apiresource.CompleteRegistrationResponse, *apierror.APIError)
}
func NewRegistrationSessionSvc ¶
func NewRegistrationSessionSvc(config *RegistrationSessionSvcConfig) RegistrationSessionSvc
type RegistrationSessionSvcConfig ¶
type RegistrationSessionSvcConfig struct {
// AuthClient (required) is the auth-service gRPC client.
AuthClient pb.AuthServiceClient
}
type ResendEmailEndpoint ¶
type ResendEmailEndpoint struct{}
Resends the verification email for a registration session, generating a new token and invalidating the previous one.
Rejected once the email has been verified or the registration has completed.
func (*ResendEmailEndpoint) Materialize ¶
func (e *ResendEmailEndpoint) Materialize() *apiendpoint.APIEndpoint[*ResendEmailRequest, *apiresource.EmptyResource]
type ResendEmailRequest ¶
type ResendEmailRequest struct {
// Session ID.
SessionID string `json:"-" path:"session_id" validate:"required"`
}
Request to resend the verification email.
type RetrieveSessionEndpoint ¶
type RetrieveSessionEndpoint struct{}
Returns a registration session by ID, including its current step and associated user and account details.
func (*RetrieveSessionEndpoint) Materialize ¶
func (e *RetrieveSessionEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveSessionRequest, *apiresource.RegistrationSession]
type RetrieveSessionRequest ¶
type RetrieveSessionRequest struct {
// Session ID.
SessionID string `json:"-" path:"session_id" validate:"required"`
}
Request to get a registration session.
type SetupBillingEndpoint ¶
type SetupBillingEndpoint struct{}
Creates a Stripe customer and Setup Intent for collecting the registration's payment method.
Returns the Setup Intent client secret and publishable key needed to collect a payment method with Stripe.js. The Stripe customer is created once and reused on later calls, but every call issues a new Setup Intent and replaces the one recorded on the session, so confirm payment with the Setup Intent from the most recent call. Rejected once the registration has completed.
func (*SetupBillingEndpoint) Materialize ¶
func (e *SetupBillingEndpoint) Materialize() *apiendpoint.APIEndpoint[*SetupBillingRequest, *apiresource.SetupBillingResponse]
type SetupBillingRequest ¶
type SetupBillingRequest struct {
// Session ID.
SessionID string `json:"-" path:"session_id" validate:"required"`
}
Request to set up billing for a registration session.
type UpdateSessionDataRequest ¶
type UpdateSessionDataRequest struct {
// Display name for the user.
UserName field.Optional[string] `json:"user_name,omitzero" validate:"omitempty,max=255"`
// Display name for the account.
//
// Becomes the name of the account created when the registration completes, and must be set before Complete Registration will succeed.
AccountName field.Optional[string] `json:"account_name,omitzero" validate:"omitempty,max=255"`
// Billing address line 1.
BillingAddressLine1 field.Optional[string] `json:"billing_address_line1,omitzero" validate:"omitempty,max=255"`
// Billing address line 2.
BillingAddressLine2 field.Optional[string] `json:"billing_address_line2,omitzero" validate:"omitempty,max=255"`
// Billing address city.
BillingAddressCity field.Optional[string] `json:"billing_address_city,omitzero" validate:"omitempty,max=255"`
// Billing address state.
BillingAddressState field.Optional[string] `json:"billing_address_state,omitzero" validate:"omitempty,max=255"`
// Billing address postal code.
BillingAddressPostalCode field.Optional[string] `json:"billing_address_postal_code,omitzero" validate:"omitempty,max=255"`
// Billing address country as a two-letter country code.
BillingAddressCountry field.Optional[string] `json:"billing_address_country,omitzero" validate:"omitempty,max=2"`
}
Mutable form data for a session update.
type UpdateSessionEndpoint ¶
type UpdateSessionEndpoint struct{}
Partially updates a registration session's step and form data.
Omitted fields are left unchanged, and a session that has already completed can no longer be updated.
func (*UpdateSessionEndpoint) Materialize ¶
func (e *UpdateSessionEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateSessionRequest, *apiresource.RegistrationSession]
type UpdateSessionRequest ¶
type UpdateSessionRequest struct {
// Session ID.
SessionID string `json:"-" path:"session_id" validate:"required"`
// Step to advance the session to.
//
// Must be later than the session's current step; moving backwards is rejected. See the session resource's `step` field for the step order.
Step field.Optional[constants.RegistrationStep] `json:"step,omitzero"`
// Session data to merge into the existing session.
SessionData field.Optional[UpdateSessionDataRequest] `json:"session_data,omitzero"`
}
Request to update a registration session.
func (*UpdateSessionRequest) SchemaExample ¶
func (*UpdateSessionRequest) SchemaExample() any
type VerifyTokenEndpoint ¶
type VerifyTokenEndpoint struct{}
Verifies the token from the registration email, marking the session as email-verified and advancing it to the `user_details` step.
A token is only accepted within 24 hours of the session's last update; Resend Verification Email issues a fresh one. Verifying a session that is already verified returns it unchanged.
func (*VerifyTokenEndpoint) Materialize ¶
func (e *VerifyTokenEndpoint) Materialize() *apiendpoint.APIEndpoint[*VerifyTokenRequest, *apiresource.RegistrationSession]
type VerifyTokenRequest ¶
type VerifyTokenRequest struct {
// Verification token from the email link.
Token string `json:"-" path:"token" validate:"required"`
}
Request to verify a registration token.