diff --git a/pkg/onboarding/application/dto/output.go b/pkg/onboarding/application/dto/output.go index 6cba8456..8b1e3815 100644 --- a/pkg/onboarding/application/dto/output.go +++ b/pkg/onboarding/application/dto/output.go @@ -5,33 +5,6 @@ import ( "github.com/savannahghi/profileutils" ) -// Admin represents agent with details inferred from their user profile -type Admin struct { - ID string `json:"id"` - - PrimaryPhone string `json:"primaryPhone"` - - PrimaryEmailAddress *string `json:"primaryEmailAddress"` - - SecondaryPhoneNumbers []string `json:"secondaryPhoneNumbers"` - - SecondaryEmailAddresses []string `json:"secondaryEmailAddresses"` - - TermsAccepted bool `json:"termsAccepted,omitempty"` - - Suspended bool `json:"suspended"` - - PhotoUploadID string `json:"photoUploadID,omitempty"` - - UserBioData profileutils.BioData `json:"userBioData,omitempty"` - - // Resend PIN helps inform the whether a send new temporary PIN - // True when the user hasn't performed the initial sign up to change PIN - ResendPIN bool `json:"resendPIN"` - - Roles []RoleOutput `json:"roles"` -} - // AccountRecoveryPhonesResponse payload sent back to the frontend when recovery an account type AccountRecoveryPhonesResponse struct { MaskedPhoneNumbers []string `json:"maskedPhoneNumbers"` diff --git a/pkg/onboarding/application/utils/admin_template.go b/pkg/onboarding/application/utils/admin_template.go deleted file mode 100644 index 6de55239..00000000 --- a/pkg/onboarding/application/utils/admin_template.go +++ /dev/null @@ -1,393 +0,0 @@ -package utils - -// AdminApprovalEmail is the email sent to an admin once registered -const AdminApprovalEmail = ` - - - - - Be.Well Professional by Slade 360° - Connected healthcare platform. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  -
-
- - - - - - - - - -
- - - - -
- -
-
- - - - -
-
-

Hello {{.Name}},

- -

- You have been successfully registered as an admin. We look - forward to working with you. -

-

- Please use this One Time PIN(OTP): {{.Pin}} and your phone number to login - to your Be.Well Professional account. -

- -

- Regards,
- Bev from Be.Well -

-
-
-
- - - - - - - -
- -
-
- - - - - - - - - - - -` diff --git a/pkg/onboarding/application/utils/agent_template.go b/pkg/onboarding/application/utils/agent_template.go deleted file mode 100644 index 9932da77..00000000 --- a/pkg/onboarding/application/utils/agent_template.go +++ /dev/null @@ -1,391 +0,0 @@ -package utils - -// AgentApprovalEmail is the email sent to an agent once registered -const AgentApprovalEmail = ` - - - - - Be.Well Professional by Slade 360° - Connected healthcare platform. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  -
-
- - - - - - - - - -
- - - - -
- -
-
- - - - -
-
-

Hello {{.Name}},

-

- You have been successfully registered as an agent. We look - forward to working with you. -

-

-

- Please use this One Time PIN(OTP): {{.Pin}} and your phone number to login to your Be.Well - Professional account. -

- -

- Regards,
- Bowi from Be.Well -

