parent
8ff5a0c443
commit
7ba5f66512
|
@ -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: ¶ms.accountID,
|
||||||
|
BackendID: params.backendID,
|
||||||
|
EndDate: dt,
|
||||||
|
ID: uuid.New().String(),
|
||||||
|
IngestDate: dt,
|
||||||
|
IngestType: "fabric",
|
||||||
|
ObjectType: ¶ms.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
|
||||||
|
}
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue