Documentation
¶
Index ¶
- type Assignment
- type AssignmentData
- type AssignmentParams
- type AssignmentsResponse
- type Client
- func (c *Client) GetAssignments(ctx context.Context, params *AssignmentParams) (*AssignmentsResponse, error)
- func (c *Client) GetLevelProgression(ctx context.Context, id string) (*LevelProgressionResponse, error)
- func (c *Client) GetLevelProgressions(ctx context.Context, params *LevelProgressionsParams) (*LevelProgressionsResponse, error)
- func (c *Client) GetReviewStatistics(ctx context.Context) (*ReviewStatisticsResponse, error)
- func (c *Client) GetReviews(ctx context.Context, params *ReviewParams) (*ReviewsResponse, error)
- func (c *Client) GetStudyMaterials(ctx context.Context, params *StudyMaterialParams) (*StudyMaterialsResponse, error)
- func (c *Client) GetSubject(ctx context.Context, id string) (*SubjectResponse, error)
- func (c *Client) GetSubjects(ctx context.Context, params *SubjectsParams) (*SubjectsResponse, error)
- func (c *Client) GetSummary(ctx context.Context) (*SummaryResponse, error)
- func (c *Client) GetUser(ctx context.Context) (*UserResponse, error)
- func (c *Client) PrintAssignments(ctx context.Context, params *AssignmentParams) error
- func (c *Client) PrintLevelProgression(ctx context.Context, id string) error
- func (c *Client) PrintLevelProgressions(ctx context.Context, params *LevelProgressionsParams) error
- func (c *Client) PrintReviewStatistics(ctx context.Context) error
- func (c *Client) PrintReviews(ctx context.Context, params *ReviewParams) error
- func (c *Client) PrintStudyMaterials(ctx context.Context, params *StudyMaterialParams) error
- func (c *Client) PrintSubject(ctx context.Context, id string) error
- func (c *Client) PrintSubjects(ctx context.Context, params *SubjectsParams) error
- func (c *Client) PrintSummary(ctx context.Context) error
- func (c *Client) PrintUser(ctx context.Context) error
- type LessonSession
- type LevelProgression
- type LevelProgressionData
- type LevelProgressionResponse
- type LevelProgressionsParams
- type LevelProgressionsResponse
- type ObjectType
- type Pages
- type Response
- type Review
- type ReviewData
- type ReviewParams
- type ReviewSession
- type ReviewStatistics
- type ReviewStatisticsData
- type ReviewStatisticsResponse
- type ReviewsResponse
- type StudyMaterial
- type StudyMaterialData
- type StudyMaterialParams
- type StudyMaterialsResponse
- type Subject
- type SubjectData
- type SubjectMeaning
- type SubjectReading
- type SubjectResponse
- type SubjectsParams
- type SubjectsResponse
- type SummaryData
- type SummaryResponse
- type UserData
- type UserPreferences
- type UserResponse
- type UserSubscription
- type WaniKaniClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assignment ¶
type Assignment struct {
Response
ID int `json:"id"`
Data AssignmentData `json:"data"`
}
Assignment represents a single assignment in the collection response. See: https://docs.api.wanikani.com/20170710/#assignment-response
type AssignmentData ¶
type AssignmentData struct {
CreatedAt string `json:"created_at"`
SubjectID int `json:"subject_id"`
SubjectType string `json:"subject_type"`
SRSStage int `json:"srs_stage"`
UnlockedAt *string `json:"unlocked_at"`
StartedAt *string `json:"started_at"`
PassedAt *string `json:"passed_at"`
BurnedAt *string `json:"burned_at"`
AvailableAt *string `json:"available_at"`
ResurrectedAt *string `json:"resurrected_at"`
Hidden bool `json:"hidden"`
}
AssignmentData represents the data field in an assignment response. See: https://docs.api.wanikani.com/20170710/#assignment-data
type AssignmentParams ¶
type AssignmentParams struct {
IDs []int
SubjectIDs []int
SubjectTypes []string
Levels []int
SRSStages []int
Unlocked *bool
Started *bool
Passed *bool
Burned *bool
Resurrected *bool
Hidden *bool
UpdatedAfter *string
}
AssignmentParams represents optional query parameters for the assignments endpoint.
type AssignmentsResponse ¶
type AssignmentsResponse struct {
Response
Pages `json:"pages"`
TotalCount int `json:"total_count"`
Data []Assignment `json:"data"`
}
AssignmentsResponse represents the response from the /v2/assignments endpoint. See: https://docs.api.wanikani.com/20170710/#assignment-response
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a simple WaniKani API client. Client implements the WaniKaniClient interface.
func NewClient ¶
NewClient constructs a new WaniKani client. If baseURL is empty, it defaults to the production WaniKani API URL. Providing a baseURL is useful for testing with mock servers.
func (*Client) GetAssignments ¶
func (c *Client) GetAssignments(ctx context.Context, params *AssignmentParams) (*AssignmentsResponse, error)
GetAssignments fetches all assignments for the current user, handling pagination automatically. See: https://docs.api.wanikani.com/20170710/#assignment-response
func (*Client) GetLevelProgression ¶
func (c *Client) GetLevelProgression(ctx context.Context, id string) (*LevelProgressionResponse, error)
GetLevelProgression fetches a single level progression by ID. See: https://docs.api.wanikani.com/20170710/#level-progression-response
func (*Client) GetLevelProgressions ¶
func (c *Client) GetLevelProgressions(ctx context.Context, params *LevelProgressionsParams) (*LevelProgressionsResponse, error)
GetLevelProgressions fetches all level progressions for the current user, handling pagination automatically. See: https://docs.api.wanikani.com/20170710/#level-progression-response
func (*Client) GetReviewStatistics ¶
func (c *Client) GetReviewStatistics(ctx context.Context) (*ReviewStatisticsResponse, error)
GetReviewStatistics fetches all review statistics for the current user, handling pagination automatically. See: https://docs.api.wanikani.com/20170710/#review-statistics-response
func (*Client) GetReviews ¶
func (c *Client) GetReviews(ctx context.Context, params *ReviewParams) (*ReviewsResponse, error)
GetReviews fetches all reviews for the current user, handling pagination automatically. See: https://docs.api.wanikani.com/20170710/#review-response
func (*Client) GetStudyMaterials ¶
func (c *Client) GetStudyMaterials(ctx context.Context, params *StudyMaterialParams) (*StudyMaterialsResponse, error)
GetStudyMaterials fetches all study materials for the current user, handling pagination automatically. See: https://docs.api.wanikani.com/20170710/#study-material-response
func (*Client) GetSubject ¶
func (*Client) GetSubjects ¶
func (c *Client) GetSubjects(ctx context.Context, params *SubjectsParams) (*SubjectsResponse, error)
GetSubjects fetches all subjects, handling pagination automatically. See: https://docs.api.wanikani.com/20170710/#subject-response
func (*Client) GetSummary ¶
func (c *Client) GetSummary(ctx context.Context) (*SummaryResponse, error)
GetSummary fetches the summary of upcoming lessons and reviews from WaniKani. See: https://docs.api.wanikani.com/20170710/#summary
func (*Client) GetUser ¶
func (c *Client) GetUser(ctx context.Context) (*UserResponse, error)
GetUser fetches the current user object from WaniKani. See: https://docs.api.wanikani.com/20170710/#get-user
func (*Client) PrintAssignments ¶
func (c *Client) PrintAssignments(ctx context.Context, params *AssignmentParams) error
PrintAssignments prints the assignments for the current user. See: https://docs.api.wanikani.com/20170710/#assignment-response
func (*Client) PrintLevelProgression ¶
PrintLevelProgression prints a single level progression. See: https://docs.api.wanikani.com/20170710/#level-progression-response
func (*Client) PrintLevelProgressions ¶
func (c *Client) PrintLevelProgressions(ctx context.Context, params *LevelProgressionsParams) error
PrintLevelProgressions prints the level progressions for the current user. See: https://docs.api.wanikani.com/20170710/#level-progression-response
func (*Client) PrintReviewStatistics ¶
PrintReviewStatistics prints the review statistics for the current user. See: https://docs.api.wanikani.com/20170710/#review-statistics-response
func (*Client) PrintReviews ¶
func (c *Client) PrintReviews(ctx context.Context, params *ReviewParams) error
PrintReviews prints the reviews for the current user. See: https://docs.api.wanikani.com/20170710/#review-response
func (*Client) PrintStudyMaterials ¶
func (c *Client) PrintStudyMaterials(ctx context.Context, params *StudyMaterialParams) error
PrintStudyMaterials prints the study materials for the current user. See: https://docs.api.wanikani.com/20170710/#study-material-response
func (*Client) PrintSubject ¶
PrintSubject prints the subject data. See: https://docs.api.wanikani.com/20170710/#subject-response
func (*Client) PrintSubjects ¶
func (c *Client) PrintSubjects(ctx context.Context, params *SubjectsParams) error
PrintSubjects prints the subjects. See: https://docs.api.wanikani.com/20170710/#subject-response
func (*Client) PrintSummary ¶
PrintSummary prints the summary data for the current user. See: https://docs.api.wanikani.com/20170710/#summary
type LessonSession ¶
type LessonSession struct {
AvailableAt string `json:"available_at"`
SubjectIDs []int `json:"subject_ids"`
}
LessonSession represents a lesson session in the summary response. See: https://docs.api.wanikani.com/20170710/#summary
type LevelProgression ¶
type LevelProgression struct {
Response
ID int `json:"id"`
Data LevelProgressionData `json:"data"`
}
LevelProgression represents a single level progression in the collection response. See: https://docs.api.wanikani.com/20170710/#level-progression-response
type LevelProgressionData ¶
type LevelProgressionData struct {
CreatedAt string `json:"created_at"`
Level int `json:"level"`
UnlockedAt *string `json:"unlocked_at"`
StartedAt *string `json:"started_at"`
PassedAt *string `json:"passed_at"`
CompletedAt *string `json:"completed_at"`
AbandonedAt *string `json:"abandoned_at"`
}
LevelProgressionData represents the data field in a level progression response. See: https://docs.api.wanikani.com/20170710/#level-progression-data
type LevelProgressionResponse ¶
type LevelProgressionResponse struct {
Response
ID int `json:"id"`
Data LevelProgressionData `json:"data"`
}
LevelProgressionResponse represents the response from the /v2/level_progressions/{id} endpoint. See: https://docs.api.wanikani.com/20170710/#level-progression-response
type LevelProgressionsParams ¶
LevelProgressionsParams represents optional query parameters for the level_progressions endpoint.
type LevelProgressionsResponse ¶
type LevelProgressionsResponse struct {
Response
Pages `json:"pages"`
TotalCount int `json:"total_count"`
Data []LevelProgression `json:"data"`
}
LevelProgressionsResponse represents the response from the /v2/level_progressions endpoint. See: https://docs.api.wanikani.com/20170710/#level-progression-response
type ObjectType ¶
type ObjectType string
ObjectType represents the type of object returned by the WaniKani API.
const ( ObjectTypeUser ObjectType = "user" ObjectTypeCollection ObjectType = "collection" ObjectTypeReviewStatistic ObjectType = "review_statistic" ObjectTypeRadical ObjectType = "radical" ObjectTypeKanji ObjectType = "kanji" ObjectTypeVocabulary ObjectType = "vocabulary" ObjectTypeSubject ObjectType = "subject" )
type Response ¶
type Response struct {
Object ObjectType `json:"object"`
URL string `json:"url"`
DataUpdatedAt string `json:"data_updated_at"`
}
Response represents the common fields in every WaniKani API response. See: https://docs.api.wanikani.com/20170710/#response-format Note: The "data" field is not included here as it varies by endpoint. Each endpoint-specific response struct should include its own Data field.
type Review ¶
type Review struct {
Response
ID int `json:"id"`
Data ReviewData `json:"data"`
}
Review represents a single review in the collection response. See: https://docs.api.wanikani.com/20170710/#review-response
type ReviewData ¶
type ReviewData struct {
CreatedAt string `json:"created_at"`
AssignmentID int `json:"assignment_id"`
SpacedRepetitionSystemID int `json:"spaced_repetition_system_id"`
SubjectID int `json:"subject_id"`
StartingSRSStage int `json:"starting_srs_stage"`
EndingSRSStage int `json:"ending_srs_stage"`
IncorrectMeaningAnswers int `json:"incorrect_meaning_answers"`
IncorrectReadingAnswers int `json:"incorrect_reading_answers"`
}
ReviewData represents the data field in a review response. See: https://docs.api.wanikani.com/20170710/#review-data
type ReviewParams ¶
ReviewParams represents optional query parameters for the reviews endpoint.
type ReviewSession ¶
type ReviewSession struct {
AvailableAt string `json:"available_at"`
SubjectIDs []int `json:"subject_ids"`
}
ReviewSession represents a review session in the summary response. See: https://docs.api.wanikani.com/20170710/#summary
type ReviewStatistics ¶
type ReviewStatistics struct {
Response
ID int `json:"id"`
Data ReviewStatisticsData `json:"data"`
}
ReviewStatistics represents a single review statistics item in the collection response. Each item in the data array is a resource object that embeds Response. See: https://docs.api.wanikani.com/20170710/#review-statistics-response
type ReviewStatisticsData ¶
type ReviewStatisticsData struct {
CreatedAt string `json:"created_at"`
MeaningCorrect int `json:"meaning_correct"`
MeaningCurrentStreak int `json:"meaning_current_streak"`
MeaningIncorrect int `json:"meaning_incorrect"`
MeaningMaxStreak int `json:"meaning_max_streak"`
PercentageCorrect float64 `json:"percentage_correct"`
ReadingCorrect int `json:"reading_correct"`
ReadingCurrentStreak int `json:"reading_current_streak"`
ReadingIncorrect int `json:"reading_incorrect"`
ReadingMaxStreak int `json:"reading_max_streak"`
SubjectID int `json:"subject_id"`
SubjectType string `json:"subject_type"`
}
ReviewStatisticsData represents the data field in a review statistics response. See: https://docs.api.wanikani.com/20170710/#review-statistics-data
type ReviewStatisticsResponse ¶
type ReviewStatisticsResponse struct {
Response
Pages `json:"pages"`
TotalCount int `json:"total_count"`
Data []ReviewStatistics `json:"data"`
}
ReviewStatisticsResponse represents the response from the /v2/review_statistics endpoint. See: https://docs.api.wanikani.com/20170710/#review-statistics-response
type ReviewsResponse ¶
type ReviewsResponse struct {
Response
Pages `json:"pages"`
TotalCount int `json:"total_count"`
Data []Review `json:"data"`
}
ReviewsResponse represents the response from the /v2/reviews endpoint. See: https://docs.api.wanikani.com/20170710/#review-response
type StudyMaterial ¶
type StudyMaterial struct {
Response
ID int `json:"id"`
Data StudyMaterialData `json:"data"`
}
StudyMaterial represents a single study material in the collection response. See: https://docs.api.wanikani.com/20170710/#study-material-response
type StudyMaterialData ¶
type StudyMaterialData struct {
CreatedAt string `json:"created_at"`
SubjectID int `json:"subject_id"`
SubjectType string `json:"subject_type"`
MeaningNote *string `json:"meaning_note"`
ReadingNote *string `json:"reading_note"`
MeaningSynonyms []string `json:"meaning_synonyms"`
Hidden bool `json:"hidden"`
}
StudyMaterialData represents the data field in a study material response. See: https://docs.api.wanikani.com/20170710/#study-material-data
type StudyMaterialParams ¶
StudyMaterialParams represents optional query parameters for the study_materials endpoint.
type StudyMaterialsResponse ¶
type StudyMaterialsResponse struct {
Response
Pages `json:"pages"`
TotalCount int `json:"total_count"`
Data []StudyMaterial `json:"data"`
}
StudyMaterialsResponse represents the response from the /v2/study_materials endpoint. See: https://docs.api.wanikani.com/20170710/#study-material-response
type Subject ¶
type Subject struct {
Response
ID int `json:"id"`
Data SubjectData `json:"data"`
}
Subject represents a single subject in the collection response. Example: https://api.wanikani.com/v2/subjects/1 See: https://docs.api.wanikani.com/20170710/#subject-response
type SubjectData ¶
type SubjectData struct {
Level int `json:"level"`
Slug string `json:"slug"`
Characters string `json:"characters"`
Meanings []SubjectMeaning `json:"meanings"`
Readings []SubjectReading `json:"readings"`
ComponentSubjectIDs []int `json:"component_subject_ids"`
ReadingMnemonic string `json:"reading_mnemonic"`
MeaningMnemonic string `json:"meaning_mnemonic"`
DocumentURL string `json:"document_url"`
}
SubjectData represents the data field in a subject response. See: https://docs.api.wanikani.com/20170710/#subject-data
type SubjectMeaning ¶
type SubjectReading ¶
type SubjectResponse ¶
type SubjectResponse struct {
Response
ID int `json:"id"`
Data SubjectData `json:"data"`
}
SubjectResponse represents the response from the /v2/subjects{id} endpoint See: https://docs.api.wanikani.com/20170710/#subject-response
type SubjectsParams ¶
SubjectsParams represents optional query parameters for the subjects endpoint.
type SubjectsResponse ¶
type SubjectsResponse struct {
Response
Pages `json:"pages"`
TotalCount int `json:"total_count"`
Data []Subject `json:"data"`
}
SubjectsResponse represents the response from the /v2/subjects endpoint. See: https://docs.api.wanikani.com/20170710/#subject-response
type SummaryData ¶
type SummaryData struct {
Lessons []LessonSession `json:"lessons"`
Reviews []ReviewSession `json:"reviews"`
}
SummaryData represents the data field in a summary response. See: https://docs.api.wanikani.com/20170710/#summary
type SummaryResponse ¶
type SummaryResponse struct {
Response
Data SummaryData `json:"data"`
}
SummaryResponse represents the response from the /v2/summary endpoint. See: https://docs.api.wanikani.com/20170710/#summary
type UserData ¶
type UserData struct {
ID string `json:"id"`
Username string `json:"username"`
Level int `json:"level"`
ProfileURL string `json:"profile_url"`
StartedAt string `json:"started_at"`
Subscription UserSubscription `json:"subscription"`
CurrentVacationStartedAt *string `json:"current_vacation_started_at"`
Preferences UserPreferences `json:"preferences"`
}
UserData represents the data field in a user response.
type UserPreferences ¶
type UserPreferences struct {
LessonsAutoplayAudio bool `json:"lessons_autoplay_audio"`
LessonsBatchSize int `json:"lessons_batch_size"`
ReviewsAutoplayAudio bool `json:"reviews_autoplay_audio"`
ReviewsDisplaySRSIndicator bool `json:"reviews_display_srs_indicator"`
ExtraStudyAutoplayAudio bool `json:"extra_study_autoplay_audio"`
ReviewsPresentationOrder string `json:"reviews_presentation_order"`
LessonsPresentationOrder string `json:"lessons_presentation_order"`
DefaultVoiceActorID int `json:"default_voice_actor_id"`
}
UserPreferences represents user preferences.
type UserResponse ¶
UserResponse represents the response from the /v2/user endpoint.
type UserSubscription ¶
type UserSubscription struct {
Active bool `json:"active"`
Type string `json:"type"`
MaxLevelGranted int `json:"max_level_granted"`
PeriodEndsAt *string `json:"period_ends_at"` // null if lifetime subscription
}
UserSubscription represents subscription information for a user.
type WaniKaniClient ¶
type WaniKaniClient interface {
GetUser(ctx context.Context) (*UserResponse, error)
GetSummary(ctx context.Context) (*SummaryResponse, error)
GetSubject(ctx context.Context, id string) (*SubjectResponse, error)
GetSubjects(ctx context.Context, params *SubjectsParams) (*SubjectsResponse, error)
GetAssignments(ctx context.Context, params *AssignmentParams) (*AssignmentsResponse, error)
GetReviews(ctx context.Context, params *ReviewParams) (*ReviewsResponse, error)
GetReviewStatistics(ctx context.Context) (*ReviewStatisticsResponse, error)
GetStudyMaterials(ctx context.Context, params *StudyMaterialParams) (*StudyMaterialsResponse, error)
GetLevelProgression(ctx context.Context, id string) (*LevelProgressionResponse, error)
GetLevelProgressions(ctx context.Context, params *LevelProgressionsParams) (*LevelProgressionsResponse, error)
}
WaniKaniClient defines the interface for WaniKani API operations. This interface enables dependency injection and makes testing easier. The Client struct implements this interface. Note: Print methods are excluded from this interface as they are convenience methods for output formatting, not core API operations.