Skip to content
Snippets Groups Projects
Commit 88e74891 authored by Lucas García's avatar Lucas García
Browse files

feat: decouple wpct_oc_set_headers fn interface from gf and use it on wpct_oc_post_odoo

parent 4b6b30c9
No related branches found
No related tags found
No related merge requests found
<?php
function wpct_oc_post_odoo($data,$endpoint) {
$post_url = wpct_oc_get_odoo_base_url().$endpoint;
function wpct_oc_post_odoo($data, $endpoint)
{
$url = parse_url($endpoint);
if (isset($url['scheme'])) {
$post_url = $endpoint;
} else {
$post_url = wpct_oc_get_odoo_base_url() . $endpoint;
}
$post_data = json_encode($data);
$args = array(
'headers' => array(
'headers' => wpct_oc_set_headers(array(
'Content-Type' => 'application/json',
'Connection' => 'keep-alive',
'accept' => 'application/json',
'API-KEY' => wpct_oc_get_api_key()
),
'Accept' => 'application/json',
)),
'body' => $post_data
);
$response = wp_remote_post( $post_url, $args);
if ( !is_wp_error( $response ) ) {
$response = wp_remote_post($post_url, $args);
if (!is_wp_error($response)) {
return $response;
}
return false;
}
......@@ -38,7 +38,7 @@ $GLOBALS['WPCT_OC_DEPENDENCIES'] = array(
wpct_oc_check_dependencies();
// Middleware headers setter
function wpct_oc_set_headers($request_headers, $feed, $entry, $form)
function wpct_oc_set_headers($request_headers)
{
$request_headers['API-KEY'] = wpct_oc_get_api_key();
$request_headers['Accept-Language'] = wpct_oc_accept_language_header();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment