Upstream sync
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package applicationservice
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"bitbucket.org/nemt/nemt-portal-api/application/entitymapping"
|
||||
@@ -183,6 +184,7 @@ func (s *rideService) Save(ride viewmodel.RideRequest) (viewmodel.Ride, error) {
|
||||
address, _ := s.svc.Users.GetAddressByUUID(rideEntity.Route.Destination.ID)
|
||||
createdUser, err := s.svc.Users.GetByUUID(ride.CreateUserUUID, "")
|
||||
if err != nil {
|
||||
fmt.Println("Ride Application.Save: Error to get User: ", err.Error())
|
||||
return viewmodel.Ride{}, errors.Wrap(err)
|
||||
}
|
||||
|
||||
@@ -190,12 +192,14 @@ func (s *rideService) Save(ride viewmodel.RideRequest) (viewmodel.Ride, error) {
|
||||
visit.DestinationAddressID = address.ID
|
||||
provider, err := s.svc.Provider.GetByMukID(address.InternalID, createdUser)
|
||||
if err != nil {
|
||||
fmt.Println("Ride Application.Save: Error to get Provider: ", err.Error())
|
||||
return viewmodel.Ride{}, errors.Wrap(err)
|
||||
}
|
||||
visit.Provider = provider
|
||||
} else {
|
||||
provider, err := s.svc.Provider.GetByMukID(rideEntity.Route.Destination.ID, createdUser)
|
||||
if err != nil {
|
||||
fmt.Println("Ride Application.Save: Error to get Provider by Route: ", err.Error())
|
||||
return viewmodel.Ride{}, errors.Wrap(err)
|
||||
}
|
||||
visit.Provider = provider
|
||||
@@ -203,17 +207,20 @@ func (s *rideService) Save(ride viewmodel.RideRequest) (viewmodel.Ride, error) {
|
||||
|
||||
visit, err = s.svc.Visits.Create(visit)
|
||||
if err != nil {
|
||||
fmt.Println("Ride Application.Save: Error creating visit: ", err.Error())
|
||||
return viewmodel.Ride{}, errors.Wrap(err)
|
||||
}
|
||||
rideEntity.Visit = visit
|
||||
} else {
|
||||
user, err := s.svc.Users.GetByUUID(ride.CreateUserUUID, "")
|
||||
if err != nil {
|
||||
fmt.Println("Ride Application.Save: Error getting User: ", err.Error())
|
||||
return viewmodel.Ride{}, errors.Wrap(err)
|
||||
}
|
||||
|
||||
visit, err := s.svc.Visits.GetByUUID(ride.Visit.UUID, user)
|
||||
if err != nil {
|
||||
fmt.Println("Ride Application.Save: Error getting Visit: ", err.Error())
|
||||
return viewmodel.Ride{}, errors.Wrap(err)
|
||||
}
|
||||
rideEntity.Visit = visit
|
||||
@@ -221,6 +228,7 @@ func (s *rideService) Save(ride viewmodel.RideRequest) (viewmodel.Ride, error) {
|
||||
|
||||
retVal, err := s.svc.Rides.Save(rideEntity)
|
||||
if err != nil {
|
||||
fmt.Println("Ride Application.Save: Error saving ride: ", err.Error())
|
||||
return viewmodel.Ride{}, errors.Wrap(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ func (mapping *userMapping) ToUserModel(item entity.User) viewmodel.User {
|
||||
Profiles: mapping.mapper.Profile.ToProfileModelSlice(item.Profiles),
|
||||
Organizations: mapping.mapper.Organization.ToOrganizationModelSlice(item.Organizations),
|
||||
Types: mapping.mapper.Organization.ToOrganizationTypeModelSlice(item.Types),
|
||||
Type: &item.Type,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +80,12 @@ func (mapping *userMapping) ToUserEntity(item viewmodel.User) entity.User {
|
||||
Types: mapping.mapper.Organization.ToOrganizationTypeEntitySlice(item.Types),
|
||||
}
|
||||
|
||||
if item.Type == nil {
|
||||
user.Type = "S"
|
||||
} else {
|
||||
user.Type = *item.Type
|
||||
}
|
||||
|
||||
if user.Name == "" {
|
||||
user.Name = fmt.Sprintf("%s %s", item.First, item.Last)
|
||||
}
|
||||
|
||||
@@ -119,11 +119,14 @@ func (s bxeService) CheckEligibility(eligibility viewmodel.Eligibility) (bcbsimo
|
||||
req.Header.Add("X-Api-Key", apiKey)
|
||||
req.Header.Add("X-Signature", s.getSignature(apiKey, secretKey))
|
||||
|
||||
eligibilityCall := time.Now()
|
||||
fmt.Println(fmt.Sprintf("Start eligibility call %s at %s", eligibility.TrackingID, eligibilityCall.Format("2006-01-02 15:04:05 PM")))
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println("Error WebService Request: ", err)
|
||||
return bcbsimodel.MemberEligibilityResponse{}, err
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("Getting Response from eligibility call %s at %s, duration %f seconds", eligibility.TrackingID, time.Now().Format("2006-01-02 15:04:05 PM"), time.Since(eligibilityCall).Seconds()))
|
||||
defer resp.Body.Close()
|
||||
|
||||
bReturn, err := ioutil.ReadAll(resp.Body)
|
||||
|
||||
@@ -14,50 +14,53 @@ type WebhookResponse struct {
|
||||
|
||||
//RideRequest has the data to dispatch a ride
|
||||
type RideRequest struct {
|
||||
UserUUID string `json:"user_uuid,omitempty"`
|
||||
UserConsent bool `json:"user_consent,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
RideID string `json:"ride_id,omitempty"`
|
||||
RideType string `json:"ride_type,omitempty"`
|
||||
Origin Location `json:"origin,omitempty"`
|
||||
Location Location `json:"location,omitempty"`
|
||||
Destination Location `json:"destination,omitempty"`
|
||||
Passenger UserLyft `json:"passenger,omitempty"`
|
||||
Notes string `json:"external_note,omitempty"`
|
||||
RouteURL string `json:"route_url,omitempty"`
|
||||
ScheduledPickupRange interface{} `json:"scheduled_pickup_range,omitempty"`
|
||||
PrimetimePercentage string `json:"primetime_percentage,omitempty"`
|
||||
Pickup Location `json:"pickup,omitempty"`
|
||||
DropOff Location `json:"dropoff,omitempty"`
|
||||
Vehicle Vehicle `json:"vehicle,omitempty"`
|
||||
Price Price `json:"price,omitempty"`
|
||||
Driver UserLyft `json:"driver,omitempty"`
|
||||
GeneratedAtMS *int64 `json:"generated_at_ms,omitempty"`
|
||||
GeneratedAt *time.Time `json:"generated_at,omitempty"`
|
||||
RequestAtMS *int64 `json:"requested_at_ms,omitempty"`
|
||||
RequestAt *time.Time `json:"requested_at,omitempty"`
|
||||
LineItems []Price `json:"line_items,omitempty"`
|
||||
BeaconColor string `json:"beacon_color,omitempty"`
|
||||
Charges []Charge `json:"charges,omitempty"`
|
||||
VisitDate *time.Time `json:"visit_date,omitempty"`
|
||||
VisitTime *time.Time `json:"visit_time,omitempty"`
|
||||
PickupTime *time.Time `json:"pickup_time,omitempty"`
|
||||
ReturnTime *time.Time `json:"return_time,omitempty"`
|
||||
Distance float64 `json:"distance,omitempty"`
|
||||
ETA int64 `json:"eta,omitempty"`
|
||||
Duration int64 `json:"duration,omitempty"`
|
||||
Visit Visit `json:"visit,omitempty"`
|
||||
CreateUserUUID string `json:"created_user_uuid,omitempty"`
|
||||
VisitExternalID string `json:"visit_external_id,omitempty"`
|
||||
CanCancel []string `json:"can_cancel,omitempty"`
|
||||
PricingDetailsURL string `json:"pricing_details_url,omitempty"`
|
||||
RideProfile string `json:"ride_profile,omitempty"`
|
||||
DistanceInMiles float64 `json:"distance_miles,omitempty"`
|
||||
DurationInSeconds float64 `json:"duration_seconds,omitempty"`
|
||||
CanceledBy string `json:"canceled_by,omitempty"`
|
||||
TripType TripType `json:"trip_type,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorDescription string `json:"error_description,omitempty"`
|
||||
UserUUID string `json:"user_uuid,omitempty"`
|
||||
UserConsent bool `json:"user_consent,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
RideID string `json:"ride_id,omitempty"`
|
||||
RideType string `json:"ride_type,omitempty"`
|
||||
Origin Location `json:"origin,omitempty"`
|
||||
Location Location `json:"location,omitempty"`
|
||||
Destination Location `json:"destination,omitempty"`
|
||||
Passenger UserLyft `json:"passenger,omitempty"`
|
||||
Notes string `json:"external_note,omitempty"`
|
||||
RouteURL string `json:"route_url,omitempty"`
|
||||
ScheduledPickupRange interface{} `json:"scheduled_pickup_range,omitempty"`
|
||||
PrimetimePercentage string `json:"primetime_percentage,omitempty"`
|
||||
Pickup Location `json:"pickup,omitempty"`
|
||||
DropOff Location `json:"dropoff,omitempty"`
|
||||
Vehicle Vehicle `json:"vehicle,omitempty"`
|
||||
Price Price `json:"price,omitempty"`
|
||||
Driver UserLyft `json:"driver,omitempty"`
|
||||
GeneratedAtMS *int64 `json:"generated_at_ms,omitempty"`
|
||||
GeneratedAt *time.Time `json:"generated_at,omitempty"`
|
||||
RequestAtMS *int64 `json:"requested_at_ms,omitempty"`
|
||||
RequestAt *time.Time `json:"requested_at,omitempty"`
|
||||
LineItems []Price `json:"line_items,omitempty"`
|
||||
BeaconColor string `json:"beacon_color,omitempty"`
|
||||
Charges []Charge `json:"charges,omitempty"`
|
||||
VisitDate *time.Time `json:"visit_date,omitempty"`
|
||||
VisitTime *time.Time `json:"visit_time,omitempty"`
|
||||
PickupTime *time.Time `json:"pickup_time,omitempty"`
|
||||
ReturnTime *time.Time `json:"return_time,omitempty"`
|
||||
Distance float64 `json:"distance,omitempty"`
|
||||
ETA int64 `json:"eta,omitempty"`
|
||||
Duration int64 `json:"duration,omitempty"`
|
||||
Visit Visit `json:"visit,omitempty"`
|
||||
CreateUserUUID string `json:"created_user_uuid,omitempty"`
|
||||
VisitExternalID string `json:"visit_external_id,omitempty"`
|
||||
CanCancel []string `json:"can_cancel,omitempty"`
|
||||
PricingDetailsURL string `json:"pricing_details_url,omitempty"`
|
||||
RideProfile string `json:"ride_profile,omitempty"`
|
||||
DistanceInMiles float64 `json:"distance_miles,omitempty"`
|
||||
DurationInSeconds float64 `json:"duration_seconds,omitempty"`
|
||||
CanceledBy string `json:"canceled_by,omitempty"`
|
||||
TripType TripType `json:"trip_type,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorDescription string `json:"error_description,omitempty"`
|
||||
User User `json:"user,omitempty"`
|
||||
Provider ProviderResp `json:"provider,omitempty"`
|
||||
RawProvider ProviderResponse `json:"raw_provider,omitempty"`
|
||||
}
|
||||
|
||||
//Charge information
|
||||
@@ -159,4 +162,4 @@ type RideRoute struct {
|
||||
Duration int64 `json:"duration,omitempty"`
|
||||
ETA int64 `json:"eta,omitempty"`
|
||||
Bearing int64 `json:"bearing,omitempty"`
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user