Upstream sync
This commit is contained in:
@@ -48,3 +48,13 @@ func (s *providerService) Get(query string, lat float64, long float64, distance
|
|||||||
}
|
}
|
||||||
return s.mapEntity.Provider.ToProviderRespModelSlice(providers), nil
|
return s.mapEntity.Provider.ToProviderRespModelSlice(providers), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *providerService) GetByUUID(providerUUID string, user viewmodel.User) (viewmodel.ProviderResp, error) {
|
||||||
|
eUser := s.mapEntity.User.ToUserEntity(user)
|
||||||
|
provider, err := s.svc.Provider.GetByUUID(providerUUID, eUser)
|
||||||
|
if err != nil {
|
||||||
|
return viewmodel.ProviderResp{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.mapEntity.Provider.ToProviderRespModel(provider), nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ func (s bxeService) CheckEligibility(eligibility viewmodel.Eligibility) (bcbsimo
|
|||||||
fmt.Println("Error WebService getting object: ", err)
|
fmt.Println("Error WebService getting object: ", err)
|
||||||
return bcbsimodel.MemberEligibilityResponse{}, err
|
return bcbsimodel.MemberEligibilityResponse{}, err
|
||||||
}
|
}
|
||||||
|
fmt.Println("Result: ", result.Body.MemberEligibilityResponse)
|
||||||
|
|
||||||
return result.Body.MemberEligibilityResponse, nil
|
return result.Body.MemberEligibilityResponse, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type User struct {
|
|||||||
BirthDate *time.Time `json:"birthdate,omitempty"`
|
BirthDate *time.Time `json:"birthdate,omitempty"`
|
||||||
Email *string `json:"email,omitempty"`
|
Email *string `json:"email,omitempty"`
|
||||||
PhoneNumber *string `json:"phonenumber,omitempty"`
|
PhoneNumber *string `json:"phonenumber,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
Pass string `json:"pass,omitempty"`
|
Pass string `json:"pass,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
Active bool `json:"active,omitempty"`
|
||||||
Created time.Time `json:"created,omitempty"`
|
Created time.Time `json:"created,omitempty"`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ pipelines:
|
|||||||
master:
|
master:
|
||||||
- step:
|
- step:
|
||||||
script:
|
script:
|
||||||
- curl https://glide.sh/get | sh
|
- curl https://glide.sh/get -L -o - | sh
|
||||||
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
||||||
- pwd
|
- pwd
|
||||||
- ls -al
|
- ls -al
|
||||||
@@ -33,7 +33,7 @@ pipelines:
|
|||||||
development:
|
development:
|
||||||
- step:
|
- step:
|
||||||
script:
|
script:
|
||||||
- curl https://glide.sh/get | sh
|
- curl https://glide.sh/get -L -o - | sh
|
||||||
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
- mkdir -p /go/src/bitbucket.org/nemt/nemt-portal-api
|
||||||
- pwd
|
- pwd
|
||||||
- ls -al
|
- ls -al
|
||||||
|
|||||||
@@ -131,6 +131,20 @@ func (c *providerRepo) GetAll(user entity.User) ([]entity.Provider, error) {
|
|||||||
return c.getKeys("", "", providers)
|
return c.getKeys("", "", providers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *providerRepo) GetByUUID(providerUUID string, user entity.User) (entity.Provider, error) {
|
||||||
|
lat := 41.886406
|
||||||
|
long := -87.624225
|
||||||
|
|
||||||
|
query, where, err := c.getProfileQuery(user)
|
||||||
|
if err != nil {
|
||||||
|
return entity.Provider{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query = c.getSelectQueryBase() + query + " WHERE a.provider_uuid = ? " + where
|
||||||
|
|
||||||
|
return c.parseEntity(c.conn.QueryRow(query, lat, long, lat, providerUUID))
|
||||||
|
}
|
||||||
|
|
||||||
func (c *providerRepo) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
|
func (c *providerRepo) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
|
||||||
lat := 41.886406
|
lat := 41.886406
|
||||||
long := -87.624225
|
long := -87.624225
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ type ProviderRepo interface {
|
|||||||
GetAll(user entity.User) ([]entity.Provider, error)
|
GetAll(user entity.User) ([]entity.Provider, error)
|
||||||
Get(query string, lat float64, long float64, distance int64, planCode string, productID string, mukID string, internalID string, sort string, user entity.User) ([]entity.Provider, error)
|
Get(query string, lat float64, long float64, distance int64, planCode string, productID string, mukID string, internalID string, sort string, user entity.User) ([]entity.Provider, error)
|
||||||
GetByMukID(mukID string, user entity.User) (entity.Provider, error)
|
GetByMukID(mukID string, user entity.User) (entity.Provider, error)
|
||||||
|
GetByUUID(providerUUID string, user entity.User) (entity.Provider, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotificationRepo defines the data set for Notification
|
// NotificationRepo defines the data set for Notification
|
||||||
|
|||||||
@@ -44,3 +44,7 @@ func (s *providerService) Get(query string, lat float64, long float64, distance
|
|||||||
func (s *providerService) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
|
func (s *providerService) GetByMukID(mukID string, user entity.User) (entity.Provider, error) {
|
||||||
return s.svc.db.Provider().GetByMukID(mukID, user)
|
return s.svc.db.Provider().GetByMukID(mukID, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *providerService) GetByUUID(providerUUID string, user entity.User) (entity.Provider, error) {
|
||||||
|
return s.svc.db.Provider().GetByUUID(providerUUID, user)
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/placesroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/placesroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/profileroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/profileroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/providerroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/providerroute"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/server/router/selfregisterroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/tncroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/tncroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/twilioroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/twilioroute"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/usersroute"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/usersroute"
|
||||||
@@ -37,6 +38,7 @@ func Register(e *echo.Echo, cfg *config.Config, svc *applicationservice.Service,
|
|||||||
lyfthookroute.Register(prefixGroup.Group("/lyfthook"), cfg, svc, tnc, notification)
|
lyfthookroute.Register(prefixGroup.Group("/lyfthook"), cfg, svc, tnc, notification)
|
||||||
externalroute.Register(prefixGroup.Group("/ext"), cfg, svc, tnc, notification)
|
externalroute.Register(prefixGroup.Group("/ext"), cfg, svc, tnc, notification)
|
||||||
authenticateroute.Register(prefixGroup.Group("/authenticate"), cfg, svc)
|
authenticateroute.Register(prefixGroup.Group("/authenticate"), cfg, svc)
|
||||||
|
selfregisterroute.Register(prefixGroup.Group("/selfregister"), cfg, svc)
|
||||||
|
|
||||||
appGroup := prefixGroup.Group("/" + cfg.App.Name)
|
appGroup := prefixGroup.Group("/" + cfg.App.Name)
|
||||||
usersroute.Register(appGroup.Group("/users"), cfg, svc)
|
usersroute.Register(appGroup.Group("/users"), cfg, svc)
|
||||||
@@ -47,4 +49,5 @@ func Register(e *echo.Echo, cfg *config.Config, svc *applicationservice.Service,
|
|||||||
placesroute.Register(appGroup.Group("/places"), cfg, svc)
|
placesroute.Register(appGroup.Group("/places"), cfg, svc)
|
||||||
profileroute.Register(appGroup.Group("/profile"), cfg, svc)
|
profileroute.Register(appGroup.Group("/profile"), cfg, svc)
|
||||||
organizationroute.Register(appGroup.Group("/organization"), cfg, svc)
|
organizationroute.Register(appGroup.Group("/organization"), cfg, svc)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
38
server/router/selfregisterroute/controller.go
Normal file
38
server/router/selfregisterroute/controller.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package selfregisterroute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/third/eligibility/bcbsi"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
||||||
|
"github.com/labstack/echo"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
instance *controller
|
||||||
|
once sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
type controller struct {
|
||||||
|
svc *applicationservice.Service
|
||||||
|
cfg *config.Config
|
||||||
|
bcbsi *bcbsi.Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *controller {
|
||||||
|
once.Do(func() {
|
||||||
|
instance = &controller{
|
||||||
|
svc: svc,
|
||||||
|
cfg: cfg,
|
||||||
|
bcbsi: bcbsi.New(cfg),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return instance
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *controller) handle(ctx echo.Context) error {
|
||||||
|
|
||||||
|
return routeutils.ResponseAPIOK(ctx, "OK")
|
||||||
|
}
|
||||||
18
server/router/selfregisterroute/router.go
Normal file
18
server/router/selfregisterroute/router.go
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package selfregisterroute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||||
|
"github.com/labstack/echo"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
rootRoute = "/"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Register registers the routes in the echo group
|
||||||
|
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service) {
|
||||||
|
ctrl := controllerInstance(svc, cfg)
|
||||||
|
|
||||||
|
r.POST(rootRoute, ctrl.handle)
|
||||||
|
}
|
||||||
@@ -228,9 +228,6 @@ func (c *controller) handle(ctx echo.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
if user.ID == "" {
|
|
||||||
return routeutils.ResponseAPIValidationError(ctx, "User not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//Validate ride request
|
//Validate ride request
|
||||||
if validationErrors := validation.ValidateRide(&requestRide, &user) ; len(validationErrors) > 0 {
|
if validationErrors := validation.ValidateRide(&requestRide, &user) ; len(validationErrors) > 0 {
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
package visitroute
|
package visitroute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
"bitbucket.org/nemt/nemt-portal-api/application/applicationservice"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/third/eligibility/bcbsi"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/auth"
|
"bitbucket.org/nemt/nemt-portal-api/infra/auth"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/server/validation"
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,20 +21,66 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type controller struct {
|
type controller struct {
|
||||||
svc *applicationservice.Service
|
svc *applicationservice.Service
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
|
bcbsi *bcbsi.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *controller {
|
func controllerInstance(svc *applicationservice.Service, cfg *config.Config) *controller {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
instance = &controller{
|
instance = &controller{
|
||||||
svc: svc,
|
svc: svc,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
|
bcbsi: bcbsi.New(cfg),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *controller) handle(ctx echo.Context) error {
|
||||||
|
var visit viewmodel.Visit
|
||||||
|
if err := ctx.Bind(&visit); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "invalid parameters")
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := auth.GetUserDetail(ctx, c.cfg)
|
||||||
|
if err != nil {
|
||||||
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, err := c.svc.Provider.GetByUUID(visit.Provider.ProviderUUID, user)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, "invalid provider")
|
||||||
|
}
|
||||||
|
|
||||||
|
if validationErrors := validation.ValidateVisit(&visit, &user); len(validationErrors) > 0 {
|
||||||
|
return routeutils.ResponseAPICustomValidationError(ctx, "visit validation failed", validationErrors)
|
||||||
|
}
|
||||||
|
|
||||||
|
eligibility := viewmodel.Eligibility{}
|
||||||
|
eligibility.Provider.ProviderNPI = provider.InternalID
|
||||||
|
eligibility.Provider.ProviderName = provider.Name
|
||||||
|
eligibility.TrackingID = *visit.User.Member
|
||||||
|
eligibility.Subscriber.SubscriberID = *visit.User.Member
|
||||||
|
eligibility.Subscriber.PatientType = *visit.User.Type
|
||||||
|
eligibility.Subscriber.Name.First = visit.User.First
|
||||||
|
eligibility.Subscriber.Name.Last = visit.User.Last
|
||||||
|
eligibility.Subscriber.DemographicInfo.DateOfBirth = *visit.User.BirthDate
|
||||||
|
eligibility.Subscriber.DemographicInfo.Gender = *visit.User.Gender
|
||||||
|
eligibility.ServiceInfo.DateOfService = time.Now()
|
||||||
|
eligibility.ServiceInfo.ServiceTypeCodes = []string{"30"}
|
||||||
|
|
||||||
|
resp, err := c.bcbsi.BXE.Get271(eligibility)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return routeutils.ResponseAPIValidationError(ctx, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return routeutils.ResponseAPIOK(ctx, resp)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *controller) handleGetByID(ctx echo.Context) error {
|
func (c *controller) handleGetByID(ctx echo.Context) error {
|
||||||
visit_uuid := ctx.Param("visit_uuid")
|
visit_uuid := ctx.Param("visit_uuid")
|
||||||
if visit_uuid == "" {
|
if visit_uuid == "" {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ const (
|
|||||||
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service) {
|
func Register(r *echo.Group, cfg *config.Config, svc *applicationservice.Service) {
|
||||||
ctrl := controllerInstance(svc, cfg)
|
ctrl := controllerInstance(svc, cfg)
|
||||||
|
|
||||||
|
r.POST(rootRoute, ctrl.handle)
|
||||||
|
|
||||||
r.GET(rootRoute, ctrl.handleGetAll)
|
r.GET(rootRoute, ctrl.handleGetAll)
|
||||||
r.GET(idRoute, ctrl.handleGetByID)
|
r.GET(idRoute, ctrl.handleGetByID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
@@ -12,11 +13,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
tripTypeFromVisit = "From Visit"
|
tripTypeFromVisit = "from_visit"
|
||||||
tripTypeToVisit = "To Visit"
|
tripTypeToVisit = "to_visit"
|
||||||
tripTypeFromVisitWillCall = "From Visit / Will Call"
|
tripTypeFromVisitWillCall = "from_visit_call"
|
||||||
tripTypeRoundTrip = "Round Trip"
|
tripTypeRoundTrip = "roundtrip"
|
||||||
tripTypeRountTripWillCall = "Round Trip / Will Call"
|
tripTypeRountTripWillCall = "roundtrip_call"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -34,14 +35,15 @@ const (
|
|||||||
|
|
||||||
func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []errors.ValidationError {
|
func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []errors.ValidationError {
|
||||||
var result []errors.ValidationError
|
var result []errors.ValidationError
|
||||||
|
var validUUIDregex = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)
|
||||||
|
|
||||||
//Step #1 validation
|
//Step #1 validation
|
||||||
|
|
||||||
if userID, err := strconv.Atoi(user.ID) ; err != nil || userID <= 0 {
|
if !validUUIDregex.MatchString(user.ID){
|
||||||
result = append(result, errors.ValidationError{Field : "user_uuid", Message : "Step #1 - Choose a Member" })
|
result = append(result, errors.ValidationError{Field : "user_uuid", Message : "Step #1 - Choose a Member" })
|
||||||
}
|
}
|
||||||
|
|
||||||
if originID, err := strconv.Atoi(requestRide.Origin.ID) ; err != nil || originID <= 0 {
|
if !validUUIDregex.MatchString(requestRide.Origin.ID) {
|
||||||
result = append (result, errors.ValidationError{Field : "origin.id", Message : "Step #1 - Choose a Pickup Address"})
|
result = append (result, errors.ValidationError{Field : "origin.id", Message : "Step #1 - Choose a Pickup Address"})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,14 +86,14 @@ func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []er
|
|||||||
|
|
||||||
//Step #4 validation
|
//Step #4 validation
|
||||||
|
|
||||||
if requestRide.TripType.Value == "" {
|
|
||||||
result = append (result, errors.ValidationError{Field : "trip_type.value", Message : "Step #4 - Choose a Trip Type"})
|
|
||||||
}
|
|
||||||
|
|
||||||
timeWithDurationAndLoadingTime := requestRide.VisitTime.Add(-time.Duration(requestRide.Duration)*time.Second).Add(-loadingTime*time.Minute)
|
timeWithDurationAndLoadingTime := requestRide.VisitTime.Add(-time.Duration(requestRide.Duration)*time.Second).Add(-loadingTime*time.Minute)
|
||||||
after10Minutes := time.Now().Add(time.Minute*time10Minutes)
|
after10Minutes := time.Now().Add(time.Minute*time10Minutes)
|
||||||
|
|
||||||
switch requestRide.TripType.Value {
|
isTripTypeValid := true
|
||||||
|
|
||||||
|
fmt.Println("\n\n",requestRide.PickupTime,"\n\n")
|
||||||
|
|
||||||
|
switch requestRide.TripType.Key {
|
||||||
case tripTypeToVisit:
|
case tripTypeToVisit:
|
||||||
if requestRide.PickupTime == nil {
|
if requestRide.PickupTime == nil {
|
||||||
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Choose a Pickup Time"})
|
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Choose a Pickup Time"})
|
||||||
@@ -178,6 +180,15 @@ func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []er
|
|||||||
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Visit cannot occur in the past "})
|
result = append (result, errors.ValidationError{Field : "pickup_time", Message : "Step #4 - Visit cannot occur in the past "})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
isTripTypeValid = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !isTripTypeValid {
|
||||||
|
result = append (result, errors.ValidationError{Field : "trip_type.key", Message : "Step #4 - Choose a Trip Type"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
package validation
|
package validation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func characterIsUpperCase(character rune) bool {
|
func characterIsUpperCase(character rune) bool {
|
||||||
@@ -25,29 +23,29 @@ func ValidatePassword(user *viewmodel.User) []errors.ValidationError {
|
|||||||
var result []errors.ValidationError
|
var result []errors.ValidationError
|
||||||
|
|
||||||
userOrganizationName := ""
|
userOrganizationName := ""
|
||||||
if len(user.Organizations) > 0{
|
if len(user.Organizations) > 0 {
|
||||||
userOrganizationName = user.Organizations[0].Name
|
userOrganizationName = user.Organizations[0].Name
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len(user.Pass) < 8) {
|
if len(user.Pass) < 8 {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password must be at least 8 characters."})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password must be at least 8 characters."})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings.Contains(user.Pass, user.First)){
|
if strings.Contains(user.Pass, user.First) {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password cannot include your First Name."})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password cannot include your First Name."})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings.Contains(user.Pass, user.Last)){
|
if strings.Contains(user.Pass, user.Last) {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password cannot include your Last Name."})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password cannot include your Last Name."})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings.Contains(user.Pass, userOrganizationName)){
|
if strings.Contains(user.Pass, userOrganizationName) {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password cannot include your Organization Name."})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password cannot include your Organization Name."})
|
||||||
}
|
}
|
||||||
|
|
||||||
containsUpperCaseLetter := false;
|
containsUpperCaseLetter := false
|
||||||
containsLowerCaseLetter := false;
|
containsLowerCaseLetter := false
|
||||||
containsNumber := false;
|
containsNumber := false
|
||||||
|
|
||||||
for _, character := range user.Pass {
|
for _, character := range user.Pass {
|
||||||
containsUpperCaseLetter = containsUpperCaseLetter || characterIsUpperCase(character)
|
containsUpperCaseLetter = containsUpperCaseLetter || characterIsUpperCase(character)
|
||||||
@@ -56,12 +54,11 @@ func ValidatePassword(user *viewmodel.User) []errors.ValidationError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !containsUpperCaseLetter || !containsLowerCaseLetter || !containsNumber {
|
if !containsUpperCaseLetter || !containsLowerCaseLetter || !containsNumber {
|
||||||
result = append(result, errors.ValidationError{Field : "password", Message : "Password must contain one of EACH :"})
|
result = append(result, errors.ValidationError{Field: "password", Message: "Password must contain one of EACH :"})
|
||||||
result = append(result, errors.ValidationError{Field : "password-tab", Message : "an uppercase letter"})
|
result = append(result, errors.ValidationError{Field: "password-tab", Message: "an uppercase letter"})
|
||||||
result = append(result, errors.ValidationError{Field : "password-tab", Message : "a lowercase letter"})
|
result = append(result, errors.ValidationError{Field: "password-tab", Message: "a lowercase letter"})
|
||||||
result = append(result, errors.ValidationError{Field : "password-tab", Message : "a number"})
|
result = append(result, errors.ValidationError{Field: "password-tab", Message: "a number"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
36
server/validation/visit.go
Normal file
36
server/validation/visit.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package validation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/infra/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ValidateVisit(visit *viewmodel.Visit, user *viewmodel.User) []errors.ValidationError {
|
||||||
|
var result []errors.ValidationError
|
||||||
|
|
||||||
|
if len(visit.User.First) == 0 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "first", Message: "Step #1 - First Name is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(visit.User.Last) == 0 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "last", Message: "Step #1 - Last Name is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.Gender == nil || (*visit.User.Gender != "M" && *visit.User.Gender != "F" && *visit.User.Gender != "U") {
|
||||||
|
result = append(result, errors.ValidationError{Field: "gender", Message: "Step #1 - Gender is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.Type == nil || (*visit.User.Type != "S" && *visit.User.Gender != "D" && *visit.User.Gender != "U") {
|
||||||
|
result = append(result, errors.ValidationError{Field: "type", Message: "Step #1 - Member Type is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.Member == nil || len(*visit.User.Member) == 0 {
|
||||||
|
result = append(result, errors.ValidationError{Field: "member", Message: "Step #1 - Member # is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if visit.User.BirthDate == nil || visit.User.BirthDate.IsZero() {
|
||||||
|
result = append(result, errors.ValidationError{Field: "birthdate", Message: "Step #1 - Birth Date is mandatory"})
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user