Add predefined parameters
Closed this issue · 1 comments
There are many many parts in the API doc stating optional parameters, which ARE NOT implemented like this in the PHP API wrapper.
For example create_campaign: The API Docs state, that the exclude_list, the attachmentUrl and the inline_image are optional. Which they AREN'T in the method call, as there are no predefined values!
function create_campaign($category, $from_name, $name, $bat_sent = '', $html_content = '', $html_url = '', $listid, $scheduled_date = '',$subject, $from_email, $reply_to = '', $to_field = '', $exclude_list = array(), $attachmentUrl = '', $inline_image = 0) {
The other option would be to simply use an array as ways to easily parse out just the required parameters, and also be easier to enhance with further parameters or remove outdated parameters in the future.
In this case, said example could look like this:
function create_campaign( $campaign_params = array() ) {
return $this->post('campaign',json_encode( $campaign_params ) );
}
But in other cases, it would be something like as follows
function do_something_specific( $params = array() ) {
extract( $params ); // now we got all params extracted, but are just going to use the ones we REQUIRE.
...
}
You also might want to take a look at the array combination function of WP for improved handling of this task: http://codex.wordpress.org/Function_Reference/wp_parse_args
cu, w0lf.
Hello,
Thank you for contacting us.
We have updated V2.0 wrapper to object-based.
You can update the wrapper & check new PHP samples in Apidoc.
Regards,
Sendinblue Team