update events

This commit is contained in:
andrusyakka
2023-08-01 16:48:54 +03:00
parent 46afe2e794
commit c55df47ada
5 changed files with 127 additions and 38 deletions

52
services/pd.go Normal file
View File

@@ -0,0 +1,52 @@
package services
import (
"astra-events/config"
"astra-events/model"
"astra-events/pkg/api"
"encoding/json"
"errors"
"github.com/google/uuid"
"net/http"
)
func GetPerson(id uuid.UUID, header http.Header) (*model.PersonalInformation, error) {
data, err, _ := api.GetRequest(
config.Env.MSHosts.PersonsHost+"/persons/"+id.String(),
header)
if err != nil {
return nil, errors.New("error Request to Personal Information Service")
}
pi := new(model.PersonalInformation)
err = json.Unmarshal(data, &pi)
if err != nil {
return nil, errors.New("bad Response from Personal Information Service")
}
return pi, nil
}
func CreatePerson(person model.PersonalInformationCreate, header http.Header) (*model.PersonalInformation, error) {
data, err := api.PostRequest(
config.Env.MSHosts.PersonsHost+"/persons/",
person,
header,
)
if err != nil {
return nil, errors.New("error Request to Personal Information Service")
}
pi := new(model.PersonalInformation)
err = json.Unmarshal(data, &pi)
if err != nil {
return nil, errors.New("bad Response from Personal Information Service")
}
return pi, nil
}