// Send sends a payload to a webhook.
Send sends a payload to a webhook.
// Send sends a payload to a webhook .
func (h *Webhook) Send(p *Payload) error {
	b, err := json.Marshal(&attachments{[]*attachment{{p.Colour, []string{"text"}, p.Message.String()}}})
	if err != nil {
		return err
	}
	q, err := http.NewRequest(http.MethodPost, h.Endpoint, bytes.NewBuffer(b))
	if err != nil {
		return err
	}
	r, err := http.DefaultClient.Do(q)
	if err != nil {
		return err
	}
	defer r.Body.Close()
	if r.StatusCode != http.StatusOK {
		return fmt.Errorf("unknown slack error: %s", r.Status)
	}
	return nil
}
func ( h * Webhook ) Send ( p * Payload ) error { b , err := json . Marshal ( & attachments { [ ] * attachment { { p . Colour , [ ] string { " " } , p . Message . String ( ) } } } ) if err != nil { return err } q , err := http . NewRequest ( http . MethodPost , h . Endpoint , bytes . NewBuffer ( b ) ) if err != nil { return err } r , err := http . DefaultClient . Do ( q ) if err != nil { return err } defer r . Body . Close ( ) if r . StatusCode != http . StatusOK { return fmt . Errorf ( " " , r . Status ) } return nil }
Send sends a payload to a webhook.
Send sends a payload to a webhook .