diff --git a/proxy/config.dist.php b/proxy/config.dist.php index 6ad7b2a..59510bb 100644 --- a/proxy/config.dist.php +++ b/proxy/config.dist.php @@ -111,7 +111,7 @@ $rest_allowed_actions = array( ), ), ), - '123.45.678.1' => array( + '123.45.67.8' => array( 'Contact' => array( 'getsingle' => array( 'first_name' => 'string', @@ -124,3 +124,35 @@ $rest_allowed_actions = array( ), ), ); + + +/**************************************************************** + ** WebHook2API CONFIGURATIONS ** + ****************************************************************/ +# remove if you don't want this feature or rename to $webhook2api to activate +$_webhook2api = [ + "configurations" => [ + "default" => [ + "name" => "Example", + "ip_sources" => ['172.10.0.1/24', '192.168.1.1/24'], // only accept source ID from the given range + "data_sources" => ["POST/json", "REQUEST"], // POST/json json-decodes the post data, REQUEST is PHP's $_REQUEST array + "sentinel" => [["type", "equal:customer.created"]], // only execute if all of these are true + "entity" => "Contact", + "action" => "create", + "api_key" => "api key", + "parameter_mapping" => [ + [["data", "object", "metadata", "salutation"], ["prefix_id"]], + [["data", "object", "metadata", "first_name"], ["first_name"]], + [["data", "object", "metadata", "last_name"], ["last_name"]], + [["data", "object", "metadata", "street"], ["street_address"]], + [["data", "object", "metadata", "zip_code"], ["postal_code"]], + [["data", "object", "metadata", "city"], ["city"]], + [["data", "object", "metadata", "country"], ["country_id"]], + [["data", "object", "metadata", "telephone"], ["phone"]], + [["data", "object", "metadata", "birthday"], ["birth_date"]], + [["data", "object", "metadata", "email"], ["email"]] + ], + "parameter_sanitation" => [], + ] + ] +]; \ No newline at end of file diff --git a/proxy/webhook2api.php b/proxy/webhook2api.php index df93aa3..3ccd54e 100644 --- a/proxy/webhook2api.php +++ b/proxy/webhook2api.php @@ -129,7 +129,8 @@ function webhook2api_processConfiguration($configuration, $post_input) { // run modifiers foreach ($modifiers as $modifier) { - // TODO: + // TODO: implement + civiproxy_log("Webhook2API.modifiers: not implemented!"); } // set to target @@ -142,6 +143,7 @@ function webhook2api_processConfiguration($configuration, $post_input) { // sanitise data if (!empty($configuration['parameter_sanitation']) && is_array($configuration['parameter_sanitation'])) { // TODO: implement + civiproxy_log("Webhook2API.sanitation: not implemented!"); } // send to target REST API @@ -161,6 +163,7 @@ function webhook2api_processConfiguration($configuration, $post_input) { // process result if (!empty($configuration['response_mapping']) && is_array($configuration['response_mapping'])) { // TODO: implement + civiproxy_log("Webhook2API.response_mapping: not implemented!"); } else { // default behaviour: @@ -221,7 +224,7 @@ function webhook2api_getValue($data, $path) { function webhook2api_setValue(&$data, $target_path, $value) { if (is_array($target_path)) { if (count($target_path) == 0) { - // error - bad spec + civiproxy_log("Webhook2API.setValue: Empty target path!"); return; } elseif (count($target_path) == 1) { @@ -237,7 +240,7 @@ function webhook2api_setValue(&$data, $target_path, $value) { if (is_array($data[$element])) { webhook2api_setValue($data[$element], $target_path, $value); } else { - // error - bad spec (path element is not array) + civiproxy_log("Webhook2API.setValue: path node is not an array!"); } } @@ -245,6 +248,6 @@ function webhook2api_setValue(&$data, $target_path, $value) { webhook2api_setValue($data, [$target_path], $value); } else { - // error - bad spec + civiproxy_log("Webhook2API.setValue: path neither string nor array!"); } } \ No newline at end of file