| 1 | package bark |
| 2 | |
| 3 | // PushPayload represents the JSON payload sent to the Bark server API. |
| 4 | // This structure contains all notification parameters that can be customized. |
| 5 | type PushPayload struct { |
| 6 | Body string `json:"body"` |
| 7 | DeviceKey string `json:"device_key"` |
| 8 | Title string `json:"title"` |
| 9 | Sound string `json:"sound,omitempty"` |
| 10 | Badge *int64 `json:"badge,omitempty"` |
| 11 | Icon string `json:"icon,omitempty"` |
| 12 | Group string `json:"group,omitempty"` |
| 13 | URL string `json:"url,omitempty"` |
| 14 | Category string `json:"category,omitempty"` |
| 15 | Copy string `json:"copy,omitempty"` |
| 16 | } |
| 17 | |
| 18 | // APIResponse represents the response structure returned by the Bark server API. |
| 19 | // The server responds with a JSON object containing status code, message, and timestamp. |
| 20 | // |
| 21 | //nolint:errname // APIResponse name is mandated by the Bark API response format |
| 22 | type APIResponse struct { |
| 23 | Code int64 `json:"code"` |
| 24 | Message string `json:"message"` |
| 25 | Timestamp int64 `json:"timestamp"` |
| 26 | } |
| 27 | |
| 28 | // Error returns the error message from the Bark API response. |
| 29 | // This method implements the error interface for APIResponse. |
| 30 | // |
| 31 | // Returns: |
| 32 | // - A formatted error string containing the server message. |
| 33 | func (e *APIResponse) Error() string { |
| 34 | return "server response: " + e.Message |
| 35 | } |