Files
apocapoc-api/internal/infrastructure/http/dto.go
T
david a2aa8b2a76 Add i18n support with English and Spanish translations
- Created i18n package with translator and middleware
- Added translation files for English (en.json) and Spanish (es.json)
- Updated all HTTP handlers to use i18n for error/success messages
- Added comprehensive test coverage for i18n (87%)
- Updated CI workflow to use Go 1.24
- All tests passing with 50.8% total coverage
2025-11-29 12:27:26 +01:00

102 lines
3.7 KiB
Go

package http
import (
"time"
"apocapoc-api/internal/domain/value_objects"
)
type CreateHabitRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Type value_objects.HabitType `json:"type"`
Frequency value_objects.Frequency `json:"frequency"`
SpecificDays []int `json:"specific_days,omitempty"`
SpecificDates []int `json:"specific_dates,omitempty"`
CarryOver bool `json:"carry_over"`
IsNegative bool `json:"is_negative"`
TargetValue *float64 `json:"target_value,omitempty"`
}
type UpdateHabitRequest struct {
Name string `json:"name"`
Description string `json:"description"`
SpecificDays []int `json:"specific_days,omitempty"`
SpecificDates []int `json:"specific_dates,omitempty"`
CarryOver bool `json:"carry_over"`
TargetValue *float64 `json:"target_value,omitempty"`
}
type HabitResponse struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Name string `json:"name"`
Description string `json:"description"`
Type value_objects.HabitType `json:"type"`
Frequency value_objects.Frequency `json:"frequency"`
SpecificDays []int `json:"specific_days,omitempty"`
SpecificDates []int `json:"specific_dates,omitempty"`
CarryOver bool `json:"carry_over"`
IsNegative bool `json:"is_negative"`
TargetValue *float64 `json:"target_value,omitempty"`
CreatedAt time.Time `json:"created_at"`
ArchivedAt *time.Time `json:"archived_at,omitempty"`
}
type MarkHabitRequest struct {
ScheduledDate string `json:"scheduled_date"`
Value *float64 `json:"value,omitempty"`
}
type TodaysHabitEntryResponse struct {
ID string `json:"id"`
Value *float64 `json:"value,omitempty"`
CompletedAt time.Time `json:"completed_at"`
}
type TodaysHabitResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Type value_objects.HabitType `json:"type"`
TargetValue *float64 `json:"target_value,omitempty"`
IsNegative bool `json:"is_negative"`
ScheduledDate time.Time `json:"scheduled_date"`
IsCarriedOver bool `json:"is_carried_over"`
Entry *TodaysHabitEntryResponse `json:"entry,omitempty"`
}
type UserHabitResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Type value_objects.HabitType `json:"type"`
Frequency value_objects.Frequency `json:"frequency"`
SpecificDays []int `json:"specific_days,omitempty"`
TargetValue *float64 `json:"target_value,omitempty"`
CarryOver bool `json:"carry_over"`
IsNegative bool `json:"is_negative"`
}
type HabitEntryResponse struct {
ID string `json:"id"`
HabitID string `json:"habit_id"`
ScheduledDate time.Time `json:"scheduled_date"`
CompletedAt time.Time `json:"completed_at"`
Value *float64 `json:"value,omitempty"`
}
type HabitEntriesResponse struct {
Entries []HabitEntryResponse `json:"entries"`
Total int `json:"total"`
Page int `json:"page"`
Limit int `json:"limit"`
}
type ErrorResponse struct {
Error string `json:"error"`
}
type ValidationErrorResponse struct {
Error string `json:"error"`
Field string `json:"field"`
}