|
|
|
@@ -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/validation"
|
|
|
|
|
|
|
|
"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"
|
|
|
|
"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.HandleAPIError(ctx, err)
|
|
|
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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.HandleAPIError(ctx, err)
|
|
|
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
|
|
|
|
if resp.StatusCode < 200 || resp.StatusCode > 300 {
|
|
|
|
if resp.StatusCode < 200 || resp.StatusCode > 300 {
|
|
|
|
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "Cannot check eligibility")
|
|
|
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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.ResponseAPINotEligibleWithMessageError(ctx, "Cannot check eligibility")
|
|
|
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//================================================================
|
|
|
|
//================================================================
|
|
|
|
|
|
|
|
|
|
|
|
if len(eligibilityResponse.Division.HealthCareEligibilityResponse.LoopHL0030) < 1 {
|
|
|
|
if len(eligibilityResponse.Division.HealthCareEligibilityResponse.LoopHL0030) < 1 {
|
|
|
|
return routeutils.ResponseAPINotEligibleWithMessageError(ctx, "Cannot check eligibility")
|
|
|
|
return routeutils.ResponseAPINotEligibleError(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
address := viewmodel.Address{}
|
|
|
|
address := viewmodel.Address{}
|
|
|
|
|