Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/convert/convertv2/gnssposition.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/way-platform/rfms-go/internal/openapi/rfmsv2oapi"
rfmsv5 "github.com/way-platform/rfms-go/proto/gen/go/wayplatform/connect/rfms/v5"
"google.golang.org/protobuf/types/known/timestamppb"
)

func gnssPosition(input *rfmsv2oapi.GNSSPositionType) *rfmsv5.GnssPosition {
Expand All @@ -25,7 +26,7 @@ func gnssPosition(input *rfmsv2oapi.GNSSPositionType) *rfmsv5.GnssPosition {
output.SetSpeedKmh(*input.Speed)
}
if input.PositionDateTime != nil {
output.SetTime(time.Time(*input.PositionDateTime).UTC().Format(time.RFC3339Nano))
output.SetTime(timestamppb.New(time.Time(*input.PositionDateTime).UTC()))
}
return &output
}
5 changes: 3 additions & 2 deletions internal/convert/convertv2/vehicleposition.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/way-platform/rfms-go/internal/openapi/rfmsv2oapi"
rfmsv5 "github.com/way-platform/rfms-go/proto/gen/go/wayplatform/connect/rfms/v5"
"google.golang.org/protobuf/types/known/timestamppb"
)

// VehiclePosition converts an rFMS v2 vehicle position to proto.
Expand All @@ -17,10 +18,10 @@ func VehiclePosition(input *rfmsv2oapi.VehiclePositionType) *rfmsv5.VehiclePosit
output.SetTrigger(trigger(input.TriggerType))
}
if input.CreatedDateTime != nil {
output.SetCreateTime(time.Time(*input.CreatedDateTime).UTC().Format(time.RFC3339Nano))
output.SetCreateTime(timestamppb.New(time.Time(*input.CreatedDateTime).UTC()))
}
if input.ReceivedDateTime != nil {
output.SetReceiveTime(time.Time(*input.ReceivedDateTime).UTC().Format(time.RFC3339Nano))
output.SetReceiveTime(timestamppb.New(time.Time(*input.ReceivedDateTime).UTC()))
}
if input.GNSSPosition != nil {
output.SetGnssPosition(gnssPosition(input.GNSSPosition))
Expand Down
5 changes: 3 additions & 2 deletions internal/convert/convertv2/vehiclestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/way-platform/rfms-go/internal/convert"
"github.com/way-platform/rfms-go/internal/openapi/rfmsv2oapi"
rfmsv5 "github.com/way-platform/rfms-go/proto/gen/go/wayplatform/connect/rfms/v5"
"google.golang.org/protobuf/types/known/timestamppb"
)

// VehicleStatus converts an rFMS v2 vehicle status to proto.
Expand All @@ -18,10 +19,10 @@ func VehicleStatus(input *rfmsv2oapi.VehicleStatusType) *rfmsv5.VehicleStatus {
output.SetTrigger(trigger(input.TriggerType))
}
if input.CreatedDateTime != nil {
output.SetCreateTime(time.Time(*input.CreatedDateTime).UTC().Format(time.RFC3339Nano))
output.SetCreateTime(timestamppb.New(time.Time(*input.CreatedDateTime).UTC()))
}
if input.ReceivedDateTime != nil {
output.SetReceiveTime(time.Time(*input.ReceivedDateTime).UTC().Format(time.RFC3339Nano))
output.SetReceiveTime(timestamppb.New(time.Time(*input.ReceivedDateTime).UTC()))
}
if input.HRTotalVehicleDistance != nil {
output.SetHrTotalVehicleDistanceM(float64(*input.HRTotalVehicleDistance))
Expand Down
3 changes: 2 additions & 1 deletion internal/convert/convertv4/gnssposition.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/way-platform/rfms-go/internal/openapi/rfmsv4oapi"
rfmsv5 "github.com/way-platform/rfms-go/proto/gen/go/wayplatform/connect/rfms/v5"
"google.golang.org/protobuf/types/known/timestamppb"
)

// gnssPosition converts an rFMS v4 GNSS position to proto.
Expand All @@ -26,7 +27,7 @@ func gnssPosition(input *rfmsv4oapi.GNSSPositionObject) *rfmsv5.GnssPosition {
output.SetSpeedKmh(*input.Speed)
}
if input.PositionDateTime != nil {
output.SetTime(time.Time(*input.PositionDateTime).UTC().Format(time.RFC3339Nano))
output.SetTime(timestamppb.New(time.Time(*input.PositionDateTime).UTC()))
}
return &output
}
5 changes: 4 additions & 1 deletion internal/convert/convertv4/snapshotdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/way-platform/rfms-go/internal/convert"
rfmsv4oapi "github.com/way-platform/rfms-go/internal/openapi/rfmsv4oapi"
rfmsv5 "github.com/way-platform/rfms-go/proto/gen/go/wayplatform/connect/rfms/v5"
"google.golang.org/protobuf/types/known/timestamppb"
)

