From 509a679ea91cc2a5017276390eea7f904c105dc6 Mon Sep 17 00:00:00 2001
From: Ryan Hanson <ryan.hanson@doppler.com>
Date: Mon, 9 Dec 2024 15:58:28 -0600
Subject: [PATCH] Adding suggested changes from @nmanoogian

---
 doppler/api.go              | 6 +++++-
 doppler/models.go           | 1 +
 doppler/resource_webhook.go | 4 ++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doppler/api.go b/doppler/api.go
index 6d33c51..1b0b260 100644
--- a/doppler/api.go
+++ b/doppler/api.go
@@ -805,7 +805,11 @@ func (client APIClient) UpdateWebhook(ctx context.Context, project string, slug
 	payload["url"] = webhookUrl
 	payload["secret"] = secret
 	payload["payload"] = webhookPayload
-	payload["name"] = webhookName
+	if webhookName != "" {
+		payload["name"] = webhookName
+	} else {
+		payload["name"] = nil
+	}
 	payload["enableConfigs"] = enabledConfigs
 	payload["disableConfigs"] = disabledConfigs
 	payload["authentication"] = auth
diff --git a/doppler/models.go b/doppler/models.go
index a86b4fc..aa8258c 100644
--- a/doppler/models.go
+++ b/doppler/models.go
@@ -160,6 +160,7 @@ type WebhookAuth struct {
 
 type Webhook struct {
 	Slug           string   `json:"id"`
+	Name           string   `json:"name"`
 	Url            string   `json:"url"`
 	Enabled        bool     `json:"enabled"`
 	EnabledConfigs []string `json:"enabledConfigs"`
diff --git a/doppler/resource_webhook.go b/doppler/resource_webhook.go
index 3c10cf1..315e163 100644
--- a/doppler/resource_webhook.go
+++ b/doppler/resource_webhook.go
@@ -248,6 +248,10 @@ func resourceWebhookRead(ctx context.Context, d *schema.ResourceData, m interfac
 		return diag.FromErr(err)
 	}
 
+	if err = d.Set("name", webhook.Name); err != nil {
+		return diag.FromErr(err)
+	}
+
 	return diags
 }