Following on from our .Net & Java SDKs, we’ve now released our php SDK. This provides a friendly way to access Paydock, making it even easier to use Paydock.
Providing the right interface
One of the questions when putting together a new SDK is how to support this in a way that is as language friendly as possible. What we’ve put together for a strongly typed language like .Net, just doesn’t make as much sense for a dynamically typed language like php.
The simplest approach to this would be to simply map through the request, serialised as json, eg something like this:
This works fine with simpler requests, but it tends to make it hard with larger, more complex request. In those cases, it’s easy to create a situation where you send through either too many parameters or too few. Also, when you can send through nested sets of parameters, it’s easy to send through parameters encoded at the wrong depth, e.g.:
For this reason we settled on a fluent style interface.
Using a fluent interface, you build up a request through a number of calls. Some good examples of fluent interfaces are things like LINQ in .Net:
These are often a very natural way of searching for data, but also work well to build up complex requests.
In order to make this as clear as possible, we’ve followed certain conventions. An example of this in the SDK is creating a charge with bank account details:
|1 2 3 4||
The first call is part of the call specifies the action (create). If this needs additional data, this is send through as with<Something>. Optional data is added through include<something>. And finally call() makes the actual call.
This made the API more complex to build, but provided a better experience of using the API.
As always, we’re open to improving this, so please raise any issues or concerns on on github and we’ll jump on it!