package app

import (
	"github.com/taxnexus/go-force/force"
)

// InitForce creates a salesforce connection using serviceAccountName
func InitForce(serviceAccountName string) *force.API {
	sugar.Infof("app.initForce: 📥 %s", serviceAccountName)
	acct := GetServiceAccount(serviceAccountName)
	theForce, err := force.Create(
		"v45.0",
		acct.ClientID,
		acct.ClientSecret,
		acct.Username,
		acct.Password,
		acct.SecurityToken,
		"production",
	)
	if err != nil {
		sugar.Errorf("app.InitForce: salesforce error: %s", err.Error())
		return nil
	}
	sugar.Info("app.InitForce: 👍 📤")
	return theForce
}
