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

Ability to call client functions not wrapped in main class #36

Closed
tomhooijenga opened this issue Sep 30, 2016 · 5 comments
Closed

Ability to call client functions not wrapped in main class #36

tomhooijenga opened this issue Sep 30, 2016 · 5 comments

Comments

@tomhooijenga
Copy link

In the Postnl class, there are setters to set the various clients. However, there are no getters for them. Because of this, there is no easy way to call some parts of the api. (For example, completeStatus from ShippingStatusClient).
Two possible fixes: Proxy all methods from each client in the Postnl class, or make the clients themselves accessible.

@ameenross
Copy link
Collaborator

ameenross commented Oct 3, 2016

Actually, there's getClient. It's just protected is all. I have considered making it public in the past, but decided not to, because I figured the main class might only be an obstacle for a developer with more custom needs.

I don't think proxying all methods is a good idea, unless the wrapper function actually adds value (which is the case for the functions currently in there). Making the getClient function public is probably the best solution.

@tomhooijenga
Copy link
Author

I think it it is more convenient to have the getClient method public. That way, there is a single access point to the api. This also prevents the consumer from dealing with the SecurityHeader. Are there any downsides in doing this?

@ameenross
Copy link
Collaborator

ameenross commented Oct 6, 2016

Are there any downsides in doing this?

Probably only psychological. In other words, no :)

@ameenross
Copy link
Collaborator

ameenross commented Oct 6, 2016

On second thought, that would result in code like this (and wouldn't catch CIF exceptions):

$request = new ComplexTypes\CompleteStatusRequest($message, $customer, $shipment);

// Query the webservice and return the result.
return $postnl->getClient('ShippingStatusClient')->completeStatus($request);

Making the call method available would be preferable, and using that will result in something like this (AND have proper CIF error handling):

$request = new ComplexTypes\CompleteStatusRequest($message, $customer, $shipment);

// Query the webservice and return the result.
return $postnl->call('ShippingStatusClient', 'completeStatus', $request);

If you agree then I'll patch it.

@tomhooijenga
Copy link
Author

That is probably better. Great work!

@ameenross ameenross changed the title Client getters Ability to call client functions not wrapped in Postnl Oct 6, 2016
@ameenross ameenross changed the title Ability to call client functions not wrapped in Postnl Ability to call client functions not wrapped in main class Oct 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants