jsgoupil/quickbooks-sync

[Questions] Can we call a step from an api endpoint

TheHollidayInn opened this issue · 3 comments

Hey! Just wondering if there is a way to call a step without waiting for the web connector to make the request. I'd like to be able to call an endpoint /sync and start the sync process.

I'm assuming I'd have to build up the manager inside of the endpoint, but not sure.

No, the steps should be used exclusively to handle what is coming or going to QuickBooks.
You should use dependency injection and put your code in something else that can be called from your own trigger.
Keep what is in your step super small, and call that code that you have injected with your dependency injection.

Does that make sense?

Thanks for the answer!

Yeah, that makes sense, but I am looking to call the manager from a Rest endpoint somehow. I'm not seeing where the methods of the manager are called after the Soap request. i.e. I'm not seeing how this is called: https://github.com/jsgoupil/quickbooks-sync/blob/master/src/WebConnector/Impl/QbManager.cs#L126

Also, forgive me as I am a Java/Node dev. Not much of a dotnet dev yet.

My guess is I need to add an option here: https://github.com/jsgoupil/quickbooks-sync/blob/master/src/WebConnector/Extensions/ApplicationBuilderExtensions.cs#L19 to pass in a REST endpoint to get the manager. Then maybe call the steps I have injected?

Hi highly recommend that you don't do that. You're passing through a lot of dependencies that even I don't handle. It's using another NuGet package.
This method is called by the https://github.com/DigDes/SoapCore package.
If you really want to call it yourself, you can request the service with the serviceProvider.GetService<IQbManager>()

But once again, I highly don't recommend this, other than unit testing.

If this is for production code, you should load your own interface and not use the SyncManager.