// snapshotData converts an rFMS v4 snapshot data to proto.
Expand Down Expand Up @@ -90,7 +91,9 @@ func snapshotData(input *rfmsv4oapi.SnapshotDataObject) *rfmsv5.SnapshotData {
output.SetBatteryPackChargingPowerW(*input.BatteryPackChargingPower)
}
if input.EstimatedTimeBatteryPackChargingCompleted != nil {
output.SetBatteryPackEstimatedChargingCompletedTime(time.Time(*input.EstimatedTimeBatteryPackChargingCompleted).UTC().Format(time.RFC3339Nano))
output.SetBatteryPackEstimatedChargingCompletedTime(
timestamppb.New(time.Time(*input.EstimatedTimeBatteryPackChargingCompleted).UTC()),
)
}
if input.EstimatedDistanceToEmpty != nil {
output.SetEstimatedDistanceToEmpty(&rfmsv5.SnapshotData_EstimatedDistanceToEmpty{})
Expand Down
5 changes: 3 additions & 2 deletions internal/convert/convertv4/vehicleposition.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/way-platform/rfms-go/internal/openapi/rfmsv4oapi"
rfmsv5 "github.com/way-platform/rfms-go/proto/gen/go/wayplatform/connect/rfms/v5"
"google.golang.org/protobuf/types/known/timestamppb"
)

// VehiclePosition converts an rFMS v4 vehicle position to proto.
Expand All @@ -17,10 +18,10 @@ func VehiclePosition(input *rfmsv4oapi.VehiclePositionObject) *rfmsv5.VehiclePos
output.SetTrigger(trigger(input.TriggerType))
}
if input.CreatedDateTime != nil {
output.SetCreateTime(time.Time(*input.CreatedDateTime).UTC().Format(time.RFC3339Nano))
output.SetCreateTime(timestamppb.New(time.Time(*input.CreatedDateTime).UTC()))
}
if input.ReceivedDateTime != nil {
output.SetReceiveTime(time.Time(*input.ReceivedDateTime).UTC().Format(time.RFC3339Nano))
output.SetReceiveTime(timestamppb.New(time.Time(*input.ReceivedDateTime).UTC()))
}
if input.GNSSPosition != nil {
output.SetGnssPosition(gnssPosition(input.GNSSPosition))
Expand Down
5 changes: 3 additions & 2 deletions internal/convert/convertv4/vehiclestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/way-platform/rfms-go/internal/convert"
"github.com/way-platform/rfms-go/internal/openapi/rfmsv4oapi"
rfmsv5 "github.com/way-platform/rfms-go/proto/gen/go/wayplatform/connect/rfms/v5"
"google.golang.org/protobuf/types/known/timestamppb"
)

// VehicleStatus converts an rFMS v4 vehicle status to proto.
Expand All @@ -18,10 +19,10 @@ func VehicleStatus(input *rfmsv4oapi.VehicleStatusObject) *rfmsv5.VehicleStatus
output.SetTrigger(trigger(input.TriggerType))
}
if input.CreatedDateTime != nil {
output.SetCreateTime(time.Time(*input.CreatedDateTime).UTC().Format(time.RFC3339Nano))
output.SetCreateTime(timestamppb.New(time.Time(*input.CreatedDateTime).UTC()))
}
if input.ReceivedDateTime != nil {
output.SetReceiveTime(time.Time(*input.ReceivedDateTime).UTC().Format(time.RFC3339Nano))
output.SetReceiveTime(timestamppb.New(time.Time(*input.ReceivedDateTime).UTC()))
}
if input.HrTotalVehicleDistance != nil {
output.SetHrTotalVehicleDistanceM(float64(*input.HrTotalVehicleDistance))
Expand Down
11 changes: 0 additions & 11 deletions proto/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ clean: true

managed:
enabled: true
disable:
- module: buf.build/googlecloudplatform/bq-schema-api
override:
- file_option: go_package_prefix
value: github.com/way-platform/rfms-go/proto/gen/go
Expand All @@ -19,12 +17,3 @@ plugins:
opt:
- module=github.com/way-platform/rfms-go/proto/gen/go
- default_api_level=API_OPAQUE

- remote: buf.build/googlecloudplatform/bq-schema:v3.1.0
out: gen/bq
opt:
- module=github.com/way-platform/rfms-go/proto/gen/bq
- single-message

- remote: buf.build/bufbuild/protoschema-pubsub:v0.5.1
out: gen/pubsub
Loading