GetNotificationDispatchMethods the available and default notification dispatch methods.
(ctx context.Context)
| 171 | |
| 172 | // GetNotificationDispatchMethods the available and default notification dispatch methods. |
| 173 | func (c *Client) GetNotificationDispatchMethods(ctx context.Context) (NotificationMethodsResponse, error) { |
| 174 | res, err := c.Request(ctx, http.MethodGet, "/api/v2/notifications/dispatch-methods", nil) |
| 175 | if err != nil { |
| 176 | return NotificationMethodsResponse{}, err |
| 177 | } |
| 178 | defer res.Body.Close() |
| 179 | |
| 180 | if res.StatusCode != http.StatusOK { |
| 181 | return NotificationMethodsResponse{}, ReadBodyAsError(res) |
| 182 | } |
| 183 | |
| 184 | var resp NotificationMethodsResponse |
| 185 | body, err := io.ReadAll(res.Body) |
| 186 | if err != nil { |
| 187 | return NotificationMethodsResponse{}, xerrors.Errorf("read response body: %w", err) |
| 188 | } |
| 189 | |
| 190 | if err := json.Unmarshal(body, &resp); err != nil { |
| 191 | return NotificationMethodsResponse{}, xerrors.Errorf("unmarshal response body: %w", err) |
| 192 | } |
| 193 | |
| 194 | return resp, nil |
| 195 | } |
| 196 | |
| 197 | func (c *Client) PostTestNotification(ctx context.Context) error { |
| 198 | res, err := c.Request(ctx, http.MethodPost, "/api/v2/notifications/test", nil) |