forked from checkout/checkout-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhooks.go
54 lines (45 loc) · 1.38 KB
/
webhooks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package abc
import (
"encoding/json"
"github.com/PaddleHQ/checkout-sdk-go/common"
)
const (
webhooks = "webhooks"
)
type ContentType string
const (
Json ContentType = "json"
)
type (
WebhookRequest struct {
Url string `json:"url"`
Active bool `json:"active,omitempty" default:"true"`
Headers map[string]interface{} `json:"headers,omitempty"`
ContentType ContentType `json:"content_type,omitempty" default:"json"`
EventTypes []string `json:"event_types"`
}
)
type (
WebhookResponse struct {
HttpResponse common.HttpMetadata
Id string `json:"id,omitempty"`
Url string `json:"url,omitempty"`
Active bool `json:"active,omitempty"`
Headers interface{} `json:"headers,omitempty"`
ContentType ContentType `json:"content_type,omitempty"`
EventTypes []string `json:"event_types,omitempty"`
Links map[string]common.Link `json:"_links" json:"links,omitempty"`
}
WebhooksResponse struct {
HttpResponse common.HttpMetadata
WebhookArray []WebhookResponse
}
)
func (e *WebhooksResponse) UnmarshalJSON(data []byte) error {
var webhookArray []WebhookResponse
if err := json.Unmarshal(data, &webhookArray); err != nil {
return err
}
e.WebhookArray = webhookArray
return nil
}