From 4921f992404a05120a02d55bb38a974304df57ef Mon Sep 17 00:00:00 2001 From: Vernon Keenan Date: Tue, 12 Jan 2021 21:09:16 -0800 Subject: [PATCH] rules --- rules/new-developer.go | 6 +++--- rules/new-lead.go | 13 ++++++++++--- rules/paymentmethod.go | 5 ++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/rules/new-developer.go b/rules/new-developer.go index d8b93c7..659d882 100644 --- a/rules/new-developer.go +++ b/rules/new-developer.go @@ -9,8 +9,8 @@ import ( "go.temporal.io/sdk/workflow" ) -// newDeveloperWrapper wraps a Lead and a user identifier (app.User) -type newDeveloperWrapper struct { +// NewDeveloperWrapper wraps a contact, account, payment method and a user identifier (app.User) +type NewDeveloperWrapper struct { contact crm_models.Contact account crm_models.Account paymentMethod ops_models.PaymentMethod @@ -18,7 +18,7 @@ type newDeveloperWrapper struct { } // NewDeveloperWorkflow is a workflow -func NewDeveloperWorkflow(ctx workflow.Context, payload *newDeveloperWrapper) error { +func NewDeveloperWorkflow(ctx workflow.Context, payload *NewDeveloperWrapper) error { ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ StartToCloseTimeout: time.Minute, }) diff --git a/rules/new-lead.go b/rules/new-lead.go index 7f530f1..835f3ef 100644 --- a/rules/new-lead.go +++ b/rules/new-lead.go @@ -3,19 +3,26 @@ package rules import ( "time" + "code.tnxs.net/taxnexus/lib/api/crm/crm_models" "code.tnxs.net/taxnexus/lib/app" "go.temporal.io/sdk/workflow" ) +// NewLeadWrapper wraps a Lead and a user identifier (app.User) +type NewLeadWrapper struct { + Lead crm_models.Lead + Principal app.User +} + // NewLeadWorkflow is a workflow -func NewLeadWorkflow(ctx workflow.Context, payload *app.LeadChannelWrapper) error { +func NewLeadWorkflow(ctx workflow.Context, payload *NewLeadWrapper) error { ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ StartToCloseTimeout: time.Minute, }) err := workflow.ExecuteActivity(ctx, StoreLeadActivity, &app.LeadChannelWrapper{ - Obj: payload.Obj, + Obj: payload.Lead, Principal: payload.Principal, }).Get(ctx, nil) if err != nil { @@ -24,7 +31,7 @@ func NewLeadWorkflow(ctx workflow.Context, payload *app.LeadChannelWrapper) erro err = workflow.ExecuteActivity(ctx, NotifyLeadActivity, &app.LeadChannelWrapper{ - Obj: payload.Obj, + Obj: payload.Lead, Principal: payload.Principal, }).Get(ctx, nil) if err != nil { diff --git a/rules/paymentmethod.go b/rules/paymentmethod.go index 1a765e4..94f6de9 100644 --- a/rules/paymentmethod.go +++ b/rules/paymentmethod.go @@ -8,7 +8,10 @@ import ( ) // StorePaymentMethodActivity posts a new paymentmethod object to datastore -func StorePaymentMethodActivity(ctx workflow.Context, w app.PaymentMethodChannelWrapper) error { //nolint:gocritic // what we want +func StorePaymentMethodActivity( + ctx workflow.Context, + w app.PaymentMethodChannelWrapper, //nolint:gocritic // what we want +) error { postPaymentMethodParams := payment_method.NewPostPaymentMethodsParamsWithTimeout(postTimeout) postPaymentMethodParams.PaymentMethodRequest = &ops_models.PaymentMethodRequest{ Data: []*ops_models.PaymentMethod{&w.Obj},