Debian Codegraph @

pkg/services/specialized/notifiarr/notifiarr_example_test.go

raw symbols SCIP
1 package notifiarrscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src . fmt/"
5 "ioscip-go gomod github.com/golang/go/src . io/"
6 "logscip-go gomod github.com/golang/go/src . log/"
7 "net/urlscip-go gomod github.com/golang/go/src . `net/url`/"
8
9 "github.com/jarcoal/httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/"
10
11 "github.com/nicholas-fedor/shoutrrr/pkg/typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/"
12 )
13
14 // Example demonstrates basic notification sending to Notifiarr.
15 func Examplescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example().() {
16 // Activate HTTP mocking for the example
17 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
18
19 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
20
21 // Mock a successful Notifiarr API response
22 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
23 "POST",
24 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
25 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
26 )
27
28 // Create and initialize the service
29 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
30 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("notifiarr://test-api-key")
31
32 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
33 if err != nil {
34 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
35
36 return
37 }
38
39 // Send a notification
40 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().("Hello from Notifiarr!", nil)
41 if err != nil {
42 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
43
44 return
45 }
46
47 // Output: Notification sent successfully
48 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Notification sent successfully")
49 }
50
51 // Example_eventID demonstrates sending a notification with an event ID for message updates.
52 func Example_eventIDscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example_eventID().() {
53 // Activate HTTP mocking for the example
54 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
55
56 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
57
58 // Mock a successful Notifiarr API response
59 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
60 "POST",
61 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
62 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
63 )
64
65 // Create and initialize the service
66 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
67 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("notifiarr://test-api-key")
68
69 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
70 if err != nil {
71 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
72
73 return
74 }
75
76 // Send a notification with event ID and title
77 params := typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#{
78 "id": "alert-123",
79 "title": "System Alert",
80 }
81
82 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().("Server CPU usage is high", &params)
83 if err != nil {
84 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
85
86 return
87 }
88
89 // Output: Notification with event ID sent successfully
90 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Notification with event ID sent successfully")
91 }
92
93 // Example_discordMentions demonstrates Discord mention parsing from message content.
94 func Example_discordMentionsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example_discordMentions().() {
95 // Activate HTTP mocking for the example
96 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
97
98 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
99
100 // Mock a successful Notifiarr API response
101 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
102 "POST",
103 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
104 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
105 )
106
107 // Create and initialize the service
108 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
109 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("notifiarr://test-api-key")
110
111 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
112 if err != nil {
113 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
114
115 return
116 }
117
118 // Send a notification with Discord mentions
119 message := "Alert for <@123456789> and role <@&987654321>"
120
121 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().(message, nil)
122 if err != nil {
123 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
124
125 return
126 }
127
128 // Output: Notification with mentions sent successfully
129 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Notification with mentions sent successfully")
130 }
131
132 // Example_imageThumbnail demonstrates sending a notification with a thumbnail image.
133 func Example_imageThumbnailscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example_imageThumbnail().() {
134 // Activate HTTP mocking for the example
135 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
136
137 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
138
139 // Mock a successful Notifiarr API response
140 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
141 "POST",
142 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
143 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
144 )
145
146 // Create and initialize the service with thumbnail
147 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
148 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("notifiarr://test-api-key?thumbnail=https://example.com/alert.png")
149
150 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
151 if err != nil {
152 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
153
154 return
155 }
156
157 // Send a notification
158 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().("System alert with thumbnail", nil)
159 if err != nil {
160 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
161
162 return
163 }
164
165 // Output: Notification with thumbnail sent successfully
166 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Notification with thumbnail sent successfully")
167 }
168
169 // Example_colorCustomization demonstrates sending a notification with custom color.
170 func Example_colorCustomizationscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example_colorCustomization().() {
171 // Activate HTTP mocking for the example
172 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
173
174 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
175
176 // Mock a successful Notifiarr API response
177 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
178 "POST",
179 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
180 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
181 )
182
183 // Create and initialize the service with color
184 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
185 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("notifiarr://test-api-key?color=16711680") // Red color
186
187 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
188 if err != nil {
189 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
190
191 return
192 }
193
194 // Send a notification
195 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().("Red alert notification", nil)
196 if err != nil {
197 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
198
199 return
200 }
201
202 // Output: Colored notification sent successfully
203 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Colored notification sent successfully")
204 }
205
206 // Example_urlParameterConfiguration demonstrates configuring notifications via URL parameters.
207 func Example_urlParameterConfigurationscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example_urlParameterConfiguration().() {
208 // Activate HTTP mocking for the example
209 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
210
211 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
212
213 // Mock a successful Notifiarr API response
214 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
215 "POST",
216 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
217 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
218 )
219
220 // Create and initialize the service with multiple parameters
221 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
222 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().(
223 "notifiarr://test-api-key?channel=123456789012345678&thumbnail=https://example.com/icon.png&image=https://example.com/image.png&color=65280",
224 )
225
226 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
227 if err != nil {
228 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
229
230 return
231 }
232
233 // Send a notification
234 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().("Fully configured notification with image", nil)
235 if err != nil {
236 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
237
238 return
239 }
240
241 // Output: Fully configured notification with image sent successfully
242 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Fully configured notification with image sent successfully")
243 }
244
245 // Example_imageAndThumbnail demonstrates sending a notification with both image and thumbnail URLs.
246 func Example_imageAndThumbnailscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example_imageAndThumbnail().() {
247 // Activate HTTP mocking for the example
248 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
249
250 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
251
252 // Mock a successful Notifiarr API response
253 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
254 "POST",
255 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
256 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
257 )
258
259 // Create and initialize the service with both image and thumbnail
260 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
261 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().(
262 "notifiarr://test-api-key?thumbnail=https://example.com/thumbnail.png&image=https://example.com/full-image.png",
263 )
264
265 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
266 if err != nil {
267 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
268
269 return
270 }
271
272 // Send a notification
273 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().("Notification with both thumbnail and full image", nil)
274 if err != nil {
275 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
276
277 return
278 }
279
280 // Output: Notification with image and thumbnail sent successfully
281 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Notification with image and thumbnail sent successfully")
282 }
283
284 // Example_advancedTextFields demonstrates sending a notification with advanced text fields including icon, content, and footer.
285 func Example_advancedTextFieldsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Example_advancedTextFields().() {
286 // Activate HTTP mocking for the example
287 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.Activatescip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/Activate().()
288
289 defer httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.DeactivateAndResetscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/DeactivateAndReset().()
290
291 // Mock a successful Notifiarr API response
292 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.RegisterResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/RegisterResponder().(
293 "POST",
294 "https://notifiarr.com/api/v1/notification/passthrough/test-api-key",
295 httpmockscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/.NewStringResponderscip-go gomod github.com/jarcoal/httpmock v1.4.2 `github.com/jarcoal/httpmock`/NewStringResponder().(200, `{"success": true}`),
296 )
297
298 // Create and initialize the service
299 service := &Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#{}
300 serviceURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("notifiarr://test-api-key")
301
302 err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Initialize().(serviceURL, logscip-go gomod github.com/golang/go/src . log/.Newscip-go gomod github.com/golang/go/src . log/New().(ioscip-go gomod github.com/golang/go/src . io/.Discardscip-go gomod github.com/golang/go/src . io/Discard., "", 0))
303 if err != nil {
304 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
305
306 return
307 }
308
309 // Send a notification with advanced text fields
310 params := typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#{
311 "title": "System Status Update",
312 "icon": "https://example.com/icon.png",
313 "content": "Detailed content about the system status",
314 "footer": "Generated by Monitoring System v2.1",
315 }
316
317 err = service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/specialized/notifiarr`/Service#Send().("System is running normally", &params)
318 if err != nil {
319 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Error:", err)
320
321 return
322 }
323
324 // Output: Notification with advanced text fields sent successfully
325 fmtscip-go gomod github.com/golang/go/src . fmt/.Printlnscip-go gomod github.com/golang/go/src . fmt/Println().("Notification with advanced text fields sent successfully")
326 }