GetSystemNotificationTemplates retrieves all notification templates pertaining to internal system events.
(ctx context.Context)
| 96 | |
| 97 | // GetSystemNotificationTemplates retrieves all notification templates pertaining to internal system events. |
| 98 | func (c *Client) GetSystemNotificationTemplates(ctx context.Context) ([]NotificationTemplate, error) { |
| 99 | res, err := c.Request(ctx, http.MethodGet, "/api/v2/notifications/templates/system", nil) |
| 100 | if err != nil { |
| 101 | return nil, err |
| 102 | } |
| 103 | defer res.Body.Close() |
| 104 | |
| 105 | if res.StatusCode != http.StatusOK { |
| 106 | return nil, ReadBodyAsError(res) |
| 107 | } |
| 108 | |
| 109 | var templates []NotificationTemplate |
| 110 | body, err := io.ReadAll(res.Body) |
| 111 | if err != nil { |
| 112 | return nil, xerrors.Errorf("read response body: %w", err) |
| 113 | } |
| 114 | |
| 115 | if err := json.Unmarshal(body, &templates); err != nil { |
| 116 | return nil, xerrors.Errorf("unmarshal response body: %w", err) |
| 117 | } |
| 118 | |
| 119 | return templates, nil |
| 120 | } |
| 121 | |
| 122 | // GetUserNotificationPreferences retrieves notification preferences for a given user. |
| 123 | func (c *Client) GetUserNotificationPreferences(ctx context.Context, userID uuid.UUID) ([]NotificationPreference, error) { |