V0.1.5
Vernon Keenan 2021-01-12 21:09:16 -08:00
parent 5136004b97
commit 4921f99240
3 changed files with 17 additions and 7 deletions

View File

@ -9,8 +9,8 @@ import (
"go.temporal.io/sdk/workflow" "go.temporal.io/sdk/workflow"
) )
// newDeveloperWrapper wraps a Lead and a user identifier (app.User) // NewDeveloperWrapper wraps a contact, account, payment method and a user identifier (app.User)
type newDeveloperWrapper struct { type NewDeveloperWrapper struct {
contact crm_models.Contact contact crm_models.Contact
account crm_models.Account account crm_models.Account
paymentMethod ops_models.PaymentMethod paymentMethod ops_models.PaymentMethod
@ -18,7 +18,7 @@ type newDeveloperWrapper struct {
} }
// NewDeveloperWorkflow is a workflow // 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{ ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
StartToCloseTimeout: time.Minute, StartToCloseTimeout: time.Minute,
}) })

View File

@ -3,19 +3,26 @@ package rules
import ( import (
"time" "time"
"code.tnxs.net/taxnexus/lib/api/crm/crm_models"
"code.tnxs.net/taxnexus/lib/app" "code.tnxs.net/taxnexus/lib/app"
"go.temporal.io/sdk/workflow" "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 // 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{ ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
StartToCloseTimeout: time.Minute, StartToCloseTimeout: time.Minute,
}) })
err := workflow.ExecuteActivity(ctx, err := workflow.ExecuteActivity(ctx,
StoreLeadActivity, StoreLeadActivity,
&app.LeadChannelWrapper{ &app.LeadChannelWrapper{
Obj: payload.Obj, Obj: payload.Lead,
Principal: payload.Principal, Principal: payload.Principal,
}).Get(ctx, nil) }).Get(ctx, nil)
if err != nil { if err != nil {
@ -24,7 +31,7 @@ func NewLeadWorkflow(ctx workflow.Context, payload *app.LeadChannelWrapper) erro
err = workflow.ExecuteActivity(ctx, err = workflow.ExecuteActivity(ctx,
NotifyLeadActivity, NotifyLeadActivity,
&app.LeadChannelWrapper{ &app.LeadChannelWrapper{
Obj: payload.Obj, Obj: payload.Lead,
Principal: payload.Principal, Principal: payload.Principal,
}).Get(ctx, nil) }).Get(ctx, nil)
if err != nil { if err != nil {

View File

@ -8,7 +8,10 @@ import (
) )
// StorePaymentMethodActivity posts a new paymentmethod object to datastore // 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 := payment_method.NewPostPaymentMethodsParamsWithTimeout(postTimeout)
postPaymentMethodParams.PaymentMethodRequest = &ops_models.PaymentMethodRequest{ postPaymentMethodParams.PaymentMethodRequest = &ops_models.PaymentMethodRequest{
Data: []*ops_models.PaymentMethod{&w.Obj}, Data: []*ops_models.PaymentMethod{&w.Obj},