package rules import ( "time" "code.tnxs.net/taxnexus/lib/app" "go.temporal.io/sdk/temporal" temporal_workflow "go.temporal.io/sdk/workflow" ) // NewLeadWorkflowWrapper wraps a Lead with auth and saga info type NewLeadWorkflowWrapper struct { APIKey string SagaID string SagaType string // // Address crm_models.Address Company string Description string Email string FirstName 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 } // NewLeadWorkflow is a Temporal workflow func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) error { //nolint:gocritic // don't care transferDetails := app.LeadActivityWrapper{ // Address: w.Address, Company: w.Company, Description: w.Description, Email: w.Email, FirstName: w.FirstName, LastName: w.LastName, MobilePhone: w.MobilePhone, Name: w.Name, Phone: w.Phone, 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, } retryPolicy := &temporal.RetryPolicy{ InitialInterval: time.Second, MaximumInterval: time.Minute, MaximumAttempts: maxAttempts, } options := temporal_workflow.ActivityOptions{ // Timeout options specify when to automatically timeout Actvitivy functions. StartToCloseTimeout: time.Minute, // Optionally provide a customized RetryPolicy. // Temporal retries failures by default, this is just an example. RetryPolicy: retryPolicy, } ctx = temporal_workflow.WithActivityOptions(ctx, options) err := temporal_workflow.ExecuteActivity(ctx, StoreLeadActivity, transferDetails).Get(ctx, nil) if err != nil { return err } err = temporal_workflow.ExecuteActivity(ctx, NotifyLeadActivity, transferDetails).Get(ctx, nil) if err != nil { return err } return nil }