From 82eb838118a1626cc635d46a886317ded4574429 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Thu, 1 Oct 2020 12:07:38 -0300
Subject: [PATCH] Bug 26595: Add smtp_server_info embed option to /libraries

This patch simply adds the option to embed the return value from
Koha::Library->smtp_server_info on the libraries GET actions.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 api/v1/swagger/definitions/library.json | 14 ++++++++++++++
 api/v1/swagger/paths/libraries.json     | 10 ++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/api/v1/swagger/definitions/library.json b/api/v1/swagger/definitions/library.json
index d31a83ff18..bae291cefd 100644
--- a/api/v1/swagger/definitions/library.json
+++ b/api/v1/swagger/definitions/library.json
@@ -83,6 +83,20 @@
     "pickup_location": {
         "type": "boolean",
         "description": "If the library can act as a pickup location"
+    },
+    "smtp_server_info": {
+        "type": "object",
+        "properties": {
+          "name": {
+            "description": "SMTP server name. 'system_default' if no SMTP server is assigned",
+            "type": "string"
+          },
+          "smtp_server_id": {
+            "description": "Internal identifier for the SMTP server",
+            "type": ["integer", "null"]
+          }
+        },
+        "description": "The library effective SMTP server information."
     }
   },
   "additionalProperties": false,
diff --git a/api/v1/swagger/paths/libraries.json b/api/v1/swagger/paths/libraries.json
index 43c4673d5c..23131a3684 100644
--- a/api/v1/swagger/paths/libraries.json
+++ b/api/v1/swagger/paths/libraries.json
@@ -178,7 +178,10 @@
         "permissions": {
           "catalogue": "1"
         }
-      }
+      },
+      "x-koha-embed": [
+        "smtp_server_info"
+      ]
     },
     "post": {
       "x-mojo-to": "Libraries#add",
@@ -284,7 +287,10 @@
         "permissions": {
           "catalogue": "1"
         }
-      }
+      },
+      "x-koha-embed": [
+        "smtp_server_info"
+      ]
     },
     "put": {
       "x-mojo-to": "Libraries#update",
-- 
2.20.1