33 lines
969 B
Go
33 lines
969 B
Go
package rules
|
|
|
|
import (
|
|
"code.tnxs.net/taxnexus/lib/api/crm/crm_client/accounts"
|
|
"code.tnxs.net/taxnexus/lib/api/crm/crm_models"
|
|
"code.tnxs.net/taxnexus/lib/app"
|
|
httptransport "github.com/go-openapi/runtime/client"
|
|
"go.temporal.io/sdk/workflow"
|
|
)
|
|
|
|
// 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.AccountActivityWrapper) error { //nolint:gocritic // what we want
|
|
postAccountParams := accounts.NewPostAccountsParamsWithTimeout(postTimeout)
|
|
postAccountParams.AccountRequest = &crm_models.AccountRequest{
|
|
Data: []*crm_models.Account{&w.Obj},
|
|
}
|
|
_, err := crmClient.Accounts.PostAccounts(
|
|
postAccountParams,
|
|
httptransport.APIKeyAuth(
|
|
"X-API-Key",
|
|
"header",
|
|
w.APIKey,
|
|
))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
sugar.Info("rules.StoreAccountActivity: 👍 📤")
|
|
return nil
|
|
}
|