Compare commits
1 Commits
send-email
...
self-regis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6065e4ded3 |
@@ -550,56 +550,6 @@ func (s *notificationService) ReadStatus(notificationUUID string, isRead bool) e
|
|||||||
return s.svc.Notification.ReadStatus(notificationUUID, isRead)
|
return s.svc.Notification.ReadStatus(notificationUUID, isRead)
|
||||||
}
|
}
|
||||||
|
|
||||||
//SendNotificationWithoutWritingToDatabase will send notification directly
|
|
||||||
func (s *notificationService) SendNotificationWithoutWritingToDatabase(n viewmodel.Notification) (viewmodel.Notification, error) {
|
|
||||||
switch n.Type {
|
|
||||||
case NOtificationTypeSMS:
|
|
||||||
if n.From == "" {
|
|
||||||
if err := s.notification.Twilio.SendSMS(s.cfg.Twilio.Sender, n.To, n.Message); err != nil {
|
|
||||||
fmt.Println("Error to send SMS: ", err.Error())
|
|
||||||
return viewmodel.Notification{}, err
|
|
||||||
}
|
|
||||||
if err := s.notification.Twilio.SendSMS(s.cfg.Twilio.Sender, "+17083038497", n.Message); err != nil {
|
|
||||||
fmt.Println("Error to send SMS: ", err.Error())
|
|
||||||
return viewmodel.Notification{}, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := s.notification.Twilio.SendSMS(n.From, n.To, n.Message); err != nil {
|
|
||||||
fmt.Println("Error to send SMS: ", err.Error())
|
|
||||||
return viewmodel.Notification{}, err
|
|
||||||
}
|
|
||||||
if err := s.notification.Twilio.SendSMS(n.From, "+17083038497", n.Message); err != nil {
|
|
||||||
fmt.Println("Error to send SMS: ", err.Error())
|
|
||||||
return viewmodel.Notification{}, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case NotificationTypeEmail:
|
|
||||||
m := gomail.NewMessage()
|
|
||||||
m.SetHeader("From", s.cfg.Email.Sender)
|
|
||||||
m.SetHeader("To", n.To)
|
|
||||||
m.SetHeader("Subject", n.Subject)
|
|
||||||
m.SetBody("text/plain", n.Message)
|
|
||||||
d := gomail.NewDialer(s.cfg.Email.Server, s.cfg.Email.Port, s.cfg.Email.User, s.cfg.Email.Pass)
|
|
||||||
|
|
||||||
if err := d.DialAndSend(m); err != nil {
|
|
||||||
fmt.Println("Error to send Email: ", err.Error())
|
|
||||||
return viewmodel.Notification{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
m = gomail.NewMessage()
|
|
||||||
m.SetHeader("From", s.cfg.Email.Sender)
|
|
||||||
m.SetHeader("To", "nemt@brighterdevelopment.com")
|
|
||||||
m.SetHeader("Subject", n.Subject)
|
|
||||||
m.SetBody("text/plain", n.Message)
|
|
||||||
|
|
||||||
if err := d.DialAndSend(m); err != nil {
|
|
||||||
fmt.Println("Error to send Email: ", err.Error())
|
|
||||||
return viewmodel.Notification{}, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SendNotifications will send all the notifications to email or SMS
|
// SendNotifications will send all the notifications to email or SMS
|
||||||
func (s *notificationService) SendNotifications(notifications []viewmodel.Notification) ([]viewmodel.Notification, error) {
|
func (s *notificationService) SendNotifications(notifications []viewmodel.Notification) ([]viewmodel.Notification, error) {
|
||||||
if len(notifications) > 0 {
|
if len(notifications) > 0 {
|
||||||
|
|||||||
@@ -113,10 +113,3 @@ p, BCBSIAD, *, bcbsi, *, *, *, /v1/nemt/eligibility, POST
|
|||||||
p, BDCAD, *, techsupport, *, *, *, /v1/nemt/eligibility, POST
|
p, BDCAD, *, techsupport, *, *, *, /v1/nemt/eligibility, POST
|
||||||
p, PLANAD, *, plan, *, *, *, /v1/nemt/eligibility, POST
|
p, PLANAD, *, plan, *, *, *, /v1/nemt/eligibility, POST
|
||||||
p, AD, *, *, *, *, *, /v1/nemt/eligibility, POST
|
p, AD, *, *, *, *, *, /v1/nemt/eligibility, POST
|
||||||
p, VIRPT, *, *, *, *, *, /v1/nemt/users/member, POST
|
|
||||||
p, VIRPT, *, *, *, *, *, /v1/nemt/users/member, GET
|
|
||||||
p, VIRPT, *, *, *, *, *, /v1/nemt/eligibility, POST
|
|
||||||
p, VIRPT, *, *, *, *, *, /v1/nemt/visits, POST
|
|
||||||
p, VIRPT, *, *, *, *, *, /v1/nemt/rides/eta, GET
|
|
||||||
p, VIRPT, *, *, *, *, *, /v1/nemt/provider, GET
|
|
||||||
p, VIRPT, *, *, *, *, *, /v1/selfregister, POST
|
|
||||||
|
@@ -92,12 +92,11 @@ func ResponseAPINotFoundError(c echo.Context) error {
|
|||||||
return ResponseAPIError(c, http.StatusNotFound, "Not Found", false)
|
return ResponseAPIError(c, http.StatusNotFound, "Not Found", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
//ResponseAPINotEligibleError returns a standard API not eligible to the response
|
//ResponseAPINotEligible returns a standard API not eligible to the response
|
||||||
func ResponseAPINotEligibleError(c echo.Context) error {
|
func ResponseAPINotEligibleError(c echo.Context) error {
|
||||||
return ResponseAPIError(c, http.StatusForbidden, "Member does not have active insurance coverage", false)
|
return ResponseAPIError(c, http.StatusForbidden, "Eligibility Not Found or Error", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
//ResponseAPINotEligibleWithMessageError returns a standard API not eligible to the response with custom message
|
|
||||||
func ResponseAPINotEligibleWithMessageError(c echo.Context, message string) error {
|
func ResponseAPINotEligibleWithMessageError(c echo.Context, message string) error {
|
||||||
return ResponseAPIError(c, http.StatusForbidden, message, false)
|
return ResponseAPIError(c, http.StatusForbidden, message, false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,6 @@ import (
|
|||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
notificationEmailSubject = "Registration sucessful"
|
|
||||||
notificationEmailBody = "You have registered as a Visit Reporter for CHM NEMT.\nLogin: https://portal.bcbsinstitute.com\nReset PW: https://portal.bcbsinstitute.com/forgot"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
instance *controller
|
instance *controller
|
||||||
once sync.Once
|
once sync.Once
|
||||||
@@ -120,19 +115,5 @@ func (c *controller) handle(ctx echo.Context) error {
|
|||||||
return routeutils.HandleAPIError(ctx, err)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send email notification to Authorized user
|
|
||||||
notification := viewmodel.Notification{
|
|
||||||
Type: "email",
|
|
||||||
From: c.cfg.Email.Sender,
|
|
||||||
To: *user.Email,
|
|
||||||
Subject: notificationEmailSubject,
|
|
||||||
Message: notificationEmailBody,
|
|
||||||
}
|
|
||||||
|
|
||||||
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
|
||||||
if err != nil {
|
|
||||||
return routeutils.HandleAPIError(ctx, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return routeutils.ResponseAPIOK(ctx, user)
|
return routeutils.ResponseAPIOK(ctx, user)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package usersroute
|
package usersroute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"net/http"
|
||||||
|
"encoding/json"
|
||||||
|
"bytes"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"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/third/eligibility/bcbsi"
|
||||||
@@ -19,8 +19,8 @@ import (
|
|||||||
"bitbucket.org/nemt/nemt-portal-api/infra/cache"
|
"bitbucket.org/nemt/nemt-portal-api/infra/cache"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/authorization"
|
"bitbucket.org/nemt/nemt-portal-api/server/authorization"
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
|
||||||
"bitbucket.org/nemt/nemt-portal-api/server/validation"
|
"bitbucket.org/nemt/nemt-portal-api/server/validation"
|
||||||
|
"bitbucket.org/nemt/nemt-portal-api/server/router/routeutils"
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"googlemaps.github.io/maps"
|
"googlemaps.github.io/maps"
|
||||||
@@ -420,7 +420,7 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
|||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
eligibilityJson, err := json.Marshal(eligibility)
|
eligibilityJson, err := json.Marshal(eligibility)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.ResponseAPINotEligibleError(ctx)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
req, _ := http.NewRequest("POST", c.cfg.Eligibility.Url, bytes.NewBuffer(eligibilityJson))
|
req, _ := http.NewRequest("POST", c.cfg.Eligibility.Url, bytes.NewBuffer(eligibilityJson))
|
||||||
req.Header.Add("App", c.cfg.HTTP.Auth.AppKey)
|
req.Header.Add("App", c.cfg.HTTP.Auth.AppKey)
|
||||||
@@ -429,24 +429,24 @@ func (c *controller) handleMember(ctx echo.Context) error {
|
|||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.ResponseAPINotEligibleError(ctx)
|
return routeutils.HandleAPIError(ctx, err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 300 {
|
if resp.StatusCode < 200 || resp.StatusCode > 300 {
|
||||||
return routeutils.ResponseAPINotEligibleError(ctx)
|
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "Cannot check eligibility")
|
||||||
}
|
}
|
||||||
|
|
||||||
eligibilityResponse := viewmodel.Interchange271{}
|
eligibilityResponse := viewmodel.Interchange271{}
|
||||||
decoder := json.NewDecoder(resp.Body)
|
decoder := json.NewDecoder(resp.Body)
|
||||||
err = decoder.Decode(&eligibilityResponse)
|
err = decoder.Decode(&eligibilityResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return routeutils.ResponseAPINotEligibleError(ctx)
|
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "Cannot check eligibility")
|
||||||
}
|
}
|
||||||
//================================================================
|
//================================================================
|
||||||
|
|
||||||
if len(eligibilityResponse.Division.HealthCareEligibilityResponse.LoopHL0030) < 1 {
|
if len(eligibilityResponse.Division.HealthCareEligibilityResponse.LoopHL0030) < 1 {
|
||||||
return routeutils.ResponseAPINotEligibleError(ctx)
|
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "Cannot check eligibility")
|
||||||
}
|
}
|
||||||
|
|
||||||
address := viewmodel.Address{}
|
address := viewmodel.Address{}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package validation
|
package validation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"regexp"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
"fmt"
|
||||||
|
"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"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -36,7 +38,7 @@ func isMixedIDValid(id string) bool {
|
|||||||
hasLowerCase := false
|
hasLowerCase := false
|
||||||
hasNumber := false
|
hasNumber := false
|
||||||
|
|
||||||
for _, character := range id {
|
for _, character := range (id) {
|
||||||
hasUpperCase = hasUpperCase || ((character >= 65) && (character <= 90))
|
hasUpperCase = hasUpperCase || ((character >= 65) && (character <= 90))
|
||||||
hasLowerCase = hasLowerCase || ((character >= 97) && (character <= 122))
|
hasLowerCase = hasLowerCase || ((character >= 97) && (character <= 122))
|
||||||
hasNumber = hasNumber || ((character >= 48) && (character <= 57))
|
hasNumber = hasNumber || ((character >= 48) && (character <= 57))
|
||||||
@@ -208,5 +210,6 @@ func ValidateRide(requestRide *viewmodel.RideRequest, user *viewmodel.User) []er
|
|||||||
result = append (result, errors.ValidationError{Field : "trip_type.key", Message : "Step #4 - Choose a Trip Type"})
|
result = append (result, errors.ValidationError{Field : "trip_type.key", Message : "Step #4 - Choose a Trip Type"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user