diff --git a/app/account.go b/app/account.go index 20a40c8..d2603ba 100644 --- a/app/account.go +++ b/app/account.go @@ -2,16 +2,54 @@ package app import ( "database/sql" - - "code.tnxs.net/taxnexus/lib/api/crm/crm_models" ) // AccountActivityWrapper wraps the object with workflow params type AccountActivityWrapper struct { - Obj crm_models.Account APIKey string SagaID string SagaType string + // + AccountSource string + AdministrativeLevel string + BillingAddress Address + BillingContactID string + BillingPreference string + BusinessAddress Address + CannabisCustomer bool + CompanyID string + CoordinateID string + CustomerID string + CustomerPriority string + DBA string + DefaultAddress Address + DefaultBackendID string + DefaultDeliveryContactID string + DefaultEndUserID string + Description string + EIN string + Email string + EnrollmentStatus string + Fax string + ISPCustomer bool + MSPCustomer bool + Name string + OrderContactID string + OrderEmail string + OwnerID string + ParentID string + Phone string + PlaceID string + PreparerID string + RatingEngineID string + Ref string + ShippingAddress Address + ShippingContactID string + Site string + TelecomCustomer bool + TenantID string + Type string + Website string } // Account is a DB struct diff --git a/app/company.go b/app/company.go index 2fcb565..6557f63 100644 --- a/app/company.go +++ b/app/company.go @@ -2,16 +2,45 @@ package app import ( "database/sql" - - "code.tnxs.net/taxnexus/lib/api/crm/crm_models" ) // CompanyActivityWrapper wraps the object with workflow params type CompanyActivityWrapper struct { - Obj crm_models.Company APIKey string SagaID string SagaType string + // + AccountID string + AccountNumberPrefix string + BillingAddress Address + BillingAdvice string + BillingContactID string + BillingEmail string + BillingPhone string + BillingWebsite string + CoaTemplateID string + ColorAccent1 string + ColorAccent2 string + ColorPrimary string + CurrentPeriodID string + CustomerSuccessID string + DefaultAddress Address + DefaultCompany bool + FontBody string + FontHeading string + FontHeadingNarrow string + FontLink string + FontMono string + International bool + LastAccountNumber int64 + LastTaxtypeNumber int64 + Logo string + Name string + OwnerID string + PreparerID string + PricebookID string + TenantID string + UserTechLeadID string } // Company is a DB struct diff --git a/app/contact.go b/app/contact.go index cb68014..0ce25a4 100644 --- a/app/contact.go +++ b/app/contact.go @@ -2,8 +2,6 @@ package app import ( "database/sql" - - "code.tnxs.net/taxnexus/lib/api/crm/crm_models" ) // NewContactActivity is an activity identifier @@ -11,10 +9,38 @@ const NewContactActivity = "NEW_CONTACT_ACTIVITY" // ContactActivityWrapper wraps the object with workflow params type ContactActivityWrapper struct { - Obj crm_models.Contact APIKey string SagaID string SagaType string + // + AccountID string + AssistantName string + AssistantPhone string + BirthDate string + Department string + Description string + Email string + FirstName string + HomePhone string + LastName string + LeadSource string + Level string + LinkedIn string + MailingAddress Address + MobilePhone string + Name string + OtherAddress Address + OtherPhone string + OwnerID string + PersonalEmail string + Phone string + PhotoURL string + Ref string + ReportsToID string + Salutation string + Status string + Title string + Type string } // Contact is a first-class object diff --git a/app/lead.go b/app/lead.go index 569d5cf..c03c854 100644 --- a/app/lead.go +++ b/app/lead.go @@ -2,16 +2,34 @@ package app import ( "database/sql" - - "code.tnxs.net/taxnexus/lib/api/crm/crm_models" ) // LeadActivityWrapper wraps the object with workflow params type LeadActivityWrapper struct { - Obj crm_models.Lead APIKey string SagaID string SagaType string + // + Address Address + Company string + Description string + Email string + FirstName string + LastName string + MobilePhone string + Name string + Phone string + RefererURL string + Status string + TenantID string + Title string + Type string + UTMCampaign string + UTMContent string + UTMMedium string + UTMSource string + UTMTerm string + Website string } // Lead is a first-class object type diff --git a/app/paymentmethod.go b/app/paymentmethod.go index 8376a65..f76edfe 100644 --- a/app/paymentmethod.go +++ b/app/paymentmethod.go @@ -2,16 +2,34 @@ package app import ( "database/sql" - - "code.tnxs.net/taxnexus/lib/api/ops/ops_models" ) // PaymentMethodActivityWrapper wraps the object with workflow params type PaymentMethodActivityWrapper struct { - Obj ops_models.PaymentMethod APIKey string SagaID string SagaType string + // + AccountID string + AchAccountType string + AchBankAccount string + AchRouting string + Active bool + Autopay bool + BankName string + BillingContactID string + CCnumber string + CCtype string + ContractID string + Default bool + ExpirationMonth string + ExpirationYear string + Gateway string + GatewayKey string + Nickname string + RecordType string + Ref string + TenantID string } // PaymentMethod is a first class object type diff --git a/app/tenant.go b/app/tenant.go index a4042d1..c6fdd9e 100644 --- a/app/tenant.go +++ b/app/tenant.go @@ -2,16 +2,23 @@ package app import ( "database/sql" - - "code.tnxs.net/taxnexus/lib/api/devops/devops_models" ) // TenantActivityWrapper wraps the object with workflow params type TenantActivityWrapper struct { - Obj devops_models.Tenant APIKey string SagaID string SagaType string + // + AccountID string + Active bool + Databases []Database + Roles []Role + Status string + TenantName string + TenantUsers []TenantUser + Type string + Version string } // Tenant is a first class object type diff --git a/rules/account.go b/rules/account.go index c78ab37..5212a2d 100644 --- a/rules/account.go +++ b/rules/account.go @@ -13,9 +13,51 @@ const StoreAccountActivityID = "STORE_ACCOUNT_ACTIVITY" // StoreAccountActivity posts a new account object to datastore func StoreAccountActivity(ctx workflow.Context, w app.AccountActivityWrapper) error { //nolint:gocritic // what we want + obj := &crm_models.Account{ + AccountSource: w.AccountSource, + AdministrativeLevel: w.AdministrativeLevel, + BillingAddress: w.BillingAddress.MarshalToCrm(), + BillingContactID: w.BillingContactID, + BillingPreference: w.BillingPreference, + BusinessAddress: w.BusinessAddress.MarshalToCrm(), + CannabisCustomer: w.CannabisCustomer, + CompanyID: w.CompanyID, + CoordinateID: w.CoordinateID, + CustomerID: w.CustomerID, + CustomerPriority: w.CustomerPriority, + DBA: w.DBA, + DefaultAddress: w.DefaultAddress.MarshalToCrm(), + DefaultBackendID: w.DefaultBackendID, + DefaultDeliveryContactID: w.DefaultDeliveryContactID, + DefaultEndUserID: w.DefaultEndUserID, + Description: w.Description, + EIN: w.EIN, + Email: w.Email, + EnrollmentStatus: w.EnrollmentStatus, + Fax: w.Fax, + ISPCustomer: w.ISPCustomer, + MSPCustomer: w.MSPCustomer, + Name: w.Name, + OrderContactID: w.OrderContactID, + OrderEmail: w.OrderEmail, + OwnerID: w.OwnerID, + ParentID: w.ParentID, + Phone: w.Phone, + PlaceID: w.PlaceID, + PreparerID: w.PreparerID, + RatingEngineID: w.RatingEngineID, + Ref: w.Ref, + ShippingAddress: w.ShippingAddress.MarshalToCrm(), + Site: w.Site, + TelecomCustomer: w.TelecomCustomer, + TenantID: w.TenantID, + Type: w.Type, + Website: w.Website, + } + postAccountParams := accounts.NewPostAccountsParamsWithTimeout(postTimeout) postAccountParams.AccountRequest = &crm_models.AccountRequest{ - Data: []*crm_models.Account{&w.Obj}, + Data: []*crm_models.Account{obj}, } _, err := crmClient.Accounts.PostAccounts( postAccountParams, diff --git a/rules/contact.go b/rules/contact.go index 0f14bdb..44d12be 100644 --- a/rules/contact.go +++ b/rules/contact.go @@ -16,12 +16,42 @@ import ( // StoreContactActivity posts a new contact object to datastore func StoreContactActivity(ctx workflow.Context, w app.ContactActivityWrapper) error { //nolint:gocritic // what we want - postContactParams := contacts.NewPostContactsParamsWithTimeout(postTimeout) - if w.Obj.Name == "" { - w.Obj.Name = w.Obj.FirstName + " " + w.Obj.LastName + obj := &crm_models.Contact{ + AccountID: w.AccountID, + AssistantName: w.AssistantName, + AssistantPhone: w.AssistantPhone, + BirthDate: w.BirthDate, + Department: w.Department, + Description: w.Description, + Email: w.Email, + FirstName: w.FirstName, + HomePhone: w.HomePhone, + LastName: w.LastName, + LeadSource: w.LeadSource, + Level: w.Level, + LinkedIn: w.LinkedIn, + MobilePhone: w.MobilePhone, + Name: w.Name, + OtherPhone: w.OtherPhone, + OwnerID: w.OwnerID, + PersonalEmail: w.PersonalEmail, + Phone: w.Phone, + PhotoURL: w.PhotoURL, + Ref: w.Ref, + ReportsToID: w.ReportsToID, + Salutation: w.Salutation, + Status: w.Status, + Title: w.Title, + Type: w.Type, + MailingAddress: w.MailingAddress.MarshalToCrm(), + OtherAddress: w.OtherAddress.MarshalToCrm(), } + if obj.Name == "" { + obj.Name = obj.FirstName + " " + obj.LastName + } + postContactParams := contacts.NewPostContactsParamsWithTimeout(postTimeout) postContactParams.ContactsRequest = &crm_models.ContactRequest{ - Data: []*crm_models.Contact{&w.Obj}, + Data: []*crm_models.Contact{obj}, } _, err := crmClient.Contacts.PostContacts(postContactParams, httptransport.APIKeyAuth( @@ -61,7 +91,7 @@ Alert! New Contact Inquiry from Taxnexus.io website. emailParams.OutgoingEmailMessageRequest = &workflow_models.OutgoingEmailMessageRequest{ Data: []*workflow_models.OutgoingEmailMessage{ { - Subject: "New lead from " + w.Obj.Name, + Subject: "New lead from " + w.Name, ValidatedFromAddress: "support@taxnexus.net", ToAddress: "info@taxnexus.net", FromName: "Taxnexus Onboarding", diff --git a/rules/lead.go b/rules/lead.go index 233ddb0..d5d10d2 100644 --- a/rules/lead.go +++ b/rules/lead.go @@ -15,13 +15,35 @@ import ( ) // StoreLeadActivity posts a new lead object to datastore -func StoreLeadActivity(ctx workflow.Context, w app.LeadActivityWrapper) error { //nolint:gocritic // what we want +func StoreLeadActivity(ctx workflow.Context, w app.LeadActivityWrapper) error { //nolint:gocritic // don't care + obj := &crm_models.Lead{ + Address: w.Address.MarshalToCrm(), + Company: w.Company, + Description: w.Description, + Email: w.Email, + FirstName: w.FirstName, + LastName: w.LastName, + MobilePhone: w.MobilePhone, + 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, + Name: w.Name, + } postLeadParams := leads.NewPostLeadsParamsWithTimeout(postTimeout) - if w.Obj.Name == "" { - w.Obj.Name = w.Obj.FirstName + " " + w.Obj.LastName + if obj.Name == "" { + obj.Name = obj.FirstName + " " + obj.LastName } postLeadParams.LeadRequest = &crm_models.LeadRequest{ - Data: []*crm_models.Lead{&w.Obj}, + Data: []*crm_models.Lead{obj}, } _, err := crmClient.Leads.PostLeads(postLeadParams, httptransport.APIKeyAuth( @@ -61,7 +83,7 @@ Alert! New Lead Inquiry from Taxnexus.io website. emailParams.OutgoingEmailMessageRequest = &workflow_models.OutgoingEmailMessageRequest{ Data: []*workflow_models.OutgoingEmailMessage{ { - Subject: "New lead from " + w.Obj.Name, + Subject: "New lead from " + w.Name, ValidatedFromAddress: "support@taxnexus.net", ToAddress: "info@taxnexus.net", FromName: "Taxnexus Onboarding", diff --git a/rules/new-developer.go b/rules/new-developer.go index c7c5bee..e64e462 100644 --- a/rules/new-developer.go +++ b/rules/new-developer.go @@ -3,8 +3,6 @@ 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" ) @@ -39,51 +37,17 @@ func NewDeveloperWorkflow(ctx workflow.Context, w NewDeveloperWorkflowWrapper) e err := workflow.ExecuteActivity(ctx, StoreContactActivity, app.ContactActivityWrapper{ - 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, + 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 @@ -91,93 +55,13 @@ func NewDeveloperWorkflow(ctx workflow.Context, w NewDeveloperWorkflowWrapper) e err = workflow.ExecuteActivity(ctx, StoreAccountActivity, &app.AccountActivityWrapper{ - 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, + // + Description: w.Description, + Email: w.Email, + Name: w.AccountName, }).Get(ctx, nil) if err != nil { return err @@ -185,37 +69,30 @@ func NewDeveloperWorkflow(ctx workflow.Context, w NewDeveloperWorkflowWrapper) e err = workflow.ExecuteActivity(ctx, StorePaymentMethodActivity, &app.PaymentMethodActivityWrapper{ - 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, + // + AccountID: "todo fix this", + AchAccountType: "", + AchBankAccount: "", + AchRouting: "", + Active: false, + Autopay: false, + BankName: "", + BillingContactID: "", + CCnumber: "", + CCtype: "", + ContractID: "", + Default: false, + ExpirationMonth: "", + ExpirationYear: "", + Gateway: "", + GatewayKey: "", + Nickname: "", + RecordType: "", + Ref: "", + TenantID: "", }).Get(ctx, nil) if err != nil { return err @@ -223,19 +100,18 @@ func NewDeveloperWorkflow(ctx workflow.Context, w NewDeveloperWorkflowWrapper) e err = workflow.ExecuteActivity(ctx, NotifyContactActivity, &app.ContactActivityWrapper{ - 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, + // + Description: w.Description, + Email: w.Email, + FirstName: w.FirstName, + LastName: w.LastName, + MobilePhone: w.MobilePhone, + Name: w.Name, + Phone: w.Phone, + Title: w.Title, }).Get(ctx, nil) if err != nil { return err diff --git a/rules/new-lead.go b/rules/new-lead.go index 9652aa2..b4d0722 100644 --- a/rules/new-lead.go +++ b/rules/new-lead.go @@ -3,7 +3,6 @@ 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" ) @@ -41,30 +40,27 @@ type NewLeadWorkflowWrapper struct { // NewLeadWorkflow is a Temporal workflow func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) error { //nolint:gocritic // don't care - obj := crm_models.Lead{ + obj := 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, - 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, + 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, } ctx = temporal_workflow. WithActivityOptions( @@ -76,12 +72,8 @@ func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) er ExecuteActivity( ctx, StoreLeadActivity, - app.LeadActivityWrapper{ - Obj: obj, - SagaID: w.SagaID, - SagaType: w.SagaType, - APIKey: w.APIKey, - }).Get(ctx, nil) + obj, + ).Get(ctx, nil) if err != nil { return err } @@ -89,10 +81,8 @@ func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) er ExecuteActivity( ctx, NotifyLeadActivity, - app.LeadActivityWrapper{ - Obj: obj, - APIKey: w.APIKey, - }).Get(ctx, nil) + obj, + ).Get(ctx, nil) if err != nil { return err } diff --git a/rules/paymentmethod.go b/rules/paymentmethod.go index 0558972..b158043 100644 --- a/rules/paymentmethod.go +++ b/rules/paymentmethod.go @@ -9,13 +9,32 @@ import ( ) // StorePaymentMethodActivity posts a new paymentmethod object to datastore -func StorePaymentMethodActivity( - ctx workflow.Context, - w app.PaymentMethodActivityWrapper, //nolint:gocritic // what we want -) error { +func StorePaymentMethodActivity(ctx workflow.Context, w app.PaymentMethodActivityWrapper) error { //nolint:gocritic // don't care postPaymentMethodParams := payment_method.NewPostPaymentMethodsParamsWithTimeout(postTimeout) + obj := &ops_models.PaymentMethod{ + AccountID: w.AccountID, + AchAccountType: w.AchAccountType, + AchBankAccount: w.AchBankAccount, + AchRouting: w.AchRouting, + Active: w.Active, + Autopay: w.Autopay, + BankName: w.BankName, + BillingContactID: w.BillingContactID, + CCnumber: w.CCnumber, + CCtype: w.CCtype, + ContractID: w.ContractID, + Default: w.Default, + ExpirationMonth: w.ExpirationMonth, + ExpirationYear: w.ExpirationYear, + Gateway: w.Gateway, + GatewayKey: w.GatewayKey, + Nickname: w.Nickname, + RecordType: w.RecordType, + Ref: w.Ref, + TenantID: w.TenantID, + } postPaymentMethodParams.PaymentMethodRequest = &ops_models.PaymentMethodRequest{ - Data: []*ops_models.PaymentMethod{&w.Obj}, + Data: []*ops_models.PaymentMethod{obj}, } _, err := opsClient.PaymentMethod.PostPaymentMethods(postPaymentMethodParams, httptransport.APIKeyAuth(