Created
November 19, 2019 21:15
-
-
Save stanfea/0e1eaffc3e0e31e5b775aa363e955ff6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"log" | |
"os" | |
"github.com/bradfitz/gomemcache/memcache" | |
"github.com/postmates/buyer-frontend/pkg/buyerpb" | |
"github.com/postmates/buyer-frontend/pkg/config" | |
"github.com/postmates/buyer-frontend/pkg/core/work" | |
ds "github.com/postmates/buyer-frontend/pkg/services/datastore" | |
"github.com/postmates/buyer-frontend/pkg/services/ipa" | |
"github.com/postmates/buyer-frontend/pkg/util/memcacheutil" | |
"github.com/postmates/go-af/logging" | |
) | |
func main() { | |
env := "PROD" | |
configFile := fmt.Sprintf("./configs/config-%s.yaml", env) | |
cfg := config.LoadConfig(configFile) | |
cfg.Env = env | |
ctx := context.TODO() | |
err := cfg.Datastore.Configure(nil) | |
if err != nil { | |
log.Fatal(err) | |
} | |
serverList := memcacheutil.NewServerList(cfg.Memcache.Hosts...) | |
mc := memcache.NewFromSelector(serverList) | |
if cfg.Memcache.MaxIdleConns > 0 { | |
mc.MaxIdleConns = cfg.Memcache.MaxIdleConns | |
} | |
if cfg.Memcache.Timeout > 0 { | |
mc.Timeout = cfg.Memcache.Timeout | |
} | |
memcacheutil.SetClient(mc) | |
email := "xxxx@postmates.com" | |
employee := &work.Employee{} | |
employeeKey := work.EmployeeKindName.MakeKey(email) | |
err = ds.ActiveClient().Get(ctx, employeeKey, employee) | |
if err != nil { | |
logging.LogError(ctx, err) | |
return | |
} | |
employeeVerification := &work.EmployeeVerification{} | |
verificationKey := work.EmployeeVerificationKindName.MakeKey(email) | |
err = ds.ActiveClient().Get(ctx, verificationKey, employeeVerification) | |
if err != nil { | |
logging.LogError(ctx, err) | |
return | |
} | |
policy, err := ipa.GetCompanyPolicy(ctx, 37.78349, -122.39884, &buyerpb.User{Email: employeeVerification.Email, Uuid: employeeVerification.CustomerUUID}) | |
if err != nil || policy == nil { | |
logging.Error(ctx, employeeVerification.Email) | |
return | |
} | |
res, _ := json.Marshal(policy) | |
fmt.Println(string(res)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
save this in
buyer_frontend/cmd/paw/check_user.go
and update the email variable and then you can right-click Run with IDEA