Jump to content

Recommended Posts

Posted

Hey there
 
I'm in the process of building a module for Web Drive, the most used domain reseller platform in New Zealand. I've got a few questions about the programming conventions.

3xmHIaL.png
 
The Web Drive API is XML-RPC (not documented properly either  :mellow:) so it's a bit different than the existing modules.
 
Now for the commands/webdrive_something files, it looks like almost all the other modules take a $vars array and call the API without any type casting or other logic. As the Web Drive API is using XML-RPC which is more strongly typed than PHP I need to do stuff like xmlrpc_set_type($date, 'datetime'); Is that the right place to do that sort of stuff? Or should I be doing that in the main Webdrive module class?
 
Another thing is that the API requires different authentication for each method, either the api key and password, or the api key, password and sub account name. I have decided to not use a magic method in commands/webdrive_all, and instead write each method which specifies the auth type when calling $this->api->submit(). Is this the best way, or again is this better in the main Webdrive module class?

Posted

It sounds like your questions are related to how the module should interface with the Webdrive API, and as far as Blesta is concerned, you can handle that however you'd like. Rather than using experimental functions like xmlrpc_set_type, you should handle XML with an XML library like SimpleXML, and make the libxml extension a dependency in your module's install() method, if you find that to be a necessity.

 

As far as your other questions, the best way to handle things is up to your judgment and what you think is best. It comes down to OOP technique and abstraction. I haven't looked at the Webdrive API, but based on what you've described, I imagine you can abstract the different authentication methods outside of your Blesta module and into the API in order to authenticate each API action properly.

 

PHP is typeless, or rather, handles types on the fly, so any necessary type casting or manipulation can be done after the data has been passed into your module. I see no need to create new methods that accept different data types, unless you find this useful for abstraction.

 

Each module in Blesta is independent, and its use of its own API is irrelevant to your module. If you need to pass an array of domains to an API method, then by all means, pass an array. You don't need to use a comma-separated list of domains just because another module does so.

 

As for programming style, we have a guide for that.

Posted

Cool, thanks for the reply. I am about 25% finished (module manage page, nameserver management and domain availability are working) so I'll post the module here in a few days under the MIT license for critique/testing. 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...