api

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetChallengeProgress

func ResetChallengeProgress(slugOrID string) error

ResetChallengeProgress is a wrapper for ResetChallenge for backward compatibility The old API used challenge ID, but the new API uses slug, so we accept slug here

func SendSubmit

func SendSubmit(challengeSlug string, staticValidation bool, dynamicValidation bool, payload interface{}) error

SendSubmit submits a challenge with validation results (backward compatibility wrapper) This function wraps SubmitChallenge to maintain compatibility with old code that uses challenge ID

func StartChallenge

func StartChallenge(slug string) error

StartChallenge starts a challenge for the user (backward compatibility wrapper) Returns only an error for compatibility with existing code

Types

type ChallengeEntity

type ChallengeEntity = ChallengeResponse

func GetChallenge

func GetChallenge(slug string) (*ChallengeEntity, error)

GetChallenge is a wrapper for GetChallengeBySlug for backward compatibility

func GetChallengeBySlug

func GetChallengeBySlug(slug string) (*ChallengeEntity, error)

GetChallengeBySlug fetches a challenge by its slug

type ChallengeResetResponse

type ChallengeResetResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

ChallengeResetResponse represents the response from POST /api/cli/challenge/[slug]/reset

func ResetChallenge

func ResetChallenge(slug string) (*ChallengeResetResponse, error)

ResetChallenge resets the user's progress for a challenge

type ChallengeResponse

type ChallengeResponse struct {
	ID               int    `json:"id"`
	Title            string `json:"title"`
	Slug             string `json:"slug"`
	Description      string `json:"description"`
	Difficulty       string `json:"difficulty"` // "easy" | "medium" | "hard"
	Theme            string `json:"theme"`
	InitialSituation string `json:"initial_situation"`
	Objective        string `json:"objective"`
}

ChallengeResponse represents the response from GET /api/cli/challenge/[slug]

type ChallengeStartResponse

type ChallengeStartResponse struct {
	Status    string  `json:"status"`    // "in_progress" | "completed"
	StartedAt string  `json:"startedAt"` // ISO 8601 date string
	Message   *string `json:"message,omitempty"`
}

ChallengeStartResponse represents the response from POST /api/cli/challenge/[slug]/start

func StartChallengeWithResponse

func StartChallengeWithResponse(slug string) (*ChallengeStartResponse, error)

StartChallengeWithResponse starts a challenge for the user and returns the full response

type ChallengeStatusResponse

type ChallengeStatusResponse struct {
	Status      string  `json:"status"`                // "not_started" | "in_progress" | "completed"
	StartedAt   *string `json:"startedAt,omitempty"`   // ISO 8601 date string
	CompletedAt *string `json:"completedAt,omitempty"` // ISO 8601 date string
}

ChallengeStatusResponse represents the response from GET /api/cli/challenge/[slug]/status

func GetChallengeProgress

func GetChallengeProgress(slug string) (*ChallengeStatusResponse, error)

GetChallengeProgress fetches the challenge status and returns it in the old format This function is provided for backward compatibility with existing code

func GetChallengeStatus

func GetChallengeStatus(slug string) (*ChallengeStatusResponse, error)

GetChallengeStatus fetches the user's progress status for a challenge

type ChallengeSubmitFailureResponse

type ChallengeSubmitFailureResponse struct {
	Success bool   `json:"success"` // Always false for this type
	Message string `json:"message"`
}

ChallengeSubmitFailureResponse represents a failed submission response

type ChallengeSubmitRequest

type ChallengeSubmitRequest struct {
	Validated         bool        `json:"validated"`                    // Overall validation result (required)
	StaticValidation  *bool       `json:"static_validation,omitempty"`  // Static validation result (optional)
	DynamicValidation *bool       `json:"dynamic_validation,omitempty"` // Dynamic validation result (optional)
	Payload           interface{} `json:"payload,omitempty"`            // Additional validation details (optional)
}

ChallengeSubmitRequest represents the request body for POST /api/cli/challenge/[slug]/submit

type ChallengeSubmitResponse

type ChallengeSubmitResponse struct {
	Success        bool    `json:"success"`
	XpAwarded      *int    `json:"xpAwarded,omitempty"`
	TotalXp        *int    `json:"totalXp,omitempty"`
	Rank           *string `json:"rank,omitempty"`
	RankUp         *bool   `json:"rankUp,omitempty"`
	FirstChallenge *bool   `json:"firstChallenge,omitempty"`
	Message        *string `json:"message,omitempty"`
}

ChallengeSubmitResponse is a union type that can be either success or failure Check the Success field to determine which type it is

func SubmitChallenge

func SubmitChallenge(slug string, req ChallengeSubmitRequest) (*ChallengeSubmitResponse, error)

SubmitChallenge submits a challenge with validation results

type ChallengeSubmitSuccessResponse

type ChallengeSubmitSuccessResponse struct {
	Success        bool   `json:"success"` // Always true for this type
	XpAwarded      int    `json:"xpAwarded"`
	TotalXp        int    `json:"totalXp"`
	Rank           string `json:"rank"`
	RankUp         *bool  `json:"rankUp,omitempty"`
	FirstChallenge *bool  `json:"firstChallenge,omitempty"`
}

ChallengeSubmitSuccessResponse represents a successful submission response

type ErrorResponse

type ErrorResponse struct {
	Error   string  `json:"error"`
	Details *string `json:"details,omitempty"`
}

ErrorResponse represents a standard error response from the API

type UserProfile

type UserProfile = UserResponse

Type aliases for backward compatibility with existing CLI code

func GetProfile

func GetProfile() (*UserProfile, error)

GetProfile fetches the current user's profile (main function name for compatibility)

func GetUserProfile

func GetUserProfile() (*UserProfile, error)

GetUserProfile is an alias for GetProfile for consistency with type names

type UserResponse

type UserResponse struct {
	FirstName string  `json:"firstName"`
	LastName  *string `json:"lastName,omitempty"`
}

UserResponse represents the response from GET /api/cli/user

Jump to

Keyboard shortcuts

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