Release 5 december 2022 - Agenda and Fleets fixes
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
|
||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
||||
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
||||
"git.coopgo.io/coopgo-platform/fleets/storage"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -21,3 +26,29 @@ func NewFleetsService(dial string) (*FleetsService, error) {
|
||||
FleetsClient: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *ServicesHandler) GetBooking(bookingid string) (booking storage.Booking, err error) {
|
||||
request := &fleets.GetBookingRequest{
|
||||
Bookingid: bookingid,
|
||||
}
|
||||
resp, err := s.GRPC.Fleets.GetBooking(context.TODO(), request)
|
||||
if err == nil {
|
||||
booking = resp.Booking.ToStorageType()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *ServicesHandler) GetBookings() (bookings []storage.Booking, err error) {
|
||||
bookings = []storage.Booking{}
|
||||
|
||||
request := &fleets.GetBookingsRequest{}
|
||||
resp, err := s.GRPC.Fleets.GetBookings(context.TODO(), request)
|
||||
if err == nil {
|
||||
for _, booking := range resp.Bookings {
|
||||
bookings = append(bookings, booking.ToStorageType())
|
||||
}
|
||||
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||
"git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -21,3 +24,37 @@ func NewMobilityAccountService(mobilityAccountsDial string) (*MobilityAccountSer
|
||||
MobilityAccountsClient: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *ServicesHandler) GetBeneficiaries() (accounts []storage.Account, err error) {
|
||||
accounts = []storage.Account{}
|
||||
request := &mobilityaccounts.GetAccountsRequest{
|
||||
Namespaces: []string{"parcoursmob_beneficiaries"},
|
||||
}
|
||||
resp, err := s.GRPC.MobilityAccounts.GetAccounts(context.TODO(), request)
|
||||
|
||||
if err == nil {
|
||||
for _, v := range resp.Accounts {
|
||||
a := v.ToStorageType()
|
||||
accounts = append(accounts, a)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *ServicesHandler) GetAccounts() (accounts []storage.Account, err error) {
|
||||
accounts = []storage.Account{}
|
||||
request := &mobilityaccounts.GetAccountsRequest{
|
||||
Namespaces: []string{"parcoursmob"},
|
||||
}
|
||||
resp, err := s.GRPC.MobilityAccounts.GetAccounts(context.TODO(), request)
|
||||
|
||||
if err == nil {
|
||||
for _, v := range resp.Accounts {
|
||||
a := v.ToStorageType()
|
||||
accounts = append(accounts, a)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user