Fix #622: support for WebhookExecute msg response (#663)

This commit is contained in:
Qais Patankar 2019-07-22 13:07:28 +09:00 committed by Chris Rhodes
parent a6d2557a8e
commit d3c96d18be

View file

@ -2067,14 +2067,20 @@ func (s *Session) WebhookDeleteWithToken(webhookID, token string) (st *Webhook,
// WebhookExecute executes a webhook. // WebhookExecute executes a webhook.
// webhookID: The ID of a webhook. // webhookID: The ID of a webhook.
// token : The auth token for the 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) uri := EndpointWebhookToken(webhookID, token)
if wait { if wait {
uri += "?wait=true" 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 return
} }