package adminaddressservice

import (
	"context"

	param "git.gocasts.ir/ebhomengo/niki/param/admin/address"
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)

func (s Service) GetAddressByID(ctx context.Context, req param.AddressGetRequest) (param.AddressGetResponse, error) {
	const op = "adminaddressservice.Get"

	address, err := s.repo.GetAddressByID(ctx, req.AddressID)
	if err != nil {
		return param.AddressGetResponse{}, richerror.New(op).WithErr(err)
	}

	return param.AddressGetResponse{Data: param.Data{
		ID:           address.ID,
		PostalCode:   address.PostalCode,
		Address:      address.Address,
		Name:         address.Name,
		Lat:          address.Lat,
		Lon:          address.Lon,
		CityID:       address.CityID,
		ProvinceID:   address.ProvinceID,
		BenefactorID: address.BenefactorID,
	}}, nil
}
