package dto

import "encoding/json"

//////////////////////////////////////////////////////////////
// Shared
//////////////////////////////////////////////////////////////

// PersonInput is one set of birth details. Dates are YYYY-MM-DD and times are
// HH:MM, matching the existing kundali endpoints; conversion to the Vedic
// DD/MM/YYYY format happens in the service.
type PersonInput struct {
	Name       string  `json:"name" binding:"required"`
	Gender     string  `json:"gender"`
	BirthDate  string  `json:"birth_date" binding:"required"`
	BirthTime  string  `json:"birth_time" binding:"required"`
	BirthPlace string  `json:"birth_place"`
	Latitude   float64 `json:"latitude" binding:"required"`
	Longitude  float64 `json:"longitude" binding:"required"`
	Timezone   float64 `json:"timezone"`
}

// VedicDataResponse passes the third-party payload through untouched. The Vedic
// schemas are wide and change between languages, so re-modelling every field
// would break the app on any upstream addition.
type VedicDataResponse struct {
	Charged float64         `json:"charged"`
	Data    json.RawMessage `json:"data"`
}

type PaginationRequest struct {
	Page   int    `json:"page"`
	Limit  int    `json:"limit"`
	Search string `json:"search"`
}

func (p PaginationRequest) Normalized() (int, int) {

	page := p.Page
	limit := p.Limit

	if page < 1 {
		page = 1
	}

	if limit < 1 {
		limit = 10
	}

	return page, limit
}
