Skip to content

Commit

Permalink
Rename sharecode.ShareCodeSender -> Sender
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed Aug 8, 2024
1 parent 2289002 commit afb4c02
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmd/event-received/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (f *Factory) ShareCodeSender(ctx context.Context) (ShareCodeSender, error)
return nil, err
}

f.shareCodeSender = sharecode.NewShareCodeSender(sharecode.NewStore(f.dynamoClient), notifyClient, f.appPublicURL, random.String, event.NewClient(f.cfg, f.eventBusName))
f.shareCodeSender = sharecode.NewSender(sharecode.NewStore(f.dynamoClient), notifyClient, f.appPublicURL, random.String, event.NewClient(f.cfg, f.eventBusName))
}

return f.shareCodeSender, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func App(
memberStore := supporter.NewMemberStore(lpaDynamoClient)
progressTracker := task.ProgressTracker{Localizer: localizer}

shareCodeSender := sharecode.NewShareCodeSender(shareCodeStore, notifyClient, appPublicURL, random.String, eventClient)
shareCodeSender := sharecode.NewSender(shareCodeStore, notifyClient, appPublicURL, random.String, eventClient)
witnessCodeSender := page.NewWitnessCodeSender(donorStore, notifyClient)

lpaStoreResolvingService := lpastore.NewResolvingService(donorStore, lpaStoreClient)
Expand Down
28 changes: 14 additions & 14 deletions internal/sharecode/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type EventClient interface {
SendPaperFormRequested(ctx context.Context, paperFormRequestedEvent event.PaperFormRequested) error
}

type ShareCodeSender struct {
type Sender struct {
testCode string
shareCodeStore ShareCodeStore
notifyClient NotifyClient
Expand All @@ -57,8 +57,8 @@ type ShareCodeSender struct {
eventClient EventClient
}

func NewShareCodeSender(shareCodeStore ShareCodeStore, notifyClient NotifyClient, appPublicURL string, randomString func(int) string, eventClient EventClient) *ShareCodeSender {
return &ShareCodeSender{
func NewSender(shareCodeStore ShareCodeStore, notifyClient NotifyClient, appPublicURL string, randomString func(int) string, eventClient EventClient) *Sender {
return &Sender{
shareCodeStore: shareCodeStore,
notifyClient: notifyClient,
appPublicURL: appPublicURL,
Expand All @@ -67,7 +67,7 @@ func NewShareCodeSender(shareCodeStore ShareCodeStore, notifyClient NotifyClient
}
}

func (s *ShareCodeSender) UseTestCode(shareCode string) {
func (s *Sender) UseTestCode(shareCode string) {
s.testCode = shareCode
}

Expand All @@ -83,7 +83,7 @@ type CertificateProviderInvite struct {
CertificateProviderEmail string
}

func (s *ShareCodeSender) SendCertificateProviderInvite(ctx context.Context, appData appcontext.Data, invite CertificateProviderInvite) error {
func (s *Sender) SendCertificateProviderInvite(ctx context.Context, appData appcontext.Data, invite CertificateProviderInvite) error {
shareCode, err := s.createShareCode(ctx, invite.LpaKey, invite.LpaOwnerKey, invite.CertificateProviderUID, actor.TypeCertificateProvider)
if err != nil {
return err
Expand All @@ -102,7 +102,7 @@ func (s *ShareCodeSender) SendCertificateProviderInvite(ctx context.Context, app
})
}

func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, appData appcontext.Data, donor *donordata.Provided) error {
func (s *Sender) SendCertificateProviderPrompt(ctx context.Context, appData appcontext.Data, donor *donordata.Provided) error {
shareCode, err := s.createShareCode(ctx, donor.PK, donor.SK, donor.CertificateProvider.UID, actor.TypeCertificateProvider)
if err != nil {
return err
Expand All @@ -121,7 +121,7 @@ func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, app
})
}

func (s *ShareCodeSender) SendAttorneys(ctx context.Context, appData appcontext.Data, donor *lpadata.Lpa) error {
func (s *Sender) SendAttorneys(ctx context.Context, appData appcontext.Data, donor *lpadata.Lpa) error {
if err := s.sendTrustCorporation(ctx, appData, donor, donor.Attorneys.TrustCorporation); err != nil {
return err
}
Expand All @@ -144,7 +144,7 @@ func (s *ShareCodeSender) SendAttorneys(ctx context.Context, appData appcontext.
return nil
}

func (s *ShareCodeSender) sendOriginalAttorney(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, attorney lpadata.Attorney) error {
func (s *Sender) sendOriginalAttorney(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, attorney lpadata.Attorney) error {
shareCode, err := s.createShareCode(ctx, lpa.LpaKey, lpa.LpaOwnerKey, attorney.UID, actor.TypeAttorney)
if err != nil {
return err
Expand All @@ -167,7 +167,7 @@ func (s *ShareCodeSender) sendOriginalAttorney(ctx context.Context, appData appc
})
}

func (s *ShareCodeSender) sendReplacementAttorney(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, attorney lpadata.Attorney) error {
func (s *Sender) sendReplacementAttorney(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, attorney lpadata.Attorney) error {
shareCode, err := s.createShareCode(ctx, lpa.LpaKey, lpa.LpaOwnerKey, attorney.UID, actor.TypeReplacementAttorney)
if err != nil {
return err
Expand All @@ -190,7 +190,7 @@ func (s *ShareCodeSender) sendReplacementAttorney(ctx context.Context, appData a
})
}

func (s *ShareCodeSender) sendTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, trustCorporation lpadata.TrustCorporation) error {
func (s *Sender) sendTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, trustCorporation lpadata.TrustCorporation) error {
if trustCorporation.Name == "" {
return nil
}
Expand All @@ -217,7 +217,7 @@ func (s *ShareCodeSender) sendTrustCorporation(ctx context.Context, appData appc
})
}

func (s *ShareCodeSender) sendReplacementTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, trustCorporation lpadata.TrustCorporation) error {
func (s *Sender) sendReplacementTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, trustCorporation lpadata.TrustCorporation) error {
if trustCorporation.Name == "" {
return nil
}
Expand All @@ -244,7 +244,7 @@ func (s *ShareCodeSender) sendReplacementTrustCorporation(ctx context.Context, a
})
}

func (s *ShareCodeSender) createShareCode(ctx context.Context, lpaKey dynamo.LpaKeyType, lpaOwnerKey dynamo.LpaOwnerKeyType, actorUID actoruid.UID, actorType actor.Type) (string, error) {
func (s *Sender) createShareCode(ctx context.Context, lpaKey dynamo.LpaKeyType, lpaOwnerKey dynamo.LpaOwnerKeyType, actorUID actoruid.UID, actorType actor.Type) (string, error) {
shareCode := s.randomString(12)
if s.testCode != "" {
shareCode = s.testCode
Expand All @@ -266,15 +266,15 @@ func (s *ShareCodeSender) createShareCode(ctx context.Context, lpaKey dynamo.Lpa
return shareCode, nil
}

func (s *ShareCodeSender) sendEmail(ctx context.Context, to string, lpaUID string, email notify.Email) error {
func (s *Sender) sendEmail(ctx context.Context, to string, lpaUID string, email notify.Email) error {
if err := s.notifyClient.SendActorEmail(ctx, to, lpaUID, email); err != nil {
return fmt.Errorf("email failed: %w", err)
}

return nil
}

func (s *ShareCodeSender) sendPaperForm(ctx context.Context, lpaUID string, actorType actor.Type, actorUID actoruid.UID, shareCode string) error {
func (s *Sender) sendPaperForm(ctx context.Context, lpaUID string, actorType actor.Type, actorUID actoruid.UID, shareCode string) error {
return s.eventClient.SendPaperFormRequested(ctx, event.PaperFormRequested{
UID: lpaUID,
ActorType: actorType.String(),
Expand Down
32 changes: 16 additions & 16 deletions internal/sharecode/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestShareCodeSenderSendCertificateProviderInvite(t *testing.T) {
}).
Return(nil)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
err := sender.SendCertificateProviderInvite(ctx, TestAppData, CertificateProviderInvite{
LpaKey: dynamo.LpaKey("lpa"),
LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")),
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T)
Once().
Return(nil)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)

if tc.useTestCode {
sender.UseTestCode("abcdef123456")
Expand Down Expand Up @@ -264,7 +264,7 @@ func TestShareCodeSenderSendCertificateProviderInviteWhenEmailErrors(t *testing.
SendActorEmail(ctx, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
err := sender.SendCertificateProviderInvite(ctx, TestAppData, CertificateProviderInvite{
LpaUID: donor.LpaUID,
Type: donor.Type,
Expand All @@ -286,7 +286,7 @@ func TestShareCodeSenderSendCertificateProviderInviteWhenShareCodeStoreErrors(t
Put(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
err := sender.SendCertificateProviderInvite(ctx, TestAppData, CertificateProviderInvite{})

assert.Equal(t, expectedError, errors.Unwrap(err))
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestShareCodeSenderSendCertificateProviderPromptOnline(t *testing.T) {
}).
Return(nil)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
err := sender.SendCertificateProviderPrompt(ctx, TestAppData, donor)

assert.Nil(t, err)
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestShareCodeSenderSendCertificateProviderPromptPaper(t *testing.T) {
}).
Return(nil)

sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, eventClient)
sender := NewSender(shareCodeStore, nil, "http://app", testRandomStringFn, eventClient)
err := sender.SendCertificateProviderPrompt(ctx, TestAppData, donor)

assert.Nil(t, err)
Expand Down Expand Up @@ -474,7 +474,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T)
Once().
Return(nil)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)

if tc.useTestCode {
sender.UseTestCode("abcdef123456")
Expand Down Expand Up @@ -503,7 +503,7 @@ func TestShareCodeSenderSendCertificateProviderPromptPaperWhenShareCodeStoreErro
Put(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
err := sender.SendCertificateProviderPrompt(ctx, TestAppData, donor)

assert.ErrorIs(t, err, expectedError)
Expand All @@ -528,7 +528,7 @@ func TestShareCodeSenderSendCertificateProviderPromptPaperWhenEventClientError(t
SendPaperFormRequested(mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, eventClient)
sender := NewSender(shareCodeStore, nil, "http://app", testRandomStringFn, eventClient)
err := sender.SendCertificateProviderPrompt(ctx, TestAppData, donor)

assert.Equal(t, expectedError, err)
Expand Down Expand Up @@ -567,7 +567,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWhenEmailErrors(t *testing.
SendActorEmail(ctx, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
err := sender.SendCertificateProviderPrompt(ctx, TestAppData, donor)

assert.Equal(t, expectedError, errors.Unwrap(err))
Expand All @@ -581,7 +581,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWhenShareCodeStoreErrors(t
Put(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
err := sender.SendCertificateProviderPrompt(ctx, TestAppData, &donordata.Provided{})

assert.Equal(t, expectedError, errors.Unwrap(err))
Expand Down Expand Up @@ -768,7 +768,7 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) {
}).
Return(nil)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, eventClient)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, eventClient)
err := sender.SendAttorneys(ctx, TestAppData, donor)

assert.Nil(t, err)
Expand Down Expand Up @@ -839,7 +839,7 @@ func TestShareCodeSenderSendAttorneysTrustCorporationsNoEmail(t *testing.T) {
}).
Return(nil)

sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, eventClient)
sender := NewSender(shareCodeStore, nil, "http://app", testRandomStringFn, eventClient)
err := sender.SendAttorneys(ctx, TestAppData, donor)

assert.Nil(t, err)
Expand Down Expand Up @@ -926,7 +926,7 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) {
}).
Return(nil)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)

if tc.useTestCode {
sender.UseTestCode("abcdef123456")
Expand Down Expand Up @@ -978,7 +978,7 @@ func TestShareCodeSenderSendAttorneysWhenEmailErrors(t *testing.T) {
SendActorEmail(ctx, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, notifyClient, "http://app", testRandomStringFn, nil)
err := sender.SendAttorneys(ctx, TestAppData, donor)

assert.Equal(t, expectedError, errors.Unwrap(err))
Expand All @@ -992,7 +992,7 @@ func TestShareCodeSenderSendAttorneysWhenShareCodeStoreErrors(t *testing.T) {
Put(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
sender := NewSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil)
err := sender.SendAttorneys(ctx, TestAppData, &lpadata.Lpa{
Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{Email: "[email protected]"}}},
})
Expand Down

0 comments on commit afb4c02

Please sign in to comment.