PostWebpushSubscription creates a push notification subscription for a given user.
(ctx context.Context, user string, req WebpushSubscription)
| 241 | |
| 242 | // PostWebpushSubscription creates a push notification subscription for a given user. |
| 243 | func (c *Client) PostWebpushSubscription(ctx context.Context, user string, req WebpushSubscription) error { |
| 244 | res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/users/%s/webpush/subscription", user), req) |
| 245 | if err != nil { |
| 246 | return err |
| 247 | } |
| 248 | defer res.Body.Close() |
| 249 | |
| 250 | if res.StatusCode != http.StatusNoContent { |
| 251 | return ReadBodyAsError(res) |
| 252 | } |
| 253 | return nil |
| 254 | } |
| 255 | |
| 256 | // DeleteWebpushSubscription deletes a push notification subscription for a given user. |
| 257 | // Think of this as an unsubscribe, but for a specific push notification subscription. |