parent
105ade2f84
commit
37245451a3
|
@ -117,8 +117,8 @@ func UnMarshalAccount(s *crm_models.Account) *Account { //nolint:funlen // too b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalToSwagger encodes a first class object to swagger
|
// Marshal encodes a first class object to swagger
|
||||||
func (obj *Account) MarshalToSwagger() *crm_models.Account {
|
func (obj *Account) Marshal() *crm_models.Account {
|
||||||
return &crm_models.Account{
|
return &crm_models.Account{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
AccountNumber: obj.AccountNumber,
|
AccountNumber: obj.AccountNumber,
|
||||||
|
|
|
@ -6,9 +6,6 @@ import (
|
||||||
"code.tnxs.net/taxnexus/lib/api/crm/crm_models"
|
"code.tnxs.net/taxnexus/lib/api/crm/crm_models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewAccountActivity is an activity identifier
|
|
||||||
const NewAccountActivity = "NEW_ACCOUNT_ACTIVITY"
|
|
||||||
|
|
||||||
// AccountChannelWrapper wraps the object with workflow params
|
// AccountChannelWrapper wraps the object with workflow params
|
||||||
type AccountChannelWrapper struct {
|
type AccountChannelWrapper struct {
|
||||||
Obj crm_models.Account
|
Obj crm_models.Account
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalAccountingRule decodes swagger to first class object
|
||||||
func UnMarshalAccountingRule(s *ledger_models.AccountingRule) *AccountingRule {
|
func UnMarshalAccountingRule(s *ledger_models.AccountingRule) *AccountingRule {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -43,6 +44,8 @@ func UnMarshalAccountingRule(s *ledger_models.AccountingRule) *AccountingRule {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *AccountingRule) MarshalToSwagger() *ledger_models.AccountingRule {
|
func (obj *AccountingRule) MarshalToSwagger() *ledger_models.AccountingRule {
|
||||||
return &ledger_models.AccountingRule{
|
return &ledger_models.AccountingRule{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalAccountingRuleset decodes swagger to first class object
|
||||||
func UnMarshalAccountingRuleset(s *ledger_models.AccountingRuleset) *AccountingRuleset {
|
func UnMarshalAccountingRuleset(s *ledger_models.AccountingRuleset) *AccountingRuleset {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -37,6 +38,8 @@ func UnMarshalAccountingRuleset(s *ledger_models.AccountingRuleset) *AccountingR
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *AccountingRuleset) MarshalToSwagger() *ledger_models.AccountingRuleset {
|
func (obj *AccountingRuleset) MarshalToSwagger() *ledger_models.AccountingRuleset {
|
||||||
theItems := []*ledger_models.AccountingRulesetItem{}
|
theItems := []*ledger_models.AccountingRulesetItem{}
|
||||||
for _, itm := range obj.Items {
|
for _, itm := range obj.Items {
|
||||||
|
|
|
@ -8,13 +8,14 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UnMarshalAppLog(s *workflow_models.AppLog) *AppLog {
|
// UnMarshalLog decodes swagger to first class object
|
||||||
|
func UnMarshalLog(s *workflow_models.AppLog) *Log {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
}
|
}
|
||||||
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
||||||
sourceTimestamp, e1 := time.Parse(dateTimeFormat, s.SourceTimestamp)
|
sourceTimestamp, e1 := time.Parse(dateTimeFormat, s.SourceTimestamp)
|
||||||
return &AppLog{
|
return &Log{
|
||||||
AccountID: s.AccountID,
|
AccountID: s.AccountID,
|
||||||
CompanyID: s.CompanyID,
|
CompanyID: s.CompanyID,
|
||||||
CreatedByID: s.CreatedByID,
|
CreatedByID: s.CreatedByID,
|
||||||
|
@ -35,7 +36,8 @@ func UnMarshalAppLog(s *workflow_models.AppLog) *AppLog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj *AppLog) MarshalToSwagger() *workflow_models.AppLog {
|
// MarshalToSwagger encodes first class object
|
||||||
|
func (obj *Log) MarshalToSwagger() *workflow_models.AppLog {
|
||||||
return &workflow_models.AppLog{
|
return &workflow_models.AppLog{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
AccountID: obj.AccountID,
|
AccountID: obj.AccountID,
|
||||||
|
|
67
app/auth0.go
67
app/auth0.go
|
@ -7,8 +7,75 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/auth0/auth0_client/user"
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/auth0/auth0_models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetAuth0UserByEmail looks up Auth0 user by email
|
||||||
|
func GetAuth0UserByEmail(email string) (string, error) {
|
||||||
|
sugar.Info("app.GetAuth0UserByEmail: 📥")
|
||||||
|
authToken := GetAuth0AccessToken()
|
||||||
|
if authToken == "" {
|
||||||
|
return "", fmt.Errorf("app.GetAuth0UserByEmail: 💣⛔ Error obtaining bearer token")
|
||||||
|
}
|
||||||
|
auth0Params := user.NewGetUserByEmailParamsWithTimeout(getTimeout)
|
||||||
|
auth0Params.Authorization = "Bearer " + authToken
|
||||||
|
auth0Params.Email = email
|
||||||
|
auth0Response, err := auth0Client.User.GetUserByEmail(auth0Params)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if len(auth0Response.Payload) == 0 {
|
||||||
|
sugar.Infof("app.GetAuth0UserByEmail: 👍📤 %s not found", email)
|
||||||
|
return constNotFound, nil
|
||||||
|
}
|
||||||
|
sugar.Infof("app.GetAuth0UserByEmail: 👍📤 %s found %s", email, auth0Response.Payload[0].UserID)
|
||||||
|
return auth0Response.Payload[0].UserID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateNewAuth0User creates a new Auth0 User
|
||||||
|
func CreateNewAuth0User(newUser *NewAuth0User) (string, error) {
|
||||||
|
sugar.Info("app.CreateNewAuth0User: 📥")
|
||||||
|
authToken := GetAuth0AccessToken()
|
||||||
|
if authToken == "" {
|
||||||
|
return "", fmt.Errorf("app.CreateNewAuth0User: 💣⛔ Error obtaining bearer token")
|
||||||
|
}
|
||||||
|
auth0Params := user.NewPostUsersParamsWithTimeout(postTimeout)
|
||||||
|
auth0Params.Authorization = "Bearer " + authToken
|
||||||
|
auth0Params.UserRequest.Users = []*auth0_models.NewUser{
|
||||||
|
{
|
||||||
|
Email: newUser.Email,
|
||||||
|
Name: newUser.Name,
|
||||||
|
FamilyName: newUser.FamilyName,
|
||||||
|
GivenName: newUser.GivenName,
|
||||||
|
Nickname: newUser.Nickname,
|
||||||
|
Password: newUser.Password,
|
||||||
|
PhoneNumber: newUser.PhoneNumber,
|
||||||
|
Blocked: newUser.Blocked,
|
||||||
|
Connection: newUser.Connection,
|
||||||
|
EmailVerified: newUser.EmailVerified,
|
||||||
|
PhoneVerified: newUser.PhoneVerified,
|
||||||
|
Picture: newUser.Picture,
|
||||||
|
UserID: newUser.UserID,
|
||||||
|
Username: newUser.Username,
|
||||||
|
VerifyEmail: newUser.VerifyEmail,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_, err := auth0Client.User.PostUsers(auth0Params)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
auth0UserID, err := GetAuth0UserByEmail(newUser.Email)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if auth0UserID != constNotFound {
|
||||||
|
return "", fmt.Errorf("app.CreateNewAuth0User: 💣⛔ Auth0 user exists: %s", auth0UserID)
|
||||||
|
}
|
||||||
|
return auth0UserID, nil
|
||||||
|
}
|
||||||
|
|
||||||
type auth0TokenResponse struct {
|
type auth0TokenResponse struct {
|
||||||
AccessToken string
|
AccessToken string
|
||||||
TokenType string
|
TokenType string
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalSwaggerAuthority decodes swagger to first class object
|
||||||
func UnMarshalSwaggerAuthority(s *regs_models.Authority) *Authority {
|
func UnMarshalSwaggerAuthority(s *regs_models.Authority) *Authority {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -71,6 +72,8 @@ func UnMarshalSwaggerAuthority(s *regs_models.Authority) *Authority {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Authority) MarshalToSwagger() *regs_models.Authority {
|
func (obj *Authority) MarshalToSwagger() *regs_models.Authority {
|
||||||
return ®s_models.Authority{
|
return ®s_models.Authority{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalContact decodes swagger to first class object
|
||||||
func UnMarshalContact(s *crm_models.Contact) *Contact {
|
func UnMarshalContact(s *crm_models.Contact) *Contact {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -75,6 +76,8 @@ func UnMarshalContact(s *crm_models.Contact) *Contact {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Contact) MarshalToSwagger() *crm_models.Contact {
|
func (obj *Contact) MarshalToSwagger() *crm_models.Contact {
|
||||||
return &crm_models.Contact{
|
return &crm_models.Contact{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalCountry decodes swagger to first class object
|
||||||
func UnMarshalCountry(s *geo_models.Country) *Country {
|
func UnMarshalCountry(s *geo_models.Country) *Country {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -58,6 +59,8 @@ func UnMarshalCountry(s *geo_models.Country) *Country {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Country) MarshalToSwagger() *geo_models.Country {
|
func (obj *Country) MarshalToSwagger() *geo_models.Country {
|
||||||
taxInstances := []*geo_models.TaxInstance{}
|
taxInstances := []*geo_models.TaxInstance{}
|
||||||
for _, itm := range obj.TaxInstances {
|
for _, itm := range obj.TaxInstances {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalCounty decodes swagger to first class object
|
||||||
func UnMarshalCounty(s *geo_models.County) *County {
|
func UnMarshalCounty(s *geo_models.County) *County {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -69,6 +70,8 @@ func UnMarshalCounty(s *geo_models.County) *County {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *County) MarshalToSwagger() *geo_models.County {
|
func (obj *County) MarshalToSwagger() *geo_models.County {
|
||||||
theInstances := []*geo_models.TaxInstance{}
|
theInstances := []*geo_models.TaxInstance{}
|
||||||
for _, itm := range obj.TaxInstances {
|
for _, itm := range obj.TaxInstances {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/geo/geo_models"
|
import "code.tnxs.net/taxnexus/lib/api/geo/geo_models"
|
||||||
|
|
||||||
|
// UnMarshalDomain decodes swagger to first class object
|
||||||
func UnMarshalDomain(swag *geo_models.Domain) *Domain {
|
func UnMarshalDomain(swag *geo_models.Domain) *Domain {
|
||||||
return &Domain{
|
return &Domain{
|
||||||
Description: swag.Description,
|
Description: swag.Description,
|
||||||
|
@ -10,6 +11,8 @@ func UnMarshalDomain(swag *geo_models.Domain) *Domain {
|
||||||
Name: swag.Name,
|
Name: swag.Name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Domain) MarshalToSwagger() *geo_models.Domain {
|
func (obj *Domain) MarshalToSwagger() *geo_models.Domain {
|
||||||
return &geo_models.Domain{
|
return &geo_models.Domain{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/workflow/workflow_models"
|
import "code.tnxs.net/taxnexus/lib/api/workflow/workflow_models"
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *EmailMessage) MarshalToSwagger() *workflow_models.EmailMessage {
|
func (obj *EmailMessage) MarshalToSwagger() *workflow_models.EmailMessage {
|
||||||
headers := &workflow_models.Headers{}
|
headers := &workflow_models.Headers{}
|
||||||
// for _, itm := range obj.Headers {
|
// for _, itm := range obj.Headers {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalSwaggerFiling decodes swagger to first class object
|
||||||
func UnMarshalSwaggerFiling(s *regs_models.Filing) *Filing {
|
func UnMarshalSwaggerFiling(s *regs_models.Filing) *Filing {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -78,8 +79,9 @@ func UnMarshalSwaggerFiling(s *regs_models.Filing) *Filing {
|
||||||
Valid: e3 == nil,
|
Valid: e3 == nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Filing) MarshalToSwagger() *regs_models.Filing {
|
func (obj *Filing) MarshalToSwagger() *regs_models.Filing {
|
||||||
return ®s_models.Filing{
|
return ®s_models.Filing{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
package app
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalFilingType decodes swagger to first class object
|
||||||
func UnMarshalFilingType(s *regs_models.FilingType) *FilingType {
|
func UnMarshalFilingType(s *regs_models.FilingType) *FilingType {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -30,15 +31,15 @@ func UnMarshalFilingType(s *regs_models.FilingType) *FilingType {
|
||||||
}
|
}
|
||||||
for _, itm := range s.DueDates {
|
for _, itm := range s.DueDates {
|
||||||
dueDates = []*FilingScheduleItem{}
|
dueDates = []*FilingScheduleItem{}
|
||||||
dueDate, e0 := time.Parse(dateTimeFormat, itm.DueDate)
|
dueDate, e2 := time.Parse(dateTimeFormat, itm.DueDate)
|
||||||
if e0 != nil {
|
if e2 != nil {
|
||||||
dueDate, e0 = time.Parse(dateFormatAlt, itm.DueDate)
|
dueDate, e2 = time.Parse(dateFormatAlt, itm.DueDate)
|
||||||
}
|
}
|
||||||
dueDates = append(dueDates, &FilingScheduleItem{
|
dueDates = append(dueDates, &FilingScheduleItem{
|
||||||
Description: itm.Description,
|
Description: itm.Description,
|
||||||
DueDate: sql.NullTime{
|
DueDate: sql.NullTime{
|
||||||
Time: dueDate,
|
Time: dueDate,
|
||||||
Valid: e0 == nil,
|
Valid: e2 == nil,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -78,6 +79,7 @@ func UnMarshalFilingType(s *regs_models.FilingType) *FilingType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *FilingType) MarshalToSwagger() *regs_models.FilingType {
|
func (obj *FilingType) MarshalToSwagger() *regs_models.FilingType {
|
||||||
var instances []*regs_models.FilingTypeInstance
|
var instances []*regs_models.FilingTypeInstance
|
||||||
if obj.Instances != nil {
|
if obj.Instances != nil {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
package app
|
|
@ -0,0 +1 @@
|
||||||
|
package app
|
|
@ -45,6 +45,7 @@ func UnMarshalGlAccount(s *ledger_models.GlAccount) *GlAccount {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *GlAccount) MarshalToSwagger() *ledger_models.GlAccount {
|
func (obj *GlAccount) MarshalToSwagger() *ledger_models.GlAccount {
|
||||||
return &ledger_models.GlAccount{
|
return &ledger_models.GlAccount{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalGlBalance decodes swagger to first class object
|
||||||
func UnMarshalGlBalance(s *ledger_models.GlBalance) *GlBalance {
|
func UnMarshalGlBalance(s *ledger_models.GlBalance) *GlBalance {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -46,6 +47,8 @@ func UnMarshalGlBalance(s *ledger_models.GlBalance) *GlBalance {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *GlBalance) MarshalToSwagger() *ledger_models.GlBalance {
|
func (obj *GlBalance) MarshalToSwagger() *ledger_models.GlBalance {
|
||||||
return &ledger_models.GlBalance{
|
return &ledger_models.GlBalance{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
||||||
|
|
||||||
// Invoice unMarshal does validation in the Ops microservice only
|
// Invoice unMarshal does validation in the Ops microservice only
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Invoice) MarshalToSwagger() *ops_models.Invoice { //nolint:funlen // big object
|
func (obj *Invoice) MarshalToSwagger() *ops_models.Invoice { //nolint:funlen // big object
|
||||||
var items []*ops_models.InvoiceItem
|
var items []*ops_models.InvoiceItem
|
||||||
if obj.Items != nil {
|
if obj.Items != nil {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
||||||
|
|
||||||
// Invoice unMarshal does validation in the Ops microservice only
|
// Invoice unMarshal does validation in the Ops microservice only
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *InvoiceItem) MarshalToSwagger() *ops_models.InvoiceItem {
|
func (obj *InvoiceItem) MarshalToSwagger() *ops_models.InvoiceItem {
|
||||||
return &ops_models.InvoiceItem{
|
return &ops_models.InvoiceItem{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalJournalEntry decodes swagger to first class object
|
||||||
func UnMarshalJournalEntry(s *ledger_models.JournalEntry) *JournalEntry {
|
func UnMarshalJournalEntry(s *ledger_models.JournalEntry) *JournalEntry {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -60,6 +61,7 @@ func UnMarshalJournalEntry(s *ledger_models.JournalEntry) *JournalEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *JournalEntry) MarshalToSwagger() *ledger_models.JournalEntry {
|
func (obj *JournalEntry) MarshalToSwagger() *ledger_models.JournalEntry {
|
||||||
swag := &ledger_models.JournalEntry{
|
swag := &ledger_models.JournalEntry{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
@ -84,7 +86,7 @@ func (obj *JournalEntry) MarshalToSwagger() *ledger_models.JournalEntry {
|
||||||
TenantID: obj.TenantID,
|
TenantID: obj.TenantID,
|
||||||
}
|
}
|
||||||
for _, itm := range obj.Items {
|
for _, itm := range obj.Items {
|
||||||
swag.Items = append(swag.Items, itm.MarshalToSwgger())
|
swag.Items = append(swag.Items, itm.MarshalToSwagger())
|
||||||
}
|
}
|
||||||
return swag
|
return swag
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ func UnMarshalJournalItem(s *ledger_models.JournalItem) *JournalItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj *JournalItem) MarshalToSwgger() *ledger_models.JournalItem {
|
// MarshalToSwagger encodes first class object
|
||||||
|
func (obj *JournalItem) MarshalToSwagger() *ledger_models.JournalItem {
|
||||||
return &ledger_models.JournalItem{
|
return &ledger_models.JournalItem{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
CreatedByID: obj.CreatedByID,
|
CreatedByID: obj.CreatedByID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalLead decodes swagger to first class object
|
||||||
func UnMarshalLead(s *crm_models.Lead) *Lead {
|
func UnMarshalLead(s *crm_models.Lead) *Lead {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -52,6 +53,7 @@ func UnMarshalLead(s *crm_models.Lead) *Lead {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Lead) MarshalToSwagger() *crm_models.Lead {
|
func (obj *Lead) MarshalToSwagger() *crm_models.Lead {
|
||||||
return &crm_models.Lead{
|
return &crm_models.Lead{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalLicense decodes swagger to first class object
|
||||||
func UnMarshalLicense(s *regs_models.License) *License {
|
func UnMarshalLicense(s *regs_models.License) *License {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -57,6 +58,8 @@ func UnMarshalLicense(s *regs_models.License) *License {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *License) MarshalToSwagger() *regs_models.License {
|
func (obj *License) MarshalToSwagger() *regs_models.License {
|
||||||
return ®s_models.License{
|
return ®s_models.License{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalLicenseType decodes swagger to first class object
|
||||||
func UnMarshalLicenseType(s *regs_models.LicenseType) *LicenseType {
|
func UnMarshalLicenseType(s *regs_models.LicenseType) *LicenseType {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -57,6 +58,7 @@ func UnMarshalLicenseType(s *regs_models.LicenseType) *LicenseType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *LicenseType) MarshalToSwagger() *regs_models.LicenseType {
|
func (obj *LicenseType) MarshalToSwagger() *regs_models.LicenseType {
|
||||||
var jurisdictions []*regs_models.GeoLicenseTypeInstance
|
var jurisdictions []*regs_models.GeoLicenseTypeInstance
|
||||||
if obj.Jurisdictions != nil {
|
if obj.Jurisdictions != nil {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"code.tnxs.net/taxnexus/lib/api/regs/regs_models"
|
"code.tnxs.net/taxnexus/lib/api/regs/regs_models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalNotebook decodes swagger to first class object
|
||||||
func UnMarshalNotebook(s *regs_models.Notebook) *Notebook {
|
func UnMarshalNotebook(s *regs_models.Notebook) *Notebook {
|
||||||
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
||||||
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
||||||
|
@ -23,7 +24,6 @@ func UnMarshalNotebook(s *regs_models.Notebook) *Notebook {
|
||||||
Title: itm.Title,
|
Title: itm.Title,
|
||||||
NotebookID: itm.NotebookID,
|
NotebookID: itm.NotebookID,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &Notebook{
|
return &Notebook{
|
||||||
|
@ -61,7 +61,9 @@ func UnMarshalNotebook(s *regs_models.Notebook) *Notebook {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (obj Notebook) MarshalToSwagger() *regs_models.Notebook {
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
|
func (obj *Notebook) MarshalToSwagger() *regs_models.Notebook {
|
||||||
var items []*regs_models.NotebookItem
|
var items []*regs_models.NotebookItem
|
||||||
if obj.Items != nil {
|
if obj.Items != nil {
|
||||||
items = []*regs_models.NotebookItem{}
|
items = []*regs_models.NotebookItem{}
|
||||||
|
@ -72,7 +74,6 @@ func (obj Notebook) MarshalToSwagger() *regs_models.Notebook {
|
||||||
Title: itm.Title,
|
Title: itm.Title,
|
||||||
NotebookID: itm.NotebookID,
|
NotebookID: itm.NotebookID,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ®s_models.Notebook{
|
return ®s_models.Notebook{
|
||||||
|
|
|
@ -8,13 +8,14 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalOrder decodes swagger to first class object
|
||||||
func UnMarshalOrder(s *ops_models.Order) *Order { //nolint:funlen // big object
|
func UnMarshalOrder(s *ops_models.Order) *Order { //nolint:funlen // big object
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
}
|
}
|
||||||
var items []*OrderItem
|
var items []*OrderItem
|
||||||
if s.Items != nil {
|
if s.Items != nil {
|
||||||
items = make([]*OrderItem, 5)
|
items = []*OrderItem{}
|
||||||
for _, itm := range s.Items {
|
for _, itm := range s.Items {
|
||||||
items = append(items, UnMarshalOrderItem(itm))
|
items = append(items, UnMarshalOrderItem(itm))
|
||||||
}
|
}
|
||||||
|
@ -137,6 +138,8 @@ func UnMarshalOrder(s *ops_models.Order) *Order { //nolint:funlen // big object
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Order) MarshalToSwagger() *ops_models.Order {
|
func (obj *Order) MarshalToSwagger() *ops_models.Order {
|
||||||
var items []*ops_models.OrderItem
|
var items []*ops_models.OrderItem
|
||||||
if obj.Items != nil {
|
if obj.Items != nil {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalOrderItem decodes swagger to first class object
|
||||||
func UnMarshalOrderItem(s *ops_models.OrderItem) *OrderItem {
|
func UnMarshalOrderItem(s *ops_models.OrderItem) *OrderItem {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -82,6 +83,7 @@ func UnMarshalOrderItem(s *ops_models.OrderItem) *OrderItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *OrderItem) MarshalToSwagger() *ops_models.OrderItem {
|
func (obj *OrderItem) MarshalToSwagger() *ops_models.OrderItem {
|
||||||
return &ops_models.OrderItem{
|
return &ops_models.OrderItem{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/workflow/workflow_models"
|
import "code.tnxs.net/taxnexus/lib/api/workflow/workflow_models"
|
||||||
|
|
||||||
|
// UnMarshalSwaggerOutgoingEmailMessage decodes swagger to first class object
|
||||||
func UnMarshalSwaggerOutgoingEmailMessage(s *workflow_models.OutgoingEmailMessage) *OutgoingEmailMessage {
|
func UnMarshalSwaggerOutgoingEmailMessage(s *workflow_models.OutgoingEmailMessage) *OutgoingEmailMessage {
|
||||||
return &OutgoingEmailMessage{
|
return &OutgoingEmailMessage{
|
||||||
ID: s.ID,
|
ID: s.ID,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/workflow/workflow_models"
|
import "code.tnxs.net/taxnexus/lib/api/workflow/workflow_models"
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *OutgoingEmailMessageReceipt) MarshalToSwagger() *workflow_models.EmailMessage {
|
func (obj *OutgoingEmailMessageReceipt) MarshalToSwagger() *workflow_models.EmailMessage {
|
||||||
return &workflow_models.EmailMessage{
|
return &workflow_models.EmailMessage{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -2,8 +2,8 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/stash/stash_models"
|
import "code.tnxs.net/taxnexus/lib/api/stash/stash_models"
|
||||||
|
|
||||||
|
// MarshalToDocument encodes first class object to swagger
|
||||||
func (obj *PDF) MarshalToDocument() *stash_models.Document {
|
func (obj *PDF) MarshalToDocument() *stash_models.Document {
|
||||||
|
|
||||||
return &stash_models.Document{
|
return &stash_models.Document{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
Filename: obj.Filename,
|
Filename: obj.Filename,
|
||||||
|
@ -13,6 +13,7 @@ func (obj *PDF) MarshalToDocument() *stash_models.Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnMarshalNewPDF decodes swagger to first class object
|
||||||
func UnMarshalNewPDF(swag *stash_models.NewPDF) *PDF {
|
func UnMarshalNewPDF(swag *stash_models.NewPDF) *PDF {
|
||||||
return &PDF{
|
return &PDF{
|
||||||
Description: swag.Description,
|
Description: swag.Description,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalPeriod decodes swagger to first class object
|
||||||
func UnMarshalPeriod(s *ledger_models.Period) *Period {
|
func UnMarshalPeriod(s *ledger_models.Period) *Period {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -51,6 +52,8 @@ func UnMarshalPeriod(s *ledger_models.Period) *Period {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Period) MarshalToSwagger() *ledger_models.Period {
|
func (obj *Period) MarshalToSwagger() *ledger_models.Period {
|
||||||
return &ledger_models.Period{
|
return &ledger_models.Period{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalPlace decodes swagger to first class object
|
||||||
func UnMarshalPlace(s *geo_models.Place) *Place {
|
func UnMarshalPlace(s *geo_models.Place) *Place {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -73,6 +74,8 @@ func UnMarshalPlace(s *geo_models.Place) *Place {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Place) MarshalToSwagger() *geo_models.Place {
|
func (obj *Place) MarshalToSwagger() *geo_models.Place {
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalPurchaseOrder decodes swagger to first class object
|
||||||
func UnMarshalPurchaseOrder(s *ops_models.PurchaseOrder) (*PurchaseOrder, error) { //nolint:funlen // big object
|
func UnMarshalPurchaseOrder(s *ops_models.PurchaseOrder) (*PurchaseOrder, error) { //nolint:funlen // big object
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -120,6 +121,8 @@ func UnMarshalPurchaseOrder(s *ops_models.PurchaseOrder) (*PurchaseOrder, error)
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *PurchaseOrder) MarshalToSwagger() *ops_models.PurchaseOrder {
|
func (obj *PurchaseOrder) MarshalToSwagger() *ops_models.PurchaseOrder {
|
||||||
var items []*ops_models.PurchaseOrderItem
|
var items []*ops_models.PurchaseOrderItem
|
||||||
if obj.Items != nil {
|
if obj.Items != nil {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalPurchaseOrderItem decodes swagger to first class object
|
||||||
func UnMarshalPurchaseOrderItem(s *ops_models.PurchaseOrderItem) *PurchaseOrderItem {
|
func UnMarshalPurchaseOrderItem(s *ops_models.PurchaseOrderItem) *PurchaseOrderItem {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -57,6 +58,8 @@ func UnMarshalPurchaseOrderItem(s *ops_models.PurchaseOrderItem) *PurchaseOrderI
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *PurchaseOrderItem) MarshalToSwagger() *ops_models.PurchaseOrderItem {
|
func (obj *PurchaseOrderItem) MarshalToSwagger() *ops_models.PurchaseOrderItem {
|
||||||
return &ops_models.PurchaseOrderItem{
|
return &ops_models.PurchaseOrderItem{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalProduct decodes swagger to first class object
|
||||||
func UnMarshalProduct(s *ops_models.Product) *Product {
|
func UnMarshalProduct(s *ops_models.Product) *Product {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -57,6 +58,8 @@ func UnMarshalProduct(s *ops_models.Product) *Product {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Product) MarshalToSwagger() *ops_models.Product {
|
func (obj *Product) MarshalToSwagger() *ops_models.Product {
|
||||||
return &ops_models.Product{
|
return &ops_models.Product{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Quote) MarshalToSwagger() *ops_models.Quote {
|
func (obj *Quote) MarshalToSwagger() *ops_models.Quote {
|
||||||
var items []*ops_models.QuoteItem
|
var items []*ops_models.QuoteItem
|
||||||
if obj.Items != nil {
|
if obj.Items != nil {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *QuoteItem) MarshalToSwagger() *ops_models.QuoteItem {
|
func (obj *QuoteItem) MarshalToSwagger() *ops_models.QuoteItem {
|
||||||
return &ops_models.QuoteItem{
|
return &ops_models.QuoteItem{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
package app
|
|
@ -0,0 +1 @@
|
||||||
|
package app
|
15
app/root.go
15
app/root.go
|
@ -3,7 +3,9 @@ package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/auth0/auth0_client"
|
||||||
"code.tnxs.net/taxnexus/lib/app/logger"
|
"code.tnxs.net/taxnexus/lib/app/logger"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -13,14 +15,17 @@ import (
|
||||||
var sugar *zap.SugaredLogger
|
var sugar *zap.SugaredLogger
|
||||||
var config = Configuration{}
|
var config = Configuration{}
|
||||||
var appViper = viper.New()
|
var appViper = viper.New()
|
||||||
|
var auth0Client = auth0_client.Default
|
||||||
|
var configured = false
|
||||||
|
|
||||||
|
const getTimeout = 6 * time.Minute
|
||||||
|
const postTimeout = 6 * time.Minute
|
||||||
|
const constNotFound = "not found"
|
||||||
const dateFormat = "2006-01-02"
|
const dateFormat = "2006-01-02"
|
||||||
const dateTimeFormat = "2006-01-02T15:04:05-0800"
|
const dateTimeFormat = "2006-01-02T15:04:05-0800"
|
||||||
const dateTimeFormatAlt = "2006-01-02 15:04:05"
|
const dateTimeFormatAlt = "2006-01-02 15:04:05"
|
||||||
const dateFormatAlt = "1/2/2006"
|
const dateFormatAlt = "1/2/2006"
|
||||||
|
|
||||||
var configured = false
|
|
||||||
|
|
||||||
// InitConfig exports the config initialization func
|
// InitConfig exports the config initialization func
|
||||||
func InitConfig(systemName string) {
|
func InitConfig(systemName string) {
|
||||||
if configured {
|
if configured {
|
||||||
|
@ -46,3 +51,9 @@ func InitConfig(systemName string) {
|
||||||
sugar.Debugf("app.InitConfig: 👍 📤 serviceAccounts: %d", len(config.ServiceAccounts))
|
sugar.Debugf("app.InitConfig: 👍 📤 serviceAccounts: %d", len(config.ServiceAccounts))
|
||||||
configured = true
|
configured = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FirstClassObject is a struct
|
||||||
|
type FirstClassObject interface {
|
||||||
|
Marshal() interface{}
|
||||||
|
UnMarshal() interface{}
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"code.tnxs.net/taxnexus/lib/api/geo/geo_models"
|
"code.tnxs.net/taxnexus/lib/api/geo/geo_models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalSwaggerState decodes swagger to first class object
|
||||||
func UnMarshalSwaggerState(s *geo_models.State) *State {
|
func UnMarshalSwaggerState(s *geo_models.State) *State {
|
||||||
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
||||||
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
||||||
|
@ -65,6 +66,7 @@ func UnMarshalSwaggerState(s *geo_models.State) *State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *State) MarshalToSwagger() *geo_models.State {
|
func (obj *State) MarshalToSwagger() *geo_models.State {
|
||||||
taxInstances := []*geo_models.TaxInstance{}
|
taxInstances := []*geo_models.TaxInstance{}
|
||||||
for _, itm := range obj.TaxInstances {
|
for _, itm := range obj.TaxInstances {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalSubmission decodes swagger to first class object
|
||||||
func UnMarshalSubmission(s *regs_models.Submission) *Submission {
|
func UnMarshalSubmission(s *regs_models.Submission) *Submission {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -57,6 +58,7 @@ func UnMarshalSubmission(s *regs_models.Submission) *Submission {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Submission) MarshalToSwagger() *regs_models.Submission {
|
func (obj *Submission) MarshalToSwagger() *regs_models.Submission {
|
||||||
return ®s_models.Submission{
|
return ®s_models.Submission{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -34,6 +34,8 @@ func UnMarshalTaxInstance(s *geo_models.TaxInstance) *TaxInstance {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *TaxInstance) MarshalToSwagger() *geo_models.TaxInstance {
|
func (obj *TaxInstance) MarshalToSwagger() *geo_models.TaxInstance {
|
||||||
return &geo_models.TaxInstance{
|
return &geo_models.TaxInstance{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalTaxnexusCode decodes swagger to first class object
|
||||||
func UnMarshalTaxnexusCode(s *geo_models.TaxnexusCode) *TaxnexusCode {
|
func UnMarshalTaxnexusCode(s *geo_models.TaxnexusCode) *TaxnexusCode {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -45,6 +46,8 @@ func UnMarshalTaxnexusCode(s *geo_models.TaxnexusCode) *TaxnexusCode {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *TaxnexusCode) MarshalToSwagger() *geo_models.TaxnexusCode {
|
func (obj *TaxnexusCode) MarshalToSwagger() *geo_models.TaxnexusCode {
|
||||||
swag := geo_models.TaxnexusCode{
|
swag := geo_models.TaxnexusCode{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
// TaxTransaction is not ingested, hence no UnMarshalTaxTransaction
|
// TaxTransaction is not ingested, hence no UnMarshalTaxTransaction
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *TaxTransaction) MarshalToSwagger() *ops_models.TaxTransaction {
|
func (obj *TaxTransaction) MarshalToSwagger() *ops_models.TaxTransaction {
|
||||||
return &ops_models.TaxTransaction{
|
return &ops_models.TaxTransaction{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalTaxTypeAccount encodes first class object
|
||||||
func UnMarshalTaxTypeAccount(s *regs_models.TaxTypeAccount) *TaxTypeAccount {
|
func UnMarshalTaxTypeAccount(s *regs_models.TaxTypeAccount) *TaxTypeAccount {
|
||||||
if s.ID == "" {
|
if s.ID == "" {
|
||||||
s.ID = uuid.New().String()
|
s.ID = uuid.New().String()
|
||||||
|
@ -64,6 +65,8 @@ func UnMarshalTaxTypeAccount(s *regs_models.TaxTypeAccount) *TaxTypeAccount {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *TaxTypeAccount) MarshalToSwagger() *regs_models.TaxTypeAccount {
|
func (obj *TaxTypeAccount) MarshalToSwagger() *regs_models.TaxTypeAccount {
|
||||||
return ®s_models.TaxTypeAccount{
|
return ®s_models.TaxTypeAccount{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/devops/devops_models"
|
import "code.tnxs.net/taxnexus/lib/api/devops/devops_models"
|
||||||
|
|
||||||
|
// UnMarshalTenantUser encodes first class object
|
||||||
func UnMarshalTenantUser(s *devops_models.TenantUser) *TenantUser {
|
func UnMarshalTenantUser(s *devops_models.TenantUser) *TenantUser {
|
||||||
return &TenantUser{
|
return &TenantUser{
|
||||||
AccessLevel: s.AccessLevel,
|
AccessLevel: s.AccessLevel,
|
||||||
|
@ -22,6 +23,8 @@ func UnMarshalTenantUser(s *devops_models.TenantUser) *TenantUser {
|
||||||
Username: s.Username,
|
Username: s.Username,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *TenantUser) MarshalToSwagger() *devops_models.TenantUser {
|
func (obj *TenantUser) MarshalToSwagger() *devops_models.TenantUser {
|
||||||
return &devops_models.TenantUser{
|
return &devops_models.TenantUser{
|
||||||
AccessLevel: obj.AccessLevel,
|
AccessLevel: obj.AccessLevel,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package app
|
||||||
|
|
||||||
import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Total) MarshalToSwagger() *ops_models.Total {
|
func (obj *Total) MarshalToSwagger() *ops_models.Total {
|
||||||
var items []*ops_models.TotalItem
|
var items []*ops_models.TotalItem
|
||||||
if obj.TotalItems != nil {
|
if obj.TotalItems != nil {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"code.tnxs.net/taxnexus/lib/api/regs/regs_models"
|
"code.tnxs.net/taxnexus/lib/api/regs/regs_models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UnMarshalTransaction encodes first class object
|
||||||
func UnMarshalTransaction(s *regs_models.Transaction) *Transaction {
|
func UnMarshalTransaction(s *regs_models.Transaction) *Transaction {
|
||||||
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
||||||
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
||||||
|
@ -29,6 +30,8 @@ func UnMarshalTransaction(s *regs_models.Transaction) *Transaction {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalToSwagger encodes first class object
|
||||||
func (obj *Transaction) MarshalToSwagger() *regs_models.Transaction {
|
func (obj *Transaction) MarshalToSwagger() *regs_models.Transaction {
|
||||||
return ®s_models.Transaction{
|
return ®s_models.Transaction{
|
||||||
ID: obj.ID,
|
ID: obj.ID,
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package app
|
||||||
|
|
||||||
|
// UserAuth is a first class object type
|
||||||
|
type UserAuth struct {
|
||||||
|
AccountID string
|
||||||
|
APIKey string
|
||||||
|
ContactID string
|
||||||
|
Email string
|
||||||
|
Roles []string
|
||||||
|
Tenants []string
|
||||||
|
UserID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAuth0User is a first class object type
|
||||||
|
type NewAuth0User struct {
|
||||||
|
Blocked bool `json:"blocked,omitempty"`
|
||||||
|
Connection string `json:"connection,omitempty"`
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
|
EmailVerified bool `json:"email_verified,omitempty"`
|
||||||
|
FamilyName string `json:"family_name,omitempty"`
|
||||||
|
GivenName string `json:"given_name,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Nickname string `json:"nickname,omitempty"`
|
||||||
|
Password string `json:"password,omitempty"`
|
||||||
|
PhoneNumber string `json:"phone_number,omitempty"`
|
||||||
|
PhoneVerified bool `json:"phone_verified,omitempty"`
|
||||||
|
Picture string `json:"picture,omitempty"`
|
||||||
|
UserID string `json:"user_id,omitempty"`
|
||||||
|
Username string `json:"username,omitempty"`
|
||||||
|
VerifyEmail bool `json:"verify_email,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
package app
|
|
@ -7,7 +7,10 @@ import (
|
||||||
"go.temporal.io/sdk/workflow"
|
"go.temporal.io/sdk/workflow"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StoreAccountActivity posts a new lead object to datastore
|
// StoreAccountActivityID is an activity identifier
|
||||||
|
const StoreAccountActivityID = "STORE_ACCOUNT_ACTIVITY"
|
||||||
|
|
||||||
|
// StoreAccountActivity posts a new account object to datastore
|
||||||
func StoreAccountActivity(ctx workflow.Context, w app.AccountChannelWrapper) error { //nolint:gocritic // what we want
|
func StoreAccountActivity(ctx workflow.Context, w app.AccountChannelWrapper) error { //nolint:gocritic // what we want
|
||||||
postAccountParams := accounts.NewPostAccountsParamsWithTimeout(postTimeout)
|
postAccountParams := accounts.NewPostAccountsParamsWithTimeout(postTimeout)
|
||||||
postAccountParams.AccountRequest = &crm_models.AccountRequest{
|
postAccountParams.AccountRequest = &crm_models.AccountRequest{
|
||||||
|
@ -17,6 +20,6 @@ func StoreAccountActivity(ctx workflow.Context, w app.AccountChannelWrapper) err
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sugar.Info("crm.storeAccount: 👍 📤")
|
sugar.Info("rules.StoreAccountActivity: 👍 📤")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/devops/devops_client/user"
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/devops/devops_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"
|
||||||
|
"go.temporal.io/sdk/workflow"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StoreAuth0UserActivity creates a new Auth0 user tied to a User record
|
||||||
|
func StoreAuth0UserActivity(ctx workflow.Context, w app.UserChannelWrapper) error {
|
||||||
|
auth0UserID, err := app.GetAuth0UserByEmail(w.Obj.Email)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if auth0UserID != "not found" {
|
||||||
|
return fmt.Errorf("rules.StoreAuth0UserActivity: 💣 ⛔ Auth0 user exists: %s", auth0UserID)
|
||||||
|
}
|
||||||
|
newAuth0UserID, err := app.CreateNewAuth0User(&app.NewAuth0User{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
putUser := w.Obj
|
||||||
|
putUser.Auth0UserID = newAuth0UserID
|
||||||
|
//
|
||||||
|
// update Taxnexus user
|
||||||
|
//
|
||||||
|
putUserParams := user.NewPutUsersParamsWithTimeout(getTimeout)
|
||||||
|
putUserParams.UserRequest = &devops_models.UserRequest{
|
||||||
|
Data: []*devops_models.User{&putUser},
|
||||||
|
}
|
||||||
|
_, err = devopsClient.User.PutUsers(putUserParams, w.Principal.Auth)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// send emails
|
||||||
|
//
|
||||||
|
emailParams := outgoing_email_message.NewPostOutgoingEmailMessagesParamsWithTimeout(postTimeout)
|
||||||
|
emailParams.OutgoingEmailMessageRequest = &workflow_models.OutgoingEmailMessageRequest{
|
||||||
|
Data: []*workflow_models.OutgoingEmailMessage{
|
||||||
|
{
|
||||||
|
Subject: putUser.ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_, err = workflowClient.
|
||||||
|
OutgoingEmailMessage.
|
||||||
|
PostOutgoingEmailMessages(
|
||||||
|
emailParams,
|
||||||
|
w.Principal.Auth,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
package rules
|
|
@ -0,0 +1 @@
|
||||||
|
package rules
|
|
@ -0,0 +1,46 @@
|
||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/devops/devops_models"
|
||||||
|
"code.tnxs.net/taxnexus/lib/app"
|
||||||
|
"go.temporal.io/sdk/workflow"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewUserChannelWrapper wraps a contact, account, payment method and a user identifier (app.User)
|
||||||
|
type NewUserChannelWrapper struct {
|
||||||
|
User devops_models.User
|
||||||
|
Principal app.User
|
||||||
|
SagaID string
|
||||||
|
SagaType string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUserWorkflow is a Temporal workflow
|
||||||
|
func NewUserWorkflow(ctx workflow.Context, payload *NewUserChannelWrapper) error {
|
||||||
|
ctx = workflow.WithActivityOptions(
|
||||||
|
ctx,
|
||||||
|
workflow.ActivityOptions{
|
||||||
|
StartToCloseTimeout: time.Minute,
|
||||||
|
})
|
||||||
|
err := workflow.ExecuteActivity(ctx,
|
||||||
|
StoreUserActivity,
|
||||||
|
&app.UserChannelWrapper{
|
||||||
|
Obj: payload.User,
|
||||||
|
Principal: payload.Principal,
|
||||||
|
SagaID: payload.SagaID,
|
||||||
|
SagaType: payload.SagaType,
|
||||||
|
}).Get(ctx, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = workflow.ExecuteActivity(
|
||||||
|
ctx,
|
||||||
|
NotifyLeadActivity,
|
||||||
|
payload,
|
||||||
|
).Get(ctx, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.tnxs.net/taxnexus/lib/api/crm/crm_client"
|
"code.tnxs.net/taxnexus/lib/api/crm/crm_client"
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/devops/devops_client"
|
||||||
"code.tnxs.net/taxnexus/lib/api/ops/ops_client"
|
"code.tnxs.net/taxnexus/lib/api/ops/ops_client"
|
||||||
"code.tnxs.net/taxnexus/lib/api/workflow/workflow_client"
|
"code.tnxs.net/taxnexus/lib/api/workflow/workflow_client"
|
||||||
"code.tnxs.net/taxnexus/lib/app"
|
"code.tnxs.net/taxnexus/lib/app"
|
||||||
|
@ -14,13 +15,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// const dateFormat = "2006-01-02"
|
// const dateFormat = "2006-01-02"
|
||||||
// const getTimeout = 6 * time.Minute
|
const getTimeout = 6 * time.Minute
|
||||||
|
|
||||||
// const dateTimeFormat = "2006-01-02T15:04:05-0800"
|
// const dateTimeFormat = "2006-01-02T15:04:05-0800"
|
||||||
const postTimeout = 6 * time.Minute
|
const postTimeout = 6 * time.Minute
|
||||||
|
|
||||||
var sugar = logger.New(zapcore.InfoLevel)
|
var sugar = logger.New(zapcore.InfoLevel)
|
||||||
|
|
||||||
var crmClient = crm_client.Default
|
var crmClient = crm_client.Default
|
||||||
|
var devopsClient = devops_client.Default
|
||||||
var opsClient = ops_client.Default
|
var opsClient = ops_client.Default
|
||||||
var workflowClient = workflow_client.Default
|
var workflowClient = workflow_client.Default
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"html/template"
|
||||||
|
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/devops/devops_client/user"
|
||||||
|
"code.tnxs.net/taxnexus/lib/api/devops/devops_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"
|
||||||
|
"go.temporal.io/sdk/workflow"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StoreUserActivity posts a new user object to datastore and creates the auth0 user
|
||||||
|
func StoreUserActivity(ctx workflow.Context, w app.UserChannelWrapper) error { //nolint:gocritic // what we want
|
||||||
|
postUserParams := user.NewPostUsersParamsWithTimeout(postTimeout)
|
||||||
|
if w.Obj.Name == "" {
|
||||||
|
w.Obj.Name = w.Obj.FirstName + " " + w.Obj.LastName
|
||||||
|
}
|
||||||
|
postUserParams.UserRequest = &devops_models.UserRequest{
|
||||||
|
Data: []*devops_models.User{&w.Obj},
|
||||||
|
}
|
||||||
|
devopsResponse, err := devopsClient.User.PostUsers(postUserParams, w.Principal.Auth)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var newUser *devops_models.User
|
||||||
|
for _, itm := range devopsResponse.Payload.Data { // single iteration execution
|
||||||
|
newUser = itm
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// create new Auth0 user
|
||||||
|
//
|
||||||
|
auth0UserID, err := app.GetAuth0UserByEmail(newUser.Email)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if auth0UserID != "not found" {
|
||||||
|
return fmt.Errorf("app.StoreUserActivity: 💣 ⛔ Auth0 user exists: %s", auth0UserID)
|
||||||
|
}
|
||||||
|
newAuth0UserID, err := app.CreateNewAuth0User(&app.NewAuth0User{
|
||||||
|
Email: newUser.Email,
|
||||||
|
EmailVerified: true,
|
||||||
|
Name: newUser.Name,
|
||||||
|
UserID: newUser.ID,
|
||||||
|
Username: newUser.Email,
|
||||||
|
FamilyName: newUser.LastName,
|
||||||
|
GivenName: newUser.FirstName,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
newUser.Auth0UserID = newAuth0UserID
|
||||||
|
//
|
||||||
|
// update Taxnexus user
|
||||||
|
//
|
||||||
|
putUserParams := user.NewPutUsersParamsWithTimeout(getTimeout)
|
||||||
|
putUserParams.UserRequest = &devops_models.UserRequest{
|
||||||
|
Data: []*devops_models.User{newUser},
|
||||||
|
}
|
||||||
|
_, err = devopsClient.User.PutUsers(putUserParams, w.Principal.Auth)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// send emails
|
||||||
|
//
|
||||||
|
sugar.Info("crm.storeUser: 👍 📤")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifyUserActivity sends an email to a new lead
|
||||||
|
func NotifyUserActivity(ctx context.Context, w *app.UserChannelWrapper) error {
|
||||||
|
sugar.Info("workflow.notifyUser: 📥")
|
||||||
|
var buf bytes.Buffer
|
||||||
|
const textBody = `
|
||||||
|
|
||||||
|
Alert! New User Inquiry from Taxnexus.io website.
|
||||||
|
|
||||||
|
Taxnexus ID: {{.ID}}
|
||||||
|
First Name: {{.FirstName}}
|
||||||
|
Last Name: {{.LastName}}
|
||||||
|
Email: {{.Email}}
|
||||||
|
Message: {{.Description}}
|
||||||
|
|
||||||
|
-- end --
|
||||||
|
`
|
||||||
|
t := template.Must(template.New("textBody").Parse(textBody))
|
||||||
|
err := t.Execute(&buf, w)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
emailParams := outgoing_email_message.NewPostOutgoingEmailMessagesParamsWithTimeout(postTimeout)
|
||||||
|
emailParams.OutgoingEmailMessageRequest = &workflow_models.OutgoingEmailMessageRequest{
|
||||||
|
Data: []*workflow_models.OutgoingEmailMessage{
|
||||||
|
{
|
||||||
|
Subject: "New lead from " + w.Obj.Name,
|
||||||
|
ValidatedFromAddress: "support@taxnexus.net",
|
||||||
|
ToAddress: "info@taxnexus.net",
|
||||||
|
FromName: "Taxnexus Onboarding",
|
||||||
|
Text: buf.String(),
|
||||||
|
HTML: "<pre>" + buf.String() + "</pre>",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_, err = workflowClient.OutgoingEmailMessage.PostOutgoingEmailMessages(emailParams, w.Principal.Auth)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sugar.Info("workflow.notifyUser: 👍 📤")
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue