Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TheHollidayInn opened this issue Feb 28, 2019 · 3 comments
Closed

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

TheHollidayInn opened this issue Feb 28, 2019 · 3 comments
Labels

Comments

@TheHollidayInn
Copy link

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.

@jsgoupil
Copy link
Owner

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?

@TheHollidayInn
Copy link
Author

TheHollidayInn commented Mar 1, 2019

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?

@jsgoupil
Copy link
Owner

jsgoupil commented Mar 1, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants