From d3c96d18be9c3c835f5a14473ca99f91b30621b3 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Mon, 22 Jul 2019 13:07:28 +0900 Subject: [PATCH] Fix #622: support for WebhookExecute msg response (#663) --- restapi.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/restapi.go b/restapi.go index ce1e823..f1a1ed4 100644 --- a/restapi.go +++ b/restapi.go @@ -2067,14 +2067,20 @@ func (s *Session) WebhookDeleteWithToken(webhookID, token string) (st *Webhook, // WebhookExecute executes a webhook. // webhookID: The ID of a webhook. // token : The auth token for the webhook -func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams) (err error) { +// wait : Waits for server confirmation of message send and ensures that the return struct is populated (it is nil otherwise) +func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams) (st *Message, err error) { uri := EndpointWebhookToken(webhookID, token) if wait { uri += "?wait=true" } - _, err = s.RequestWithBucketID("POST", uri, data, EndpointWebhookToken("", "")) + response, err := s.RequestWithBucketID("POST", uri, data, EndpointWebhookToken("", "")) + if !wait || err != nil { + return + } + + err = unmarshal(response, &st) return }