From 0c2096ec7c64beb9bb38f05d2c4e776566783b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beyaty=20D=C3=A1vid?= Date: Thu, 23 Mar 2017 12:20:47 +0100 Subject: [PATCH] delete_attribute parameter fix --- src/Sendinblue/Mailin.php | 189 +++++++++++++++++++------------------- 1 file changed, 94 insertions(+), 95 deletions(-) diff --git a/src/Sendinblue/Mailin.php b/src/Sendinblue/Mailin.php index 150f81e..bcdf8d0 100644 --- a/src/Sendinblue/Mailin.php +++ b/src/Sendinblue/Mailin.php @@ -1,20 +1,21 @@ base_url = $base_url; @@ -24,7 +25,7 @@ public function __construct($base_url,$api_key,$timeout='') /** * Do CURL request with authorization */ - private function do_request($resource,$method,$input) + private function do_request($resource, $method, $input) { $called_url = $this->base_url."/".$resource; $ch = curl_init($called_url); @@ -42,44 +43,43 @@ private function do_request($resource,$method,$input) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout); + curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $input); $data = curl_exec($ch); - if(curl_errno($ch)) - { + if (curl_errno($ch)) { throw new RuntimeException('cURL error: ' . curl_error($ch)); } - if(!is_string($data) || !strlen($data)) { + if (!is_string($data) || !strlen($data)) { throw new RuntimeException('Request Failed'); } curl_close($ch); - return json_decode($data,true); + return json_decode($data, true); } - public function get($resource,$input) + public function get($resource, $input) { - return $this->do_request($resource,"GET",$input); - } - public function put($resource,$input) + return $this->do_request($resource, "GET", $input); + } + public function put($resource, $input) { - return $this->do_request($resource,"PUT",$input); + return $this->do_request($resource, "PUT", $input); } - public function post($resource,$input) + public function post($resource, $input) { - return $this->do_request($resource,"POST",$input); + return $this->do_request($resource, "POST", $input); } - public function delete($resource,$input) + public function delete($resource, $input) { - return $this->do_request($resource,"DELETE",$input); + return $this->do_request($resource, "DELETE", $input); } - + /* Get Account. No input required */ public function get_account() { - return $this->get("account",""); + return $this->get("account", ""); } /* @@ -88,7 +88,7 @@ public function get_account() */ public function get_smtp_details() { - return $this->get("account/smtpdetail",""); + return $this->get("account/smtpdetail", ""); } /* @@ -106,7 +106,7 @@ public function get_smtp_details() */ public function create_child_account($data) { - return $this->post("account",json_encode($data)); + return $this->post("account", json_encode($data)); } /* @@ -122,17 +122,17 @@ public function create_child_account($data) */ public function update_child_account($data) { - return $this->put("account",json_encode($data)); + return $this->put("account", json_encode($data)); } /* Delete Child Account. @param {Array} data contains php array with key value pair. @options data {String} auth_key: 16 character authorization key of Reseller child to be deleted [Mandatory] - */ + */ public function delete_child_account($data) - { - return $this->delete("account/".$data['auth_key'],""); + { + return $this->delete("account/".$data['auth_key'], ""); } /* @@ -142,7 +142,7 @@ public function delete_child_account($data) */ public function get_reseller_child($data) { - return $this->post("account/getchildv2",json_encode($data)); + return $this->post("account/getchildv2", json_encode($data)); } /* @@ -158,17 +158,17 @@ public function get_reseller_child($data) */ public function add_remove_child_credits($data) { - return $this->post("account/addrmvcredit",json_encode($data)); + return $this->post("account/addrmvcredit", json_encode($data)); } - /* + /* Get a particular campaign detail. @param {Array} data contains php array with key value pair. @options data {Integer} id: Unique Id of the campaign [Mandatory] */ public function get_campaign_v2($data) { - return $this->get("campaign/".$data['id']."/detailsv2",""); + return $this->get("campaign/".$data['id']."/detailsv2", ""); } /* @@ -181,7 +181,7 @@ public function get_campaign_v2($data) */ public function get_campaigns_v2($data) { - return $this->get("campaign/detailsv2",json_encode($data)); + return $this->get("campaign/detailsv2", json_encode($data)); } /* @@ -208,7 +208,7 @@ public function get_campaigns_v2($data) */ public function create_campaign($data) { - return $this->post("campaign",json_encode($data)); + return $this->post("campaign", json_encode($data)); } /* @@ -234,10 +234,10 @@ public function create_campaign($data) @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional] */ public function update_campaign($data) - { + { $id = $data['id']; unset($data['id']); - return $this->put("campaign/".$id,json_encode($data)); + return $this->put("campaign/".$id, json_encode($data)); } /* @@ -247,7 +247,7 @@ public function update_campaign($data) */ public function delete_campaign($data) { - return $this->delete("campaign/".$data['id'],""); + return $this->delete("campaign/".$data['id'], ""); } /* @@ -266,7 +266,7 @@ public function campaign_report_email($data) { $id = $data['id']; unset($data['id']); - return $this->post("campaign/".$id."/report",json_encode($data)); + return $this->post("campaign/".$id."/report", json_encode($data)); } /* @@ -280,7 +280,7 @@ public function campaign_recipients_export($data) { $id = $data['id']; unset($data['id']); - return $this->post("campaign/".$id."/recipients",json_encode($data)); + return $this->post("campaign/".$id."/recipients", json_encode($data)); } /* @@ -291,7 +291,7 @@ public function campaign_recipients_export($data) public function share_campaign($data) { - return $this->post("campaign/sharelinkv2",json_encode($data)); + return $this->post("campaign/sharelinkv2", json_encode($data)); } /* @@ -304,7 +304,7 @@ public function send_bat_email($data) { $id = $data['id']; unset($data['id']); - return $this->post("campaign/".$id."/test",json_encode($data)); + return $this->post("campaign/".$id."/test", json_encode($data)); } /* @@ -317,7 +317,7 @@ public function update_campaign_status($data) { $id = $data['id']; unset($data['id']); - return $this->put("campaign/".$id."/updatecampstatus",json_encode($data)); + return $this->put("campaign/".$id."/updatecampstatus", json_encode($data)); } /* @@ -344,7 +344,7 @@ public function update_campaign_status($data) */ public function create_trigger_campaign($data) { - return $this->post("campaign",json_encode($data)); + return $this->post("campaign", json_encode($data)); } /* @@ -374,7 +374,7 @@ public function update_trigger_campaign($data) { $id = $data['id']; unset($data['id']); - return $this->put("campaign/".$id,json_encode($data)); + return $this->put("campaign/".$id, json_encode($data)); } /* @@ -385,7 +385,7 @@ public function update_trigger_campaign($data) */ public function get_folders($data) { - return $this->get("folder",json_encode($data)); + return $this->get("folder", json_encode($data)); } /* @@ -395,7 +395,7 @@ public function get_folders($data) */ public function get_folder($data) { - return $this->get("folder/".$data['id'],""); + return $this->get("folder/".$data['id'], ""); } /* @@ -405,7 +405,7 @@ public function get_folder($data) */ public function create_folder($data) { - return $this->post("folder",json_encode($data)); + return $this->post("folder", json_encode($data)); } /* @@ -415,7 +415,7 @@ public function create_folder($data) */ public function delete_folder($data) { - return $this->delete("folder/".$data['id'],""); + return $this->delete("folder/".$data['id'], ""); } /* @@ -428,7 +428,7 @@ public function update_folder($data) { $id = $data['id']; unset($data['id']); - return $this->put("folder/".$id,json_encode($data)); + return $this->put("folder/".$id, json_encode($data)); } /* @@ -440,7 +440,7 @@ public function update_folder($data) */ public function get_lists($data) { - return $this->get("list",json_encode($data)); + return $this->get("list", json_encode($data)); } /* @@ -450,7 +450,7 @@ public function get_lists($data) */ public function get_list($data) { - return $this->get("list/".$data['id'],""); + return $this->get("list/".$data['id'], ""); } /* @@ -461,7 +461,7 @@ public function get_list($data) */ public function create_list($data) { - return $this->post("list",json_encode($data)); + return $this->post("list", json_encode($data)); } /* @@ -475,7 +475,7 @@ public function update_list($data) { $id = $data['id']; unset($data['id']); - return $this->put("list/".$id,json_encode($data)); + return $this->put("list/".$id, json_encode($data)); } /* @@ -485,9 +485,9 @@ public function update_list($data) */ public function delete_list($data) { - return $this->delete("list/".$data['id'],""); + return $this->delete("list/".$data['id'], ""); } - + /* Display details of all users for the given lists. @param {Array} data contains php array with key value pair. @@ -498,7 +498,7 @@ public function delete_list($data) */ public function display_list_users($data) { - return $this->post("list/display",json_encode($data)); + return $this->post("list/display", json_encode($data)); } /* @@ -512,7 +512,7 @@ public function add_users_list($data) { $id = $data['id']; unset($data['id']); - return $this->post("list/".$id."/users",json_encode($data)); + return $this->post("list/".$id."/users", json_encode($data)); } /* @@ -525,7 +525,7 @@ public function delete_users_list($data) { $id = $data['id']; unset($data['id']); - return $this->delete("list/".$id."/delusers",json_encode($data)); + return $this->delete("list/".$id."/delusers", json_encode($data)); } /* @@ -534,7 +534,7 @@ public function delete_users_list($data) */ public function get_attributes() { - return $this->get("attribute",""); + return $this->get("attribute", ""); } /* @@ -544,7 +544,7 @@ public function get_attributes() */ public function get_attribute($data) { - return $this->get("attribute/".$data['type'],""); + return $this->get("attribute/".$data['type'], ""); } /* @@ -556,7 +556,7 @@ public function get_attribute($data) */ public function create_attribute($data) { - return $this->post("attribute/",json_encode($data)); + return $this->post("attribute/", json_encode($data)); } /* @@ -564,11 +564,11 @@ public function create_attribute($data) @param {Array} data contains php array with key value pair. @options data {Integer} type: Type of attribute to be deleted [Mandatory] */ - public function delete_attribute($type,$data) + public function delete_attribute($data) { $type = $data['type']; unset($data['type']); - return $this->post("attribute/".$type,json_encode($data)); + return $this->post("attribute/".$type, json_encode($data)); } /* @@ -583,7 +583,7 @@ public function delete_attribute($type,$data) */ public function create_update_user($data) { - return $this->post("user/createdituser",json_encode($data)); + return $this->post("user/createdituser", json_encode($data)); } /* @@ -593,7 +593,7 @@ public function create_update_user($data) */ public function get_user($data) { - return $this->get("user/".$data['email'],""); + return $this->get("user/".$data['email'], ""); } /* @@ -603,7 +603,7 @@ public function get_user($data) */ public function delete_user($data) { - return $this->delete("user/".$data['email'],""); + return $this->delete("user/".$data['email'], ""); } /* @@ -618,7 +618,7 @@ public function delete_user($data) */ public function import_users($data) { - return $this->post("user/import",json_encode($data)); + return $this->post("user/import", json_encode($data)); } /* @@ -630,8 +630,8 @@ public function import_users($data) */ public function export_users($data) { - return $this->post("user/export",json_encode($data)); - } + return $this->post("user/export", json_encode($data)); + } /* Get all the processes information under the account. @@ -641,7 +641,7 @@ public function export_users($data) */ public function get_processes($data) { - return $this->get("process",json_encode($data)); + return $this->get("process", json_encode($data)); } /* @@ -651,7 +651,7 @@ public function get_processes($data) */ public function get_process($data) { - return $this->get("process/".$data['id'],""); + return $this->get("process/".$data['id'], ""); } /* @@ -661,7 +661,7 @@ public function get_process($data) */ public function get_webhooks($data) { - return $this->get("webhook",json_encode($data)); + return $this->get("webhook", json_encode($data)); } /* @@ -671,7 +671,7 @@ public function get_webhooks($data) */ public function get_webhook($data) { - return $this->get("webhook/".$data['id'],""); + return $this->get("webhook/".$data['id'], ""); } /* @@ -684,7 +684,7 @@ public function get_webhook($data) */ public function create_webhook($data) { - return $this->post("webhook",json_encode($data)); + return $this->post("webhook", json_encode($data)); } /* @@ -694,7 +694,7 @@ public function create_webhook($data) */ public function delete_webhook($data) { - return $this->delete("webhook/".$data['id'],""); + return $this->delete("webhook/".$data['id'], ""); } /* @@ -709,7 +709,7 @@ public function update_webhook($data) { $id = $data['id']; unset($data['id']); - return $this->put("webhook/".$id,json_encode($data)); + return $this->put("webhook/".$id, json_encode($data)); } /* @@ -719,7 +719,7 @@ public function update_webhook($data) */ public function get_senders($data) { - return $this->get("advanced",json_encode($data)); + return $this->get("advanced", json_encode($data)); } /* @@ -731,7 +731,7 @@ public function get_senders($data) */ public function create_sender($data) { - return $this->post("advanced",json_encode($data)); + return $this->post("advanced", json_encode($data)); } /* @@ -745,7 +745,7 @@ public function update_sender($data) { $id = $data['id']; unset($data['id']); - return $this->put("advanced/".$id,json_encode($data)); + return $this->put("advanced/".$id, json_encode($data)); } /* @@ -755,7 +755,7 @@ public function update_sender($data) */ public function delete_sender($data) { - return $this->delete("advanced/".$data['id'],""); + return $this->delete("advanced/".$data['id'], ""); } /* @@ -764,7 +764,7 @@ public function delete_sender($data) @options data {Array} to: Email address of the recipient(s). It should be sent as an associative array. Example: array("to@example.net"=>"to whom"). You can use commas to separate multiple recipients [Mandatory] @options data {String} subject: Message subject [Mandatory] @options data {Array} from Email address for From header. It should be sent as an array. Example: array("from@email.com","from email") [Mandatory] - @options data {String} html: Body of the message. (HTML version) [Mandatory]. To send inline images, use image, the 'src' attribute value inside {} (curly braces) should be same as the filename used in 'inline_image' parameter + @options data {String} html: Body of the message. (HTML version) [Mandatory]. To send inline images, use image, the 'src' attribute value inside {} (curly braces) should be same as the filename used in 'inline_image' parameter @options data {String} text: Body of the message. (text version) [Optional] @options data {Array} cc: Same as to but for Cc. Example: array("cc@example.net","cc whom") [Optional] @options data {Array} bcc: Same as to but for Bcc. Example: array("bcc@example.net","bcc whom") [Optional] @@ -775,9 +775,9 @@ public function delete_sender($data) */ public function send_email($data) { - return $this->post("email",json_encode($data)); + return $this->post("email", json_encode($data)); } - + /* Aggregate / date-wise report of the SendinBlue SMTP account. @param {Array} data contains php array with key value pair. @@ -789,9 +789,9 @@ public function send_email($data) */ public function get_statistics($data) { - return $this->post("statistics",json_encode($data)); + return $this->post("statistics", json_encode($data)); } - + /* Get Email Event report. @param {Array} data contains php array with key value pair. @@ -805,7 +805,7 @@ public function get_statistics($data) */ public function get_report($data) { - return $this->post("report",json_encode($data)); + return $this->post("report", json_encode($data)); } /* @@ -817,7 +817,7 @@ public function get_report($data) */ public function delete_bounces($data) { - return $this->post("bounces",json_encode($data)); + return $this->post("bounces", json_encode($data)); } /* @@ -835,7 +835,7 @@ public function send_transactional_template($data) { $id = $data['id']; unset($data['id']); - return $this->put("template/".$id,json_encode($data)); + return $this->put("template/".$id, json_encode($data)); } /* @@ -855,7 +855,7 @@ public function send_transactional_template($data) */ public function create_template($data) { - return $this->post("template",json_encode($data)); + return $this->post("template", json_encode($data)); } /* @@ -878,9 +878,9 @@ public function update_template($data) { $id = $data['id']; unset($data['id']); - return $this->put("template/".$id,json_encode($data)); + return $this->put("template/".$id, json_encode($data)); } - + /* Send a transactional SMS. @param {Array} data contains php array with key value pair. @@ -893,7 +893,7 @@ public function update_template($data) */ public function send_sms($data) { - return $this->post("sms",json_encode($data)); + return $this->post("sms", json_encode($data)); } /* @@ -910,7 +910,7 @@ public function send_sms($data) */ public function create_sms_campaign($data) { - return $this->post("sms",json_encode($data)); + return $this->post("sms", json_encode($data)); } /* @@ -930,7 +930,7 @@ public function update_sms_campaign($data) { $id = $data['id']; unset($data['id']); - return $this->put("sms/".$id,json_encode($data)); + return $this->put("sms/".$id, json_encode($data)); } /* @@ -943,7 +943,6 @@ public function send_bat_sms($data) { $id = $data['id']; unset($data['id']); - return $this->get("sms/".$id,json_encode($data)); + return $this->get("sms/".$id, json_encode($data)); } } -?> \ No newline at end of file