package rules import ( "time" "code.tnxs.net/taxnexus/lib/api/crm/crm_models" "code.tnxs.net/taxnexus/lib/app" temporal_workflow "go.temporal.io/sdk/workflow" ) // NewLeadWorkflowWrapper wraps a Lead with auth and saga info type NewLeadWorkflowWrapper struct { // Address crm_models.Address Company string Description string Email string FirstName string ID string LastName string MobilePhone string Name string OwnerID string PartnerAccountID string Phone string ProductID string RefererURL string Status string TenantID string Title string Type string UTMCampaign string UTMContent string UTMMedium string UTMSource string UTMTerm string Website string APIKey string SagaID string SagaType string } // NewLeadWorkflow is a Temporal workflow func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) error { //nolint:gocritic // don't care obj := crm_models.Lead{ // Address: w.Address, Company: w.Company, Description: w.Description, Email: w.Email, FirstName: w.FirstName, LastName: w.LastName, MobilePhone: w.MobilePhone, Name: w.Name, OwnerID: w.OwnerID, PartnerAccountID: w.PartnerAccountID, Phone: w.Phone, ProductID: w.ProductID, RefererURL: w.RefererURL, Status: w.Status, TenantID: w.TenantID, Title: w.Title, Type: w.Type, UTMCampaign: w.UTMCampaign, UTMContent: w.UTMContent, UTMMedium: w.UTMMedium, UTMSource: w.UTMSource, UTMTerm: w.UTMTerm, Website: w.Website, } ctx = temporal_workflow. WithActivityOptions( ctx, temporal_workflow.ActivityOptions{ StartToCloseTimeout: time.Minute, }) err := temporal_workflow. ExecuteActivity( ctx, StoreLeadActivity, app.LeadActivityWrapper{ Obj: obj, SagaID: w.SagaID, SagaType: w.SagaType, APIKey: w.APIKey, }).Get(ctx, nil) if err != nil { return err } err = temporal_workflow. ExecuteActivity( ctx, NotifyLeadActivity, app.LeadActivityWrapper{ Obj: obj, APIKey: w.APIKey, }).Get(ctx, nil) if err != nil { return err } return nil }