core/internal/port/internal/apimodel/village.go

39 lines
784 B
Go

package apimodel
import (
"gitea.dwysokinski.me/twhelp/corev3/internal/domain"
)
func NewVillage(v domain.Village) Village {
return Village{
Bonus: v.Bonus(),
Continent: v.Continent(),
CreatedAt: v.CreatedAt(),
FullName: v.FullName(),
Id: v.ID(),
Name: v.Name(),
Points: v.Points(),
ProfileUrl: v.ProfileURL().String(),
X: v.X(),
Y: v.Y(),
}
}
func NewListVillagesResponse(res domain.ListVillagesResult) ListVillagesResponse {
versions := res.Villages()
resp := ListVillagesResponse{
Data: make([]Village, 0, len(versions)),
Cursor: Cursor{
Next: res.Next().Encode(),
Self: res.Self().Encode(),
},
}
for _, v := range versions {
resp.Data = append(resp.Data, NewVillage(v))
}
return resp
}