Lighter Objects

v0.1.26 v0.1.26
Vernon Keenan 2021-01-20 19:04:43 -08:00
parent 89f6c0a13a
commit a12863e619
4 changed files with 26 additions and 96 deletions

View File

@ -4,34 +4,6 @@ import (
"database/sql"
)
// LeadActivityWrapper wraps the object with workflow params
type LeadActivityWrapper struct {
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
type Lead struct {
ID string

View File

@ -67,7 +67,7 @@ func StoreContactActivity(ctx workflow.Context, w app.ContactActivityWrapper) er
}
// NotifyContactActivity sends an email to a new lead
func NotifyContactActivity(ctx context.Context, w app.ContactActivityWrapper) error { //nolint:dupl,gocritic,lll // todo #2 need email templates
func NotifyContactActivity(ctx context.Context, w app.ContactActivityWrapper) error { //nolint:gocritic,lll // todo #2 need email templates
sugar.Info("workflow.notifyContact: 📥")
var buf bytes.Buffer
const textBody = `

View File

@ -9,39 +9,36 @@ import (
"code.tnxs.net/taxnexus/lib/api/crm/crm_models"
"code.tnxs.net/taxnexus/lib/api/workflow/workflow_client/outgoing_email_message"
"code.tnxs.net/taxnexus/lib/api/workflow/workflow_models"
"code.tnxs.net/taxnexus/lib/app"
httptransport "github.com/go-openapi/runtime/client"
"go.temporal.io/sdk/workflow"
)
// NewLeadActivityWrapper wraps the object with workflow params
type NewLeadActivityWrapper struct {
APIKey string
SagaID string
SagaType string
//
Company string
Description string
Email string
FirstName string
LastName string
UTMSource string
}
// StoreLeadActivity posts a new lead object to datastore
func StoreLeadActivity(ctx workflow.Context, w app.LeadActivityWrapper) error { //nolint:gocritic // don't care
func StoreLeadActivity(ctx workflow.Context, w NewLeadActivityWrapper) 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,
Name: w.FirstName + " " + w.LastName,
UTMSource: w.UTMSource,
UTMTerm: w.UTMTerm,
Website: w.Website,
Name: w.Name,
}
postLeadParams := leads.NewPostLeadsParamsWithTimeout(postTimeout)
if obj.Name == "" {
obj.Name = obj.FirstName + " " + obj.LastName
}
postLeadParams.LeadRequest = &crm_models.LeadRequest{
Data: []*crm_models.Lead{obj},
}
@ -59,7 +56,7 @@ func StoreLeadActivity(ctx workflow.Context, w app.LeadActivityWrapper) error {
}
// NotifyLeadActivity sends an email to a new lead
func NotifyLeadActivity(ctx context.Context, w app.LeadActivityWrapper) error { //nolint:dupl,gocritic,lll // todo #2 need email templates
func NotifyLeadActivity(ctx context.Context, w NewLeadActivityWrapper) error { //nolint:gocritic,lll // todo #2 need email templates
sugar.Info("workflow.notifyLead: 📥")
var buf bytes.Buffer
const textBody = `
@ -83,7 +80,7 @@ Alert! New Lead Inquiry from Taxnexus.io website.
emailParams.OutgoingEmailMessageRequest = &workflow_models.OutgoingEmailMessageRequest{
Data: []*workflow_models.OutgoingEmailMessage{
{
Subject: "New lead from " + w.Name,
Subject: "New lead from " + w.FirstName + " " + w.LastName,
ValidatedFromAddress: "support@taxnexus.net",
ToAddress: "info@taxnexus.net",
FromName: "Taxnexus Onboarding",

View File

@ -3,7 +3,6 @@ package rules
import (
"time"
"code.tnxs.net/taxnexus/lib/app"
"go.temporal.io/sdk/temporal"
temporal_workflow "go.temporal.io/sdk/workflow"
)
@ -14,57 +13,19 @@ type NewLeadWorkflowWrapper struct {
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
sugar.Info("rules.NewLeadWorkflow: 📥")
sugar.Debugf("rules.NewLeadWorkflow: wrapper: %v", w)
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,
}
transferDetails := NewLeadActivityWrapper(w)
retryPolicy := &temporal.RetryPolicy{
InitialInterval: time.Second,
MaximumInterval: time.Minute,