-
-
-
- - - - - - - -
- -
-
- - - - - - - - - - - -` diff --git a/pkg/onboarding/domain/model/models_gen.go b/pkg/onboarding/domain/model/models_gen.go index 2b5aae47..6e8962b9 100644 --- a/pkg/onboarding/domain/model/models_gen.go +++ b/pkg/onboarding/domain/model/models_gen.go @@ -8,10 +8,26 @@ import ( "strconv" "github.com/savannahghi/enumutils" + "github.com/savannahghi/onboarding/pkg/onboarding/application/dto" "github.com/savannahghi/onboarding/pkg/onboarding/domain" + "github.com/savannahghi/profileutils" "github.com/savannahghi/scalarutils" ) +type Admin struct { + ID string `json:"id"` + PrimaryPhone string `json:"primaryPhone"` + PrimaryEmailAddress *string `json:"primaryEmailAddress"` + SecondaryPhoneNumbers []*string `json:"secondaryPhoneNumbers"` + SecondaryEmailAddresses []*string `json:"secondaryEmailAddresses"` + TermsAccepted *bool `json:"termsAccepted"` + Suspended *bool `json:"suspended"` + PhotoUploadID *string `json:"photoUploadID"` + UserBioData *profileutils.BioData `json:"userBioData"` + ResendPin *bool `json:"resendPIN"` + Roles []*dto.RoleOutput `json:"roles"` +} + type Beneficiary struct { Name string `json:"name"` Msisdns []string `json:"msisdns"` diff --git a/pkg/onboarding/presentation/graph/generated/generated.go b/pkg/onboarding/presentation/graph/generated/generated.go index ef28c231..04f4292b 100644 --- a/pkg/onboarding/presentation/graph/generated/generated.go +++ b/pkg/onboarding/presentation/graph/generated/generated.go @@ -69,7 +69,7 @@ type ComplexityRoot struct { PhotoUploadID func(childComplexity int) int PrimaryEmailAddress func(childComplexity int) int PrimaryPhone func(childComplexity int) int - ResendPIN func(childComplexity int) int + ResendPin func(childComplexity int) int Roles func(childComplexity int) int SecondaryEmailAddresses func(childComplexity int) int SecondaryPhoneNumbers func(childComplexity int) int @@ -519,11 +519,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Admin.PrimaryPhone(childComplexity), true case "Admin.resendPIN": - if e.complexity.Admin.ResendPIN == nil { + if e.complexity.Admin.ResendPin == nil { break } - return e.complexity.Admin.ResendPIN(childComplexity), true + return e.complexity.Admin.ResendPin(childComplexity), true case "Admin.roles": if e.complexity.Admin.Roles == nil { @@ -3839,7 +3839,7 @@ func (ec *executionContext) _Address_formattedAddress(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_id(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_id(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -3874,7 +3874,7 @@ func (ec *executionContext) _Admin_id(ctx context.Context, field graphql.Collect return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_primaryPhone(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_primaryPhone(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -3909,7 +3909,7 @@ func (ec *executionContext) _Admin_primaryPhone(ctx context.Context, field graph return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_primaryEmailAddress(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_primaryEmailAddress(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -3941,7 +3941,7 @@ func (ec *executionContext) _Admin_primaryEmailAddress(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_secondaryPhoneNumbers(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_secondaryPhoneNumbers(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -3968,12 +3968,12 @@ func (ec *executionContext) _Admin_secondaryPhoneNumbers(ctx context.Context, fi if resTmp == nil { return graphql.Null } - res := resTmp.([]string) + res := resTmp.([]*string) fc.Result = res - return ec.marshalOString2ᚕstring(ctx, field.Selections, res) + return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_secondaryEmailAddresses(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_secondaryEmailAddresses(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4000,12 +4000,12 @@ func (ec *executionContext) _Admin_secondaryEmailAddresses(ctx context.Context, if resTmp == nil { return graphql.Null } - res := resTmp.([]string) + res := resTmp.([]*string) fc.Result = res - return ec.marshalOString2ᚕstring(ctx, field.Selections, res) + return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_termsAccepted(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_termsAccepted(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4032,12 +4032,12 @@ func (ec *executionContext) _Admin_termsAccepted(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*bool) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_suspended(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_suspended(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4064,12 +4064,12 @@ func (ec *executionContext) _Admin_suspended(ctx context.Context, field graphql. if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*bool) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_photoUploadID(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_photoUploadID(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4096,12 +4096,12 @@ func (ec *executionContext) _Admin_photoUploadID(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_userBioData(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_userBioData(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4128,12 +4128,12 @@ func (ec *executionContext) _Admin_userBioData(ctx context.Context, field graphq if resTmp == nil { return graphql.Null } - res := resTmp.(profileutils.BioData) + res := resTmp.(*profileutils.BioData) fc.Result = res - return ec.marshalOBioData2githubᚗcomᚋsavannahghiᚋprofileutilsᚐBioData(ctx, field.Selections, res) + return ec.marshalOBioData2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐBioData(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_resendPIN(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_resendPIN(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4151,7 +4151,7 @@ func (ec *executionContext) _Admin_resendPIN(ctx context.Context, field graphql. ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ResendPIN, nil + return obj.ResendPin, nil }) if err != nil { ec.Error(ctx, err) @@ -4160,12 +4160,12 @@ func (ec *executionContext) _Admin_resendPIN(ctx context.Context, field graphql. if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*bool) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } -func (ec *executionContext) _Admin_roles(ctx context.Context, field graphql.CollectedField, obj *dto.Admin) (ret graphql.Marshaler) { +func (ec *executionContext) _Admin_roles(ctx context.Context, field graphql.CollectedField, obj *model.Admin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4192,9 +4192,9 @@ func (ec *executionContext) _Admin_roles(ctx context.Context, field graphql.Coll if resTmp == nil { return graphql.Null } - res := resTmp.([]dto.RoleOutput) + res := resTmp.([]*dto.RoleOutput) fc.Result = res - return ec.marshalORoleOutput2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) + return ec.marshalORoleOutput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } func (ec *executionContext) _Beneficiary_name(ctx context.Context, field graphql.CollectedField, obj *model.Beneficiary) (ret graphql.Marshaler) { @@ -12988,7 +12988,7 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, var adminImplementors = []string{"Admin"} -func (ec *executionContext) _Admin(ctx context.Context, sel ast.SelectionSet, obj *dto.Admin) graphql.Marshaler { +func (ec *executionContext) _Admin(ctx context.Context, sel ast.SelectionSet, obj *model.Admin) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, adminImplementors) out := graphql.NewFieldSet(fields) @@ -16087,6 +16087,13 @@ func (ec *executionContext) marshalOBioData2githubᚗcomᚋsavannahghiᚋprofile return ec._BioData(ctx, sel, &v) } +func (ec *executionContext) marshalOBioData2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐBioData(ctx context.Context, sel ast.SelectionSet, v *profileutils.BioData) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._BioData(ctx, sel, v) +} + func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { res, err := graphql.UnmarshalBoolean(v) return res, graphql.ErrorOnPath(ctx, err) @@ -16569,50 +16576,6 @@ func (ec *executionContext) marshalOReceivablesAccount2githubᚗcomᚋsavannahgh return ec._ReceivablesAccount(ctx, sel, &v) } -func (ec *executionContext) marshalORoleOutput2githubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx context.Context, sel ast.SelectionSet, v dto.RoleOutput) graphql.Marshaler { - return ec._RoleOutput(ctx, sel, &v) -} - -func (ec *executionContext) marshalORoleOutput2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx context.Context, sel ast.SelectionSet, v []dto.RoleOutput) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalORoleOutput2githubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - func (ec *executionContext) marshalORoleOutput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx context.Context, sel ast.SelectionSet, v []*dto.RoleOutput) graphql.Marshaler { if v == nil { return graphql.Null @@ -16773,6 +16736,42 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel return ret } +func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]*string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i]) + } + + return ret +} + func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil diff --git a/pkg/onboarding/usecases/roles.go b/pkg/onboarding/usecases/roles.go index 46d4076d..11f6ac19 100644 --- a/pkg/onboarding/usecases/roles.go +++ b/pkg/onboarding/usecases/roles.go @@ -13,7 +13,7 @@ import ( "github.com/savannahghi/profileutils" ) -// RoleUseCase represent the business logic required for management of agents +// RoleUseCase represent the business logic required for management of roles type RoleUseCase interface { CreateRole(ctx context.Context, input dto.RoleInput) (*dto.RoleOutput, error)