From 2182e3069d6bef955a0edd1876d41ba822e5a366 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Fri, 29 Mar 2019 18:05:58 +0300 Subject: Version on webhooks --- api.go | 7 ++++++- examples/example_1.go | 6 +----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/api.go b/api.go index 1ad4611..f3bc90e 100644 --- a/api.go +++ b/api.go @@ -308,7 +308,12 @@ func (a *Api) GetSubscriptions() (*GetSubscriptionsResult, error) { return result, json.NewDecoder(body).Decode(result) } -func (a *Api) Subscribe(subscription *SubscriptionRequestBody) (*SimpleQueryResult, error) { +func (a *Api) Subscribe(subscribeURL string, updateTypes []string) (*SimpleQueryResult, error) { + subscription := &SubscriptionRequestBody{ + Url: subscribeURL, + UpdateTypes: updateTypes, + Version: a.version, + } result := new(SimpleQueryResult) values := url.Values{} body, err := a.request(http.MethodPost, "subscriptions", values, subscription) diff --git a/examples/example_1.go b/examples/example_1.go index a1fb967..5c03063 100644 --- a/examples/example_1.go +++ b/examples/example_1.go @@ -1,5 +1,3 @@ -// +build ignore - /** * Webhook example */ @@ -30,9 +28,7 @@ func main() { for _, s := range subs.Subscriptions { _, _ = api.Unsubscribe(s.Url) } - subscriptionResp, err := api.Subscribe(&tamtam.SubscriptionRequestBody{ - Url: " https://576df2ec.ngrok.io/webhook", // Replace by your webhook! - }) + subscriptionResp, err := api.Subscribe("https://576df2ec.ngrok.io/webhook", []string{}) log.Printf("Subscription: %#v %#v", subscriptionResp, err) ch := make(chan interface{}) // Channel with updates from TamTam -- cgit v1.2.3