Skip to content

Commit

Permalink
add extra metadata info to grpc resp
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesReate committed Aug 10, 2023
1 parent 0b005f0 commit a8ee36f
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 188 deletions.
11 changes: 10 additions & 1 deletion internal/rpc/user_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ func (s *userDeviceService) deviceModelToAPI(ud *models.UserDevice) *pb.UserDevi
out.CountryCode = ud.CountryCode.String
}

// metadata properties
md := services.UserDeviceMetadata{}
if err := ud.Metadata.Unmarshal(&md); err != nil {
s.logger.Error().Msgf("Could not unmarshal userdevice metadata for device: %s", ud.ID)
Expand All @@ -494,10 +495,18 @@ func (s *userDeviceService) deviceModelToAPI(ud *models.UserDevice) *pb.UserDevi
if md.PowertrainType != nil {
out.PowerTrainType = md.PowertrainType.String()
}

if md.CANProtocol != nil {
out.CANProtocol = *md.CANProtocol
}
if md.PostalCode != nil {
out.PostalCode = *md.PostalCode
}
if md.GeoDecodedStateProv != nil {
out.GeoDecodedStateProv = *md.GeoDecodedStateProv
}
if md.GeoDecodedCountry != nil {
out.GeoDecodedCountry = *md.GeoDecodedCountry
}

return out
}
Expand Down
Loading

0 comments on commit a8ee36f

Please sign in to comment.