diff --git a/rules/new-developer.go b/rules/new-developer.go index 477b4eb..1b46107 100644 --- a/rules/new-developer.go +++ b/rules/new-developer.go @@ -14,7 +14,7 @@ type NewDeveloperWrapper struct { Contact crm_models.Contact Account crm_models.Account PaymentMethod ops_models.PaymentMethod - Principal app.User + APIKey string SagaID string SagaType string } @@ -22,7 +22,7 @@ type NewDeveloperWrapper struct { // NewDeveloperWorkflow is a Temporal workflow func NewDeveloperWorkflow( ctx workflow.Context, - payload *NewDeveloperWrapper, + w *NewDeveloperWrapper, ) error { ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ StartToCloseTimeout: time.Minute, @@ -30,10 +30,10 @@ func NewDeveloperWorkflow( err := workflow.ExecuteActivity(ctx, StoreContactActivity, &app.ContactChannelWrapper{ - Obj: payload.Contact, - APIKey: payload.Principal.APIKey, - SagaID: payload.SagaID, - SagaType: payload.SagaType, + Obj: w.Contact, + APIKey: w.APIKey, + SagaID: w.SagaID, + SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err @@ -41,10 +41,10 @@ func NewDeveloperWorkflow( err = workflow.ExecuteActivity(ctx, StoreAccountActivity, &app.AccountChannelWrapper{ - Obj: payload.Account, - APIKey: payload.Principal.APIKey, - SagaID: payload.SagaID, - SagaType: payload.SagaType, + Obj: w.Account, + APIKey: w.APIKey, + SagaID: w.SagaID, + SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err @@ -52,10 +52,10 @@ func NewDeveloperWorkflow( err = workflow.ExecuteActivity(ctx, StorePaymentMethodActivity, &app.PaymentMethodChannelWrapper{ - Obj: payload.PaymentMethod, - APIKey: payload.Principal.APIKey, - SagaID: payload.SagaID, - SagaType: payload.SagaType, + Obj: w.PaymentMethod, + APIKey: w.APIKey, + SagaID: w.SagaID, + SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err @@ -63,15 +63,15 @@ func NewDeveloperWorkflow( err = workflow.ExecuteActivity(ctx, NotifyContactActivity, &app.ContactChannelWrapper{ - Obj: payload.Contact, - APIKey: payload.Principal.APIKey, - SagaID: payload.SagaID, - SagaType: payload.SagaType, + Obj: w.Contact, + APIKey: w.APIKey, + SagaID: w.SagaID, + SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err } - err = workflow.ExecuteActivity(ctx, NotifyLeadActivity, payload).Get(ctx, nil) + err = workflow.ExecuteActivity(ctx, NotifyLeadActivity, w).Get(ctx, nil) if err != nil { return err } diff --git a/rules/new-lead.go b/rules/new-lead.go index fac391b..d9d7067 100644 --- a/rules/new-lead.go +++ b/rules/new-lead.go @@ -10,10 +10,10 @@ import ( // NewLeadWrapper wraps a Lead and a user identifier (app.User) type NewLeadWrapper struct { - Lead crm_models.Lead - Principal app.User - SagaID string - SagaType string + Lead crm_models.Lead + APIKey string + SagaID string + SagaType string } // NewLeadWorkflow is a Temporal workflow @@ -30,7 +30,7 @@ func NewLeadWorkflow(ctx temporal_workflow.Context, payload *NewLeadWrapper) err StoreLeadActivity, &app.LeadChannelWrapper{ Obj: payload.Lead, - APIKey: payload.Principal.APIKey, + APIKey: payload.APIKey, }).Get(ctx, nil) if err != nil { return err @@ -41,7 +41,7 @@ func NewLeadWorkflow(ctx temporal_workflow.Context, payload *NewLeadWrapper) err NotifyLeadActivity, &app.LeadChannelWrapper{ Obj: payload.Lead, - APIKey: payload.Principal.APIKey, + APIKey: payload.APIKey, }).Get(ctx, nil) if err != nil { return err