Skip to content

Commit

Permalink
Merge pull request #84 from OperationSpark/feat/snapmail-cohort
Browse files Browse the repository at this point in the history
Add Session Cohort to SNAPmail payload
  • Loading branch information
harveysanders authored Nov 30, 2023
2 parents d58b442 + a689ac3 commit f88d205
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions signup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,15 @@ func TestSnapMail(t *testing.T) {
SessionID: "tMisBjpLQt8H3oD8B",
StartDateTime: mustMakeTime(t, time.RFC3339, "2023-09-23T18:00:00.000Z"),
Cell: "555-555-5555",
Cohort: "is-sep-23-23-12pm",
}
wantJSON := `{"eventType":"SESSION_SIGNUP","payload":{"email":"[email protected]","nameFirst":"Abigail","nameLast":"Test","sessionId":"tMisBjpLQt8H3oD8B","startDateTime":"2023-09-23T18:00:00Z","mobile":"555-555-5555"}}`
wantJSON := `{"eventType":"SESSION_SIGNUP","payload":{"email":"[email protected]","nameFirst":"Abigail","nameLast":"Test","sessionCohort":"is-sep-23-23-12pm","sessionId":"tMisBjpLQt8H3oD8B","startDateTime":"2023-09-23T18:00:00Z","mobile":"555-555-5555"}}`

mockSnapServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assertEqual(t, r.URL.Path, "/events")

signature := r.Header.Get("X-Signature-256")
assertEqual(t, signature, "sha256=d0c60e4c56076f1128f496fe7e6d4f696c5e8684ff407a3f25c95371e4bd9fbc")
assertEqual(t, signature, "sha256=9ed748a0bec0b1783ceee360c0a99657c1161c56e13af77c91bc01be72111e1d")

gotJSON, err := io.ReadAll(r.Body)
assertNilError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions snapmail.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Payload struct {
Email string `json:"email"`
NameFirst string `json:"nameFirst"`
NameLast string `json:"nameLast"`
SessionCohort string `json:"sessionCohort"`
SessionID string `json:"sessionId"`
StartDateTime time.Time `json:"startDateTime,omitempty"`
Mobile string `json:"mobile"`
Expand Down Expand Up @@ -66,6 +67,7 @@ func (sm *SnapMail) run(ctx context.Context, signup Signup) error {
NameFirst: signup.NameFirst,
NameLast: signup.NameLast,
SessionID: signup.SessionID,
SessionCohort: signup.Cohort,
StartDateTime: signup.StartDateTime,
Mobile: signup.Cell,
},
Expand Down

0 comments on commit f88d205

Please sign in to comment.