Webhook decoding

This commit is contained in:
Ricardo Baptista
2019-10-31 13:36:57 -03:00
parent ad67345b1f
commit d073bb7962
2 changed files with 97 additions and 0 deletions

View File

@ -274,6 +274,19 @@ type Content struct {
Revision string `json:"revision"`
}
type WebhookConfiguration struct {
Secret string `json:"secret"`
}
type Webhook struct {
ID int `json:"id"`
Name string `json:"name"`
Events []string `json:"events"`
Url string `json:"url"`
Active bool `json:"active"`
Configuration WebhookConfiguration `json:"configuration"`
}
func (k *SSHKey) String() string {
parts := make([]string, 1, 2)
parts[0] = strings.TrimSpace(k.Text)
@ -343,6 +356,13 @@ func GetContentResponse(r *APIResponse) (Content, error) {
return c, err
}
// GetWebhooksResponse cast Webhooks into structure
func GetWebhooksResponse(r *APIResponse) ([]Webhook, error) {
var h []Webhook
err := mapstructure.Decode(r.Values["values"], &h)
return h, err
}
// NewAPIResponse create new APIResponse from http.Response
func NewAPIResponse(r *http.Response) *APIResponse {