package rules import ( "time" "code.tnxs.net/taxnexus/lib/api/crm/crm_models" "code.tnxs.net/taxnexus/lib/api/ops/ops_models" "code.tnxs.net/taxnexus/lib/app" "go.temporal.io/sdk/workflow" ) // NewDeveloperWrapper wraps a contact, account, payment method and a user identifier (app.User) type NewDeveloperWrapper struct { AccountName string BillingStreet string BillingCity string BillingState string BillingPostalCode string Company string Description string Email string FirstName string LastName string MobilePhone string Name string Phone string Title string Website string APIKey string SagaID string SagaType string } // NewDeveloperWorkflow is a Temporal workflow func NewDeveloperWorkflow( ctx workflow.Context, w *NewDeveloperWrapper, ) error { ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ StartToCloseTimeout: time.Minute, }) err := workflow.ExecuteActivity(ctx, StoreContactActivity, &app.ContactChannelWrapper{ Obj: crm_models.Contact{ AccountID: "", AssistantName: "", AssistantPhone: "", BirthDate: "", Department: "", Description: w.Description, DoNotCall: false, Email: w.Email, EmailBounceDate: "", EmailBouncedReason: "", EnrollmentStatus: "", Fax: "", FirstName: w.FirstName, HasOptedOutOfEmail: false, HasOptedOutOfFax: false, HomePhone: "", IsEmailBounced: false, IsProvisioned: false, LastName: w.LastName, LeadSource: "", Level: "", LinkedIn: "", MailingAddress: &crm_models.Address{}, MailingLists: "", MobilePhone: w.MobilePhone, Name: w.Name, OtherAddress: &crm_models.Address{}, OtherPhone: "", OwnerID: "", PersonalEmail: "", Phone: w.Phone, PhotoURL: "", RecruitingStatus: "", Ref: "", ReportsToID: "", Salutation: "", Status: "", TenantID: "", Title: w.Title, Type: "", }, APIKey: w.APIKey, SagaID: w.SagaID, SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err } err = workflow.ExecuteActivity(ctx, StoreAccountActivity, &app.AccountChannelWrapper{ Obj: crm_models.Account{ AccountNumber: "", AccountSource: "", Active: false, AdministrativeLevel: "", Amount: 0, AmountInvoiced: 0, AmountPaid: 0, AnnualRevenue: 0, Balance: 0, BillingAddress: &crm_models.Address{City: w.BillingCity, Street: w.BillingStreet, State: w.BillingState, PostalCode: w.BillingPostalCode}, BillingContactID: "", BillingPreference: "", BusinessAddress: &crm_models.Address{}, CannabisCustomer: false, ChannelProgramLevelName: "", ChannelProgramName: "", ClientEndDate: "", ClientStartDate: "", CompanyID: "", CoordinateID: "", CustomerID: "", CustomerPriority: "", DBA: "", DUNSNumber: "", DandBCompanyID: "", DefaultAddress: &crm_models.Address{}, DefaultBackendID: "", DefaultDeliveryContactID: "", DefaultEndUserID: "", Description: w.Description, EIN: "", Email: w.Email, EnrollmentStatus: "", Fax: "", ISPCustomer: false, Industry: "", IsCustomerPortal: false, IsPartner: false, MSPCustomer: false, NAICSCode: "", NAICSDesc: "", Name: w.AccountName, NumberOfEmployees: 0, NumberOfLocations: 0, OpenCharges: 0, OrderContactID: "", OrderEmail: "", OwnerID: "", Ownership: "", ParentFK: "", ParentID: "", Phone: "", PlaceID: "", PreparerID: "", Rating: "", RatingEngineID: "", Ref: "", RevenueBase: 0, RevenueNet: 0, RevenueNotTaxable: 0, SIC: "", SICDesc: "", ShippingAddress: &crm_models.Address{}, ShippingCensusTract: "", ShippingConactID: "", ShippingCounty: "", Site: "", Status: "", TaxExemption: "", TaxOnTax: 0, TelecomCustomer: false, TenantID: "", TickerSymbol: "", TradeStyle: "", Type: "", UnappliedPayments: 0, UnitBase: 0, UpsellOpportunity: "", WHMCSClientID: 0, Website: "", XeroContactID: "", YearStarted: "", }, APIKey: w.APIKey, SagaID: w.SagaID, SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err } err = workflow.ExecuteActivity(ctx, StorePaymentMethodActivity, &app.PaymentMethodChannelWrapper{ Obj: ops_models.PaymentMethod{ AccountID: "todo fix this", AchAccountType: "", AchBankAccount: "", AchRouting: "", Active: false, Autopay: false, BankName: "", BillingContactID: "", CCnumber: "", CCtype: "", CompanyID: "", ContractID: "", CreatedByID: "", CreatedDate: "", Default: false, ExpirationDate: "", ExpirationMonth: "", ExpirationYear: "", Gateway: "", GatewayKey: "", LastModifiedByID: "", LastModifiedDate: "", Nickname: "", RecordType: "", Ref: "", TenantID: "", }, APIKey: w.APIKey, SagaID: w.SagaID, SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err } err = workflow.ExecuteActivity(ctx, NotifyContactActivity, &app.ContactChannelWrapper{ Obj: crm_models.Contact{ Description: w.Description, Email: w.Email, FirstName: w.FirstName, LastName: w.LastName, MobilePhone: w.MobilePhone, Name: w.Name, Phone: w.Phone, Title: w.Title, }, APIKey: w.APIKey, SagaID: w.SagaID, SagaType: w.SagaType, }).Get(ctx, nil) if err != nil { return err } err = workflow.ExecuteActivity(ctx, NotifyLeadActivity, w).Get(ctx, nil) if err != nil { return err } return nil }