lib/rules/account.go

33 lines
968 B
Go
Raw Normal View History

2021-01-13 02:41:43 +00:00
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"
2021-01-19 01:50:45 +00:00
httptransport "github.com/go-openapi/runtime/client"
2021-01-13 02:41:43 +00:00
"go.temporal.io/sdk/workflow"
)
2021-01-18 03:13:54 +00:00
// StoreAccountActivityID is an activity identifier
const StoreAccountActivityID = "STORE_ACCOUNT_ACTIVITY"
// StoreAccountActivity posts a new account object to datastore
2021-01-13 02:41:43 +00:00
func StoreAccountActivity(ctx workflow.Context, w app.AccountChannelWrapper) error { //nolint:gocritic // what we want
postAccountParams := accounts.NewPostAccountsParamsWithTimeout(postTimeout)
postAccountParams.AccountRequest = &crm_models.AccountRequest{
Data: []*crm_models.Account{&w.Obj},
}
2021-01-19 01:50:45 +00:00
_, err := crmClient.Accounts.PostAccounts(
postAccountParams,
httptransport.APIKeyAuth(
"X-API-Key",
"header",
w.APIKey,
))
2021-01-13 02:41:43 +00:00
if err != nil {
return err
}
2021-01-18 03:13:54 +00:00
sugar.Info("rules.StoreAccountActivity: 👍 📤")
2021-01-13 02:41:43 +00:00
return nil
}