v0.2.7 V0.2.7
Vernon Keenan 2021-02-06 13:18:47 -08:00
parent 8ff5a0c443
commit 7ba5f66512
2 changed files with 66 additions and 1 deletions

64
app/ingest-services.go Normal file
View File

@ -0,0 +1,64 @@
package app
import (
"fmt"
"time"
"code.tnxs.net/taxnexus/lib/api/devops/devops_client/ingest"
"code.tnxs.net/taxnexus/lib/api/devops/devops_models"
"github.com/google/uuid"
)
// NewIngestParams is a prams type
type NewIngestParams struct {
accountID string
backendID string
objectType string
objList []*devops_models.Ingest
principal *User
ref string
}
// NewIngest is an ingest helper function
func NewIngest(params *NewIngestParams) (string, error) {
sugar.Debug("ops.newIngest: 📥")
if params.accountID == "" || params.principal.TenantID == "" {
return "", fmt.Errorf("ops.newIngest: 💣 ⛔ params.AccountID or params.TaxnexusAccount are blank")
}
dt := time.Now().Format(dateTimeFormat)
theIngest := &devops_models.Ingest{
AccountID: &params.accountID,
BackendID: params.backendID,
EndDate: dt,
ID: uuid.New().String(),
IngestDate: dt,
IngestType: "fabric",
ObjectType: &params.objectType,
Ref: params.ref,
StartDate: dt,
Status: "new",
}
params.objList = []*devops_models.Ingest{theIngest}
_, err := PostIngests(params)
if err != nil {
return "", err
}
sugar.Debugf("ops.newIngest: 👍 📤, Ingest ID=%s", theIngest.ID)
return theIngest.ID, nil
}
// PostIngests is an ingest helper function
func PostIngests(params *NewIngestParams) ([]*devops_models.Ingest, error) {
sugar.Debugf("ops.postIngests: 📥 len=%d", len(params.objList))
devopsParams := ingest.NewPostIngestsParams()
devopsParams.IngestRequest = &devops_models.IngestRequest{
Data: params.objList,
}
response, err := devopsClient.Ingest.PostIngests(devopsParams, params.principal.Auth)
if err != nil {
sugar.Errorf("ops.postIngests: 💣 ⛔ post to devops error %w", err)
return nil, err
}
sugar.Debugf("ops.postIngests: 👍 📤 len(ingests)=%d", len(response.Payload.Data))
return response.Payload.Data, nil
}

View File

@ -8,6 +8,7 @@ import (
"code.tnxs.net/taxnexus/lib/api/auth/auth_client" "code.tnxs.net/taxnexus/lib/api/auth/auth_client"
"code.tnxs.net/taxnexus/lib/api/auth0/auth0_client" "code.tnxs.net/taxnexus/lib/api/auth0/auth0_client"
"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/geo/geo_client" "code.tnxs.net/taxnexus/lib/api/geo/geo_client"
"code.tnxs.net/taxnexus/lib/api/ledger/ledger_client" "code.tnxs.net/taxnexus/lib/api/ledger/ledger_client"
"code.tnxs.net/taxnexus/lib/api/ops/ops_client" "code.tnxs.net/taxnexus/lib/api/ops/ops_client"
@ -27,6 +28,7 @@ var authUser *User
var config = Configuration{} var config = Configuration{}
var configured = false var configured = false
var crmClient = crm_client.Default var crmClient = crm_client.Default
var devopsClient = devops_client.Default
var geoClient = geo_client.Default var geoClient = geo_client.Default
var ledgerClient = ledger_client.Default var ledgerClient = ledger_client.Default
var opsClient = ops_client.Default var opsClient = ops_client.Default
@ -40,7 +42,6 @@ const constNotFound = "not found"
const percentFactor = 100 const percentFactor = 100
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 dateFormatAlt = "1/2/2006" const dateFormatAlt = "1/2/2006"
const countyGeocodeLength = 7 const countyGeocodeLength = 7