From 3ba30c173cbdc7f25265142e214a3a1cdb2b4030 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lucas=20Garc=C3=ADa?= <lucas@codeccoop.org>
Date: Sat, 9 Nov 2024 04:30:39 +0100
Subject: [PATCH] feat: add backend headers schema

---
 includes/class-http-client.php |  2 +-
 includes/class-settings.php    | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/includes/class-http-client.php b/includes/class-http-client.php
index 92f86f4..f4bcd7a 100644
--- a/includes/class-http-client.php
+++ b/includes/class-http-client.php
@@ -8,7 +8,7 @@ require_once 'class-multipart.php';
 
 class Http_Client
 {
-    private static const settings_defaults = [
+    private const settings_defaults = [
 		'params' => [],
         'data' => [],
         'headers' => [
diff --git a/includes/class-settings.php b/includes/class-settings.php
index 31fffc9..ba5ec2e 100644
--- a/includes/class-settings.php
+++ b/includes/class-settings.php
@@ -21,7 +21,13 @@ class Settings extends BaseSettings
                             'base_url' => ['type' => 'string'],
                             'headers' => [
                                 'type' => 'array',
-                                'items' => ['type' => 'string'],
+                                'items' => [
+                                    'type' => 'object',
+                                    'properties' => [
+                                        'name' => ['type' => 'string'],
+                                        'value' => ['type' => 'string'],
+                                    ],
+                                ],
                             ],
                         ],
                     ],
@@ -32,7 +38,12 @@ class Settings extends BaseSettings
                     [
                         'name' => 'ERP',
                         'base_url' => 'https://erp.' . $url['host'],
-                        'headers' => ['Authorization: Bearer <backend-api-token>'],
+                        'headers' => [
+							[
+								'name' => 'Authorization',
+                                'value' => 'Bearer <backend-api-token>'
+							]
+						],
                     ],
                 ],
             ],
-- 
GitLab