churchtools_api/generated/api.rs
1//! Resource handles returned by the accessors of [`Client`](crate::Client), e.g.
2//! `client.persons()`, with one method per endpoint.
3//!
4//! Generated by codegen/generate.py from the OpenAPI spec of ChurchTools 3.138.1 (build 32938). Do not edit. The spec is licensed under CC BY 4.0 (<https://creativecommons.org/licenses/by/4.0/>); see NOTICE.
5
6#![allow(clippy::all, deprecated, unused_mut)]
7
8use std::fmt::Display;
9
10use super::models;
11use super::queries::*;
12use crate::client::{Client, Items, Method, Query, Upload, encode_path_segment as seg};
13use crate::error::Result;
14
15impl Client {
16 /// Endpoints under `/actions` (1 operations), see [`ActionsResource`].
17 pub fn actions(&self) -> ActionsResource<'_> {
18 ActionsResource { client: self }
19 }
20 /// Endpoints under `/addresses` (5 operations), see [`AddressesResource`].
21 pub fn addresses(&self) -> AddressesResource<'_> {
22 AddressesResource { client: self }
23 }
24 /// Endpoints under `/agenda_templates` (11 operations), see [`AgendaTemplatesResource`].
25 pub fn agenda_templates(&self) -> AgendaTemplatesResource<'_> {
26 AgendaTemplatesResource { client: self }
27 }
28 /// Endpoints under `/agendas` (1 operations), see [`AgendasResource`].
29 pub fn agendas(&self) -> AgendasResource<'_> {
30 AgendasResource { client: self }
31 }
32 /// Endpoints under `/bookings` (9 operations), see [`BookingsResource`].
33 pub fn bookings(&self) -> BookingsResource<'_> {
34 BookingsResource { client: self }
35 }
36 /// Endpoints under `/bulk_jobs` (2 operations), see [`BulkJobsResource`].
37 pub fn bulk_jobs(&self) -> BulkJobsResource<'_> {
38 BulkJobsResource { client: self }
39 }
40 /// Endpoints under `/bulk_letters` (6 operations), see [`BulkLettersResource`].
41 pub fn bulk_letters(&self) -> BulkLettersResource<'_> {
42 BulkLettersResource { client: self }
43 }
44 /// Endpoints under `/calendars` (28 operations), see [`CalendarsResource`].
45 pub fn calendars(&self) -> CalendarsResource<'_> {
46 CalendarsResource { client: self }
47 }
48 /// Endpoints under `/campuses` (5 operations), see [`CampusesResource`].
49 pub fn campuses(&self) -> CampusesResource<'_> {
50 CampusesResource { client: self }
51 }
52 /// Endpoints under `/captcha` (2 operations), see [`CaptchaResource`].
53 pub fn captcha(&self) -> CaptchaResource<'_> {
54 CaptchaResource { client: self }
55 }
56 /// Endpoints under `/chat` (4 operations), see [`ChatResource`].
57 pub fn chat(&self) -> ChatResource<'_> {
58 ChatResource { client: self }
59 }
60 /// Endpoints under `/checkin` (2 operations), see [`CheckinResource`].
61 pub fn checkin(&self) -> CheckinResource<'_> {
62 CheckinResource { client: self }
63 }
64 /// Endpoints under `/church_query` (2 operations), see [`ChurchQueryResource`].
65 pub fn church_query(&self) -> ChurchQueryResource<'_> {
66 ChurchQueryResource { client: self }
67 }
68 /// Endpoints under `/config` (2 operations), see [`ConfigResource`].
69 pub fn config(&self) -> ConfigResource<'_> {
70 ConfigResource { client: self }
71 }
72 /// Endpoints under `/contact_labels` (5 operations), see [`ContactLabelsResource`].
73 pub fn contact_labels(&self) -> ContactLabelsResource<'_> {
74 ContactLabelsResource { client: self }
75 }
76 /// Endpoints under `/csrf_token` (1 operations), see [`CsrfTokenResource`].
77 pub fn csrf_token(&self) -> CsrfTokenResource<'_> {
78 CsrfTokenResource { client: self }
79 }
80 /// Endpoints under `/db_field_types` (1 operations), see [`DbFieldTypesResource`].
81 pub fn db_field_types(&self) -> DbFieldTypesResource<'_> {
82 DbFieldTypesResource { client: self }
83 }
84 /// Endpoints under `/db_fields` (10 operations), see [`DbFieldsResource`].
85 pub fn db_fields(&self) -> DbFieldsResource<'_> {
86 DbFieldsResource { client: self }
87 }
88 /// Endpoints under `/departments` (1 operations), see [`DepartmentsResource`].
89 pub fn departments(&self) -> DepartmentsResource<'_> {
90 DepartmentsResource { client: self }
91 }
92 /// Endpoints under `/domain_objects` (2 operations), see [`DomainObjectsResource`].
93 pub fn domain_objects(&self) -> DomainObjectsResource<'_> {
94 DomainObjectsResource { client: self }
95 }
96 /// Endpoints under `/dynamic_groups` (8 operations), see [`DynamicGroupsResource`].
97 pub fn dynamic_groups(&self) -> DynamicGroupsResource<'_> {
98 DynamicGroupsResource { client: self }
99 }
100 /// Endpoints under `/emails` (2 operations), see [`EmailsResource`].
101 pub fn emails(&self) -> EmailsResource<'_> {
102 EmailsResource { client: self }
103 }
104 /// Endpoints under `/evangelische_termine` (3 operations), see [`EvangelischeTermineResource`].
105 pub fn evangelische_termine(&self) -> EvangelischeTermineResource<'_> {
106 EvangelischeTermineResource { client: self }
107 }
108 /// Endpoints under `/event` (1 operations), see [`EventResource`].
109 pub fn event(&self) -> EventResource<'_> {
110 EventResource { client: self }
111 }
112 /// Endpoints under `/event_templates` (1 operations), see [`EventTemplatesResource`].
113 pub fn event_templates(&self) -> EventTemplatesResource<'_> {
114 EventTemplatesResource { client: self }
115 }
116 /// Endpoints under `/events` (39 operations), see [`EventsResource`].
117 pub fn events(&self) -> EventsResource<'_> {
118 EventsResource { client: self }
119 }
120 /// Endpoints under `/external_logins` (24 operations), see [`ExternalLoginsResource`].
121 pub fn external_logins(&self) -> ExternalLoginsResource<'_> {
122 ExternalLoginsResource { client: self }
123 }
124 /// Endpoints under `/external_posts` (2 operations), see [`ExternalPostsResource`].
125 pub fn external_posts(&self) -> ExternalPostsResource<'_> {
126 ExternalPostsResource { client: self }
127 }
128 /// Endpoints under `/facts` (5 operations), see [`FactsResource`].
129 pub fn facts(&self) -> FactsResource<'_> {
130 FactsResource { client: self }
131 }
132 /// Endpoints under `/feature_usage` (1 operations), see [`FeatureUsageResource`].
133 pub fn feature_usage(&self) -> FeatureUsageResource<'_> {
134 FeatureUsageResource { client: self }
135 }
136 /// Endpoints under `/fields` (1 operations), see [`FieldsResource`].
137 pub fn fields(&self) -> FieldsResource<'_> {
138 FieldsResource { client: self }
139 }
140 /// Endpoints under `/files` (10 operations), see [`FilesResource`].
141 pub fn files(&self) -> FilesResource<'_> {
142 FilesResource { client: self }
143 }
144 /// Endpoints under `/finance` (134 operations), see [`FinanceResource`].
145 pub fn finance(&self) -> FinanceResource<'_> {
146 FinanceResource { client: self }
147 }
148 /// Endpoints under `/followups` (9 operations), see [`FollowupsResource`].
149 pub fn followups(&self) -> FollowupsResource<'_> {
150 FollowupsResource { client: self }
151 }
152 /// Endpoints under `/further_links` (5 operations), see [`FurtherLinksResource`].
153 pub fn further_links(&self) -> FurtherLinksResource<'_> {
154 FurtherLinksResource { client: self }
155 }
156 /// Endpoints under `/group` (31 operations), see [`GroupResource`].
157 pub fn group(&self) -> GroupResource<'_> {
158 GroupResource { client: self }
159 }
160 /// Endpoints under `/group_homepages` (2 operations), see [`GroupHomepagesResource`].
161 pub fn group_homepages(&self) -> GroupHomepagesResource<'_> {
162 GroupHomepagesResource { client: self }
163 }
164 /// Endpoints under `/groups` (78 operations), see [`GroupsResource`].
165 pub fn groups(&self) -> GroupsResource<'_> {
166 GroupsResource { client: self }
167 }
168 /// Endpoints under `/history` (1 operations), see [`HistoryResource`].
169 pub fn history(&self) -> HistoryResource<'_> {
170 HistoryResource { client: self }
171 }
172 /// Endpoints under `/html_templates` (9 operations), see [`HtmlTemplatesResource`].
173 pub fn html_templates(&self) -> HtmlTemplatesResource<'_> {
174 HtmlTemplatesResource { client: self }
175 }
176 /// Endpoints under `/images` (4 operations), see [`ImagesResource`].
177 pub fn images(&self) -> ImagesResource<'_> {
178 ImagesResource { client: self }
179 }
180 /// Endpoints under `/info` (1 operations), see [`InfoResource`].
181 pub fn info(&self) -> InfoResource<'_> {
182 InfoResource { client: self }
183 }
184 /// Endpoints under `/installation_sync` (1 operations), see [`InstallationSyncResource`].
185 pub fn installation_sync(&self) -> InstallationSyncResource<'_> {
186 InstallationSyncResource { client: self }
187 }
188 /// Endpoints under `/job_log` (1 operations), see [`JobLogResource`].
189 pub fn job_log(&self) -> JobLogResource<'_> {
190 JobLogResource { client: self }
191 }
192 /// Endpoints under `/jobs` (3 operations), see [`JobsResource`].
193 pub fn jobs(&self) -> JobsResource<'_> {
194 JobsResource { client: self }
195 }
196 /// Endpoints under `/labels` (2 operations), see [`LabelsResource`].
197 pub fn labels(&self) -> LabelsResource<'_> {
198 LabelsResource { client: self }
199 }
200 /// Endpoints under `/languages` (1 operations), see [`LanguagesResource`].
201 pub fn languages(&self) -> LanguagesResource<'_> {
202 LanguagesResource { client: self }
203 }
204 /// Endpoints under `/license` (1 operations), see [`LicenseResource`].
205 pub fn license(&self) -> LicenseResource<'_> {
206 LicenseResource { client: self }
207 }
208 /// Endpoints under `/login` (5 operations), see [`LoginResource`].
209 pub fn login(&self) -> LoginResource<'_> {
210 LoginResource { client: self }
211 }
212 /// Endpoints under `/logout` (1 operations), see [`LogoutResource`].
213 pub fn logout(&self) -> LogoutResource<'_> {
214 LogoutResource { client: self }
215 }
216 /// Endpoints under `/logs` (3 operations), see [`LogsResource`].
217 pub fn logs(&self) -> LogsResource<'_> {
218 LogsResource { client: self }
219 }
220 /// Endpoints under `/markdown` (2 operations), see [`MarkdownResource`].
221 pub fn markdown(&self) -> MarkdownResource<'_> {
222 MarkdownResource { client: self }
223 }
224 /// Endpoints under `/master_data` (1 operations), see [`MasterDataResource`].
225 pub fn master_data(&self) -> MasterDataResource<'_> {
226 MasterDataResource { client: self }
227 }
228 /// Endpoints under `/meeting_requests` (1 operations), see [`MeetingRequestsResource`].
229 pub fn meeting_requests(&self) -> MeetingRequestsResource<'_> {
230 MeetingRequestsResource { client: self }
231 }
232 /// Endpoints under `/menu` (1 operations), see [`MenuResource`].
233 pub fn menu(&self) -> MenuResource<'_> {
234 MenuResource { client: self }
235 }
236 /// Endpoints under `/news_letter_integrations` (1 operations), see [`NewsLetterIntegrationsResource`].
237 pub fn news_letter_integrations(&self) -> NewsLetterIntegrationsResource<'_> {
238 NewsLetterIntegrationsResource { client: self }
239 }
240 /// Endpoints under `/notes` (5 operations), see [`NotesResource`].
241 pub fn notes(&self) -> NotesResource<'_> {
242 NotesResource { client: self }
243 }
244 /// Endpoints under `/notifications` (1 operations), see [`NotificationsResource`].
245 pub fn notifications(&self) -> NotificationsResource<'_> {
246 NotificationsResource { client: self }
247 }
248 /// Endpoints under `/nps` (1 operations), see [`NpsResource`].
249 pub fn nps(&self) -> NpsResource<'_> {
250 NpsResource { client: self }
251 }
252 /// Endpoints under `/oauth_clients` (4 operations), see [`OauthClientsResource`].
253 pub fn oauth_clients(&self) -> OauthClientsResource<'_> {
254 OauthClientsResource { client: self }
255 }
256 /// Endpoints under `/permissions` (21 operations), see [`PermissionsResource`].
257 pub fn permissions(&self) -> PermissionsResource<'_> {
258 PermissionsResource { client: self }
259 }
260 /// Endpoints under `/person` (21 operations), see [`PersonResource`].
261 pub fn person(&self) -> PersonResource<'_> {
262 PersonResource { client: self }
263 }
264 /// Endpoints under `/persons` (72 operations), see [`PersonsResource`].
265 pub fn persons(&self) -> PersonsResource<'_> {
266 PersonsResource { client: self }
267 }
268 /// Endpoints under `/placeholders` (2 operations), see [`PlaceholdersResource`].
269 pub fn placeholders(&self) -> PlaceholdersResource<'_> {
270 PlaceholdersResource { client: self }
271 }
272 /// Endpoints under `/poll_for_news` (1 operations), see [`PollForNewsResource`].
273 pub fn poll_for_news(&self) -> PollForNewsResource<'_> {
274 PollForNewsResource { client: self }
275 }
276 /// Endpoints under `/post` (8 operations), see [`PostResource`].
277 pub fn post(&self) -> PostResource<'_> {
278 PostResource { client: self }
279 }
280 /// Endpoints under `/posts` (16 operations), see [`PostsResource`].
281 pub fn posts(&self) -> PostsResource<'_> {
282 PostsResource { client: self }
283 }
284 /// Endpoints under `/pr` (1 operations), see [`PrResource`].
285 pub fn pr(&self) -> PrResource<'_> {
286 PrResource { client: self }
287 }
288 /// Endpoints under `/printers` (1 operations), see [`PrintersResource`].
289 pub fn printers(&self) -> PrintersResource<'_> {
290 PrintersResource { client: self }
291 }
292 /// Endpoints under `/probes` (1 operations), see [`ProbesResource`].
293 pub fn probes(&self) -> ProbesResource<'_> {
294 ProbesResource { client: self }
295 }
296 /// Endpoints under `/profiles` (5 operations), see [`ProfilesResource`].
297 pub fn profiles(&self) -> ProfilesResource<'_> {
298 ProfilesResource { client: self }
299 }
300 /// Endpoints under `/public_groups` (11 operations), see [`PublicGroupsResource`].
301 pub fn public_groups(&self) -> PublicGroupsResource<'_> {
302 PublicGroupsResource { client: self }
303 }
304 /// Endpoints under `/queues` (2 operations), see [`QueuesResource`].
305 pub fn queues(&self) -> QueuesResource<'_> {
306 QueuesResource { client: self }
307 }
308 /// Endpoints under `/registration_config` (2 operations), see [`RegistrationConfigResource`].
309 pub fn registration_config(&self) -> RegistrationConfigResource<'_> {
310 RegistrationConfigResource { client: self }
311 }
312 /// Endpoints under `/registrations` (5 operations), see [`RegistrationsResource`].
313 pub fn registrations(&self) -> RegistrationsResource<'_> {
314 RegistrationsResource { client: self }
315 }
316 /// Endpoints under `/repeat_calculation` (5 operations), see [`RepeatCalculationResource`].
317 pub fn repeat_calculation(&self) -> RepeatCalculationResource<'_> {
318 RepeatCalculationResource { client: self }
319 }
320 /// Endpoints under `/reset_password` (1 operations), see [`ResetPasswordResource`].
321 pub fn reset_password(&self) -> ResetPasswordResource<'_> {
322 ResetPasswordResource { client: self }
323 }
324 /// Endpoints under `/resource` (1 operations), see [`ResourceResource`].
325 pub fn resource(&self) -> ResourceResource<'_> {
326 ResourceResource { client: self }
327 }
328 /// Endpoints under `/resource_types` (5 operations), see [`ResourceTypesResource`].
329 pub fn resource_types(&self) -> ResourceTypesResource<'_> {
330 ResourceTypesResource { client: self }
331 }
332 /// Endpoints under `/resources` (6 operations), see [`ResourcesResource`].
333 pub fn resources(&self) -> ResourcesResource<'_> {
334 ResourcesResource { client: self }
335 }
336 /// Endpoints under `/routines` (10 operations), see [`RoutinesResource`].
337 pub fn routines(&self) -> RoutinesResource<'_> {
338 RoutinesResource { client: self }
339 }
340 /// Endpoints under `/saml` (3 operations), see [`SamlResource`].
341 pub fn saml(&self) -> SamlResource<'_> {
342 SamlResource { client: self }
343 }
344 /// Endpoints under `/search` (1 operations), see [`SearchResource`].
345 pub fn search(&self) -> SearchResource<'_> {
346 SearchResource { client: self }
347 }
348 /// Endpoints under `/security_levels` (5 operations), see [`SecurityLevelsResource`].
349 pub fn security_levels(&self) -> SecurityLevelsResource<'_> {
350 SecurityLevelsResource { client: self }
351 }
352 /// Endpoints under `/service_groups` (5 operations), see [`ServiceGroupsResource`].
353 pub fn service_groups(&self) -> ServiceGroupsResource<'_> {
354 ServiceGroupsResource { client: self }
355 }
356 /// Endpoints under `/services` (5 operations), see [`ServicesResource`].
357 pub fn services(&self) -> ServicesResource<'_> {
358 ServicesResource { client: self }
359 }
360 /// Endpoints under `/simulate` (2 operations), see [`SimulateResource`].
361 pub fn simulate(&self) -> SimulateResource<'_> {
362 SimulateResource { client: self }
363 }
364 /// Endpoints under `/song` (10 operations), see [`SongResource`].
365 pub fn song(&self) -> SongResource<'_> {
366 SongResource { client: self }
367 }
368 /// Endpoints under `/songs` (12 operations), see [`SongsResource`].
369 pub fn songs(&self) -> SongsResource<'_> {
370 SongsResource { client: self }
371 }
372 /// Endpoints under `/sso_logins` (1 operations), see [`SsoLoginsResource`].
373 pub fn sso_logins(&self) -> SsoLoginsResource<'_> {
374 SsoLoginsResource { client: self }
375 }
376 /// Endpoints under `/start_page` (1 operations), see [`StartPageResource`].
377 pub fn start_page(&self) -> StartPageResource<'_> {
378 StartPageResource { client: self }
379 }
380 /// Endpoints under `/statuses` (6 operations), see [`StatusesResource`].
381 pub fn statuses(&self) -> StatusesResource<'_> {
382 StatusesResource { client: self }
383 }
384 /// Endpoints under `/subscriptions` (5 operations), see [`SubscriptionsResource`].
385 pub fn subscriptions(&self) -> SubscriptionsResource<'_> {
386 SubscriptionsResource { client: self }
387 }
388 /// Endpoints under `/sync` (55 operations), see [`SyncResource`].
389 pub fn sync(&self) -> SyncResource<'_> {
390 SyncResource { client: self }
391 }
392 /// Endpoints under `/tags` (9 operations), see [`TagsResource`].
393 pub fn tags(&self) -> TagsResource<'_> {
394 TagsResource { client: self }
395 }
396 /// Endpoints under `/translations` (5 operations), see [`TranslationsResource`].
397 pub fn translations(&self) -> TranslationsResource<'_> {
398 TranslationsResource { client: self }
399 }
400 /// Endpoints under `/two_factor` (1 operations), see [`TwoFactorResource`].
401 pub fn two_factor(&self) -> TwoFactorResource<'_> {
402 TwoFactorResource { client: self }
403 }
404 /// Endpoints under `/website` (4 operations), see [`WebsiteResource`].
405 pub fn website(&self) -> WebsiteResource<'_> {
406 WebsiteResource { client: self }
407 }
408 /// Endpoints under `/whoami` (1 operations), see [`WhoamiResource`].
409 pub fn whoami(&self) -> WhoamiResource<'_> {
410 WhoamiResource { client: self }
411 }
412 /// Endpoints under `/widgets` (2 operations), see [`WidgetsResource`].
413 pub fn widgets(&self) -> WidgetsResource<'_> {
414 WidgetsResource { client: self }
415 }
416 /// Endpoints under `/wiki` (13 operations), see [`WikiResource`].
417 pub fn wiki(&self) -> WikiResource<'_> {
418 WikiResource { client: self }
419 }
420}
421
422/// `client.actions()`
423#[derive(Clone, Copy)]
424pub struct ActionsResource<'a> {
425 client: &'a Client,
426}
427
428impl<'a> ActionsResource<'a> {
429 /// Get filtered actions
430 ///
431 /// `POST /actions`
432 ///
433 /// Returns all available actions filtered by one or more domain types. Actions represent executable operations on domain objects (e.g. adding a member to a group, changing a member status). The optional filter object can be used to further narrow down the returned actions based on domain-specific criteria.
434 ///
435 /// # Example
436 ///
437 /// ```no_run
438 /// # use churchtools_api::*;
439 /// # use churchtools_api::queries::*;
440 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
441 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
442 /// let body = models::PostActionsBody {
443 /// domain_type: vec!["group_membership".into()],
444 /// ..Default::default()
445 /// };
446 /// for action in client.actions().filter(&body)? {
447 /// println!("{}", action.domain_type);
448 /// }
449 /// # Ok(())
450 /// # }
451 /// ```
452 pub fn filter(&self, body: &models::PostActionsBody) -> Result<Vec<models::Action>> {
453 let path = "/actions".to_owned();
454 let query: Query = Query::new();
455 let body = serde_json::to_value(body).expect("request body serializes");
456 self.client.request_data(Method::Post, &path, &query, Some(&body))
457 }
458
459}
460
461/// `client.addresses()`
462#[derive(Clone, Copy)]
463pub struct AddressesResource<'a> {
464 client: &'a Client,
465}
466
467impl<'a> AddressesResource<'a> {
468 /// Create an address for a domain object
469 ///
470 /// `POST /addresses/{domainType}/{domainIdentifier}`
471 ///
472 /// Creates another stored meeting-place address for the group. Only domainType=group is registered. Requires permission to edit the group’s meeting-place field (treffpunkt). Ownership and address ID are supplied in the path. Coordinates are accepted as numbers or decimal strings and returned as strings or null. The request does not geocode a postal address automatically.
473 ///
474 /// # Example
475 ///
476 /// ```
477 /// # use churchtools_api::*;
478 /// # use churchtools_api::queries::*;
479 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
480 /// # let client = churchtools_api::replay::client("post-addresses-domainType-domainIdentifier");
481 /// let body = models::GroupAddressCreate {
482 /// name: Some(Some("Retreat Center".into())),
483 /// ..Default::default()
484 /// };
485 /// let result = client.addresses().create("group", "42", &body)?;
486 /// println!("{:?}", result.name);
487 /// # Ok(())
488 /// # }
489 /// ```
490 pub fn create(&self, domain_type: impl Display, domain_identifier: impl Display, body: &models::GroupAddressCreate) -> Result<models::StoredAddress> {
491 let path = format!("/addresses/{}/{}", seg(domain_type), seg(domain_identifier));
492 let query: Query = Query::new();
493 let body = serde_json::to_value(body).expect("request body serializes");
494 self.client.request_data(Method::Post, &path, &query, Some(&body))
495 }
496
497 /// Delete an address
498 ///
499 /// `DELETE /addresses/{domainType}/{domainIdentifier}/{addressId}`
500 ///
501 /// Deletes the stored address identified by addressId. Only domainType=group is registered. Requires permission to edit the meeting-place field (treffpunkt) of the group in the path. The group itself remains. This operation has no dry-run mode; an unknown address ID returns 404.
502 ///
503 /// # Example
504 ///
505 /// ```no_run
506 /// # use churchtools_api::*;
507 /// # use churchtools_api::queries::*;
508 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
509 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
510 /// client.addresses().delete("group", "42", 7)?;
511 /// # Ok(())
512 /// # }
513 /// ```
514 pub fn delete(&self, domain_type: impl Display, domain_identifier: impl Display, address_id: impl Display) -> Result<()> {
515 let path = format!("/addresses/{}/{}/{}", seg(domain_type), seg(domain_identifier), seg(address_id));
516 let query: Query = Query::new();
517 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
518 }
519
520 /// Get addresses by domain object
521 ///
522 /// `GET /addresses/{domainType}/{domainIdentifier}`
523 ///
524 /// Returns stored meeting-place addresses for the group in the path. Only domainType=group is currently registered for this endpoint. Requires permission to view the group. The list is unpaginated, with no guaranteed order; meta.count is the number of addresses returned. An existing group without addresses returns an empty list.
525 ///
526 /// # Example
527 ///
528 /// ```
529 /// # use churchtools_api::*;
530 /// # use churchtools_api::queries::*;
531 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
532 /// # let client = churchtools_api::replay::client("get-addresses-domainType-domainIdentifier");
533 /// for address in client.addresses().get("group", "42")? {
534 /// println!("{:?}", address.name);
535 /// }
536 /// # Ok(())
537 /// # }
538 /// ```
539 pub fn get(&self, domain_type: impl Display, domain_identifier: impl Display) -> Result<Vec<models::StoredAddress>> {
540 let path = format!("/addresses/{}/{}", seg(domain_type), seg(domain_identifier));
541 let query: Query = Query::new();
542 self.client.request_data(Method::Get, &path, &query, None)
543 }
544
545 /// Search for addresses
546 ///
547 /// `GET /addresses/search`
548 ///
549 /// Searches for addresses across persons and a global geocoding service (e.g. Nominatim/Photon). Returns matching results from both sources. The query must be at least 2 characters long.
550 ///
551 /// # Example
552 ///
553 /// ```
554 /// # use churchtools_api::*;
555 /// # use churchtools_api::queries::*;
556 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
557 /// # let client = churchtools_api::replay::client("get-addresses-search");
558 /// let query = GetAddressesSearchQuery {
559 /// query: Some("Musterstraße".into()),
560 /// ..Default::default()
561 /// };
562 /// for search in client.addresses().list_search(&query)? {
563 /// println!("{:?}", search);
564 /// }
565 /// # Ok(())
566 /// # }
567 /// ```
568 pub fn list_search(&self, query: &GetAddressesSearchQuery) -> Result<Vec<models::AddressSearchResult>> {
569 let path = "/addresses/search".to_owned();
570 let query: Query = query.to_query();
571 self.client.request_data(Method::Get, &path, &query, None)
572 }
573
574 /// Update an address
575 ///
576 /// `PUT /addresses/{domainType}/{domainIdentifier}/{addressId}`
577 ///
578 /// Replaces a stored meeting-place address. Omitted body fields are cleared; send all values to retain. Only domainType=group is registered. Requires permission to edit the group’s meeting-place field (treffpunkt). Ownership and address ID are supplied in the path. Coordinates are accepted as numbers or decimal strings and returned as strings or null. The request does not geocode a postal address automatically.
579 ///
580 /// # Example
581 ///
582 /// ```
583 /// # use churchtools_api::*;
584 /// # use churchtools_api::queries::*;
585 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
586 /// # let client = churchtools_api::replay::client("put-addresses-domainType-domainIdentifier-addressId");
587 /// let body = models::GroupAddressUpdate {
588 /// name: Some(Some("Retreat Center".into())),
589 /// ..Default::default()
590 /// };
591 /// let result = client.addresses().update("group", "42", 7, &body)?;
592 /// println!("{:?}", result.name);
593 /// # Ok(())
594 /// # }
595 /// ```
596 pub fn update(&self, domain_type: impl Display, domain_identifier: impl Display, address_id: impl Display, body: &models::GroupAddressUpdate) -> Result<models::StoredAddress> {
597 let path = format!("/addresses/{}/{}/{}", seg(domain_type), seg(domain_identifier), seg(address_id));
598 let query: Query = Query::new();
599 let body = serde_json::to_value(body).expect("request body serializes");
600 self.client.request_data(Method::Put, &path, &query, Some(&body))
601 }
602
603}
604
605/// `client.agenda_templates()`
606#[derive(Clone, Copy)]
607pub struct AgendaTemplatesResource<'a> {
608 client: &'a Client,
609}
610
611impl<'a> AgendaTemplatesResource<'a> {
612 pub fn items(&self) -> AgendaTemplatesItemsResource<'a> {
613 AgendaTemplatesItemsResource { client: self.client }
614 }
615
616 /// Create agenda template
617 ///
618 /// `POST /agendatemplates`
619 ///
620 /// Creates a reusable agenda template and returns HTTP `200` with its complete representation. The caller must be a super administrator or have "edit agenda templates" for the supplied calendar. Items are optional and new templates start unlocked. Template responses use the Agenda schema: name is the stored template name, item start values are `null` and `startTimes` objects are empty.
621 ///
622 /// # Example
623 ///
624 /// ```
625 /// # use churchtools_api::*;
626 /// # use churchtools_api::queries::*;
627 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
628 /// # let client = churchtools_api::replay::client("post-agendatemplates");
629 /// let body = models::AgendaTemplateCreate {
630 /// calendar_id: 1,
631 /// name: "Sunday Service Template".into(),
632 /// ..Default::default()
633 /// };
634 /// let result = client.agenda_templates().create(&body)?;
635 /// println!("{:?}", result.name);
636 /// # Ok(())
637 /// # }
638 /// ```
639 pub fn create(&self, body: &models::AgendaTemplateCreate) -> Result<models::Agenda> {
640 let path = "/agendatemplates".to_owned();
641 let query: Query = Query::new();
642 let body = serde_json::to_value(body).expect("request body serializes");
643 self.client.request_data(Method::Post, &path, &query, Some(&body))
644 }
645
646 /// Delete agenda template
647 ///
648 /// `DELETE /agendatemplates/{agendaId}`
649 ///
650 /// Deletes an unlocked agenda template. Previously copied event agendas retain their independent content. Requires a super administrator or "edit agenda templates" for the template calendar. Passing `dryRun`=`true` still deletes the template; this endpoint does not offer a deletion preview.
651 ///
652 /// Use [`Self::delete_with`] to pass query parameters.
653 ///
654 /// # Example
655 ///
656 /// ```no_run
657 /// # use churchtools_api::*;
658 /// # use churchtools_api::queries::*;
659 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
660 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
661 /// client.agenda_templates().delete(35)?;
662 /// # Ok(())
663 /// # }
664 /// ```
665 pub fn delete(&self, agenda_id: impl Display) -> Result<()> {
666 self.delete_with(agenda_id, &Default::default())
667 }
668
669 /// Delete agenda template
670 ///
671 /// Like [`Self::delete`], with query parameters.
672 ///
673 /// `DELETE /agendatemplates/{agendaId}`
674 ///
675 /// Deletes an unlocked agenda template. Previously copied event agendas retain their independent content. Requires a super administrator or "edit agenda templates" for the template calendar. Passing `dryRun`=`true` still deletes the template; this endpoint does not offer a deletion preview.
676 pub fn delete_with(&self, agenda_id: impl Display, query: &DeleteAgendatemplatesAgendaIdQuery) -> Result<()> {
677 let path = format!("/agendatemplates/{}", seg(agenda_id));
678 let query: Query = query.to_query();
679 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
680 }
681
682 /// Export agenda template
683 ///
684 /// `POST /agendatemplates/{agendaId}/export`
685 ///
686 /// Generates a presenter import archive from an agenda template. Requires a super administrator or "view agenda", "edit agenda" or "edit agenda templates" for its calendar. Locked and unlocked agendas can be exported. Exports of unlocked agendas have a DRAFT label in the generated export name.
687 ///
688 /// # Example
689 ///
690 /// ```no_run
691 /// # use churchtools_api::*;
692 /// # use churchtools_api::queries::*;
693 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
694 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
695 /// let query = PostAgendatemplatesAgendaIdExportQuery {
696 /// format: Some("SONG_BEAMER".into()),
697 /// ..Default::default()
698 /// };
699 /// let body = models::AgendaExportCreate {
700 /// append_arrangement: true,
701 /// export_songs: true,
702 /// with_category: false,
703 /// ..Default::default()
704 /// };
705 /// let agenda_template = client.agenda_templates().export(35, &query, &body)?;
706 /// println!("{}", agenda_template.url);
707 /// # Ok(())
708 /// # }
709 /// ```
710 pub fn export(&self, agenda_id: impl Display, query: &PostAgendatemplatesAgendaIdExportQuery, body: &models::AgendaExportCreate) -> Result<models::AgendaExport> {
711 let path = format!("/agendatemplates/{}/export", seg(agenda_id));
712 let query: Query = query.to_query();
713 let body = serde_json::to_value(body).expect("request body serializes");
714 self.client.request_data(Method::Post, &path, &query, Some(&body))
715 }
716
717 /// Get agenda template
718 ///
719 /// `GET /agendatemplates/{agendaId}`
720 ///
721 /// Returns one agenda template with its complete ordered item list. An ID belonging to an event agenda is not a template and returns `404`. Visibility requires a super administrator or one of "view agenda", "edit agenda" or "edit agenda templates" for the template calendar. Template responses use the Agenda schema: name is the stored template name, item start values are `null` and `startTimes` objects are empty.
722 ///
723 /// # Example
724 ///
725 /// ```
726 /// # use churchtools_api::*;
727 /// # use churchtools_api::queries::*;
728 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
729 /// # let client = churchtools_api::replay::client("get-agendatemplates-agendaId");
730 /// let agenda_template = client.agenda_templates().get(35)?;
731 /// println!("{:?}", agenda_template.name);
732 /// # Ok(())
733 /// # }
734 /// ```
735 pub fn get(&self, agenda_id: impl Display) -> Result<models::Agenda> {
736 let path = format!("/agendatemplates/{}", seg(agenda_id));
737 let query: Query = Query::new();
738 self.client.request_data(Method::Get, &path, &query, None)
739 }
740
741 /// Get all agenda templates
742 ///
743 /// `GET /agendatemplates`
744 ///
745 /// Returns every agenda template visible to the caller, including its items. Visibility requires a super administrator or one of "view agenda", "edit agenda" or "edit agenda templates" for the template calendar. Template responses use the Agenda schema: name is the stored template name, item start values are `null` and `startTimes` objects are empty.
746 ///
747 /// # Example
748 ///
749 /// ```
750 /// # use churchtools_api::*;
751 /// # use churchtools_api::queries::*;
752 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
753 /// # let client = churchtools_api::replay::client("get-agendatemplates");
754 /// for agenda_template in client.agenda_templates().list()? {
755 /// println!("{:?}", agenda_template.name);
756 /// }
757 /// # Ok(())
758 /// # }
759 /// ```
760 pub fn list(&self) -> Result<Vec<models::Agenda>> {
761 let path = "/agendatemplates".to_owned();
762 let query: Query = Query::new();
763 self.client.request_data(Method::Get, &path, &query, None)
764 }
765
766 /// Update agenda template
767 ///
768 /// `PUT /agendatemplates/{agendaId}`
769 ///
770 /// Updates the template metadata and, when supplied, replaces its complete item list. Existing item IDs may be supplied once each to retain those items. The template must be unlocked. Requires a super administrator or "edit agenda templates" for the template's existing calendar.
771 ///
772 /// # Example
773 ///
774 /// ```
775 /// # use churchtools_api::*;
776 /// # use churchtools_api::queries::*;
777 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
778 /// # let client = churchtools_api::replay::client("put-agendatemplates-agendaId");
779 /// let body = models::AgendaTemplateUpdate {
780 /// calendar_id: 1,
781 /// name: "Sunday Service Template".into(),
782 /// ..Default::default()
783 /// };
784 /// let result = client.agenda_templates().update(35, &body)?;
785 /// println!("{:?}", result.name);
786 /// # Ok(())
787 /// # }
788 /// ```
789 pub fn update(&self, agenda_id: impl Display, body: &models::AgendaTemplateUpdate) -> Result<models::Agenda> {
790 let path = format!("/agendatemplates/{}", seg(agenda_id));
791 let query: Query = Query::new();
792 let body = serde_json::to_value(body).expect("request body serializes");
793 self.client.request_data(Method::Put, &path, &query, Some(&body))
794 }
795
796}
797
798/// `client.agenda_templates().items()`
799#[derive(Clone, Copy)]
800pub struct AgendaTemplatesItemsResource<'a> {
801 client: &'a Client,
802}
803
804impl<'a> AgendaTemplatesItemsResource<'a> {
805 pub fn service_groups(&self) -> AgendaTemplatesItemsServiceGroupsResource<'a> {
806 AgendaTemplatesItemsServiceGroupsResource { client: self.client }
807 }
808
809 /// Create agenda template item
810 ///
811 /// `POST /agendatemplates/{agendaId}/items`
812 ///
813 /// Adds a header, text or song item to an existing agenda template. Without `before_id` or `after_id`, the new item is appended. Use at most one of `before_id` and `after_id`, referring to an item in the same template. Relative positioning can adjust `eventStartPosition`. Requires a super administrator or "edit agenda templates" for the template calendar.
814 ///
815 /// Use [`Self::create_with`] to pass query parameters.
816 ///
817 /// # Example
818 ///
819 /// ```
820 /// # use churchtools_api::*;
821 /// # use churchtools_api::queries::*;
822 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
823 /// # let client = churchtools_api::replay::client("post-agendatemplates-agendaId-items");
824 /// let body = serde_json::json!({
825 /// "type": "header"
826 /// });
827 /// let result = client.agenda_templates().items().create(35, &body)?;
828 /// println!("{:?}", result);
829 /// # Ok(())
830 /// # }
831 /// ```
832 pub fn create(&self, agenda_id: impl Display, body: &serde_json::Value) -> Result<serde_json::Value> {
833 self.create_with(agenda_id, &Default::default(), body)
834 }
835
836 /// Create agenda template item
837 ///
838 /// Like [`Self::create`], with query parameters.
839 ///
840 /// `POST /agendatemplates/{agendaId}/items`
841 ///
842 /// Adds a header, text or song item to an existing agenda template. Without `before_id` or `after_id`, the new item is appended. Use at most one of `before_id` and `after_id`, referring to an item in the same template. Relative positioning can adjust `eventStartPosition`. Requires a super administrator or "edit agenda templates" for the template calendar.
843 pub fn create_with(&self, agenda_id: impl Display, query: &PostAgendatemplatesAgendaIdItemsQuery, body: &serde_json::Value) -> Result<serde_json::Value> {
844 let path = format!("/agendatemplates/{}/items", seg(agenda_id));
845 let query: Query = query.to_query();
846 let body = serde_json::to_value(body).expect("request body serializes");
847 self.client.request_data(Method::Post, &path, &query, Some(&body))
848 }
849
850 /// Delete agenda template item
851 ///
852 /// `DELETE /agendatemplates/{agendaId}/items/{itemId}`
853 ///
854 /// Removes one item from the template, including its service-group notes. Other items remain. Repeating the deletion returns `404` because the item no longer exists. Requires a super administrator or "edit agenda templates" for the template calendar.
855 ///
856 /// # Example
857 ///
858 /// ```no_run
859 /// # use churchtools_api::*;
860 /// # use churchtools_api::queries::*;
861 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
862 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
863 /// client.agenda_templates().items().delete(35, 123)?;
864 /// # Ok(())
865 /// # }
866 /// ```
867 pub fn delete(&self, agenda_id: impl Display, item_id: impl Display) -> Result<()> {
868 let path = format!("/agendatemplates/{}/items/{}", seg(agenda_id), seg(item_id));
869 let query: Query = Query::new();
870 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
871 }
872
873 /// Update agenda template item
874 ///
875 /// `PUT /agendatemplates/{agendaId}/items/{itemId}`
876 ///
877 /// Updates one item in an agenda template. The item must belong to this template. Without `before_id` or `after_id` its position is retained. Moving an item still requires type and, for a song, `arrangementId`; this is not a position-only patch. Requires a super administrator or "edit agenda templates" for the template calendar.
878 ///
879 /// Use [`Self::update_with`] to pass query parameters.
880 ///
881 /// # Example
882 ///
883 /// ```
884 /// # use churchtools_api::*;
885 /// # use churchtools_api::queries::*;
886 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
887 /// # let client = churchtools_api::replay::client("put-agendatemplates-agendaId-items-itemId");
888 /// let body = serde_json::json!({
889 /// "type": "header"
890 /// });
891 /// let result = client.agenda_templates().items().update(35, 123, &body)?;
892 /// println!("{:?}", result);
893 /// # Ok(())
894 /// # }
895 /// ```
896 pub fn update(&self, agenda_id: impl Display, item_id: impl Display, body: &serde_json::Value) -> Result<serde_json::Value> {
897 self.update_with(agenda_id, item_id, &Default::default(), body)
898 }
899
900 /// Update agenda template item
901 ///
902 /// Like [`Self::update`], with query parameters.
903 ///
904 /// `PUT /agendatemplates/{agendaId}/items/{itemId}`
905 ///
906 /// Updates one item in an agenda template. The item must belong to this template. Without `before_id` or `after_id` its position is retained. Moving an item still requires type and, for a song, `arrangementId`; this is not a position-only patch. Requires a super administrator or "edit agenda templates" for the template calendar.
907 pub fn update_with(&self, agenda_id: impl Display, item_id: impl Display, query: &PutAgendatemplatesAgendaIdItemsItemIdQuery, body: &serde_json::Value) -> Result<serde_json::Value> {
908 let path = format!("/agendatemplates/{}/items/{}", seg(agenda_id), seg(item_id));
909 let query: Query = query.to_query();
910 let body = serde_json::to_value(body).expect("request body serializes");
911 self.client.request_data(Method::Put, &path, &query, Some(&body))
912 }
913
914}
915
916/// `client.agenda_templates().items().service_groups()`
917#[derive(Clone, Copy)]
918pub struct AgendaTemplatesItemsServiceGroupsResource<'a> {
919 client: &'a Client,
920}
921
922impl<'a> AgendaTemplatesItemsServiceGroupsResource<'a> {
923 /// Delete service group note from agenda template item
924 ///
925 /// `DELETE /agendatemplates/{agendaId}/items/{itemId}/servicegroups/{serviceGroupId}`
926 ///
927 /// Removes the note for one service group on a template item. An already absent note still returns `204`; an absent item returns `404`. Notes for other service groups and the remaining item content are retained. Template reads return service-group notes without filtering by service-group visibility. Requires a super administrator or "edit agenda templates" for the template calendar.
928 ///
929 /// # Example
930 ///
931 /// ```no_run
932 /// # use churchtools_api::*;
933 /// # use churchtools_api::queries::*;
934 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
935 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
936 /// client.agenda_templates().items().service_groups().delete(35, 123, 13)?;
937 /// # Ok(())
938 /// # }
939 /// ```
940 pub fn delete(&self, agenda_id: impl Display, item_id: impl Display, service_group_id: impl Display) -> Result<()> {
941 let path = format!("/agendatemplates/{}/items/{}/servicegroups/{}", seg(agenda_id), seg(item_id), seg(service_group_id));
942 let query: Query = Query::new();
943 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
944 }
945
946 /// Add or update service group note for agenda template item
947 ///
948 /// `PUT /agendatemplates/{agendaId}/items/{itemId}/servicegroups/{serviceGroupId}`
949 ///
950 /// Creates or replaces the note for one service group on a template item. Notes for other service groups and the remaining item content are retained. Template reads return service-group notes without filtering by service-group visibility. Requires a super administrator or "edit agenda templates" for the template calendar.
951 ///
952 /// # Example
953 ///
954 /// ```no_run
955 /// # use churchtools_api::*;
956 /// # use churchtools_api::queries::*;
957 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
958 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
959 /// let body = models::AgendaServiceGroupNoteUpdate {
960 /// note: Some(Some("Remember to bring the sheet music".into())),
961 /// ..Default::default()
962 /// };
963 /// client.agenda_templates().items().service_groups().update(35, 123, 13, &body)?;
964 /// # Ok(())
965 /// # }
966 /// ```
967 pub fn update(&self, agenda_id: impl Display, item_id: impl Display, service_group_id: impl Display, body: &models::AgendaServiceGroupNoteUpdate) -> Result<()> {
968 let path = format!("/agendatemplates/{}/items/{}/servicegroups/{}", seg(agenda_id), seg(item_id), seg(service_group_id));
969 let query: Query = Query::new();
970 let body = serde_json::to_value(body).expect("request body serializes");
971 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
972 }
973
974}
975
976/// `client.agendas()`
977#[derive(Clone, Copy)]
978pub struct AgendasResource<'a> {
979 client: &'a Client,
980}
981
982impl<'a> AgendasResource<'a> {
983 /// Send agenda email to recipients
984 ///
985 /// `POST /agendas/send`
986 ///
987 /// Deprecated compatibility endpoint for `POST /events/send`. Recipients are filtered to selected participants in visible service groups or other selected people the sender may view and the response reports the effective scope. `sendCopyToMe` can add the sender. Events do not have to share an agenda. Agenda links are included for events whose agenda the sender may view.
988 ///
989 /// # Example
990 ///
991 /// ```no_run
992 /// # use churchtools_api::*;
993 /// # use churchtools_api::queries::*;
994 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
995 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
996 /// let body = models::AgendaMailCreate {
997 /// body: "<p>Please review the updated agenda for Sunday.</p>".into(),
998 /// event_ids: vec![31, 32],
999 /// recipients: vec![40, 41],
1000 /// subject: "Updated Sunday agenda".into(),
1001 /// ..Default::default()
1002 /// };
1003 /// let agenda = client.agendas().send(&body)?;
1004 /// println!("{:?}", agenda);
1005 /// # Ok(())
1006 /// # }
1007 /// ```
1008 #[deprecated = "POST /agendas/send is deprecated in the ChurchTools API."]
1009 pub fn send(&self, body: &models::AgendaMailCreate) -> Result<models::EventMailSendResult> {
1010 let path = "/agendas/send".to_owned();
1011 let query: Query = Query::new();
1012 let body = serde_json::to_value(body).expect("request body serializes");
1013 self.client.request_data(Method::Post, &path, &query, Some(&body))
1014 }
1015
1016}
1017
1018/// `client.bookings()`
1019#[derive(Clone, Copy)]
1020pub struct BookingsResource<'a> {
1021 client: &'a Client,
1022}
1023
1024impl<'a> BookingsResource<'a> {
1025 /// Answer a booking request
1026 ///
1027 /// `PUT /bookings/{bookingId}/{answer}`
1028 ///
1029 /// Changes the status of the entire booking: `approve` sets approved (2), `reject` sets rejected (3), and `reset` sets pending (1). `cancel` is a legacy alias for `reject`. Requires permission to update the booking to the target status.
1030 ///
1031 /// # Example
1032 ///
1033 /// ```no_run
1034 /// # use churchtools_api::*;
1035 /// # use churchtools_api::queries::*;
1036 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1037 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1038 /// let booking = client.bookings().answer(8, "approve")?;
1039 /// println!("{}", booking.title);
1040 /// # Ok(())
1041 /// # }
1042 /// ```
1043 pub fn answer(&self, booking_id: impl Display, answer: impl Display) -> Result<models::BookingBase> {
1044 let path = format!("/bookings/{}/{}", seg(booking_id), seg(answer));
1045 let query: Query = Query::new();
1046 self.client.request_data(Method::Put, &path, &query, None)
1047 }
1048
1049 /// Create a resource booking
1050 ///
1051 /// `POST /bookings`
1052 ///
1053 /// Creates an independent booking for one resource. Requires permission to create bookings with the requested status. Resources with `needsAppointment=true` return 422. Automatic approval and conflicts can change the returned `statusId`.
1054 ///
1055 /// # Example
1056 ///
1057 /// ```
1058 /// # use churchtools_api::*;
1059 /// # use churchtools_api::queries::*;
1060 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1061 /// # let client = churchtools_api::replay::client("post-bookings");
1062 /// let body = models::BookingCreate {
1063 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
1064 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
1065 /// resource_id: 7,
1066 /// show_in_cal: true,
1067 /// status_id: 1,
1068 /// title: "Band rehearsal".into(),
1069 /// ..Default::default()
1070 /// };
1071 /// let result = client.bookings().create(&body)?;
1072 /// println!("{}", result.title);
1073 /// # Ok(())
1074 /// # }
1075 /// ```
1076 pub fn create(&self, body: &models::BookingCreate) -> Result<models::BookingBase> {
1077 let path = "/bookings".to_owned();
1078 let query: Query = Query::new();
1079 let body = serde_json::to_value(body).expect("request body serializes");
1080 self.client.request_data(Method::Post, &path, &query, Some(&body))
1081 }
1082
1083 /// Delete a booking series
1084 ///
1085 /// `DELETE /bookings/{bookingId}`
1086 ///
1087 /// Deletes the complete booking, including all occurrences. To remove only an occurrence, update the independent booking’s exceptions or the linked appointment. Allowed for the booking creator, users with permission to administer bookings for the resource, or its resource administrators.
1088 ///
1089 /// # Example
1090 ///
1091 /// ```no_run
1092 /// # use churchtools_api::*;
1093 /// # use churchtools_api::queries::*;
1094 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1095 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1096 /// client.bookings().delete(8)?;
1097 /// # Ok(())
1098 /// # }
1099 /// ```
1100 pub fn delete(&self, booking_id: impl Display) -> Result<()> {
1101 let path = format!("/bookings/{}", seg(booking_id));
1102 let query: Query = Query::new();
1103 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
1104 }
1105
1106 /// Get a booking series
1107 ///
1108 /// `GET /bookings/{bookingId}`
1109 ///
1110 /// Returns the stored booking and every calculated occurrence of its series, indexed by local start date. Requires permission to view its resource. Booking details may be anonymized. Use `include[]` to request conflicts or involved persons.
1111 ///
1112 /// Use [`Self::get_with`] to pass query parameters.
1113 ///
1114 /// # Example
1115 ///
1116 /// ```
1117 /// # use churchtools_api::*;
1118 /// # use churchtools_api::queries::*;
1119 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1120 /// # let client = churchtools_api::replay::client("get-bookings-id");
1121 /// let booking = client.bookings().get(8)?;
1122 /// println!("{:?}", booking);
1123 /// # Ok(())
1124 /// # }
1125 /// ```
1126 pub fn get(&self, booking_id: impl Display) -> Result<models::BookingWithIncludes> {
1127 self.get_with(booking_id, &Default::default())
1128 }
1129
1130 /// Get a booking series
1131 ///
1132 /// Like [`Self::get`], with query parameters.
1133 ///
1134 /// `GET /bookings/{bookingId}`
1135 ///
1136 /// Returns the stored booking and every calculated occurrence of its series, indexed by local start date. Requires permission to view its resource. Booking details may be anonymized. Use `include[]` to request conflicts or involved persons.
1137 pub fn get_with(&self, booking_id: impl Display, query: &GetBookingsIdQuery) -> Result<models::BookingWithIncludes> {
1138 let path = format!("/bookings/{}", seg(booking_id));
1139 let query: Query = query.to_query();
1140 self.client.request_data(Method::Get, &path, &query, None)
1141 }
1142
1143 /// List booking occurrences
1144 ///
1145 /// `GET /bookings`
1146 ///
1147 /// Returns occurrences overlapping the requested date range for the selected resources. The same recurring booking ID can appear more than once with different `booking.calculated` dates. `from` and `to` are inclusive local dates. Requires permission to view every selected resource. Booking details may be anonymized.
1148 ///
1149 /// # Example
1150 ///
1151 /// ```
1152 /// # use churchtools_api::*;
1153 /// # use churchtools_api::queries::*;
1154 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1155 /// # let client = churchtools_api::replay::client("get-bookings");
1156 /// let query = GetBookingsQuery {
1157 /// resource_ids: Some(vec![42]),
1158 /// ..Default::default()
1159 /// };
1160 /// for booking in client.bookings().list(&query)? {
1161 /// println!("{:?}", booking);
1162 /// }
1163 /// # Ok(())
1164 /// # }
1165 /// ```
1166 pub fn list(&self, query: &GetBookingsQuery) -> Result<Vec<models::BookingCalculatedWithIncludes>> {
1167 let path = "/bookings".to_owned();
1168 let query: Query = query.to_query();
1169 self.client.request_data(Method::Get, &path, &query, None)
1170 }
1171
1172 /// Preview conflicts for a new booking
1173 ///
1174 /// `POST /bookings/conflicts`
1175 ///
1176 /// Calculates overlapping occurrences of other pending or approved bookings for the proposed resource and schedule. Does not create a booking or reserve availability. Returns the conflicting occurrences, whose titles may be anonymized. Adjacent timed bookings do not conflict. Repeated overlaps can return the same conflicting occurrence more than once.
1177 ///
1178 /// # Example
1179 ///
1180 /// ```
1181 /// # use churchtools_api::*;
1182 /// # use churchtools_api::queries::*;
1183 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1184 /// # let client = churchtools_api::replay::client("post-bookings-conflicts");
1185 /// let body = models::BookingConflictRequestBody {
1186 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
1187 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
1188 /// resource_id: 7,
1189 /// ..Default::default()
1190 /// };
1191 /// for booking in client.bookings().preview_conflicts(&body)? {
1192 /// println!("{}", booking.title);
1193 /// }
1194 /// # Ok(())
1195 /// # }
1196 /// ```
1197 pub fn preview_conflicts(&self, body: &models::BookingConflictRequestBody) -> Result<Vec<models::BookingConflict>> {
1198 let path = "/bookings/conflicts".to_owned();
1199 let query: Query = Query::new();
1200 let body = serde_json::to_value(body).expect("request body serializes");
1201 self.client.request_data(Method::Post, &path, &query, Some(&body))
1202 }
1203
1204 /// Preview conflicts for an existing booking
1205 ///
1206 /// `POST /bookings/{bookingId}/conflicts`
1207 ///
1208 /// Calculates conflicts for a replacement schedule using the stored booking’s resource. The booking itself is excluded; resourceId in the request is not used. Requires permission to update the booking. No changes are saved. Returns the conflicting occurrences, whose titles may be anonymized. Adjacent timed bookings do not conflict. Repeated overlaps can return the same conflicting occurrence more than once.
1209 ///
1210 /// # Example
1211 ///
1212 /// ```
1213 /// # use churchtools_api::*;
1214 /// # use churchtools_api::queries::*;
1215 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1216 /// # let client = churchtools_api::replay::client("post-bookings-id-conflicts");
1217 /// let body = models::BookingConflictUpdate {
1218 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
1219 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
1220 /// ..Default::default()
1221 /// };
1222 /// for booking in client.bookings().preview_conflicts_for(8, &body)? {
1223 /// println!("{}", booking.title);
1224 /// }
1225 /// # Ok(())
1226 /// # }
1227 /// ```
1228 pub fn preview_conflicts_for(&self, booking_id: impl Display, body: &models::BookingConflictUpdate) -> Result<Vec<models::BookingConflict>> {
1229 let path = format!("/bookings/{}/conflicts", seg(booking_id));
1230 let query: Query = Query::new();
1231 let body = serde_json::to_value(body).expect("request body serializes");
1232 self.client.request_data(Method::Post, &path, &query, Some(&body))
1233 }
1234
1235 /// Split and replace a booking occurrence
1236 ///
1237 /// `POST /bookings/{bookingId}`
1238 ///
1239 /// Removes one date or the remainder of an independent series and creates a replacement booking. `splitDate` identifies the original occurrence. Appointment-linked bookings cannot be split here. Requires permission to update the booking. Automatic approval and conflicts can change the returned `statusId`.
1240 ///
1241 /// # Example
1242 ///
1243 /// ```no_run
1244 /// # use churchtools_api::*;
1245 /// # use churchtools_api::queries::*;
1246 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1247 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1248 /// let body = models::BookingSplitCreate {
1249 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
1250 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
1251 /// resource_id: 7,
1252 /// show_in_cal: true,
1253 /// status_id: 1,
1254 /// title: "Band rehearsal".into(),
1255 /// split_date: "2026-09-20".parse()?,
1256 /// split_until_end: false,
1257 /// ..Default::default()
1258 /// };
1259 /// let booking = client.bookings().split(8, &body)?;
1260 /// println!("{}", booking.title);
1261 /// # Ok(())
1262 /// # }
1263 /// ```
1264 pub fn split(&self, booking_id: impl Display, body: &models::BookingSplitCreate) -> Result<models::BookingBase> {
1265 let path = format!("/bookings/{}", seg(booking_id));
1266 let query: Query = Query::new();
1267 let body = serde_json::to_value(body).expect("request body serializes");
1268 self.client.request_data(Method::Post, &path, &query, Some(&body))
1269 }
1270
1271 /// Update a resource booking
1272 ///
1273 /// `PUT /bookings/{bookingId}`
1274 ///
1275 /// Replaces an independent booking. For an appointment-linked booking, only `statusId` and `description` are processed; update its resource and schedule through the appointment APIs. Requires permission to update the booking. Automatic approval and conflicts can change the returned `statusId`.
1276 ///
1277 /// # Example
1278 ///
1279 /// ```
1280 /// # use churchtools_api::*;
1281 /// # use churchtools_api::queries::*;
1282 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1283 /// # let client = churchtools_api::replay::client("put-bookings-id");
1284 /// let body = serde_json::json!({
1285 /// "endDate": "2026-09-20T09:30:00Z",
1286 /// "startDate": "2026-09-20T08:00:00Z",
1287 /// "resourceId": 7,
1288 /// "showInCal": true,
1289 /// "statusId": 1,
1290 /// "title": "Band rehearsal"
1291 /// });
1292 /// let result = client.bookings().update(8, &body)?;
1293 /// println!("{}", result.title);
1294 /// # Ok(())
1295 /// # }
1296 /// ```
1297 pub fn update(&self, booking_id: impl Display, body: &serde_json::Value) -> Result<models::BookingBase> {
1298 let path = format!("/bookings/{}", seg(booking_id));
1299 let query: Query = Query::new();
1300 let body = serde_json::to_value(body).expect("request body serializes");
1301 self.client.request_data(Method::Put, &path, &query, Some(&body))
1302 }
1303
1304}
1305
1306/// `client.bulk_jobs()`
1307#[derive(Clone, Copy)]
1308pub struct BulkJobsResource<'a> {
1309 client: &'a Client,
1310}
1311
1312impl<'a> BulkJobsResource<'a> {
1313 /// Enqueue a bulk operation
1314 ///
1315 /// `POST /bulkjobs/{domainType}/{jobKey}/enqueue`
1316 ///
1317 /// Queues the selected operation for targets allowed by its preflight permission check. Forbidden targets are omitted; remaining IDs retain order and duplicates. Each queued chunk normally contains up to 50 IDs, or 5 for group/delete. HTTP 201 confirms enqueueing, not successful execution, and can contain zero queued jobs. Each target is processed separately. Follow job or queue status using the returned identifiers.
1318 ///
1319 /// # Example
1320 ///
1321 /// ```no_run
1322 /// # use churchtools_api::*;
1323 /// # use churchtools_api::queries::*;
1324 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1325 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1326 /// let body = models::BulkJobCreate {
1327 /// domain_object_identifiers: vec![serde_json::json!(42)],
1328 /// job_data: serde_json::json!({}),
1329 /// ..Default::default()
1330 /// };
1331 /// let bulk_job = client.bulk_jobs().enqueue("group", "setMaxMembers", &body)?;
1332 /// println!("{}", bulk_job.job_group);
1333 /// # Ok(())
1334 /// # }
1335 /// ```
1336 pub fn enqueue(&self, domain_type: impl Display, job_key: impl Display, body: &models::BulkJobCreate) -> Result<models::BulkJobQueued> {
1337 let path = format!("/bulkjobs/{}/{}/enqueue", seg(domain_type), seg(job_key));
1338 let query: Query = Query::new();
1339 let body = serde_json::to_value(body).expect("request body serializes");
1340 self.client.request_data(Method::Post, &path, &query, Some(&body))
1341 }
1342
1343 /// Preview permitted bulk targets
1344 ///
1345 /// `POST /bulkjobs/{domainType}/{jobKey}/infos`
1346 ///
1347 /// Checks which supplied target identifiers the current user is allowed to process for the chosen job and payload. This is a read-only permission preview: it does not queue or execute the operation. Forbidden targets are silently omitted, while missing targets, invalid data and other errors may abort the whole request. Order and duplicate identifiers are retained. No reservation is made. See BulkJobCreate for domain/key mappings.
1348 ///
1349 /// # Example
1350 ///
1351 /// ```no_run
1352 /// # use churchtools_api::*;
1353 /// # use churchtools_api::queries::*;
1354 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1355 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1356 /// let body = models::BulkJobCreate {
1357 /// domain_object_identifiers: vec![serde_json::json!(42)],
1358 /// job_data: serde_json::json!({}),
1359 /// ..Default::default()
1360 /// };
1361 /// let bulk_job = client.bulk_jobs().infos("group", "setMaxMembers", &body)?;
1362 /// println!("{:?}", bulk_job);
1363 /// # Ok(())
1364 /// # }
1365 /// ```
1366 pub fn infos(&self, domain_type: impl Display, job_key: impl Display, body: &models::BulkJobCreate) -> Result<models::BulkInfos> {
1367 let path = format!("/bulkjobs/{}/{}/infos", seg(domain_type), seg(job_key));
1368 let query: Query = Query::new();
1369 let body = serde_json::to_value(body).expect("request body serializes");
1370 self.client.request_data(Method::Post, &path, &query, Some(&body))
1371 }
1372
1373}
1374
1375/// `client.bulk_letters()`
1376#[derive(Clone, Copy)]
1377pub struct BulkLettersResource<'a> {
1378 client: &'a Client,
1379}
1380
1381impl<'a> BulkLettersResource<'a> {
1382 /// Create a bulkletter
1383 ///
1384 /// `POST /bulkletters`
1385 ///
1386 /// Schedules a mail-merge rendering job and starts the worker in the background. Requires edit bulkletter permission and access to the selected HTML template. Returns HTTP 200 with only {id}, plus a Location header for the job; it does not return the job object or finished PDF. Poll that URL until the job is DONE and has fileId/url. The final download is a ZIP containing individual PDFs. groupByHousehold groups exact addresses rather than family relationships.
1387 ///
1388 /// # Example
1389 ///
1390 /// ```no_run
1391 /// # use churchtools_api::*;
1392 /// # use churchtools_api::queries::*;
1393 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1394 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1395 /// let body = models::BulkletterCreate {
1396 /// content: "<p>Hello [Spitzname]!</p>".into(),
1397 /// group_by_household: true,
1398 /// html_template_id: 39,
1399 /// name: "Newsletter April 2025".into(),
1400 /// person_ids: vec![13, 14],
1401 /// ..Default::default()
1402 /// };
1403 /// let result = client.bulk_letters().create(&body)?;
1404 /// println!("{}", result.id);
1405 /// # Ok(())
1406 /// # }
1407 /// ```
1408 pub fn create(&self, body: &models::BulkletterCreate) -> Result<models::BulkletterCreated> {
1409 let path = "/bulkletters".to_owned();
1410 let query: Query = Query::new();
1411 let body = serde_json::to_value(body).expect("request body serializes");
1412 self.client.request_json(Method::Post, &path, &query, Some(&body))
1413 }
1414
1415 /// Delete bulkletter
1416 ///
1417 /// `DELETE /bulkletters/{id}`
1418 ///
1419 /// Deletes the mail-merge job, its recipient rows, temporary rendering directory and generated ZIP file. Requires edit bulkletter permission and the same owner restriction as the detail read. No dry-run mode is supported. The operation does not coordinate with a currently running renderer.
1420 ///
1421 /// # Example
1422 ///
1423 /// ```no_run
1424 /// # use churchtools_api::*;
1425 /// # use churchtools_api::queries::*;
1426 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1427 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1428 /// client.bulk_letters().delete(36)?;
1429 /// # Ok(())
1430 /// # }
1431 /// ```
1432 pub fn delete(&self, id: impl Display) -> Result<()> {
1433 let path = format!("/bulkletters/{}", seg(id));
1434 let query: Query = Query::new();
1435 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
1436 }
1437
1438 /// Execute pending bulkletter jobs
1439 ///
1440 /// `POST /bulkletters/execute`
1441 ///
1442 /// Internal worker entry point, normally started automatically after creation. Processes up to ten recipient rows of the first unfinished mail-merge job, then starts another background request while work remains. Operates across creators. It renders separate PDFs and packages them into a ZIP; it does not send mail. A recently active worker causes this request to do no work. Returns 204 regardless of whether processing was skipped or a rendering exception was recorded as job status ERROR; inspect the job status for the result.
1443 ///
1444 /// # Example
1445 ///
1446 /// ```no_run
1447 /// # use churchtools_api::*;
1448 /// # use churchtools_api::queries::*;
1449 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1450 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1451 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
1452 /// client.bulk_letters().execute(&body)?;
1453 /// # Ok(())
1454 /// # }
1455 /// ```
1456 pub fn execute(&self, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<()> {
1457 let path = "/bulkletters/execute".to_owned();
1458 let query: Query = Query::new();
1459 let body = serde_json::to_value(body).expect("request body serializes");
1460 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
1461 }
1462
1463 /// Get bulkletter
1464 ///
1465 /// `GET /bulkletters/{id}`
1466 ///
1467 /// Reads one mail-merge job as a bare object, without a data wrapper. Requires edit bulkletter permission. Only the creator’s jobs and jobs with created_pid=0 are visible; other owners are reported as 404. The final file is a ZIP archive, not a combined PDF.
1468 ///
1469 /// # Example
1470 ///
1471 /// ```
1472 /// # use churchtools_api::*;
1473 /// # use churchtools_api::queries::*;
1474 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1475 /// # let client = churchtools_api::replay::client("get-bulkletters-id");
1476 /// let bulk_letter = client.bulk_letters().get(36)?;
1477 /// println!("{}", bulk_letter.name);
1478 /// # Ok(())
1479 /// # }
1480 /// ```
1481 pub fn get(&self, id: impl Display) -> Result<models::Bulkletter> {
1482 let path = format!("/bulkletters/{}", seg(id));
1483 let query: Query = Query::new();
1484 self.client.request_json(Method::Get, &path, &query, None)
1485 }
1486
1487 /// Get all bulkletters
1488 ///
1489 /// `GET /bulkletters`
1490 ///
1491 /// Lists the current user’s mail-merge jobs and jobs with created_pid=0. Requires edit bulkletter permission. Returns a bare array without data or meta; no pagination, status filter or ordering is defined.
1492 ///
1493 /// # Example
1494 ///
1495 /// ```
1496 /// # use churchtools_api::*;
1497 /// # use churchtools_api::queries::*;
1498 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1499 /// # let client = churchtools_api::replay::client("get-bulkletters");
1500 /// for bulk_letter in client.bulk_letters().list()? {
1501 /// println!("{}", bulk_letter.name);
1502 /// }
1503 /// # Ok(())
1504 /// # }
1505 /// ```
1506 pub fn list(&self) -> Result<Vec<models::Bulkletter>> {
1507 let path = "/bulkletters".to_owned();
1508 let query: Query = Query::new();
1509 self.client.request_json(Method::Get, &path, &query, None)
1510 }
1511
1512 /// Get receivers of a bulkletter
1513 ///
1514 /// `GET /bulkletters/{id}/persons`
1515 ///
1516 /// Lists scheduled recipient persons whose person records the caller may view. Requires edit bulkletter or create print labels permission. Returns data only, without meta or pagination. Address fields reflect current person data. This endpoint does not apply the job-owner restriction of the detail read; a nonexistent job normally yields an empty list.
1517 ///
1518 /// # Example
1519 ///
1520 /// ```
1521 /// # use churchtools_api::*;
1522 /// # use churchtools_api::queries::*;
1523 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1524 /// # let client = churchtools_api::replay::client("get-bulkletters-id-persons");
1525 /// for person in client.bulk_letters().list_persons(36)? {
1526 /// println!("{:?}", person.name);
1527 /// }
1528 /// # Ok(())
1529 /// # }
1530 /// ```
1531 pub fn list_persons(&self, id: impl Display) -> Result<Vec<models::BulkletterReceiver>> {
1532 let path = format!("/bulkletters/{}/persons", seg(id));
1533 let query: Query = Query::new();
1534 self.client.request_data(Method::Get, &path, &query, None)
1535 }
1536
1537}
1538
1539/// `client.calendars()`
1540#[derive(Clone, Copy)]
1541pub struct CalendarsResource<'a> {
1542 client: &'a Client,
1543}
1544
1545impl<'a> CalendarsResource<'a> {
1546 pub fn appointments(&self) -> CalendarsAppointmentsResource<'a> {
1547 CalendarsAppointmentsResource { client: self.client }
1548 }
1549
1550 pub fn meeting_request(&self) -> CalendarsMeetingRequestResource<'a> {
1551 CalendarsMeetingRequestResource { client: self.client }
1552 }
1553
1554 /// Create a calendar
1555 ///
1556 /// `POST /calendars`
1557 ///
1558 /// Creates a calendar of the chosen type. church requires permission to administer church calendars; group and personal require permission to create or administer their respective category. The creator receives permission to edit appointments in the new calendar. Optional iCalSourceUrl starts an immediate external-feed import.
1559 ///
1560 /// # Example
1561 ///
1562 /// ```
1563 /// # use churchtools_api::*;
1564 /// # use churchtools_api::queries::*;
1565 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1566 /// # let client = churchtools_api::replay::client("post-calendars");
1567 /// let body = models::CalendarCreate {
1568 /// name: "Community events".into(),
1569 /// sort_key: 10,
1570 /// r#type: "church".into(),
1571 /// ..Default::default()
1572 /// };
1573 /// let result = client.calendars().create(&body)?;
1574 /// println!("{}", result.name);
1575 /// # Ok(())
1576 /// # }
1577 /// ```
1578 pub fn create(&self, body: &models::CalendarCreate) -> Result<models::Calendar> {
1579 let path = "/calendars".to_owned();
1580 let query: Query = Query::new();
1581 let body = serde_json::to_value(body).expect("request body serializes");
1582 self.client.request_data(Method::Post, &path, &query, Some(&body))
1583 }
1584
1585 /// Delete a calendar and its contents
1586 ///
1587 /// `DELETE /calendars/{calendarId}`
1588 ///
1589 /// Deletes the calendar and its appointment contents, and removes permissions attached to that calendar. Requires edit-category permission for the calendar or ownership as its creator. Deletion can be blocked by references, including agenda templates belonging to the calendar; 409 returns the blocking references.
1590 ///
1591 /// # Example
1592 ///
1593 /// ```no_run
1594 /// # use churchtools_api::*;
1595 /// # use churchtools_api::queries::*;
1596 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1597 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1598 /// client.calendars().delete(42)?;
1599 /// # Ok(())
1600 /// # }
1601 /// ```
1602 pub fn delete(&self, calendar_id: impl Display) -> Result<()> {
1603 let path = format!("/calendars/{}", seg(calendar_id));
1604 let query: Query = Query::new();
1605 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
1606 }
1607
1608 /// Get calendar settings
1609 ///
1610 /// `GET /calendars/{calendarId}`
1611 ///
1612 /// Returns one calendar’s settings. Reading is allowed with view-category or edit-category permission for the calendar, or for its creator. This creator check is additional to the permission filter used by GET /calendars. Use /calendars/{calendarId}/appointments to retrieve occurrences.
1613 ///
1614 /// # Example
1615 ///
1616 /// ```
1617 /// # use churchtools_api::*;
1618 /// # use churchtools_api::queries::*;
1619 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1620 /// # let client = churchtools_api::replay::client("get-calendars-calendarId");
1621 /// let calendar = client.calendars().get(42)?;
1622 /// println!("{}", calendar.name);
1623 /// # Ok(())
1624 /// # }
1625 /// ```
1626 pub fn get(&self, calendar_id: impl Display) -> Result<models::Calendar> {
1627 let path = format!("/calendars/{}", seg(calendar_id));
1628 let query: Query = Query::new();
1629 self.client.request_data(Method::Get, &path, &query, None)
1630 }
1631
1632 /// List calendars accessible through calendar permissions
1633 ///
1634 /// `GET /calendars`
1635 ///
1636 /// Returns calendars for which the current user has view-category or edit-category permission, ordered by sortKey ascending.
1637 ///
1638 /// # Example
1639 ///
1640 /// ```
1641 /// # use churchtools_api::*;
1642 /// # use churchtools_api::queries::*;
1643 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1644 /// # let client = churchtools_api::replay::client("get-calendars");
1645 /// for calendar in client.calendars().list()? {
1646 /// println!("{}", calendar.name);
1647 /// }
1648 /// # Ok(())
1649 /// # }
1650 /// ```
1651 pub fn list(&self) -> Result<Vec<models::Calendar>> {
1652 let path = "/calendars".to_owned();
1653 let query: Query = Query::new();
1654 self.client.request_data(Method::Get, &path, &query, None)
1655 }
1656
1657 /// Get candidates for a meeting request (deprecated)
1658 ///
1659 /// `GET /calendars/{calendarId}/meetingrequestpersons`
1660 ///
1661 /// Deprecated alias for /calendars/{calendarId}/meetingrequest/candidates. Returns the same visible candidates.
1662 ///
1663 /// Use [`Self::list_meeting_request_persons_with`] to pass query parameters.
1664 ///
1665 /// # Example
1666 ///
1667 /// ```
1668 /// # use churchtools_api::*;
1669 /// # use churchtools_api::queries::*;
1670 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1671 /// # let client = churchtools_api::replay::client("get-calendars-calendarId-meetingrequestpersons");
1672 /// for meeting_request_person in client.calendars().list_meeting_request_persons(42)? {
1673 /// println!("{:?}", meeting_request_person.group_name);
1674 /// }
1675 /// # Ok(())
1676 /// # }
1677 /// ```
1678 #[deprecated = "GET /calendars/{calendarId}/meetingrequestpersons is deprecated in the ChurchTools API."]
1679 pub fn list_meeting_request_persons(&self, calendar_id: impl Display) -> Result<Vec<models::MeetingRequestCandidate>> {
1680 self.list_meeting_request_persons_with(calendar_id, &Default::default())
1681 }
1682
1683 /// Get candidates for a meeting request (deprecated)
1684 ///
1685 /// Like [`Self::list_meeting_request_persons`], with query parameters.
1686 ///
1687 /// `GET /calendars/{calendarId}/meetingrequestpersons`
1688 ///
1689 /// Deprecated alias for /calendars/{calendarId}/meetingrequest/candidates. Returns the same visible candidates.
1690 #[deprecated = "GET /calendars/{calendarId}/meetingrequestpersons is deprecated in the ChurchTools API."]
1691 pub fn list_meeting_request_persons_with(&self, calendar_id: impl Display, query: &GetCalendarsCalendarIdMeetingrequestpersonsQuery) -> Result<Vec<models::MeetingRequestCandidate>> {
1692 let path = format!("/calendars/{}/meetingrequestpersons", seg(calendar_id));
1693 let query: Query = query.to_query();
1694 self.client.request_data(Method::Get, &path, &query, None)
1695 }
1696
1697 /// Update calendar settings
1698 ///
1699 /// `PUT /calendars/{calendarId}`
1700 ///
1701 /// Replaces editable calendar settings while preserving the calendar type. Requires administration permission for the calendar’s type or ownership as its creator; permission to edit appointments alone is not sufficient. iCalSourceUrl triggers an external calendar import.
1702 ///
1703 /// # Example
1704 ///
1705 /// ```
1706 /// # use churchtools_api::*;
1707 /// # use churchtools_api::queries::*;
1708 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1709 /// # let client = churchtools_api::replay::client("put-calendars-calendarId");
1710 /// let body = models::CalendarUpdate {
1711 /// name: "Community events".into(),
1712 /// sort_key: 10,
1713 /// ..Default::default()
1714 /// };
1715 /// let result = client.calendars().update(42, &body)?;
1716 /// println!("{}", result.name);
1717 /// # Ok(())
1718 /// # }
1719 /// ```
1720 pub fn update(&self, calendar_id: impl Display, body: &models::CalendarUpdate) -> Result<models::Calendar> {
1721 let path = format!("/calendars/{}", seg(calendar_id));
1722 let query: Query = Query::new();
1723 let body = serde_json::to_value(body).expect("request body serializes");
1724 self.client.request_data(Method::Put, &path, &query, Some(&body))
1725 }
1726
1727}
1728
1729/// `client.calendars().appointments()`
1730#[derive(Clone, Copy)]
1731pub struct CalendarsAppointmentsResource<'a> {
1732 client: &'a Client,
1733}
1734
1735impl<'a> CalendarsAppointmentsResource<'a> {
1736 pub fn meeting_requests(&self) -> CalendarsAppointmentsMeetingRequestsResource<'a> {
1737 CalendarsAppointmentsMeetingRequestsResource { client: self.client }
1738 }
1739
1740 pub fn templates(&self) -> CalendarsAppointmentsTemplatesResource<'a> {
1741 CalendarsAppointmentsTemplatesResource { client: self.client }
1742 }
1743
1744 /// Preview impacts of an appointment schedule change
1745 ///
1746 /// `POST /calendars/{calendarId}/appointments/{appointmentId}/changeimpact`
1747 ///
1748 /// Calculates supported event, service-assignment and resource-booking impacts of the proposed schedule without saving the appointment.
1749 ///
1750 /// # Example
1751 ///
1752 /// ```
1753 /// # use churchtools_api::*;
1754 /// # use churchtools_api::queries::*;
1755 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1756 /// # let client = churchtools_api::replay::client("post-calendars-calendarId-appointments-appointmentId-changeimpact");
1757 /// let body = models::AppointmentChangeImpactCreate {
1758 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
1759 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
1760 /// ..Default::default()
1761 /// };
1762 /// for appointment in client.calendars().appointments().change_impact(42, 4, &body)? {
1763 /// println!("{:?}", appointment);
1764 /// }
1765 /// # Ok(())
1766 /// # }
1767 /// ```
1768 pub fn change_impact(&self, calendar_id: impl Display, appointment_id: impl Display, body: &models::AppointmentChangeImpactCreate) -> Result<Vec<serde_json::Value>> {
1769 let path = format!("/calendars/{}/appointments/{}/changeimpact", seg(calendar_id), seg(appointment_id));
1770 let query: Query = Query::new();
1771 let body = serde_json::to_value(body).expect("request body serializes");
1772 self.client.request_data(Method::Post, &path, &query, Some(&body))
1773 }
1774
1775 /// Create an appointment or series
1776 ///
1777 /// `POST /calendars/{calendarId}/appointments`
1778 ///
1779 /// Creates a calendar appointment, with optional recurrence, resource reservations, service-planning events and meeting invitations. calendarId comes from the path. Creating registration groups and linked resources requires the corresponding permissions.
1780 ///
1781 /// # Example
1782 ///
1783 /// ```
1784 /// # use churchtools_api::*;
1785 /// # use churchtools_api::queries::*;
1786 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1787 /// # let client = churchtools_api::replay::client("post-calendars-calendarId-appointments");
1788 /// let body = models::AppointmentCreate {
1789 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
1790 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
1791 /// is_internal: true,
1792 /// title: "Sunday service".into(),
1793 /// ..Default::default()
1794 /// };
1795 /// let result = client.calendars().appointments().create(42, &body)?;
1796 /// println!("{}", result.title);
1797 /// # Ok(())
1798 /// # }
1799 /// ```
1800 pub fn create(&self, calendar_id: impl Display, body: &models::AppointmentCreate) -> Result<models::AppointmentBase> {
1801 let path = format!("/calendars/{}/appointments", seg(calendar_id));
1802 let query: Query = Query::new();
1803 let body = serde_json::to_value(body).expect("request body serializes");
1804 self.client.request_data(Method::Post, &path, &query, Some(&body))
1805 }
1806
1807 /// Delete an appointment or entire series
1808 ///
1809 /// `DELETE /calendars/{calendarId}/appointments/{appointmentId}`
1810 ///
1811 /// Deletes the stored appointment and triggers the cleanup of linked resources. For recurring appointments this removes the whole series. To remove only one occurrence, update the complete series with that local date in exceptions. This requires calendar editing permission or being the appointment’s last editor.
1812 ///
1813 /// # Example
1814 ///
1815 /// ```no_run
1816 /// # use churchtools_api::*;
1817 /// # use churchtools_api::queries::*;
1818 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1819 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1820 /// client.calendars().appointments().delete(42, 4)?;
1821 /// # Ok(())
1822 /// # }
1823 /// ```
1824 pub fn delete(&self, calendar_id: impl Display, appointment_id: impl Display) -> Result<()> {
1825 let path = format!("/calendars/{}/appointments/{}", seg(calendar_id), seg(appointment_id));
1826 let query: Query = Query::new();
1827 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
1828 }
1829
1830 /// Get an appointment series and its dates
1831 ///
1832 /// `GET /calendars/{calendarId}/appointments/{appointmentId}`
1833 ///
1834 /// Returns the stored appointment and all dates calculated from its recurrence settings. calculatedDates is keyed by local start date and contains UTC start/end timestamps even for all-day appointments. This differs from the date-or-timestamp format used by occurrence endpoints.
1835 ///
1836 /// Use [`Self::get_with`] to pass query parameters.
1837 ///
1838 /// # Example
1839 ///
1840 /// ```
1841 /// # use churchtools_api::*;
1842 /// # use churchtools_api::queries::*;
1843 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1844 /// # let client = churchtools_api::replay::client("get-calendars-calendarId-appointments-appointmentId");
1845 /// let appointment = client.calendars().appointments().get(42, 4)?;
1846 /// println!("{:?}", appointment);
1847 /// # Ok(())
1848 /// # }
1849 /// ```
1850 pub fn get(&self, calendar_id: impl Display, appointment_id: impl Display) -> Result<models::AppointmentCalculated> {
1851 self.get_with(calendar_id, appointment_id, &Default::default())
1852 }
1853
1854 /// Get an appointment series and its dates
1855 ///
1856 /// Like [`Self::get`], with query parameters.
1857 ///
1858 /// `GET /calendars/{calendarId}/appointments/{appointmentId}`
1859 ///
1860 /// Returns the stored appointment and all dates calculated from its recurrence settings. calculatedDates is keyed by local start date and contains UTC start/end timestamps even for all-day appointments. This differs from the date-or-timestamp format used by occurrence endpoints.
1861 pub fn get_with(&self, calendar_id: impl Display, appointment_id: impl Display, query: &GetCalendarsCalendarIdAppointmentsAppointmentIdQuery) -> Result<models::AppointmentCalculated> {
1862 let path = format!("/calendars/{}/appointments/{}", seg(calendar_id), seg(appointment_id));
1863 let query: Query = query.to_query();
1864 self.client.request_data(Method::Get, &path, &query, None)
1865 }
1866
1867 /// Export an appointment or series as iCalendar
1868 ///
1869 /// `GET /calendars/{calendarId}/appointments/{appointmentId}/ical`
1870 ///
1871 /// Downloads appointment.ics as text/calendar. The export includes recurrence rules, excluded dates and additional dates; it may contain multiple VEVENT entries for additional recurring or standalone dates. This exports the stored appointment/series, not a selected occurrence.
1872 ///
1873 /// # Example
1874 ///
1875 /// ```no_run
1876 /// # use churchtools_api::*;
1877 /// # use churchtools_api::queries::*;
1878 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1879 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
1880 /// let data = client.calendars().appointments().get_ical(42, 4)?;
1881 /// std::fs::write("ergebnis.ics", &data)?;
1882 /// # Ok(())
1883 /// # }
1884 /// ```
1885 pub fn get_ical(&self, calendar_id: impl Display, appointment_id: impl Display) -> Result<Vec<u8>> {
1886 let path = format!("/calendars/{}/appointments/{}/ical", seg(calendar_id), seg(appointment_id));
1887 let query: Query = Query::new();
1888 self.client.request(Method::Get, &path, &query, None)
1889 }
1890
1891 /// Get one appointment occurrence
1892 ///
1893 /// `GET /calendars/appointments/{appointmentId}/{startDate}`
1894 ///
1895 /// Returns the occurrence starting on the specified local date. appointment.base describes the stored series and appointment.calculated describes this occurrence. Returns 404 if no matching occurrence is available.
1896 ///
1897 /// Use [`Self::get_occurrence_with`] to pass query parameters.
1898 ///
1899 /// # Example
1900 ///
1901 /// ```
1902 /// # use churchtools_api::*;
1903 /// # use churchtools_api::queries::*;
1904 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1905 /// # let client = churchtools_api::replay::client("get-calendars-appointments-appointmentId-startDate");
1906 /// let occurrence = client.calendars().appointments().get_occurrence(4, "2026-09-20")?;
1907 /// println!("{:?}", occurrence.title_suffix);
1908 /// # Ok(())
1909 /// # }
1910 /// ```
1911 pub fn get_occurrence(&self, appointment_id: impl Display, start_date: impl Display) -> Result<models::AppointmentOccurrence> {
1912 self.get_occurrence_with(appointment_id, start_date, &Default::default())
1913 }
1914
1915 /// Get one appointment occurrence
1916 ///
1917 /// Like [`Self::get_occurrence`], with query parameters.
1918 ///
1919 /// `GET /calendars/appointments/{appointmentId}/{startDate}`
1920 ///
1921 /// Returns the occurrence starting on the specified local date. appointment.base describes the stored series and appointment.calculated describes this occurrence. Returns 404 if no matching occurrence is available.
1922 pub fn get_occurrence_with(&self, appointment_id: impl Display, start_date: impl Display, query: &GetCalendarsAppointmentsAppointmentIdStartDateQuery) -> Result<models::AppointmentOccurrence> {
1923 let path = format!("/calendars/appointments/{}/{}", seg(appointment_id), seg(start_date));
1924 let query: Query = query.to_query();
1925 self.client.request_data(Method::Get, &path, &query, None)
1926 }
1927
1928 /// Get one appointment occurrence
1929 ///
1930 /// `GET /calendars/{calendarId}/appointments/{appointmentId}/{startDate}`
1931 ///
1932 /// Returns the occurrence starting on the specified local date. appointment.base describes the stored series and appointment.calculated describes this occurrence. Returns 404 if no matching occurrence is available.
1933 ///
1934 /// Use [`Self::get_occurrence_in_calendar_with`] to pass query parameters.
1935 ///
1936 /// # Example
1937 ///
1938 /// ```
1939 /// # use churchtools_api::*;
1940 /// # use churchtools_api::queries::*;
1941 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1942 /// # let client = churchtools_api::replay::client("get-calendars-calendarId-appointments-appointmentId-startDate");
1943 /// let occurrence_in_calendar = client.calendars().appointments().get_occurrence_in_calendar(42, 4, "2026-09-20")?;
1944 /// println!("{:?}", occurrence_in_calendar.title_suffix);
1945 /// # Ok(())
1946 /// # }
1947 /// ```
1948 pub fn get_occurrence_in_calendar(&self, calendar_id: impl Display, appointment_id: impl Display, start_date: impl Display) -> Result<models::AppointmentOccurrence> {
1949 self.get_occurrence_in_calendar_with(calendar_id, appointment_id, start_date, &Default::default())
1950 }
1951
1952 /// Get one appointment occurrence
1953 ///
1954 /// Like [`Self::get_occurrence_in_calendar`], with query parameters.
1955 ///
1956 /// `GET /calendars/{calendarId}/appointments/{appointmentId}/{startDate}`
1957 ///
1958 /// Returns the occurrence starting on the specified local date. appointment.base describes the stored series and appointment.calculated describes this occurrence. Returns 404 if no matching occurrence is available.
1959 pub fn get_occurrence_in_calendar_with(&self, calendar_id: impl Display, appointment_id: impl Display, start_date: impl Display, query: &GetCalendarsCalendarIdAppointmentsAppointmentIdStartDateQuery) -> Result<models::AppointmentOccurrence> {
1960 let path = format!("/calendars/{}/appointments/{}/{}", seg(calendar_id), seg(appointment_id), seg(start_date));
1961 let query: Query = query.to_query();
1962 self.client.request_data(Method::Get, &path, &query, None)
1963 }
1964
1965 /// List appointment occurrences across calendars
1966 ///
1967 /// `GET /calendars/appointments`
1968 ///
1969 /// Returns calculated occurrences for the requested date range, with one entry per occurrence rather than per series. Use appointment.base for the stored series and appointment.calculated for the displayed dates. Recurring occurrences use the installation’s local time across daylight-saving changes. Anonymous users receive only non-internal appointments in calendars they may view.
1970 ///
1971 /// # Example
1972 ///
1973 /// ```
1974 /// # use churchtools_api::*;
1975 /// # use churchtools_api::queries::*;
1976 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
1977 /// # let client = churchtools_api::replay::client("get-calendars-appointments");
1978 /// let query = GetCalendarsAppointmentsQuery {
1979 /// calendar_ids: Some(vec![2, 3]),
1980 /// ..Default::default()
1981 /// };
1982 /// for appointment in client.calendars().appointments().list(&query)? {
1983 /// println!("{:?}", appointment.title_suffix);
1984 /// }
1985 /// # Ok(())
1986 /// # }
1987 /// ```
1988 pub fn list(&self, query: &GetCalendarsAppointmentsQuery) -> Result<Vec<models::AppointmentOccurrenceList>> {
1989 let path = "/calendars/appointments".to_owned();
1990 let query: Query = query.to_query();
1991 self.client.request_data(Method::Get, &path, &query, None)
1992 }
1993
1994 /// List appointment occurrences in a calendar
1995 ///
1996 /// `GET /calendars/{calendarId}/appointments`
1997 ///
1998 /// Returns calculated occurrences for the requested date range, with one entry per occurrence rather than per series. Use appointment.base for the stored series and appointment.calculated for the displayed dates. Recurring occurrences use the installation’s local time across daylight-saving changes. Anonymous users receive only non-internal appointments in calendars they may view.
1999 ///
2000 /// Use [`Self::list_in_calendar_with`] to pass query parameters.
2001 ///
2002 /// # Example
2003 ///
2004 /// ```
2005 /// # use churchtools_api::*;
2006 /// # use churchtools_api::queries::*;
2007 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2008 /// # let client = churchtools_api::replay::client("get-calendars-calendarId-appointments");
2009 /// for in_calendar in client.calendars().appointments().list_in_calendar(42)? {
2010 /// println!("{:?}", in_calendar.title_suffix);
2011 /// }
2012 /// # Ok(())
2013 /// # }
2014 /// ```
2015 pub fn list_in_calendar(&self, calendar_id: impl Display) -> Result<Vec<models::AppointmentOccurrenceList>> {
2016 self.list_in_calendar_with(calendar_id, &Default::default())
2017 }
2018
2019 /// List appointment occurrences in a calendar
2020 ///
2021 /// Like [`Self::list_in_calendar`], with query parameters.
2022 ///
2023 /// `GET /calendars/{calendarId}/appointments`
2024 ///
2025 /// Returns calculated occurrences for the requested date range, with one entry per occurrence rather than per series. Use appointment.base for the stored series and appointment.calculated for the displayed dates. Recurring occurrences use the installation’s local time across daylight-saving changes. Anonymous users receive only non-internal appointments in calendars they may view.
2026 pub fn list_in_calendar_with(&self, calendar_id: impl Display, query: &GetCalendarsCalendarIdAppointmentsQuery) -> Result<Vec<models::AppointmentOccurrenceList>> {
2027 let path = format!("/calendars/{}/appointments", seg(calendar_id));
2028 let query: Query = query.to_query();
2029 self.client.request_data(Method::Get, &path, &query, None)
2030 }
2031
2032 /// Split and update an appointment series
2033 ///
2034 /// `POST /calendars/{calendarId}/appointments/{appointmentId}`
2035 ///
2036 /// Creates a new stored appointment from the supplied complete data and removes the selected scope from the original. splitUntilEnd=true cuts the original off before splitDate and requires a split after the original start. false excludes only splitDate and allows splitting the first occurrence. The returned data.id belongs to the new appointment. The new recurrence must describe the intended replacement; splitting does not automatically restrict it to one date. Linked resources are adjusted by their respective workflows.
2037 ///
2038 /// # Example
2039 ///
2040 /// ```no_run
2041 /// # use churchtools_api::*;
2042 /// # use churchtools_api::queries::*;
2043 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2044 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2045 /// let body = models::AppointmentSplitUpdate {
2046 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
2047 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
2048 /// is_internal: true,
2049 /// title: "Sunday service".into(),
2050 /// split_date: "2026-10-04".parse()?,
2051 /// split_until_end: true,
2052 /// ..Default::default()
2053 /// };
2054 /// let appointment = client.calendars().appointments().split(42, 4, &body)?;
2055 /// println!("{}", appointment.title);
2056 /// # Ok(())
2057 /// # }
2058 /// ```
2059 pub fn split(&self, calendar_id: impl Display, appointment_id: impl Display, body: &models::AppointmentSplitUpdate) -> Result<models::AppointmentBase> {
2060 let path = format!("/calendars/{}/appointments/{}", seg(calendar_id), seg(appointment_id));
2061 let query: Query = Query::new();
2062 let body = serde_json::to_value(body).expect("request body serializes");
2063 self.client.request_data(Method::Post, &path, &query, Some(&body))
2064 }
2065
2066 /// Update an appointment or series
2067 ///
2068 /// `PUT /calendars/{calendarId}/appointments/{appointmentId}`
2069 ///
2070 /// Replaces editable base fields and the schedule of the stored appointment. This affects the entire series. Existing events and bookings follow the changed schedule. Use changeimpact to inspect supported consequences before submitting a schedule change.
2071 ///
2072 /// # Example
2073 ///
2074 /// ```
2075 /// # use churchtools_api::*;
2076 /// # use churchtools_api::queries::*;
2077 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2078 /// # let client = churchtools_api::replay::client("put-calendars-calendarId-appointments-appointmentId");
2079 /// let body = models::AppointmentUpdate {
2080 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
2081 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
2082 /// is_internal: true,
2083 /// title: "Sunday service".into(),
2084 /// ..Default::default()
2085 /// };
2086 /// let result = client.calendars().appointments().update(42, 4, &body)?;
2087 /// println!("{}", result.title);
2088 /// # Ok(())
2089 /// # }
2090 /// ```
2091 pub fn update(&self, calendar_id: impl Display, appointment_id: impl Display, body: &models::AppointmentUpdate) -> Result<models::AppointmentBase> {
2092 let path = format!("/calendars/{}/appointments/{}", seg(calendar_id), seg(appointment_id));
2093 let query: Query = Query::new();
2094 let body = serde_json::to_value(body).expect("request body serializes");
2095 self.client.request_data(Method::Put, &path, &query, Some(&body))
2096 }
2097
2098}
2099
2100/// `client.calendars().appointments().meeting_requests()`
2101#[derive(Clone, Copy)]
2102pub struct CalendarsAppointmentsMeetingRequestsResource<'a> {
2103 client: &'a Client,
2104}
2105
2106impl<'a> CalendarsAppointmentsMeetingRequestsResource<'a> {
2107 /// Answer a meeting invitation
2108 ///
2109 /// `POST /calendars/{calendarId}/appointments/{appointmentId}/meetingrequests/{meetingRequestId}/{answer}`
2110 ///
2111 /// Records the answer of the invited person. accept, decline and tentative set the corresponding state; reset returns the request to pending. maybe remains accepted as a deprecated alias for tentative. Only the invitee may answer.
2112 ///
2113 /// # Example
2114 ///
2115 /// ```no_run
2116 /// # use churchtools_api::*;
2117 /// # use churchtools_api::queries::*;
2118 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2119 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2120 /// client.calendars().appointments().meeting_requests().answer(42, 4, 19, "accept")?;
2121 /// # Ok(())
2122 /// # }
2123 /// ```
2124 pub fn answer(&self, calendar_id: impl Display, appointment_id: impl Display, meeting_request_id: impl Display, answer: impl Display) -> Result<()> {
2125 let path = format!("/calendars/{}/appointments/{}/meetingrequests/{}/{}", seg(calendar_id), seg(appointment_id), seg(meeting_request_id), seg(answer));
2126 let query: Query = Query::new();
2127 self.client.request(Method::Post, &path, &query, None).map(|_| ())
2128 }
2129
2130 /// Invite a person to an appointment
2131 ///
2132 /// `POST /calendars/{calendarId}/appointments/{appointmentId}/meetingrequests`
2133 ///
2134 /// Creates a meeting invitation for inviteeId. Requires permission to edit the appointment and view the invited person. The inviter is onBehalfOfPid when set, otherwise the current user. An invitation to the inviter is automatically accepted.
2135 ///
2136 /// # Example
2137 ///
2138 /// ```no_run
2139 /// # use churchtools_api::*;
2140 /// # use churchtools_api::queries::*;
2141 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2142 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2143 /// let body = models::MeetingRequestCreate {
2144 /// invitee_id: 42,
2145 /// ..Default::default()
2146 /// };
2147 /// let result = client.calendars().appointments().meeting_requests().create(42, 4, &body)?;
2148 /// println!("{}", result.id);
2149 /// # Ok(())
2150 /// # }
2151 /// ```
2152 pub fn create(&self, calendar_id: impl Display, appointment_id: impl Display, body: &models::MeetingRequestCreate) -> Result<models::MeetingRequest> {
2153 let path = format!("/calendars/{}/appointments/{}/meetingrequests", seg(calendar_id), seg(appointment_id));
2154 let query: Query = Query::new();
2155 let body = serde_json::to_value(body).expect("request body serializes");
2156 self.client.request_json(Method::Post, &path, &query, Some(&body))
2157 }
2158
2159 /// Delete a meeting invitation
2160 ///
2161 /// `DELETE /calendars/{calendarId}/appointments/{appointmentId}/meetingrequests/{meetingRequestId}`
2162 ///
2163 /// Removes a meeting request. This requires permission to edit the appointment; invitees can use the answer endpoint to decline instead.
2164 ///
2165 /// # Example
2166 ///
2167 /// ```no_run
2168 /// # use churchtools_api::*;
2169 /// # use churchtools_api::queries::*;
2170 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2171 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2172 /// client.calendars().appointments().meeting_requests().delete(42, 4, 19)?;
2173 /// # Ok(())
2174 /// # }
2175 /// ```
2176 pub fn delete(&self, calendar_id: impl Display, appointment_id: impl Display, meeting_request_id: impl Display) -> Result<()> {
2177 let path = format!("/calendars/{}/appointments/{}/meetingrequests/{}", seg(calendar_id), seg(appointment_id), seg(meeting_request_id));
2178 let query: Query = Query::new();
2179 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
2180 }
2181
2182 /// List meeting invitations for an appointment
2183 ///
2184 /// `GET /calendars/{calendarId}/appointments/{appointmentId}/meetingrequests`
2185 ///
2186 /// Returns all meeting requests associated with the stored appointment/series. Requests are not per-occurrence attendance records.
2187 ///
2188 /// # Example
2189 ///
2190 /// ```
2191 /// # use churchtools_api::*;
2192 /// # use churchtools_api::queries::*;
2193 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2194 /// # let client = churchtools_api::replay::client("get-calendars-calendarId-appointments-appointmentId-meetingrequests");
2195 /// for meeting_request in client.calendars().appointments().meeting_requests().list(42, 4)? {
2196 /// println!("{}", meeting_request.id);
2197 /// }
2198 /// # Ok(())
2199 /// # }
2200 /// ```
2201 pub fn list(&self, calendar_id: impl Display, appointment_id: impl Display) -> Result<Vec<models::MeetingRequest>> {
2202 let path = format!("/calendars/{}/appointments/{}/meetingrequests", seg(calendar_id), seg(appointment_id));
2203 let query: Query = Query::new();
2204 self.client.request_data(Method::Get, &path, &query, None)
2205 }
2206
2207 /// Answer a meeting invitation
2208 ///
2209 /// `PUT /calendars/{calendarId}/appointments/{appointmentId}/meetingrequests/{meetingRequestId}`
2210 ///
2211 /// Legacy body-based endpoint for answering a meeting request. Only the invited person may answer. Use POST on the path ending in /{answer}.
2212 ///
2213 /// # Example
2214 ///
2215 /// ```no_run
2216 /// # use churchtools_api::*;
2217 /// # use churchtools_api::queries::*;
2218 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2219 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2220 /// let body = models::MeetingRequestUpdate {
2221 /// answer: "accept".into(),
2222 /// ..Default::default()
2223 /// };
2224 /// client.calendars().appointments().meeting_requests().update(42, 4, 19, &body)?;
2225 /// # Ok(())
2226 /// # }
2227 /// ```
2228 #[deprecated = "PUT /calendars/{calendarId}/appointments/{appointmentId}/meetingrequests/{meetingRequestId} is deprecated in the ChurchTools API. Use POST on the path ending in /{answer}."]
2229 pub fn update(&self, calendar_id: impl Display, appointment_id: impl Display, meeting_request_id: impl Display, body: &models::MeetingRequestUpdate) -> Result<()> {
2230 let path = format!("/calendars/{}/appointments/{}/meetingrequests/{}", seg(calendar_id), seg(appointment_id), seg(meeting_request_id));
2231 let query: Query = Query::new();
2232 let body = serde_json::to_value(body).expect("request body serializes");
2233 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
2234 }
2235
2236}
2237
2238/// `client.calendars().appointments().templates()`
2239#[derive(Clone, Copy)]
2240pub struct CalendarsAppointmentsTemplatesResource<'a> {
2241 client: &'a Client,
2242}
2243
2244impl<'a> CalendarsAppointmentsTemplatesResource<'a> {
2245 /// Create an appointment template
2246 ///
2247 /// `POST /calendars/appointments/templates`
2248 ///
2249 /// Stores reusable defaults for future appointments. Requires permission to edit calendar entry templates for the selected calendar.
2250 ///
2251 /// # Example
2252 ///
2253 /// ```
2254 /// # use churchtools_api::*;
2255 /// # use churchtools_api::queries::*;
2256 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2257 /// # let client = churchtools_api::replay::client("post-calendars-appointments-templates");
2258 /// let body = models::AppointmentTemplateCreate {
2259 /// calendar_id: 1,
2260 /// duration: 3600,
2261 /// start_time: "10:00".into(),
2262 /// title: "Service".into(),
2263 /// ..Default::default()
2264 /// };
2265 /// let result = client.calendars().appointments().templates().create(&body)?;
2266 /// println!("{}", result.title);
2267 /// # Ok(())
2268 /// # }
2269 /// ```
2270 pub fn create(&self, body: &models::AppointmentTemplateCreate) -> Result<models::AppointmentTemplateWritten> {
2271 let path = "/calendars/appointments/templates".to_owned();
2272 let query: Query = Query::new();
2273 let body = serde_json::to_value(body).expect("request body serializes");
2274 self.client.request_data(Method::Post, &path, &query, Some(&body))
2275 }
2276
2277 /// Delete an appointment template
2278 ///
2279 /// `DELETE /calendars/appointments/templates/{templateId}`
2280 ///
2281 /// Deletes the reusable template and its associated image files. Requires permission to edit appointment templates in its calendar.
2282 ///
2283 /// # Example
2284 ///
2285 /// ```no_run
2286 /// # use churchtools_api::*;
2287 /// # use churchtools_api::queries::*;
2288 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2289 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2290 /// client.calendars().appointments().templates().delete(1)?;
2291 /// # Ok(())
2292 /// # }
2293 /// ```
2294 pub fn delete(&self, template_id: impl Display) -> Result<()> {
2295 let path = format!("/calendars/appointments/templates/{}", seg(template_id));
2296 let query: Query = Query::new();
2297 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
2298 }
2299
2300 /// Get an appointment template
2301 ///
2302 /// `GET /calendars/appointments/templates/{templateId}`
2303 ///
2304 /// Returns the saved defaults of one template, including its ID and metadata.
2305 ///
2306 /// # Example
2307 ///
2308 /// ```
2309 /// # use churchtools_api::*;
2310 /// # use churchtools_api::queries::*;
2311 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2312 /// # let client = churchtools_api::replay::client("get-calendars-appointments-templates-id");
2313 /// let template = client.calendars().appointments().templates().get(1)?;
2314 /// println!("{:?}", template.title);
2315 /// # Ok(())
2316 /// # }
2317 /// ```
2318 pub fn get(&self, template_id: impl Display) -> Result<models::AppointmentTemplate> {
2319 let path = format!("/calendars/appointments/templates/{}", seg(template_id));
2320 let query: Query = Query::new();
2321 self.client.request_data(Method::Get, &path, &query, None)
2322 }
2323
2324 /// List appointment templates
2325 ///
2326 /// `GET /calendars/appointments/templates`
2327 ///
2328 /// Returns all saved appointment templates and their reusable defaults.
2329 ///
2330 /// # Example
2331 ///
2332 /// ```
2333 /// # use churchtools_api::*;
2334 /// # use churchtools_api::queries::*;
2335 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2336 /// # let client = churchtools_api::replay::client("get-calendars-appointments-templates");
2337 /// for template in client.calendars().appointments().templates().list()? {
2338 /// println!("{:?}", template.title);
2339 /// }
2340 /// # Ok(())
2341 /// # }
2342 /// ```
2343 pub fn list(&self) -> Result<Vec<models::AppointmentTemplate>> {
2344 let path = "/calendars/appointments/templates".to_owned();
2345 let query: Query = Query::new();
2346 self.client.request_data(Method::Get, &path, &query, None)
2347 }
2348
2349 /// Update an appointment template
2350 ///
2351 /// `PUT /calendars/appointments/templates/{templateId}`
2352 ///
2353 /// Replaces the template’s saved defaults. Permission is checked for the calendar selected by calendarId.
2354 ///
2355 /// # Example
2356 ///
2357 /// ```
2358 /// # use churchtools_api::*;
2359 /// # use churchtools_api::queries::*;
2360 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2361 /// # let client = churchtools_api::replay::client("put-calendars-appointments-templates-id");
2362 /// let body = models::AppointmentTemplateUpdate {
2363 /// calendar_id: 1,
2364 /// duration: 3600,
2365 /// start_time: "10:00".into(),
2366 /// title: "Service".into(),
2367 /// ..Default::default()
2368 /// };
2369 /// let result = client.calendars().appointments().templates().update(1, &body)?;
2370 /// println!("{}", result.title);
2371 /// # Ok(())
2372 /// # }
2373 /// ```
2374 pub fn update(&self, template_id: impl Display, body: &models::AppointmentTemplateUpdate) -> Result<models::AppointmentTemplateWritten> {
2375 let path = format!("/calendars/appointments/templates/{}", seg(template_id));
2376 let query: Query = Query::new();
2377 let body = serde_json::to_value(body).expect("request body serializes");
2378 self.client.request_data(Method::Put, &path, &query, Some(&body))
2379 }
2380
2381}
2382
2383/// `client.calendars().meeting_request()`
2384#[derive(Clone, Copy)]
2385pub struct CalendarsMeetingRequestResource<'a> {
2386 client: &'a Client,
2387}
2388
2389impl<'a> CalendarsMeetingRequestResource<'a> {
2390 /// Get candidates for a meeting request
2391 ///
2392 /// `GET /calendars/{calendarId}/meetingrequest/candidates`
2393 ///
2394 /// Returns visible people with direct, person-status, group-derived, or group-type-derived calendar permissions. When appointmentId is supplied, visible invitees already associated with that appointment are also included.
2395 ///
2396 /// Use [`Self::list_candidates_with`] to pass query parameters.
2397 ///
2398 /// # Example
2399 ///
2400 /// ```
2401 /// # use churchtools_api::*;
2402 /// # use churchtools_api::queries::*;
2403 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2404 /// # let client = churchtools_api::replay::client("get-calendars-calendarId-meetingrequest-candidates");
2405 /// for candidate in client.calendars().meeting_request().list_candidates(42)? {
2406 /// println!("{:?}", candidate.group_name);
2407 /// }
2408 /// # Ok(())
2409 /// # }
2410 /// ```
2411 pub fn list_candidates(&self, calendar_id: impl Display) -> Result<Vec<models::MeetingRequestCandidate>> {
2412 self.list_candidates_with(calendar_id, &Default::default())
2413 }
2414
2415 /// Get candidates for a meeting request
2416 ///
2417 /// Like [`Self::list_candidates`], with query parameters.
2418 ///
2419 /// `GET /calendars/{calendarId}/meetingrequest/candidates`
2420 ///
2421 /// Returns visible people with direct, person-status, group-derived, or group-type-derived calendar permissions. When appointmentId is supplied, visible invitees already associated with that appointment are also included.
2422 pub fn list_candidates_with(&self, calendar_id: impl Display, query: &GetCalendarsCalendarIdMeetingrequestCandidatesQuery) -> Result<Vec<models::MeetingRequestCandidate>> {
2423 let path = format!("/calendars/{}/meetingrequest/candidates", seg(calendar_id));
2424 let query: Query = query.to_query();
2425 self.client.request_data(Method::Get, &path, &query, None)
2426 }
2427
2428}
2429
2430/// `client.campuses()`
2431#[derive(Clone, Copy)]
2432pub struct CampusesResource<'a> {
2433 client: &'a Client,
2434}
2435
2436impl<'a> CampusesResource<'a> {
2437 /// Create new campus
2438 ///
2439 /// `POST /campuses`
2440 ///
2441 /// Save new campus
2442 ///
2443 /// # Example
2444 ///
2445 /// ```
2446 /// # use churchtools_api::*;
2447 /// # use churchtools_api::queries::*;
2448 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2449 /// # let client = churchtools_api::replay::client("post-campuses");
2450 /// let body = models::CampusCreate {
2451 /// name: "Hamburg Altona".into(),
2452 /// shorty: "ALT".into(),
2453 /// ..Default::default()
2454 /// };
2455 /// let result = client.campuses().create(&body)?;
2456 /// println!("{}", result.name);
2457 /// # Ok(())
2458 /// # }
2459 /// ```
2460 pub fn create(&self, body: &models::CampusCreate) -> Result<models::Campus> {
2461 let path = "/campuses".to_owned();
2462 let query: Query = Query::new();
2463 let body = serde_json::to_value(body).expect("request body serializes");
2464 self.client.request_data(Method::Post, &path, &query, Some(&body))
2465 }
2466
2467 /// Delete a campus
2468 ///
2469 /// `DELETE /campuses/{id}`
2470 ///
2471 /// # Example
2472 ///
2473 /// ```no_run
2474 /// # use churchtools_api::*;
2475 /// # use churchtools_api::queries::*;
2476 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2477 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2478 /// client.campuses().delete(1)?;
2479 /// # Ok(())
2480 /// # }
2481 /// ```
2482 pub fn delete(&self, id: impl Display) -> Result<()> {
2483 let path = format!("/campuses/{}", seg(id));
2484 let query: Query = Query::new();
2485 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
2486 }
2487
2488 /// Get a campus
2489 ///
2490 /// `GET /campuses/{id}`
2491 ///
2492 /// Get a specific campus
2493 ///
2494 /// # Example
2495 ///
2496 /// ```
2497 /// # use churchtools_api::*;
2498 /// # use churchtools_api::queries::*;
2499 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2500 /// # let client = churchtools_api::replay::client("get-campuses-id");
2501 /// let campus = client.campuses().get(1)?;
2502 /// println!("{}", campus.name);
2503 /// # Ok(())
2504 /// # }
2505 /// ```
2506 pub fn get(&self, id: impl Display) -> Result<models::Campus> {
2507 let path = format!("/campuses/{}", seg(id));
2508 let query: Query = Query::new();
2509 self.client.request_data(Method::Get, &path, &query, None)
2510 }
2511
2512 /// Get all campuses
2513 ///
2514 /// `GET /campuses`
2515 ///
2516 /// Returns an array of all campuses defined in ChurchTools. Campuses are sorted by its `sortKey` by default.
2517 ///
2518 /// # Example
2519 ///
2520 /// ```
2521 /// # use churchtools_api::*;
2522 /// # use churchtools_api::queries::*;
2523 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2524 /// # let client = churchtools_api::replay::client("get-campuses");
2525 /// for campus in client.campuses().list()? {
2526 /// println!("{}", campus.name);
2527 /// }
2528 /// # Ok(())
2529 /// # }
2530 /// ```
2531 pub fn list(&self) -> Result<Vec<models::Campus>> {
2532 let path = "/campuses".to_owned();
2533 let query: Query = Query::new();
2534 self.client.request_data(Method::Get, &path, &query, None)
2535 }
2536
2537 /// Update campus
2538 ///
2539 /// `PUT /campuses/{id}`
2540 ///
2541 /// # Example
2542 ///
2543 /// ```
2544 /// # use churchtools_api::*;
2545 /// # use churchtools_api::queries::*;
2546 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2547 /// # let client = churchtools_api::replay::client("put-campuses-id");
2548 /// let body = models::CampusUpdate {
2549 /// name: Some(Some("Hauskreis Nord".into())),
2550 /// ..Default::default()
2551 /// };
2552 /// let result = client.campuses().update(1, &body)?;
2553 /// println!("{}", result.name);
2554 /// # Ok(())
2555 /// # }
2556 /// ```
2557 pub fn update(&self, id: impl Display, body: &models::CampusUpdate) -> Result<models::Campus> {
2558 let path = format!("/campuses/{}", seg(id));
2559 let query: Query = Query::new();
2560 let body = serde_json::to_value(body).expect("request body serializes");
2561 self.client.request_data(Method::Put, &path, &query, Some(&body))
2562 }
2563
2564}
2565
2566/// `client.captcha()`
2567#[derive(Clone, Copy)]
2568pub struct CaptchaResource<'a> {
2569 client: &'a Client,
2570}
2571
2572impl<'a> CaptchaResource<'a> {
2573 /// Altcha Captcha Verification
2574 ///
2575 /// `POST /captcha`
2576 ///
2577 /// Verify a captcha solution. Only for testing purposes. Other endpoints that require a captcha take the solution directly. See <https://altcha.org/docs/website-integration/> for more information
2578 ///
2579 /// # Example
2580 ///
2581 /// ```no_run
2582 /// # use churchtools_api::*;
2583 /// # use churchtools_api::queries::*;
2584 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2585 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2586 /// let body = models::PostCaptchaBody {
2587 /// solution: "beispiel".into(),
2588 /// ..Default::default()
2589 /// };
2590 /// let result = client.captcha().create(&body)?;
2591 /// println!("{}", result.is_valid);
2592 /// # Ok(())
2593 /// # }
2594 /// ```
2595 pub fn create(&self, body: &models::PostCaptchaBody) -> Result<models::PostCaptchaResponse> {
2596 let path = "/captcha".to_owned();
2597 let query: Query = Query::new();
2598 let body = serde_json::to_value(body).expect("request body serializes");
2599 self.client.request_json(Method::Post, &path, &query, Some(&body))
2600 }
2601
2602 /// Altcha Captcha Challenge
2603 ///
2604 /// `GET /captcha`
2605 ///
2606 /// Get a new challenge to solve. To be used with <https://altcha.org/docs/website-integration/>
2607 ///
2608 /// # Example
2609 ///
2610 /// ```
2611 /// # use churchtools_api::*;
2612 /// # use churchtools_api::queries::*;
2613 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2614 /// # let client = churchtools_api::replay::client("get-captcha");
2615 /// let captcha = client.captcha().get()?;
2616 /// println!("{}", captcha.signature);
2617 /// # Ok(())
2618 /// # }
2619 /// ```
2620 pub fn get(&self) -> Result<models::GetCaptchaResponse> {
2621 let path = "/captcha".to_owned();
2622 let query: Query = Query::new();
2623 self.client.request_json(Method::Get, &path, &query, None)
2624 }
2625
2626}
2627
2628/// `client.chat()`
2629#[derive(Clone, Copy)]
2630pub struct ChatResource<'a> {
2631 client: &'a Client,
2632}
2633
2634impl<'a> ChatResource<'a> {
2635 /// Start new chat
2636 ///
2637 /// `POST /chat`
2638 ///
2639 /// Starts synchronization of a chat room with Matrix. New rooms have `STARTING` status and record the current user as creator.
2640 ///
2641 /// # Example
2642 ///
2643 /// ```no_run
2644 /// # use churchtools_api::*;
2645 /// # use churchtools_api::queries::*;
2646 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2647 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2648 /// let body = models::ChatCreate {
2649 /// domain_id: 9,
2650 /// guid: "681F54E3-2EB7-40A4-84F0-EFF8E8F05727".into(),
2651 /// prefix: "ctg".into(),
2652 /// roomname: "Technical team".into(),
2653 /// ..Default::default()
2654 /// };
2655 /// let result = client.chat().create(&body)?;
2656 /// println!("{:?}", result.creator);
2657 /// # Ok(())
2658 /// # }
2659 /// ```
2660 pub fn create(&self, body: &models::ChatCreate) -> Result<models::Chat> {
2661 let path = "/chat".to_owned();
2662 let query: Query = Query::new();
2663 let body = serde_json::to_value(body).expect("request body serializes");
2664 self.client.request_data(Method::Post, &path, &query, Some(&body))
2665 }
2666
2667 /// Delete a chat
2668 ///
2669 /// `DELETE /chat/{guid}`
2670 ///
2671 /// Deletes the local chat room record. A missing record is treated as already deleted.
2672 ///
2673 /// Use [`Self::delete_with`] to pass query parameters.
2674 ///
2675 /// # Example
2676 ///
2677 /// ```no_run
2678 /// # use churchtools_api::*;
2679 /// # use churchtools_api::queries::*;
2680 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2681 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2682 /// client.chat().delete("681F54E3-2EB7-40A4-84F0-EFF8E8F05727")?;
2683 /// # Ok(())
2684 /// # }
2685 /// ```
2686 pub fn delete(&self, guid: impl Display) -> Result<()> {
2687 self.delete_with(guid, &Default::default())
2688 }
2689
2690 /// Delete a chat
2691 ///
2692 /// Like [`Self::delete`], with query parameters.
2693 ///
2694 /// `DELETE /chat/{guid}`
2695 ///
2696 /// Deletes the local chat room record. A missing record is treated as already deleted.
2697 pub fn delete_with(&self, guid: impl Display, query: &DeleteChatGuidQuery) -> Result<()> {
2698 let path = format!("/chat/{}", seg(guid));
2699 let query: Query = query.to_query();
2700 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
2701 }
2702
2703 /// Get all chats
2704 ///
2705 /// `GET /chat`
2706 ///
2707 /// Returns all chat rooms, or only rooms matching the supplied synchronization token.
2708 ///
2709 /// Use [`Self::list_with`] to pass query parameters.
2710 ///
2711 /// # Example
2712 ///
2713 /// ```
2714 /// # use churchtools_api::*;
2715 /// # use churchtools_api::queries::*;
2716 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2717 /// # let client = churchtools_api::replay::client("get-chat");
2718 /// for chat in client.chat().list()? {
2719 /// println!("{:?}", chat.creator);
2720 /// }
2721 /// # Ok(())
2722 /// # }
2723 /// ```
2724 pub fn list(&self) -> Result<Vec<models::Chat>> {
2725 self.list_with(&Default::default())
2726 }
2727
2728 /// Get all chats
2729 ///
2730 /// Like [`Self::list`], with query parameters.
2731 ///
2732 /// `GET /chat`
2733 ///
2734 /// Returns all chat rooms, or only rooms matching the supplied synchronization token.
2735 pub fn list_with(&self, query: &GetChatQuery) -> Result<Vec<models::Chat>> {
2736 let path = "/chat".to_owned();
2737 let query: Query = query.to_query();
2738 self.client.request_data(Method::Get, &path, &query, None)
2739 }
2740
2741 /// Update a chat
2742 ///
2743 /// `PATCH /chat/{guid}`
2744 ///
2745 /// Updates chat room metadata or requests a lifecycle transition.
2746 ///
2747 /// # Example
2748 ///
2749 /// ```no_run
2750 /// # use churchtools_api::*;
2751 /// # use churchtools_api::queries::*;
2752 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2753 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2754 /// let body = models::ChatUpdate {
2755 /// creator: Some(1),
2756 /// ..Default::default()
2757 /// };
2758 /// let result = client.chat().patch("681F54E3-2EB7-40A4-84F0-EFF8E8F05727", &body)?;
2759 /// println!("{:?}", result.creator);
2760 /// # Ok(())
2761 /// # }
2762 /// ```
2763 pub fn patch(&self, guid: impl Display, body: &models::ChatUpdate) -> Result<models::Chat> {
2764 let path = format!("/chat/{}", seg(guid));
2765 let query: Query = Query::new();
2766 let body = serde_json::to_value(body).expect("request body serializes");
2767 self.client.request_data(Method::Patch, &path, &query, Some(&body))
2768 }
2769
2770}
2771
2772/// `client.checkin()`
2773#[derive(Clone, Copy)]
2774pub struct CheckinResource<'a> {
2775 client: &'a Client,
2776}
2777
2778impl<'a> CheckinResource<'a> {
2779 /// Create new person and add to group
2780 ///
2781 /// `POST /checkin/persons`
2782 ///
2783 /// Creates a person and admits them to a group for the check-in workflow. Requires administer persons, or create person in churchcheckin plus group meeting permission and a person security level covering the selected status. Masterdata IDs are installation-specific. Ordinary duplicate-person confirmation is bypassed; a unique GUID and license limits still apply. A creation note and optional tag are saved before the membership. This request does not record meeting attendance or print a label; perform the actual check-in separately. Failure can leave earlier steps saved because the whole workflow is not one transaction. The response is the legacy person model, not the regular Person representation.
2784 ///
2785 /// Use [`Self::create_persons_with`] to pass query parameters.
2786 ///
2787 /// # Example
2788 ///
2789 /// ```no_run
2790 /// # use churchtools_api::*;
2791 /// # use churchtools_api::queries::*;
2792 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2793 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2794 /// let body = models::CheckinPersonCreate {
2795 /// group: models::CheckinMembershipCreate {
2796 /// id: 9,
2797 /// person_fields: Default::default(),
2798 /// ..Default::default()
2799 /// },
2800 /// person: models::CheckinPersonDataCreate {
2801 /// campus_id: 42,
2802 /// department_ids: vec![42],
2803 /// first_name: Some("Alex".into()),
2804 /// last_name: "Example".into(),
2805 /// status_id: 42,
2806 /// ..Default::default()
2807 /// },
2808 /// ..Default::default()
2809 /// };
2810 /// let result = client.checkin().create_persons(&body)?;
2811 /// println!("{:?}", result.first_name);
2812 /// # Ok(())
2813 /// # }
2814 /// ```
2815 pub fn create_persons(&self, body: &models::CheckinPersonCreate) -> Result<models::CheckinPerson> {
2816 self.create_persons_with(&Default::default(), body)
2817 }
2818
2819 /// Create new person and add to group
2820 ///
2821 /// Like [`Self::create_persons`], with query parameters.
2822 ///
2823 /// `POST /checkin/persons`
2824 ///
2825 /// Creates a person and admits them to a group for the check-in workflow. Requires administer persons, or create person in churchcheckin plus group meeting permission and a person security level covering the selected status. Masterdata IDs are installation-specific. Ordinary duplicate-person confirmation is bypassed; a unique GUID and license limits still apply. A creation note and optional tag are saved before the membership. This request does not record meeting attendance or print a label; perform the actual check-in separately. Failure can leave earlier steps saved because the whole workflow is not one transaction. The response is the legacy person model, not the regular Person representation.
2826 pub fn create_persons_with(&self, query: &PostCheckinPersonsQuery, body: &models::CheckinPersonCreate) -> Result<models::CheckinPerson> {
2827 let path = "/checkin/persons".to_owned();
2828 let query: Query = query.to_query();
2829 let body = serde_json::to_value(body).expect("request body serializes");
2830 self.client.request_data(Method::Post, &path, &query, Some(&body))
2831 }
2832
2833 /// Put existing person into group
2834 ///
2835 /// `PUT /checkin/persons`
2836 ///
2837 /// Admits an existing person to a group using its default role and check-in membership origin, optionally adds a tag, and updates person fields configured for that group. Requires administer persons or group meeting permission. Existing membership is a conflict, not an idempotent success. The operation does not record attendance or print labels. Tag changes occur before membership creation and can remain after a failed request. The returned legacy person-model representation differs from the regular Person API.
2838 ///
2839 /// # Example
2840 ///
2841 /// ```no_run
2842 /// # use churchtools_api::*;
2843 /// # use churchtools_api::queries::*;
2844 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2845 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2846 /// let body = models::CheckinPersonUpdate {
2847 /// group: models::CheckinMembershipCreate {
2848 /// id: 9,
2849 /// person_fields: Default::default(),
2850 /// ..Default::default()
2851 /// },
2852 /// person_id: 42,
2853 /// ..Default::default()
2854 /// };
2855 /// let result = client.checkin().update_persons(&body)?;
2856 /// println!("{:?}", result.first_name);
2857 /// # Ok(())
2858 /// # }
2859 /// ```
2860 pub fn update_persons(&self, body: &models::CheckinPersonUpdate) -> Result<models::CheckinPerson> {
2861 let path = "/checkin/persons".to_owned();
2862 let query: Query = Query::new();
2863 let body = serde_json::to_value(body).expect("request body serializes");
2864 self.client.request_data(Method::Put, &path, &query, Some(&body))
2865 }
2866
2867}
2868
2869/// `client.church_query()`
2870#[derive(Clone, Copy)]
2871pub struct ChurchQueryResource<'a> {
2872 client: &'a Client,
2873}
2874
2875impl<'a> ChurchQueryResource<'a> {
2876 pub fn debug(&self) -> ChurchQueryDebugResource<'a> {
2877 ChurchQueryDebugResource { client: self.client }
2878 }
2879
2880 /// Get masterdata for ChurchQuery
2881 ///
2882 /// `GET /churchquery/metadata`
2883 ///
2884 /// Use [`Self::get_metadata_with`] to pass query parameters.
2885 ///
2886 /// # Example
2887 ///
2888 /// ```
2889 /// # use churchtools_api::*;
2890 /// # use churchtools_api::queries::*;
2891 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2892 /// # let client = churchtools_api::replay::client("get-churchquery-metadata");
2893 /// let result = client.church_query().get_metadata()?;
2894 /// println!("{:?}", result);
2895 /// # Ok(())
2896 /// # }
2897 /// ```
2898 pub fn get_metadata(&self) -> Result<serde_json::Value> {
2899 self.get_metadata_with(&Default::default())
2900 }
2901
2902 /// Get masterdata for ChurchQuery
2903 ///
2904 /// Like [`Self::get_metadata`], with query parameters.
2905 ///
2906 /// `GET /churchquery/metadata`
2907 pub fn get_metadata_with(&self, query: &GetChurchqueryMetadataQuery) -> Result<serde_json::Value> {
2908 let path = "/churchquery/metadata".to_owned();
2909 let query: Query = query.to_query();
2910 self.client.request_data(Method::Get, &path, &query, None)
2911 }
2912
2913}
2914
2915/// `client.church_query().debug()`
2916#[derive(Clone, Copy)]
2917pub struct ChurchQueryDebugResource<'a> {
2918 client: &'a Client,
2919}
2920
2921impl<'a> ChurchQueryDebugResource<'a> {
2922 /// Export result of ChurchQuery
2923 ///
2924 /// `POST /churchquery/debug/export`
2925 ///
2926 /// **Caution**: This is an preliminary API, and is subject to be changed. It provides a downloadfile with the result of a given query.
2927 ///
2928 /// Use [`Self::export_with`] to pass query parameters.
2929 ///
2930 /// # Example
2931 ///
2932 /// ```no_run
2933 /// # use churchtools_api::*;
2934 /// # use churchtools_api::queries::*;
2935 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2936 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
2937 /// let body: String = "beispiel".into();
2938 /// client.church_query().debug().export(&body)?;
2939 /// # Ok(())
2940 /// # }
2941 /// ```
2942 pub fn export(&self, body: &String) -> Result<()> {
2943 self.export_with(&Default::default(), body)
2944 }
2945
2946 /// Export result of ChurchQuery
2947 ///
2948 /// Like [`Self::export`], with query parameters.
2949 ///
2950 /// `POST /churchquery/debug/export`
2951 ///
2952 /// **Caution**: This is an preliminary API, and is subject to be changed. It provides a downloadfile with the result of a given query.
2953 pub fn export_with(&self, query: &PostChurchqueryDebugExportQuery, body: &String) -> Result<()> {
2954 let path = "/churchquery/debug/export".to_owned();
2955 let query: Query = query.to_query();
2956 let body = serde_json::to_value(body).expect("request body serializes");
2957 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
2958 }
2959
2960}
2961
2962/// `client.config()`
2963#[derive(Clone, Copy)]
2964pub struct ConfigResource<'a> {
2965 client: &'a Client,
2966}
2967
2968impl<'a> ConfigResource<'a> {
2969 /// Get the ChurchTools-Config
2970 ///
2971 /// `GET /config`
2972 ///
2973 /// Use [`Self::get_with`] to pass query parameters.
2974 ///
2975 /// # Example
2976 ///
2977 /// ```
2978 /// # use churchtools_api::*;
2979 /// # use churchtools_api::queries::*;
2980 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
2981 /// # let client = churchtools_api::replay::client("get-config");
2982 /// let config = client.config().get()?;
2983 /// println!("{:?}", config.current_config_file);
2984 /// # Ok(())
2985 /// # }
2986 /// ```
2987 pub fn get(&self) -> Result<models::GetConfigResponse> {
2988 self.get_with(&Default::default())
2989 }
2990
2991 /// Get the ChurchTools-Config
2992 ///
2993 /// Like [`Self::get`], with query parameters.
2994 ///
2995 /// `GET /config`
2996 pub fn get_with(&self, query: &GetConfigQuery) -> Result<models::GetConfigResponse> {
2997 let path = "/config".to_owned();
2998 let query: Query = query.to_query();
2999 self.client.request_json(Method::Get, &path, &query, None)
3000 }
3001
3002 /// Change the ChurchTools-Config
3003 ///
3004 /// `PUT /config`
3005 ///
3006 /// # Example
3007 ///
3008 /// ```no_run
3009 /// # use churchtools_api::*;
3010 /// # use churchtools_api::queries::*;
3011 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3012 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3013 /// let body = models::PutConfigRequest {
3014 /// accept_datasecurity: Some(true),
3015 /// ..Default::default()
3016 /// };
3017 /// client.config().update(&body)?;
3018 /// # Ok(())
3019 /// # }
3020 /// ```
3021 pub fn update(&self, body: &models::PutConfigRequest) -> Result<()> {
3022 let path = "/config".to_owned();
3023 let query: Query = Query::new();
3024 let body = serde_json::to_value(body).expect("request body serializes");
3025 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
3026 }
3027
3028}
3029
3030/// `client.contact_labels()`
3031#[derive(Clone, Copy)]
3032pub struct ContactLabelsResource<'a> {
3033 client: &'a Client,
3034}
3035
3036impl<'a> ContactLabelsResource<'a> {
3037 /// Create new Contact Label
3038 ///
3039 /// `POST /contactlabels`
3040 ///
3041 /// Creates a reusable email contact label. Requires "edit masterdata" permission in `churchdb`. Setting `isDefault` to `true` replaces the existing default.
3042 ///
3043 /// # Example
3044 ///
3045 /// ```
3046 /// # use churchtools_api::*;
3047 /// # use churchtools_api::queries::*;
3048 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3049 /// # let client = churchtools_api::replay::client("post-contactlabels");
3050 /// let body = models::ContactLabelCreate {
3051 /// is_default: false,
3052 /// name: "Private".into(),
3053 /// sort_key: 10,
3054 /// ..Default::default()
3055 /// };
3056 /// let result = client.contact_labels().create(&body)?;
3057 /// println!("{}", result.name);
3058 /// # Ok(())
3059 /// # }
3060 /// ```
3061 pub fn create(&self, body: &models::ContactLabelCreate) -> Result<models::ContactLabel> {
3062 let path = "/contactlabels".to_owned();
3063 let query: Query = Query::new();
3064 let body = serde_json::to_value(body).expect("request body serializes");
3065 self.client.request_data(Method::Post, &path, &query, Some(&body))
3066 }
3067
3068 /// Delete Contact Label
3069 ///
3070 /// `DELETE /contactlabels/{id}`
3071 ///
3072 /// Deletes an email contact label. Requires "edit masterdata" permission in `churchdb`. Email-address references can block deletion.
3073 ///
3074 /// Use [`Self::delete_with`] to pass query parameters.
3075 ///
3076 /// # Example
3077 ///
3078 /// ```no_run
3079 /// # use churchtools_api::*;
3080 /// # use churchtools_api::queries::*;
3081 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3082 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3083 /// client.contact_labels().delete(1)?;
3084 /// # Ok(())
3085 /// # }
3086 /// ```
3087 pub fn delete(&self, id: impl Display) -> Result<()> {
3088 self.delete_with(id, &Default::default())
3089 }
3090
3091 /// Delete Contact Label
3092 ///
3093 /// Like [`Self::delete`], with query parameters.
3094 ///
3095 /// `DELETE /contactlabels/{id}`
3096 ///
3097 /// Deletes an email contact label. Requires "edit masterdata" permission in `churchdb`. Email-address references can block deletion.
3098 pub fn delete_with(&self, id: impl Display, query: &DeleteContactlabelsIdQuery) -> Result<()> {
3099 let path = format!("/contactlabels/{}", seg(id));
3100 let query: Query = query.to_query();
3101 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
3102 }
3103
3104 /// Get Contact Label
3105 ///
3106 /// `GET /contactlabels/{id}`
3107 ///
3108 /// Returns a contact-label definition, including its translated display name and default flag.
3109 ///
3110 /// # Example
3111 ///
3112 /// ```
3113 /// # use churchtools_api::*;
3114 /// # use churchtools_api::queries::*;
3115 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3116 /// # let client = churchtools_api::replay::client("get-contactlabels-id");
3117 /// let contact_label = client.contact_labels().get(1)?;
3118 /// println!("{}", contact_label.name);
3119 /// # Ok(())
3120 /// # }
3121 /// ```
3122 pub fn get(&self, id: impl Display) -> Result<models::ContactLabel> {
3123 let path = format!("/contactlabels/{}", seg(id));
3124 let query: Query = Query::new();
3125 self.client.request_data(Method::Get, &path, &query, None)
3126 }
3127
3128 /// Get All Contact Labels
3129 ///
3130 /// `GET /contactlabels`
3131 ///
3132 /// Returns all email contact labels, ordered by `sortKey` and then `name`, both ascending. Labels classify addresses such as private and work.
3133 ///
3134 /// # Example
3135 ///
3136 /// ```
3137 /// # use churchtools_api::*;
3138 /// # use churchtools_api::queries::*;
3139 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3140 /// # let client = churchtools_api::replay::client("get-contactlabels");
3141 /// for contact_label in client.contact_labels().list()? {
3142 /// println!("{}", contact_label.name);
3143 /// }
3144 /// # Ok(())
3145 /// # }
3146 /// ```
3147 pub fn list(&self) -> Result<Vec<models::ContactLabel>> {
3148 let path = "/contactlabels".to_owned();
3149 let query: Query = Query::new();
3150 self.client.request_data(Method::Get, &path, &query, None)
3151 }
3152
3153 /// Update Contact Label
3154 ///
3155 /// `PUT /contactlabels/{id}`
3156 ///
3157 /// Replaces an email contact label. Requires "edit masterdata" permission in `churchdb`. Existing email-address associations retain the label ID.
3158 ///
3159 /// # Example
3160 ///
3161 /// ```
3162 /// # use churchtools_api::*;
3163 /// # use churchtools_api::queries::*;
3164 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3165 /// # let client = churchtools_api::replay::client("put-contactlabels-id");
3166 /// let body = models::ContactLabelUpdate {
3167 /// is_default: false,
3168 /// name: "Private".into(),
3169 /// sort_key: 10,
3170 /// ..Default::default()
3171 /// };
3172 /// let result = client.contact_labels().update(1, &body)?;
3173 /// println!("{}", result.name);
3174 /// # Ok(())
3175 /// # }
3176 /// ```
3177 pub fn update(&self, id: impl Display, body: &models::ContactLabelUpdate) -> Result<models::ContactLabel> {
3178 let path = format!("/contactlabels/{}", seg(id));
3179 let query: Query = Query::new();
3180 let body = serde_json::to_value(body).expect("request body serializes");
3181 self.client.request_data(Method::Put, &path, &query, Some(&body))
3182 }
3183
3184}
3185
3186/// `client.csrf_token()`
3187#[derive(Clone, Copy)]
3188pub struct CsrfTokenResource<'a> {
3189 client: &'a Client,
3190}
3191
3192impl<'a> CsrfTokenResource<'a> {
3193 /// CSRF token for the current user
3194 ///
3195 /// `GET /csrftoken`
3196 ///
3197 /// Returns the CSRF-Token for the current user in the current session. If the session does not exist, null is returned.
3198 ///
3199 /// # Example
3200 ///
3201 /// ```
3202 /// # use churchtools_api::*;
3203 /// # use churchtools_api::queries::*;
3204 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3205 /// # let client = churchtools_api::replay::client("get-csrftoken");
3206 /// let result = client.csrf_token().get()?;
3207 /// println!("{:?}", result);
3208 /// # Ok(())
3209 /// # }
3210 /// ```
3211 pub fn get(&self) -> Result<Option<String>> {
3212 let path = "/csrftoken".to_owned();
3213 let query: Query = Query::new();
3214 self.client.request_data(Method::Get, &path, &query, None)
3215 }
3216
3217}
3218
3219/// `client.db_field_types()`
3220#[derive(Clone, Copy)]
3221pub struct DbFieldTypesResource<'a> {
3222 client: &'a Client,
3223}
3224
3225impl<'a> DbFieldTypesResource<'a> {
3226 /// Get available field types
3227 ///
3228 /// `GET /dbfieldtypes`
3229 ///
3230 /// Returns registered database-field types, ordered by sortKey and then name. These types describe the value and input behavior of configurable fields. Names are returned as stored and can be translation keys.
3231 ///
3232 /// # Example
3233 ///
3234 /// ```
3235 /// # use churchtools_api::*;
3236 /// # use churchtools_api::queries::*;
3237 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3238 /// # let client = churchtools_api::replay::client("get-dbfieldtypes");
3239 /// for db_field_type in client.db_field_types().list()? {
3240 /// println!("{}", db_field_type.name);
3241 /// }
3242 /// # Ok(())
3243 /// # }
3244 /// ```
3245 pub fn list(&self) -> Result<Vec<models::DbFieldType>> {
3246 let path = "/dbfieldtypes".to_owned();
3247 let query: Query = Query::new();
3248 self.client.request_data(Method::Get, &path, &query, None)
3249 }
3250
3251}
3252
3253/// `client.db_fields()`
3254#[derive(Clone, Copy)]
3255pub struct DbFieldsResource<'a> {
3256 client: &'a Client,
3257}
3258
3259impl<'a> DbFieldsResource<'a> {
3260 pub fn options(&self) -> DbFieldsOptionsResource<'a> {
3261 DbFieldsOptionsResource { client: self.client }
3262 }
3263
3264 /// Create a database field
3265 ///
3266 /// `POST /dbfields`
3267 ///
3268 /// Creates an installation-specific field definition and database column. Selection types also create an option table with one initial choice. Checkbox fields are non-nullable and cannot be cleared on archive.
3269 ///
3270 /// # Example
3271 ///
3272 /// ```no_run
3273 /// # use churchtools_api::*;
3274 /// # use churchtools_api::queries::*;
3275 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3276 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3277 /// let body = models::DbFieldCreate {
3278 /// delete_on_archive: true,
3279 /// is_active: true,
3280 /// is_new_person_field: true,
3281 /// name: "Dietary notes".into(),
3282 /// security_level: 1,
3283 /// sort_key: 50,
3284 /// use_as_placeholder: false,
3285 /// field_category_intern_code: "f_address".into(),
3286 /// ..Default::default()
3287 /// };
3288 /// let result = client.db_fields().create(&body)?;
3289 /// println!("{}", result.name);
3290 /// # Ok(())
3291 /// # }
3292 /// ```
3293 pub fn create(&self, body: &models::DbFieldCreate) -> Result<models::DbField> {
3294 let path = "/dbfields".to_owned();
3295 let query: Query = Query::new();
3296 let body = serde_json::to_value(body).expect("request body serializes");
3297 self.client.request_data(Method::Post, &path, &query, Some(&body))
3298 }
3299
3300 /// Delete a database field
3301 ///
3302 /// `DELETE /dbfields/{fieldId}`
3303 ///
3304 /// Deletes a field definition, its physical database column and all values stored in that column; also removes its group-person-field mappings and custom selection table if present. Protected built-in fields cause a conflict.
3305 ///
3306 /// # Example
3307 ///
3308 /// ```no_run
3309 /// # use churchtools_api::*;
3310 /// # use churchtools_api::queries::*;
3311 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3312 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3313 /// client.db_fields().delete(200)?;
3314 /// # Ok(())
3315 /// # }
3316 /// ```
3317 pub fn delete(&self, field_id: impl Display) -> Result<()> {
3318 let path = format!("/dbfields/{}", seg(field_id));
3319 let query: Query = Query::new();
3320 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
3321 }
3322
3323 /// Get a database-field definition
3324 ///
3325 /// `GET /dbfields/{fieldId}`
3326 ///
3327 /// Returns one database-field definition, including its type, category and API key.
3328 ///
3329 /// # Example
3330 ///
3331 /// ```
3332 /// # use churchtools_api::*;
3333 /// # use churchtools_api::queries::*;
3334 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3335 /// # let client = churchtools_api::replay::client("get-dbfields-fieldId");
3336 /// let db_field = client.db_fields().get(200)?;
3337 /// println!("{}", db_field.name);
3338 /// # Ok(())
3339 /// # }
3340 /// ```
3341 pub fn get(&self, field_id: impl Display) -> Result<models::DbField> {
3342 let path = format!("/dbfields/{}", seg(field_id));
3343 let query: Query = Query::new();
3344 self.client.request_data(Method::Get, &path, &query, None)
3345 }
3346
3347 /// List database-field definitions
3348 ///
3349 /// `GET /dbfields`
3350 ///
3351 /// Lists built-in and custom field definitions, not the values stored on individual persons or groups. Use `categories[]` to restrict the result and `include[]=options` to expand available choices.
3352 ///
3353 /// Use [`Self::list_with`] to pass query parameters.
3354 ///
3355 /// # Example
3356 ///
3357 /// ```
3358 /// # use churchtools_api::*;
3359 /// # use churchtools_api::queries::*;
3360 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3361 /// # let client = churchtools_api::replay::client("get-dbfields");
3362 /// for db_field in client.db_fields().list()? {
3363 /// println!("{}", db_field.name);
3364 /// }
3365 /// # Ok(())
3366 /// # }
3367 /// ```
3368 pub fn list(&self) -> Result<Vec<models::DbField>> {
3369 self.list_with(&Default::default())
3370 }
3371
3372 /// List database-field definitions
3373 ///
3374 /// Like [`Self::list`], with query parameters.
3375 ///
3376 /// `GET /dbfields`
3377 ///
3378 /// Lists built-in and custom field definitions, not the values stored on individual persons or groups. Use `categories[]` to restrict the result and `include[]=options` to expand available choices.
3379 pub fn list_with(&self, query: &GetDbfieldsQuery) -> Result<Vec<models::DbField>> {
3380 let path = "/dbfields".to_owned();
3381 let query: Query = query.to_query();
3382 self.client.request_data(Method::Get, &path, &query, None)
3383 }
3384
3385 /// Update a database field
3386 ///
3387 /// `PUT /dbfields/{fieldId}`
3388 ///
3389 /// Updates a database-field definition. The existing field determines its type. Installation-created person fields can move between `f_address`, `f_church`, `f_category` and `f_datasecurity`.
3390 ///
3391 /// # Example
3392 ///
3393 /// ```no_run
3394 /// # use churchtools_api::*;
3395 /// # use churchtools_api::queries::*;
3396 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3397 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3398 /// let body = models::DbFieldUpdate {
3399 /// delete_on_archive: true,
3400 /// is_new_person_field: true,
3401 /// security_level: 1,
3402 /// sort_key: 50,
3403 /// use_as_placeholder: false,
3404 /// ..Default::default()
3405 /// };
3406 /// let result = client.db_fields().update(200, &body)?;
3407 /// println!("{}", result.name);
3408 /// # Ok(())
3409 /// # }
3410 /// ```
3411 pub fn update(&self, field_id: impl Display, body: &models::DbFieldUpdate) -> Result<models::DbField> {
3412 let path = format!("/dbfields/{}", seg(field_id));
3413 let query: Query = Query::new();
3414 let body = serde_json::to_value(body).expect("request body serializes");
3415 self.client.request_data(Method::Put, &path, &query, Some(&body))
3416 }
3417
3418}
3419
3420/// `client.db_fields().options()`
3421#[derive(Clone, Copy)]
3422pub struct DbFieldsOptionsResource<'a> {
3423 client: &'a Client,
3424}
3425
3426impl<'a> DbFieldsOptionsResource<'a> {
3427 /// Create a database-field option
3428 ///
3429 /// `POST /dbfields/{fieldId}/options`
3430 ///
3431 /// Creates an option in the selected field’s backing table. Use the metadata endpoint to determine the complete request shape. Fields without a backing table do not support this operation.
3432 ///
3433 /// # Example
3434 ///
3435 /// ```no_run
3436 /// # use churchtools_api::*;
3437 /// # use churchtools_api::queries::*;
3438 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3439 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3440 /// let body = models::DbFieldOptionCreate {
3441 /// name: Some("Vegetarian".into()),
3442 /// ..Default::default()
3443 /// };
3444 /// let result = client.db_fields().options().create(200, &body)?;
3445 /// println!("{:?}", result.name);
3446 /// # Ok(())
3447 /// # }
3448 /// ```
3449 pub fn create(&self, field_id: impl Display, body: &models::DbFieldOptionCreate) -> Result<models::DbFieldOption> {
3450 let path = format!("/dbfields/{}/options", seg(field_id));
3451 let query: Query = Query::new();
3452 let body = serde_json::to_value(body).expect("request body serializes");
3453 self.client.request_data(Method::Post, &path, &query, Some(&body))
3454 }
3455
3456 /// Delete a database-field option
3457 ///
3458 /// `DELETE /dbfields/{fieldId}/options/{optionId}`
3459 ///
3460 /// Deletes an option row from the selected field’s backing masterdata table through the shared deletion service. References can block deletion. `dryRun=true` returns the deletion preview with HTTP 409 without removing the row.
3461 ///
3462 /// Use [`Self::delete_with`] to pass query parameters.
3463 ///
3464 /// # Example
3465 ///
3466 /// ```no_run
3467 /// # use churchtools_api::*;
3468 /// # use churchtools_api::queries::*;
3469 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3470 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3471 /// client.db_fields().options().delete(200, 3)?;
3472 /// # Ok(())
3473 /// # }
3474 /// ```
3475 pub fn delete(&self, field_id: impl Display, option_id: impl Display) -> Result<()> {
3476 self.delete_with(field_id, option_id, &Default::default())
3477 }
3478
3479 /// Delete a database-field option
3480 ///
3481 /// Like [`Self::delete`], with query parameters.
3482 ///
3483 /// `DELETE /dbfields/{fieldId}/options/{optionId}`
3484 ///
3485 /// Deletes an option row from the selected field’s backing masterdata table through the shared deletion service. References can block deletion. `dryRun=true` returns the deletion preview with HTTP 409 without removing the row.
3486 pub fn delete_with(&self, field_id: impl Display, option_id: impl Display, query: &DeleteDbfieldsFieldIdOptionsOptionIdQuery) -> Result<()> {
3487 let path = format!("/dbfields/{}/options/{}", seg(field_id), seg(option_id));
3488 let query: Query = query.to_query();
3489 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
3490 }
3491
3492 /// List options for a database field
3493 ///
3494 /// `GET /dbfields/{fieldId}/options`
3495 ///
3496 /// Lists option rows from the field’s backing masterdata table. Rows are ordered by `sortKey` when available. Fields without a backing table return an empty list. Read the option metadata to interpret row keys.
3497 ///
3498 /// # Example
3499 ///
3500 /// ```
3501 /// # use churchtools_api::*;
3502 /// # use churchtools_api::queries::*;
3503 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3504 /// # let client = churchtools_api::replay::client("get-dbfields-fieldId-options");
3505 /// for option in client.db_fields().options().list(200)? {
3506 /// println!("{:?}", option.name);
3507 /// }
3508 /// # Ok(())
3509 /// # }
3510 /// ```
3511 pub fn list(&self, field_id: impl Display) -> Result<Vec<models::DbFieldOption>> {
3512 let path = format!("/dbfields/{}/options", seg(field_id));
3513 let query: Query = Query::new();
3514 self.client.request_data(Method::Get, &path, &query, None)
3515 }
3516
3517 /// Get metadata for field options
3518 ///
3519 /// `GET /dbfields/{fieldId}/options/metadata`
3520 ///
3521 /// Describes the actual SQL columns of the selected field’s backing option table as API properties. Audit columns are omitted. Use this operation only for fields backed by a table.
3522 ///
3523 /// # Example
3524 ///
3525 /// ```no_run
3526 /// # use churchtools_api::*;
3527 /// # use churchtools_api::queries::*;
3528 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3529 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3530 /// for metadata in client.db_fields().options().list_metadata(200)? {
3531 /// println!("{}", metadata.name);
3532 /// }
3533 /// # Ok(())
3534 /// # }
3535 /// ```
3536 pub fn list_metadata(&self, field_id: impl Display) -> Result<Vec<models::DbFieldOptionColumn>> {
3537 let path = format!("/dbfields/{}/options/metadata", seg(field_id));
3538 let query: Query = Query::new();
3539 self.client.request_data(Method::Get, &path, &query, None)
3540 }
3541
3542 /// Update a database-field option
3543 ///
3544 /// `PUT /dbfields/{fieldId}/options/{optionId}`
3545 ///
3546 /// Updates an option row using all non-auto-increment columns from the metadata endpoint. This operation replaces the complete metadata-defined row and supports only fields backed by a table.
3547 ///
3548 /// # Example
3549 ///
3550 /// ```no_run
3551 /// # use churchtools_api::*;
3552 /// # use churchtools_api::queries::*;
3553 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3554 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3555 /// let body = models::DbFieldOptionUpdate {
3556 /// name: Some("Vegetarian".into()),
3557 /// ..Default::default()
3558 /// };
3559 /// let result = client.db_fields().options().update(200, 3, &body)?;
3560 /// println!("{:?}", result.name);
3561 /// # Ok(())
3562 /// # }
3563 /// ```
3564 pub fn update(&self, field_id: impl Display, option_id: impl Display, body: &models::DbFieldOptionUpdate) -> Result<models::DbFieldOption> {
3565 let path = format!("/dbfields/{}/options/{}", seg(field_id), seg(option_id));
3566 let query: Query = Query::new();
3567 let body = serde_json::to_value(body).expect("request body serializes");
3568 self.client.request_data(Method::Put, &path, &query, Some(&body))
3569 }
3570
3571}
3572
3573/// `client.departments()`
3574#[derive(Clone, Copy)]
3575pub struct DepartmentsResource<'a> {
3576 client: &'a Client,
3577}
3578
3579impl<'a> DepartmentsResource<'a> {
3580 /// Get all departments
3581 ///
3582 /// `GET /departments`
3583 ///
3584 /// Returns all department definitions, ordered by `sortKey` and then `name`. The caller must be allowed to view `departmentIds` on their current person record. This is a definition list, not a list of persons visible through those departments.
3585 ///
3586 /// # Example
3587 ///
3588 /// ```
3589 /// # use churchtools_api::*;
3590 /// # use churchtools_api::queries::*;
3591 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3592 /// # let client = churchtools_api::replay::client("get-departments");
3593 /// for department in client.departments().list()? {
3594 /// println!("{}", department.name);
3595 /// }
3596 /// # Ok(())
3597 /// # }
3598 /// ```
3599 pub fn list(&self) -> Result<Vec<models::Department>> {
3600 let path = "/departments".to_owned();
3601 let query: Query = Query::new();
3602 self.client.request_data(Method::Get, &path, &query, None)
3603 }
3604
3605}
3606
3607/// `client.domain_objects()`
3608#[derive(Clone, Copy)]
3609pub struct DomainObjectsResource<'a> {
3610 client: &'a Client,
3611}
3612
3613impl<'a> DomainObjectsResource<'a> {
3614 /// Get domain objects
3615 ///
3616 /// `GET /domainobjects`
3617 ///
3618 /// Resolves heterogeneous ChurchTools references into compact display objects. Pair `domain_types[]` and `domain_identifiers[]` by index. Output order and count may differ from the input, and repeated IDs may not produce repeated results. Missing or inaccessible objects are usually omitted, but an unresolved `appointment_occurrence` may fail the request. Resolver permissions differ by domain type.
3619 ///
3620 /// # Example
3621 ///
3622 /// ```
3623 /// # use churchtools_api::*;
3624 /// # use churchtools_api::queries::*;
3625 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3626 /// # let client = churchtools_api::replay::client("get-domainobjects");
3627 /// let query = GetDomainobjectsQuery {
3628 /// domain_types: Some(vec!["person".into(), "group".into()]),
3629 /// domain_identifiers: Some(vec!["42".into(), "7".into()]),
3630 /// ..Default::default()
3631 /// };
3632 /// for domain_object in client.domain_objects().list(&query)? {
3633 /// println!("{:?}", domain_object.api_url);
3634 /// }
3635 /// # Ok(())
3636 /// # }
3637 /// ```
3638 pub fn list(&self, query: &GetDomainobjectsQuery) -> Result<Vec<models::ResolvedDomainObject>> {
3639 let path = "/domainobjects".to_owned();
3640 let query: Query = query.to_query();
3641 self.client.request_data(Method::Get, &path, &query, None)
3642 }
3643
3644 /// Resolve domain objects from a JSON payload
3645 ///
3646 /// `POST /domainobjects`
3647 ///
3648 /// Read-only JSON alternative to `GET /domainobjects` with the same resolution and permission behavior. Output order and count may differ from the input. Missing or inaccessible objects are usually omitted, but an unresolved `appointment_occurrence` may fail the request.
3649 ///
3650 /// # Example
3651 ///
3652 /// ```
3653 /// # use churchtools_api::*;
3654 /// # use churchtools_api::queries::*;
3655 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3656 /// # let client = churchtools_api::replay::client("post-domainobjects");
3657 /// let body = models::DomainObjectPayload {
3658 /// domain_identifiers: vec!["42".into(), "7".into()],
3659 /// domain_types: vec!["person".into(), "group".into()],
3660 /// ..Default::default()
3661 /// };
3662 /// for domain_object in client.domain_objects().resolve(&body)? {
3663 /// println!("{:?}", domain_object.api_url);
3664 /// }
3665 /// # Ok(())
3666 /// # }
3667 /// ```
3668 pub fn resolve(&self, body: &models::DomainObjectPayload) -> Result<Vec<models::ResolvedDomainObject>> {
3669 let path = "/domainobjects".to_owned();
3670 let query: Query = Query::new();
3671 let body = serde_json::to_value(body).expect("request body serializes");
3672 self.client.request_data(Method::Post, &path, &query, Some(&body))
3673 }
3674
3675}
3676
3677/// `client.dynamic_groups()`
3678#[derive(Clone, Copy)]
3679pub struct DynamicGroupsResource<'a> {
3680 client: &'a Client,
3681}
3682
3683impl<'a> DynamicGroupsResource<'a> {
3684 /// Remove automatic membership rules
3685 ///
3686 /// `DELETE /dynamicgroups/{groupId}/ruleset`
3687 ///
3688 /// Clears the stored rule set and resets the stored dynamicGroupStatus to null (reported as none by GET /status). Requires churchcore administer persons. Existing group memberships and the group itself remain in place. No refresh is run. The current implementation returns HTTP 200 with an empty body, including when no rule set was stored.
3689 ///
3690 /// # Example
3691 ///
3692 /// ```no_run
3693 /// # use churchtools_api::*;
3694 /// # use churchtools_api::queries::*;
3695 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3696 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3697 /// client.dynamic_groups().delete_ruleset(42)?;
3698 /// # Ok(())
3699 /// # }
3700 /// ```
3701 pub fn delete_ruleset(&self, group_id: impl Display) -> Result<()> {
3702 let path = format!("/dynamicgroups/{}/ruleset", seg(group_id));
3703 let query: Query = Query::new();
3704 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
3705 }
3706
3707 /// Get the dynamic membership refresh mode
3708 ///
3709 /// `GET /dynamicgroups/{groupId}/status`
3710 ///
3711 /// Returns the stored refresh mode of an ordinary group. A missing/null stored status is returned as none. This is configuration, not the progress of an in-flight job or proof that the rules are valid. Requires churchcore administer persons. The response is a flat object without a data wrapper.
3712 ///
3713 /// # Example
3714 ///
3715 /// ```
3716 /// # use churchtools_api::*;
3717 /// # use churchtools_api::queries::*;
3718 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3719 /// # let client = churchtools_api::replay::client("get-dynamicgroups-id-status");
3720 /// let statu = client.dynamic_groups().get_status(42)?;
3721 /// println!("{}", statu.dynamic_group_status);
3722 /// # Ok(())
3723 /// # }
3724 /// ```
3725 pub fn get_status(&self, group_id: impl Display) -> Result<models::DynamicGroupStatusUpdate> {
3726 let path = format!("/dynamicgroups/{}/status", seg(group_id));
3727 let query: Query = Query::new();
3728 self.client.request_json(Method::Get, &path, &query, None)
3729 }
3730
3731 /// List groups with automatic membership refresh
3732 ///
3733 /// `GET /dynamicgroups`
3734 ///
3735 /// Returns IDs of groups whose dynamicGroupStatus is active. A dynamic group is an ordinary ChurchTools group whose memberships can be maintained by a set of query rules. Groups in manual, inactive or none status are excluded, even when a rule set is stored. Conversely, active groups without a valid rule set are included and may fail during refresh. Requires churchcore administer persons. Results are not paginated and no ordering is guaranteed. This preliminary API may change.
3736 ///
3737 /// # Example
3738 ///
3739 /// ```
3740 /// # use churchtools_api::*;
3741 /// # use churchtools_api::queries::*;
3742 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3743 /// # let client = churchtools_api::replay::client("get-dynamicgroups");
3744 /// for dynamic_group in client.dynamic_groups().list()? {
3745 /// println!("{:?}", dynamic_group);
3746 /// }
3747 /// # Ok(())
3748 /// # }
3749 /// ```
3750 pub fn list(&self) -> Result<Vec<i64>> {
3751 let path = "/dynamicgroups".to_owned();
3752 let query: Query = Query::new();
3753 self.client.request_data(Method::Get, &path, &query, None)
3754 }
3755
3756 /// Get stored automatic membership rules
3757 ///
3758 /// `GET /dynamicgroups/{groupId}/ruleset`
3759 ///
3760 /// Returns the stored rule array directly, without a data wrapper. Requires churchcore administer persons. Rules can exist independently of the refresh status. If the group has no rules, including after an empty array was saved, this returns 404. Reading rules does not execute or validate their query results.
3761 ///
3762 /// # Example
3763 ///
3764 /// ```
3765 /// # use churchtools_api::*;
3766 /// # use churchtools_api::queries::*;
3767 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3768 /// # let client = churchtools_api::replay::client("get-dynamicgroups-id-ruleset");
3769 /// for ruleset in client.dynamic_groups().list_ruleset(42)? {
3770 /// println!("{}", ruleset.description);
3771 /// }
3772 /// # Ok(())
3773 /// # }
3774 /// ```
3775 pub fn list_ruleset(&self, group_id: impl Display) -> Result<Vec<models::DynamicGroupRule>> {
3776 let path = format!("/dynamicgroups/{}/ruleset", seg(group_id));
3777 let query: Query = Query::new();
3778 self.client.request_json(Method::Get, &path, &query, None)
3779 }
3780
3781 /// Refresh memberships of one dynamic group
3782 ///
3783 /// `POST /dynamicgroups/{groupId}/refresh`
3784 ///
3785 /// Synchronously evaluates and applies the stored rules of one group. Requires churchcore administer persons and dynamicGroupStatus active or manual. inactive and none reject manual refreshes. The request has no body and no dry-run option. Rules run against the initial membership snapshot and changes are applied as the system user, with at most 500 actual changes per run. Inspect unprocessed and runsNeeded before assuming convergence. A caught processing failure returns 400 with a message; it does not return a successful statistics object. Membership updates have their own transaction, but later timestamp/event/logging failures can occur after those changes have committed.
3786 ///
3787 /// # Example
3788 ///
3789 /// ```no_run
3790 /// # use churchtools_api::*;
3791 /// # use churchtools_api::queries::*;
3792 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3793 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3794 /// for dynamic_group in client.dynamic_groups().refresh(42)? {
3795 /// println!("{}", dynamic_group.created);
3796 /// }
3797 /// # Ok(())
3798 /// # }
3799 /// ```
3800 pub fn refresh(&self, group_id: impl Display) -> Result<Vec<models::DynamicGroupRefreshResult>> {
3801 let path = format!("/dynamicgroups/{}/refresh", seg(group_id));
3802 let query: Query = Query::new();
3803 self.client.request_data(Method::Post, &path, &query, None)
3804 }
3805
3806 /// Refresh all active dynamic groups
3807 ///
3808 /// `POST /dynamicgroups/refresh`
3809 ///
3810 /// Synchronously evaluates and applies membership rules for all groups with active dynamicGroupStatus. Requires churchcore administer persons. Manual, inactive and none groups are excluded. Rules run in ascending importance order against the starting membership snapshot; later field updates can override earlier ones, while any deletion action takes precedence. Membership writes run as the system user and can bypass the group size limit. Each group is processed separately; this is not a transaction across groups. At most 500 actual changes are applied per group per run, so inspect unprocessed and runsNeeded and repeat if necessary. A 200 response can contain per-group failures alongside successful statistics. Error entries lack a structured groupId; unexpected Errors can still abort the whole request. This endpoint performs changes immediately and does not support a dry run.
3811 ///
3812 /// # Example
3813 ///
3814 /// ```no_run
3815 /// # use churchtools_api::*;
3816 /// # use churchtools_api::queries::*;
3817 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3818 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3819 /// for dynamic_group in client.dynamic_groups().refresh_all()? {
3820 /// println!("{:?}", dynamic_group);
3821 /// }
3822 /// # Ok(())
3823 /// # }
3824 /// ```
3825 pub fn refresh_all(&self) -> Result<Vec<serde_json::Value>> {
3826 let path = "/dynamicgroups/refresh".to_owned();
3827 let query: Query = Query::new();
3828 self.client.request_data(Method::Post, &path, &query, None)
3829 }
3830
3831 /// Replace automatic membership rules
3832 ///
3833 /// `PUT /dynamicgroups/{groupId}/ruleset`
3834 ///
3835 /// Stores the complete rule array after validation against the dynamic-group JSON schema. Requires churchcore administer persons. Rule syntax validation does not execute queries or validate all referenced roles, fields and runtime process values. Saving rules does not change dynamicGroupStatus or immediately update memberships. Use PUT /status to select the refresh mode and POST /refresh to run it explicitly. An empty array stores no rule set and returns dynamicGroupRuleSet: null, even if the group remains active. The response has a dynamicGroupRuleSet property directly, without a data wrapper.
3836 ///
3837 /// # Example
3838 ///
3839 /// ```no_run
3840 /// # use churchtools_api::*;
3841 /// # use churchtools_api::queries::*;
3842 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3843 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3844 /// let body = models::DynamicGroupRuleSetUpdate {
3845 /// dynamic_group_rule_set: vec![models::DynamicGroupRule {
3846 /// description: "Add selected people to the group.".into(),
3847 /// importance: 10,
3848 /// person_id_field_name: "person.id".into(),
3849 /// process: models::DynamicGroupProcessSets {
3850 /// group_and_query_result: models::DynamicGroupProcessSetsGroupAndQueryResult::default(),
3851 /// group_only: models::DynamicGroupProcessSetsGroupOnly::default(),
3852 /// query_result_only: models::DynamicGroupProcessSetsQueryResultOnly::default(),
3853 /// ..Default::default()
3854 /// },
3855 /// query: models::DynamicGroupQuery {
3856 /// method: "ChurchQuery".into(),
3857 /// params: models::DynamicGroupQueryParams::default(),
3858 /// ..Default::default()
3859 /// },
3860 /// shorty: "selected-people".into(),
3861 /// ..Default::default()
3862 /// }],
3863 /// ..Default::default()
3864 /// };
3865 /// let result = client.dynamic_groups().update_ruleset(42, &body)?;
3866 /// println!("{:?}", result);
3867 /// # Ok(())
3868 /// # }
3869 /// ```
3870 pub fn update_ruleset(&self, group_id: impl Display, body: &models::DynamicGroupRuleSetUpdate) -> Result<models::PutDynamicgroupsIdRulesetResponse> {
3871 let path = format!("/dynamicgroups/{}/ruleset", seg(group_id));
3872 let query: Query = Query::new();
3873 let body = serde_json::to_value(body).expect("request body serializes");
3874 self.client.request_json(Method::Put, &path, &query, Some(&body))
3875 }
3876
3877 /// Set the dynamic membership refresh mode
3878 ///
3879 /// `PUT /dynamicgroups/{groupId}/status`
3880 ///
3881 /// Sets active, manual, inactive or none for an existing group. Requires churchcore administer persons. This does not run a refresh, delete stored rules or alter existing memberships. The mode is not checked against the presence or validity of a rule set, so an active group can subsequently fail to refresh. To remove rules as well, use DELETE /ruleset. The response is a flat object without a data wrapper.
3882 ///
3883 /// # Example
3884 ///
3885 /// ```no_run
3886 /// # use churchtools_api::*;
3887 /// # use churchtools_api::queries::*;
3888 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3889 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3890 /// let body = models::DynamicGroupStatusUpdate {
3891 /// dynamic_group_status: "manual".into(),
3892 /// ..Default::default()
3893 /// };
3894 /// let result = client.dynamic_groups().update_status(42, &body)?;
3895 /// println!("{}", result.dynamic_group_status);
3896 /// # Ok(())
3897 /// # }
3898 /// ```
3899 pub fn update_status(&self, group_id: impl Display, body: &models::DynamicGroupStatusUpdate) -> Result<models::DynamicGroupStatusUpdate> {
3900 let path = format!("/dynamicgroups/{}/status", seg(group_id));
3901 let query: Query = Query::new();
3902 let body = serde_json::to_value(body).expect("request body serializes");
3903 self.client.request_json(Method::Put, &path, &query, Some(&body))
3904 }
3905
3906}
3907
3908/// `client.emails()`
3909#[derive(Clone, Copy)]
3910pub struct EmailsResource<'a> {
3911 client: &'a Client,
3912}
3913
3914impl<'a> EmailsResource<'a> {
3915 /// Get email placeholder statistics
3916 ///
3917 /// `POST /emails/placeholderstatistics`
3918 ///
3919 /// Renders placeholder statistics for the visible subset of personIds without sending emails. Content fragments are concatenated, optionally inserted into an accessible HTML template, then evaluated for each person. Missing/inaccessible recipients are omitted; if none are visible, the request returns 404. Without placeholder-like syntax in the resulting text, data is empty even when recipients were supplied. Results follow the loaded recipient order, not necessarily the input order; correlate by personId. Stats report availability of evaluated placeholders, not their values or occurrence counts. A subject is not part of this request. The automaticEmailId parameter currently has no effect.
3920 ///
3921 /// # Example
3922 ///
3923 /// ```no_run
3924 /// # use churchtools_api::*;
3925 /// # use churchtools_api::queries::*;
3926 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3927 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3928 /// let body = models::EmailPlaceholderStatisticsCreate {
3929 /// content: vec!["Hello {{person.firstName}}".into()],
3930 /// person_ids: vec![1, 2],
3931 /// ..Default::default()
3932 /// };
3933 /// for email in client.emails().placeholder_statistics(&body)? {
3934 /// println!("{}", email.person_id);
3935 /// }
3936 /// # Ok(())
3937 /// # }
3938 /// ```
3939 pub fn placeholder_statistics(&self, body: &models::EmailPlaceholderStatisticsCreate) -> Result<Vec<models::EmailPlaceholderStatistics>> {
3940 let path = "/emails/placeholderstatistics".to_owned();
3941 let query: Query = Query::new();
3942 let body = serde_json::to_value(body).expect("request body serializes");
3943 self.client.request_data(Method::Post, &path, &query, Some(&body))
3944 }
3945
3946 /// Render an email preview
3947 ///
3948 /// `POST /emails/preview`
3949 ///
3950 /// Renders content and an optional subject for one person visible to the caller. No email is sent and no draft is saved. Content fragments are concatenated without separators; an optional template replaces its {{body}} tokens before placeholder expansion. groupId adds group and membership context and requires access to that group. The HTML template requires template-view permission, or permission to view automatic emails for the supplied group. Missing or inaccessible recipients return 404. The flat response always contains html and contains subject only when supplied. userId selects a placeholder acting context rather than a recipient and is handled differently by individual decorators; it is not an authenticated-user switch for the whole request.
3951 ///
3952 /// # Example
3953 ///
3954 /// ```
3955 /// # use churchtools_api::*;
3956 /// # use churchtools_api::queries::*;
3957 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3958 /// # let client = churchtools_api::replay::client("post-emails-preview");
3959 /// let body = models::EmailPreviewCreate {
3960 /// content: vec!["Hello {{person.firstName}}".into()],
3961 /// person_id: 1,
3962 /// ..Default::default()
3963 /// };
3964 /// let email = client.emails().preview(&body)?;
3965 /// println!("{}", email.html);
3966 /// # Ok(())
3967 /// # }
3968 /// ```
3969 pub fn preview(&self, body: &models::EmailPreviewCreate) -> Result<models::EmailPreview> {
3970 let path = "/emails/preview".to_owned();
3971 let query: Query = Query::new();
3972 let body = serde_json::to_value(body).expect("request body serializes");
3973 self.client.request_json(Method::Post, &path, &query, Some(&body))
3974 }
3975
3976}
3977
3978/// `client.evangelische_termine()`
3979#[derive(Clone, Copy)]
3980pub struct EvangelischeTermineResource<'a> {
3981 client: &'a Client,
3982}
3983
3984impl<'a> EvangelischeTermineResource<'a> {
3985 /// Queue deletion of published external appointments
3986 ///
3987 /// `DELETE /evangelischetermine`
3988 ///
3989 /// Queues removal of ChurchTools-published appointments from the configured Evangelische Termine organizer. Local ChurchTools appointments are retained. The background job reads the external JSON event list and deletes remote dates whose external identifier starts with ChurchTools; it does not limit removal to calendars currently selected for synchronization. Requires the churchcore permission "administer settings". HTTP 204 means the deletion job was queued and started in the background, not that remote deletion has completed. If synchronization is disabled, this call returns 204 without queuing a job. It does not disable synchronization, so later synchronization can publish appointments again. There is no dry-run option or returned job identifier.
3990 ///
3991 /// # Example
3992 ///
3993 /// ```no_run
3994 /// # use churchtools_api::*;
3995 /// # use churchtools_api::queries::*;
3996 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
3997 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
3998 /// client.evangelische_termine().delete()?;
3999 /// # Ok(())
4000 /// # }
4001 /// ```
4002 pub fn delete(&self) -> Result<()> {
4003 let path = "/evangelischetermine".to_owned();
4004 let query: Query = Query::new();
4005 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
4006 }
4007
4008 /// Get external event classifications
4009 ///
4010 /// `GET /evangelischetermine/eventtypes`
4011 ///
4012 /// Fetches the eventtype parameter values from the configured Evangelische Termine SOAP service. Use the returned keys and labels when selecting an external event classification. ChurchTools forwards the external list without adding pagination or meta. Synchronization must already be enabled and its stored connection settings must work. The controller has no additional settings-administration permission check beyond API authentication.
4013 ///
4014 /// # Example
4015 ///
4016 /// ```no_run
4017 /// # use churchtools_api::*;
4018 /// # use churchtools_api::queries::*;
4019 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4020 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4021 /// for event_type in client.evangelische_termine().list_event_types()? {
4022 /// println!("{}", event_type.key);
4023 /// }
4024 /// # Ok(())
4025 /// # }
4026 /// ```
4027 pub fn list_event_types(&self) -> Result<Vec<models::EvangelischeTermineEventType>> {
4028 let path = "/evangelischetermine/eventtypes".to_owned();
4029 let query: Query = Query::new();
4030 self.client.request_data(Method::Get, &path, &query, None)
4031 }
4032
4033 /// Test external synchronization settings
4034 ///
4035 /// `POST /evangelischetermine/validatesettings`
4036 ///
4037 /// Tests the supplied server URL, organizer ID and API key by creating a SOAP connection and requesting the external event types. Requires the churchcore permission "administer settings". The integration need not already be enabled. A successful test returns 200 with an empty body; it does not save the settings, enable synchronization or publish appointments. A rejected URL or failed connection/authentication check returns 400 with an empty body. Invalid request-field types can instead return a JSON validation error.
4038 ///
4039 /// # Example
4040 ///
4041 /// ```no_run
4042 /// # use churchtools_api::*;
4043 /// # use churchtools_api::queries::*;
4044 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4045 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4046 /// let body = models::EvangelischeTermineSettingsValidateCreate {
4047 /// api_key: "*****".into(),
4048 /// url: "https://www.evangelische-termine.de".into(),
4049 /// vid: "1234".into(),
4050 /// ..Default::default()
4051 /// };
4052 /// client.evangelische_termine().validate_settings(&body)?;
4053 /// # Ok(())
4054 /// # }
4055 /// ```
4056 pub fn validate_settings(&self, body: &models::EvangelischeTermineSettingsValidateCreate) -> Result<()> {
4057 let path = "/evangelischetermine/validatesettings".to_owned();
4058 let query: Query = Query::new();
4059 let body = serde_json::to_value(body).expect("request body serializes");
4060 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
4061 }
4062
4063}
4064
4065/// `client.event()`
4066#[derive(Clone, Copy)]
4067pub struct EventResource<'a> {
4068 client: &'a Client,
4069}
4070
4071impl<'a> EventResource<'a> {
4072 /// Get Event module reference data
4073 ///
4074 /// `GET /event/masterdata`
4075 ///
4076 /// Returns six complete reference-data lists for the Event module together with their individual counts in `meta`. All lists are present and unpaginated; receiving a record does not grant permission to use or edit it. Song categories and sources have no guaranteed list order.
4077 ///
4078 /// # Example
4079 ///
4080 /// ```
4081 /// # use churchtools_api::*;
4082 /// # use churchtools_api::queries::*;
4083 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4084 /// # let client = churchtools_api::replay::client("get-event-masterdata");
4085 /// let master_data = client.event().get_master_data()?;
4086 /// println!("{:?}", master_data);
4087 /// # Ok(())
4088 /// # }
4089 /// ```
4090 pub fn get_master_data(&self) -> Result<models::EventMasterData> {
4091 let path = "/event/masterdata".to_owned();
4092 let query: Query = Query::new();
4093 self.client.request_data(Method::Get, &path, &query, None)
4094 }
4095
4096}
4097
4098/// `client.event_templates()`
4099#[derive(Clone, Copy)]
4100pub struct EventTemplatesResource<'a> {
4101 client: &'a Client,
4102}
4103
4104impl<'a> EventTemplatesResource<'a> {
4105 /// Get all event templates
4106 ///
4107 /// `GET /eventtemplates`
4108 ///
4109 /// Returns all event templates as an unpaginated list, sorted by `sortKey` ascending. No per-template visibility filter is applied.
4110 ///
4111 /// # Example
4112 ///
4113 /// ```
4114 /// # use churchtools_api::*;
4115 /// # use churchtools_api::queries::*;
4116 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4117 /// # let client = churchtools_api::replay::client("get-eventtemplates");
4118 /// for event_template in client.event_templates().list()? {
4119 /// println!("{}", event_template.id);
4120 /// }
4121 /// # Ok(())
4122 /// # }
4123 /// ```
4124 pub fn list(&self) -> Result<Vec<models::EventTemplate>> {
4125 let path = "/eventtemplates".to_owned();
4126 let query: Query = Query::new();
4127 self.client.request_data(Method::Get, &path, &query, None)
4128 }
4129
4130}
4131
4132/// `client.events()`
4133#[derive(Clone, Copy)]
4134pub struct EventsResource<'a> {
4135 client: &'a Client,
4136}
4137
4138impl<'a> EventsResource<'a> {
4139 pub fn agenda(&self) -> EventsAgendaResource<'a> {
4140 EventsAgendaResource { client: self.client }
4141 }
4142
4143 pub fn event_services(&self) -> EventsEventServicesResource<'a> {
4144 EventsEventServicesResource { client: self.client }
4145 }
4146
4147 pub fn facts(&self) -> EventsFactsResource<'a> {
4148 EventsFactsResource { client: self.client }
4149 }
4150
4151 pub fn service_requests(&self) -> EventsServiceRequestsResource<'a> {
4152 EventsServiceRequestsResource { client: self.client }
4153 }
4154
4155 pub fn services(&self) -> EventsServicesResource<'a> {
4156 EventsServicesResource { client: self.client }
4157 }
4158
4159 /// Start or stop an event chat
4160 ///
4161 /// `POST /events/{eventId}/chat`
4162 ///
4163 /// Starts, reactivates or stops the chat linked to this event. Requires access to the event, an active chat installation with event chats enabled, and permission to administer persons, start an event chat through event permissions, or administer this event. A new room is provisioned through the chat service; HTTP `200` does not guarantee that remote room setup is already complete. Stopping a chat that has never been created returns `404`.
4164 ///
4165 /// # Example
4166 ///
4167 /// ```no_run
4168 /// # use churchtools_api::*;
4169 /// # use churchtools_api::queries::*;
4170 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4171 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4172 /// let body = models::EventChatUpdate {
4173 /// enabled: true,
4174 /// ..Default::default()
4175 /// };
4176 /// client.events().chat(42, &body)?;
4177 /// # Ok(())
4178 /// # }
4179 /// ```
4180 pub fn chat(&self, event_id: impl Display, body: &models::EventChatUpdate) -> Result<()> {
4181 let path = format!("/events/{}/chat", seg(event_id));
4182 let query: Query = Query::new();
4183 let body = serde_json::to_value(body).expect("request body serializes");
4184 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
4185 }
4186
4187 /// Create iCal roster link
4188 ///
4189 /// `POST /events/ical`
4190 ///
4191 /// Creates a new personal roster subscription secret and returns the link as JSON. Use `meta.iCalUrl` to fetch the actual iCalendar feed. A roster contains the person's service assignments at events, including pending requests and confirmed assignments.
4192 ///
4193 /// # Example
4194 ///
4195 /// ```no_run
4196 /// # use churchtools_api::*;
4197 /// # use churchtools_api::queries::*;
4198 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4199 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4200 /// let query = PostEventsIcalQuery {
4201 /// person_id: Some(42),
4202 /// ..Default::default()
4203 /// };
4204 /// let result = client.events().create_ical(&query)?;
4205 /// println!("{}", result.attribute);
4206 /// # Ok(())
4207 /// # }
4208 /// ```
4209 pub fn create_ical(&self, query: &PostEventsIcalQuery) -> Result<models::RosterICalSetting> {
4210 let path = "/events/ical".to_owned();
4211 let query: Query = query.to_query();
4212 self.client.request_data(Method::Post, &path, &query, None)
4213 }
4214
4215 /// Delete a single event
4216 ///
4217 /// `DELETE /events/{eventId}`
4218 ///
4219 /// Deletes the service-planning event through the dependency-aware deletion service. With `dryRun`=`true`, the deletion check returns a `409` report without deleting the event, but `sendMail` is processed before that check. Requires event administration access, the "edit events" permission for the event calendar, or a corresponding internal group permission.
4220 ///
4221 /// Use [`Self::delete_with`] to pass query parameters.
4222 ///
4223 /// # Example
4224 ///
4225 /// ```no_run
4226 /// # use churchtools_api::*;
4227 /// # use churchtools_api::queries::*;
4228 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4229 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4230 /// client.events().delete(42)?;
4231 /// # Ok(())
4232 /// # }
4233 /// ```
4234 pub fn delete(&self, event_id: impl Display) -> Result<()> {
4235 self.delete_with(event_id, &Default::default())
4236 }
4237
4238 /// Delete a single event
4239 ///
4240 /// Like [`Self::delete`], with query parameters.
4241 ///
4242 /// `DELETE /events/{eventId}`
4243 ///
4244 /// Deletes the service-planning event through the dependency-aware deletion service. With `dryRun`=`true`, the deletion check returns a `409` report without deleting the event, but `sendMail` is processed before that check. Requires event administration access, the "edit events" permission for the event calendar, or a corresponding internal group permission.
4245 pub fn delete_with(&self, event_id: impl Display, query: &DeleteEventsIdQuery) -> Result<()> {
4246 let path = format!("/events/{}", seg(event_id));
4247 let query: Query = query.to_query();
4248 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
4249 }
4250
4251 /// Get a single event
4252 ///
4253 /// `GET /events/{eventId}`
4254 ///
4255 /// Returns the event visible to the current user, including calendar, eventFiles and eventServices. Service assignments are filtered by service-group visibility or own assignment; persons can be concealed. The eventServices property is present even when empty. Cancelled events can also be read if visible.
4256 ///
4257 /// # Example
4258 ///
4259 /// ```
4260 /// # use churchtools_api::*;
4261 /// # use churchtools_api::queries::*;
4262 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4263 /// # let client = churchtools_api::replay::client("get-events-id");
4264 /// let event = client.events().get(42)?;
4265 /// println!("{}", event.name);
4266 /// # Ok(())
4267 /// # }
4268 /// ```
4269 pub fn get(&self, event_id: impl Display) -> Result<models::EventReadWithServices> {
4270 let path = format!("/events/{}", seg(event_id));
4271 let query: Query = Query::new();
4272 self.client.request_data(Method::Get, &path, &query, None)
4273 }
4274
4275 /// Get iCal roster link
4276 ///
4277 /// `GET /events/ical`
4278 ///
4279 /// Returns the personal roster subscription as JSON. If no secret exists, this `GET` creates one; otherwise it preserves the existing link. Use `meta.iCalUrl` to fetch the actual iCalendar feed. A roster contains the person's service assignments at events, including pending requests and confirmed assignments.
4280 ///
4281 /// # Example
4282 ///
4283 /// ```
4284 /// # use churchtools_api::*;
4285 /// # use churchtools_api::queries::*;
4286 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4287 /// # let client = churchtools_api::replay::client("get-events-ical");
4288 /// let query = GetEventsIcalQuery {
4289 /// person_id: Some(42),
4290 /// ..Default::default()
4291 /// };
4292 /// let ical = client.events().get_ical(&query)?;
4293 /// println!("{}", ical.attribute);
4294 /// # Ok(())
4295 /// # }
4296 /// ```
4297 pub fn get_ical(&self, query: &GetEventsIcalQuery) -> Result<models::RosterICalSetting> {
4298 let path = "/events/ical".to_owned();
4299 let query: Query = query.to_query();
4300 self.client.request_data(Method::Get, &path, &query, None)
4301 }
4302
4303 /// Get all events
4304 ///
4305 /// `GET /events`
4306 ///
4307 /// Returns events visible through calendar permissions or the current user’s valid service assignments. Date comparisons use midnight in the application time zone: to includes exactly midnight, not later events that day. Results from calendar access are merged with events where the user is assigned and deduplicated; this merged range list is not guaranteed to be globally sorted. With direction, selects one page relative to from and ignores to.
4308 ///
4309 /// Use [`Self::list_with`] to pass query parameters.
4310 ///
4311 /// # Example
4312 ///
4313 /// ```
4314 /// # use churchtools_api::*;
4315 /// # use churchtools_api::queries::*;
4316 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4317 /// # let client = churchtools_api::replay::client("get-events");
4318 /// for event in client.events().list()? {
4319 /// println!("{}", event.name);
4320 /// }
4321 /// # Ok(())
4322 /// # }
4323 /// ```
4324 pub fn list(&self) -> Result<Vec<models::Event>> {
4325 self.list_with(&Default::default())
4326 }
4327
4328 /// Get all events
4329 ///
4330 /// Like [`Self::list`], with query parameters.
4331 ///
4332 /// `GET /events`
4333 ///
4334 /// Returns events visible through calendar permissions or the current user’s valid service assignments. Date comparisons use midnight in the application time zone: to includes exactly midnight, not later events that day. Results from calendar access are merged with events where the user is assigned and deduplicated; this merged range list is not guaranteed to be globally sorted. With direction, selects one page relative to from and ignores to.
4335 pub fn list_with(&self, query: &GetEventsQuery) -> Result<Vec<models::Event>> {
4336 let path = "/events".to_owned();
4337 let query: Query = query.to_query();
4338 self.client.collect_pages(&path, query)
4339 }
4340
4341 /// Get all events
4342 ///
4343 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
4344 /// Breaking off early saves the remaining requests.
4345 pub fn list_iter(&self, query: &GetEventsQuery) -> Items<models::Event> {
4346 let path = "/events".to_owned();
4347 self.client.items(&path, query.to_query())
4348 }
4349
4350 /// Get all possible persons for a service
4351 ///
4352 /// `GET /events/{serviceId}/possiblepersonsforservice`
4353 ///
4354 /// Returns an unpaginated, deduplicated list of persons from active, non-hidden memberships in groups connected to the service. If connected tags exist, a matching tag is also required. Archived or deceased persons are excluded and hidden-person visibility is respected. With no connected groups, the result is empty.
4355 ///
4356 /// # Example
4357 ///
4358 /// ```
4359 /// # use churchtools_api::*;
4360 /// # use churchtools_api::queries::*;
4361 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4362 /// # let client = churchtools_api::replay::client("get-events-id-possiblepersonsforservice");
4363 /// for possible_persons_for_service in client.events().list_possible_persons_for_service(2)? {
4364 /// println!("{}", possible_persons_for_service.full_name);
4365 /// }
4366 /// # Ok(())
4367 /// # }
4368 /// ```
4369 pub fn list_possible_persons_for_service(&self, service_id: impl Display) -> Result<Vec<models::ServiceCandidate>> {
4370 let path = format!("/events/{}/possiblepersonsforservice", seg(service_id));
4371 let query: Query = Query::new();
4372 self.client.request_data(Method::Get, &path, &query, None)
4373 }
4374
4375 /// Send an email to selected event recipients
4376 ///
4377 /// `POST /events/send`
4378 ///
4379 /// Sends an email to selected people in the context of one or more events. ChurchTools filters service participants by visible service groups and other selected recipients by person visibility. The response reports effective and rejected recipients. `sendCopyToMe` can add the sender. Optional agenda buttons require agenda visibility for each event; sending does not require an agenda or a shared agenda across events.
4380 ///
4381 /// # Example
4382 ///
4383 /// ```no_run
4384 /// # use churchtools_api::*;
4385 /// # use churchtools_api::queries::*;
4386 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4387 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4388 /// let body = models::EventMailCreate {
4389 /// body: "<p>Please review the updated agenda for Sunday.</p>".into(),
4390 /// event_ids: vec![31, 32],
4391 /// recipients: vec![40, 41],
4392 /// subject: "Updated Sunday agenda".into(),
4393 /// append_agenda_button: true,
4394 /// files: vec![42],
4395 /// ..Default::default()
4396 /// };
4397 /// let event = client.events().send(&body)?;
4398 /// println!("{:?}", event);
4399 /// # Ok(())
4400 /// # }
4401 /// ```
4402 pub fn send(&self, body: &models::EventMailCreate) -> Result<models::EventMailSendResult> {
4403 let path = "/events/send".to_owned();
4404 let query: Query = Query::new();
4405 let body = serde_json::to_value(body).expect("request body serializes");
4406 self.client.request_data(Method::Post, &path, &query, Some(&body))
4407 }
4408
4409 /// Update event details
4410 ///
4411 /// `PUT /events/{eventId}`
4412 ///
4413 /// Updates the description, administrators and cancellation state for this service-planning event. It does not update service assignments or the calendar appointment. Changing the administrator set additionally requires the "edit masterdata" permission for the service planning domain; other changes require event administration access, the "edit events" permission for the event calendar, or a corresponding internal group permission.
4414 ///
4415 /// # Example
4416 ///
4417 /// ```no_run
4418 /// # use churchtools_api::*;
4419 /// # use churchtools_api::queries::*;
4420 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4421 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4422 /// let body = models::EventDetailsUpdate {
4423 /// description: Some(Some("Sound check starts 30 minutes before the gathering.".into())),
4424 /// ..Default::default()
4425 /// };
4426 /// let result = client.events().update(42, &body)?;
4427 /// println!("{}", result.id);
4428 /// # Ok(())
4429 /// # }
4430 /// ```
4431 pub fn update(&self, event_id: impl Display, body: &models::EventDetailsUpdate) -> Result<models::EventDetailsUpdateResult> {
4432 let path = format!("/events/{}", seg(event_id));
4433 let query: Query = Query::new();
4434 let body = serde_json::to_value(body).expect("request body serializes");
4435 self.client.request_data(Method::Put, &path, &query, Some(&body))
4436 }
4437
4438}
4439
4440/// `client.events().agenda()`
4441#[derive(Clone, Copy)]
4442pub struct EventsAgendaResource<'a> {
4443 client: &'a Client,
4444}
4445
4446impl<'a> EventsAgendaResource<'a> {
4447 pub fn items(&self) -> EventsAgendaItemsResource<'a> {
4448 EventsAgendaItemsResource { client: self.client }
4449 }
4450
4451 /// Detach the agenda from an event
4452 ///
4453 /// `DELETE /events/{eventId}/agenda`
4454 ///
4455 /// Removes only the link between the event and its agenda. Other events sharing this agenda retain their links and content. If no event links remain, the unused agenda is cleaned up later. A locked agenda can also be detached. Requires agenda editing access for the event.
4456 ///
4457 /// # Example
4458 ///
4459 /// ```no_run
4460 /// # use churchtools_api::*;
4461 /// # use churchtools_api::queries::*;
4462 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4463 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4464 /// client.events().agenda().delete(42)?;
4465 /// # Ok(())
4466 /// # }
4467 /// ```
4468 pub fn delete(&self, event_id: impl Display) -> Result<()> {
4469 let path = format!("/events/{}/agenda", seg(event_id));
4470 let query: Query = Query::new();
4471 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
4472 }
4473
4474 /// Export event agenda
4475 ///
4476 /// `POST /events/{eventId}/agenda/export`
4477 ///
4478 /// Generates a presenter import archive for an event agenda. Requires a super administrator, an event administrator, "view agenda" or "edit agenda" for the event calendar, or involvement in the event. The current exporters use all items from the shared agenda, including items hidden for the requested event; the archive is not filtered to that event's visible positions. Locked and unlocked agendas can be exported.
4479 ///
4480 /// # Example
4481 ///
4482 /// ```no_run
4483 /// # use churchtools_api::*;
4484 /// # use churchtools_api::queries::*;
4485 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4486 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4487 /// let query = PostEventsIdAgendaExportQuery {
4488 /// format: Some("SONG_BEAMER".into()),
4489 /// ..Default::default()
4490 /// };
4491 /// let body = models::AgendaExportCreate {
4492 /// append_arrangement: true,
4493 /// export_songs: true,
4494 /// with_category: false,
4495 /// ..Default::default()
4496 /// };
4497 /// let agenda = client.events().agenda().export(42, &query, &body)?;
4498 /// println!("{}", agenda.url);
4499 /// # Ok(())
4500 /// # }
4501 /// ```
4502 pub fn export(&self, event_id: impl Display, query: &PostEventsIdAgendaExportQuery, body: &models::AgendaExportCreate) -> Result<models::AgendaExport> {
4503 let path = format!("/events/{}/agenda/export", seg(event_id));
4504 let query: Query = query.to_query();
4505 let body = serde_json::to_value(body).expect("request body serializes");
4506 self.client.request_data(Method::Post, &path, &query, Some(&body))
4507 }
4508
4509 /// Get agenda for event
4510 ///
4511 /// `GET /events/{eventId}/agenda`
4512 ///
4513 /// Returns the event's running plan, including all ordered items, shared lock state and calculated times for linked events. Header, text and song items use different response fields; hidden items remain in `items` with a `null` entry in `startTimes`. Responsibility placeholders are resolved for the requested event and service-group notes are visibility-filtered.
4514 ///
4515 /// # Example
4516 ///
4517 /// ```
4518 /// # use churchtools_api::*;
4519 /// # use churchtools_api::queries::*;
4520 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4521 /// # let client = churchtools_api::replay::client("get-events-id-agenda");
4522 /// let agenda = client.events().agenda().get(42)?;
4523 /// println!("{:?}", agenda.name);
4524 /// # Ok(())
4525 /// # }
4526 /// ```
4527 pub fn get(&self, event_id: impl Display) -> Result<models::Agenda> {
4528 let path = format!("/events/{}/agenda", seg(event_id));
4529 let query: Query = Query::new();
4530 self.client.request_data(Method::Get, &path, &query, None)
4531 }
4532
4533 /// Integrate agenda with another event
4534 ///
4535 /// `POST /events/{eventId}/agenda/integrate`
4536 ///
4537 /// Links the target event in the path to the existing agenda of the source event given by `event_id`. This creates a shared agenda, not a copy: item IDs, content and lock state are shared with all already linked events. Event dates remain independent and item times are calculated per event. Hidden-item settings of the source event are not copied to the new link. Requires agenda editing permission for the target and agenda viewing permission for the source.
4538 ///
4539 /// # Example
4540 ///
4541 /// ```no_run
4542 /// # use churchtools_api::*;
4543 /// # use churchtools_api::queries::*;
4544 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4545 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4546 /// let query = PostEventsIdAgendaIntegrateQuery {
4547 /// event_id: Some(1337),
4548 /// ..Default::default()
4549 /// };
4550 /// let agenda = client.events().agenda().integrate(42, &query)?;
4551 /// println!("{:?}", agenda.name);
4552 /// # Ok(())
4553 /// # }
4554 /// ```
4555 pub fn integrate(&self, event_id: impl Display, query: &PostEventsIdAgendaIntegrateQuery) -> Result<models::Agenda> {
4556 let path = format!("/events/{}/agenda/integrate", seg(event_id));
4557 let query: Query = query.to_query();
4558 self.client.request_data(Method::Post, &path, &query, None)
4559 }
4560
4561 /// Get songs referenced by an agenda
4562 ///
4563 /// `GET /events/{eventId}/agenda/songs`
4564 ///
4565 /// Returns the distinct songs referenced by song items with an assigned arrangement in the event's agenda. Includes songs from positions hidden for this event because the complete shared agenda is inspected. Multiple positions or arrangements referring to one song produce one song record. Each record includes all arrangements of that song, not only the arrangement selected in the agenda.
4566 ///
4567 /// # Example
4568 ///
4569 /// ```
4570 /// # use churchtools_api::*;
4571 /// # use churchtools_api::queries::*;
4572 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4573 /// # let client = churchtools_api::replay::client("get-events-id-agenda-songs");
4574 /// for song in client.events().agenda().list_songs(42)? {
4575 /// println!("{}", song.name);
4576 /// }
4577 /// # Ok(())
4578 /// # }
4579 /// ```
4580 pub fn list_songs(&self, event_id: impl Display) -> Result<Vec<models::Song>> {
4581 let path = format!("/events/{}/agenda/songs", seg(event_id));
4582 let query: Query = Query::new();
4583 self.client.request_data(Method::Get, &path, &query, None)
4584 }
4585
4586 /// Lock a shared agenda
4587 ///
4588 /// `POST /events/{eventId}/agenda/lock`
4589 ///
4590 /// Locks the event's agenda against content changes. Events integrated with this event share the same agenda and therefore the same lock state. This is an agenda state, not a temporary editing lock owned by the caller. Calling lock on an already locked agenda returns `403`. Requires agenda editing access for the event.
4591 ///
4592 /// # Example
4593 ///
4594 /// ```no_run
4595 /// # use churchtools_api::*;
4596 /// # use churchtools_api::queries::*;
4597 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4598 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4599 /// client.events().agenda().lock(42)?;
4600 /// # Ok(())
4601 /// # }
4602 /// ```
4603 pub fn lock(&self, event_id: impl Display) -> Result<()> {
4604 let path = format!("/events/{}/agenda/lock", seg(event_id));
4605 let query: Query = Query::new();
4606 self.client.request(Method::Post, &path, &query, None).map(|_| ())
4607 }
4608
4609 /// Unlock a shared agenda
4610 ///
4611 /// `POST /events/{eventId}/agenda/unlock`
4612 ///
4613 /// Unlocks the event's agenda so its content can be edited again. The change applies to all events sharing the agenda. Calling unlock on an already unlocked agenda returns `403`. Any caller with the required agenda editing permission can unlock it; the caller need not be the person who locked it. Requires agenda editing access for the event.
4614 ///
4615 /// # Example
4616 ///
4617 /// ```no_run
4618 /// # use churchtools_api::*;
4619 /// # use churchtools_api::queries::*;
4620 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4621 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4622 /// client.events().agenda().unlock(42)?;
4623 /// # Ok(())
4624 /// # }
4625 /// ```
4626 pub fn unlock(&self, event_id: impl Display) -> Result<()> {
4627 let path = format!("/events/{}/agenda/unlock", seg(event_id));
4628 let query: Query = Query::new();
4629 self.client.request(Method::Post, &path, &query, None).map(|_| ())
4630 }
4631
4632 /// Create or update agenda
4633 ///
4634 /// `PUT /events/{eventId}/agenda`
4635 ///
4636 /// Creates an agenda for an event that has none, or updates its existing agenda. The operation always returns `200`. Supply `calendarId` when creating without a copy source. On update, the agenda must be unlocked; changes to a shared agenda affect every linked event. Requires agenda editing permission for the target and viewing permission for a selected source agenda or template.
4637 ///
4638 /// Use [`Self::update_with`] to pass query parameters.
4639 ///
4640 /// # Example
4641 ///
4642 /// ```no_run
4643 /// # use churchtools_api::*;
4644 /// # use churchtools_api::queries::*;
4645 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4646 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4647 /// let body = serde_json::json!({});
4648 /// let result = client.events().agenda().update(42, &body)?;
4649 /// println!("{:?}", result.name);
4650 /// # Ok(())
4651 /// # }
4652 /// ```
4653 pub fn update(&self, event_id: impl Display, body: &serde_json::Value) -> Result<models::Agenda> {
4654 self.update_with(event_id, &Default::default(), body)
4655 }
4656
4657 /// Create or update agenda
4658 ///
4659 /// Like [`Self::update`], with query parameters.
4660 ///
4661 /// `PUT /events/{eventId}/agenda`
4662 ///
4663 /// Creates an agenda for an event that has none, or updates its existing agenda. The operation always returns `200`. Supply `calendarId` when creating without a copy source. On update, the agenda must be unlocked; changes to a shared agenda affect every linked event. Requires agenda editing permission for the target and viewing permission for a selected source agenda or template.
4664 pub fn update_with(&self, event_id: impl Display, query: &PutEventsIdAgendaQuery, body: &serde_json::Value) -> Result<models::Agenda> {
4665 let path = format!("/events/{}/agenda", seg(event_id));
4666 let query: Query = query.to_query();
4667 let body = serde_json::to_value(body).expect("request body serializes");
4668 self.client.request_data(Method::Put, &path, &query, Some(&body))
4669 }
4670
4671}
4672
4673/// `client.events().agenda().items()`
4674#[derive(Clone, Copy)]
4675pub struct EventsAgendaItemsResource<'a> {
4676 client: &'a Client,
4677}
4678
4679impl<'a> EventsAgendaItemsResource<'a> {
4680 pub fn service_groups(&self) -> EventsAgendaItemsServiceGroupsResource<'a> {
4681 EventsAgendaItemsServiceGroupsResource { client: self.client }
4682 }
4683
4684 /// Create agenda item
4685 ///
4686 /// `POST /events/{eventId}/agenda/items`
4687 ///
4688 /// Creates one header, text or song item in an existing, unlocked agenda. Without `before_id` or `after_id`, the item is appended. The agenda is not created automatically. Positioning references must belong to the same agenda. Requires agenda editing access for the event.
4689 ///
4690 /// Use [`Self::create_with`] to pass query parameters.
4691 ///
4692 /// # Example
4693 ///
4694 /// ```
4695 /// # use churchtools_api::*;
4696 /// # use churchtools_api::queries::*;
4697 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4698 /// # let client = churchtools_api::replay::client("post-events-id-agenda-items");
4699 /// let body = serde_json::json!({
4700 /// "type": "header"
4701 /// });
4702 /// let result = client.events().agenda().items().create(42, &body)?;
4703 /// println!("{:?}", result);
4704 /// # Ok(())
4705 /// # }
4706 /// ```
4707 pub fn create(&self, event_id: impl Display, body: &serde_json::Value) -> Result<serde_json::Value> {
4708 self.create_with(event_id, &Default::default(), body)
4709 }
4710
4711 /// Create agenda item
4712 ///
4713 /// Like [`Self::create`], with query parameters.
4714 ///
4715 /// `POST /events/{eventId}/agenda/items`
4716 ///
4717 /// Creates one header, text or song item in an existing, unlocked agenda. Without `before_id` or `after_id`, the item is appended. The agenda is not created automatically. Positioning references must belong to the same agenda. Requires agenda editing access for the event.
4718 pub fn create_with(&self, event_id: impl Display, query: &PostEventsIdAgendaItemsQuery, body: &serde_json::Value) -> Result<serde_json::Value> {
4719 let path = format!("/events/{}/agenda/items", seg(event_id));
4720 let query: Query = query.to_query();
4721 let body = serde_json::to_value(body).expect("request body serializes");
4722 self.client.request_data(Method::Post, &path, &query, Some(&body))
4723 }
4724
4725 /// Delete an item from a shared agenda
4726 ///
4727 /// `DELETE /events/{eventId}/agenda/items/{itemId}`
4728 ///
4729 /// Permanently removes an item from the agenda, affecting every event sharing that agenda. The agenda must be unlocked and the item must belong to the event's agenda. Repeating the deletion returns `404` once the item no longer exists. Requires agenda editing access for the event.
4730 ///
4731 /// # Example
4732 ///
4733 /// ```no_run
4734 /// # use churchtools_api::*;
4735 /// # use churchtools_api::queries::*;
4736 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4737 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4738 /// client.events().agenda().items().delete(42, 123)?;
4739 /// # Ok(())
4740 /// # }
4741 /// ```
4742 pub fn delete(&self, event_id: impl Display, item_id: impl Display) -> Result<()> {
4743 let path = format!("/events/{}/agenda/items/{}", seg(event_id), seg(item_id));
4744 let query: Query = Query::new();
4745 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
4746 }
4747
4748 /// Hide an agenda item for one event
4749 ///
4750 /// `POST /events/{eventId}/agenda/items/{itemId}/hide`
4751 ///
4752 /// Omits an agenda item only for the event in the path. The item remains part of the shared agenda and its visibility in other integrated events is unchanged. It no longer contributes to the timing of this event. Agenda responses still contain the item: its `startTimes` entry for this event is `null`. Requires agenda editing access for the event.
4753 ///
4754 /// # Example
4755 ///
4756 /// ```no_run
4757 /// # use churchtools_api::*;
4758 /// # use churchtools_api::queries::*;
4759 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4760 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4761 /// client.events().agenda().items().hide(42, 123)?;
4762 /// # Ok(())
4763 /// # }
4764 /// ```
4765 pub fn hide(&self, event_id: impl Display, item_id: impl Display) -> Result<()> {
4766 let path = format!("/events/{}/agenda/items/{}/hide", seg(event_id), seg(item_id));
4767 let query: Query = Query::new();
4768 self.client.request(Method::Post, &path, &query, None).map(|_| ())
4769 }
4770
4771 /// Show an agenda item for one event
4772 ///
4773 /// `POST /events/{eventId}/agenda/items/{itemId}/unhide`
4774 ///
4775 /// Includes a previously hidden item in the event's agenda timing again. This only changes its visibility for the event in the path; other integrated events retain their visibility settings. The agenda must be unlocked and the item must belong to it. Showing an already visible item succeeds with `204`. Requires agenda editing access for the event.
4776 ///
4777 /// # Example
4778 ///
4779 /// ```no_run
4780 /// # use churchtools_api::*;
4781 /// # use churchtools_api::queries::*;
4782 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4783 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4784 /// client.events().agenda().items().unhide(42, 123)?;
4785 /// # Ok(())
4786 /// # }
4787 /// ```
4788 pub fn unhide(&self, event_id: impl Display, item_id: impl Display) -> Result<()> {
4789 let path = format!("/events/{}/agenda/items/{}/unhide", seg(event_id), seg(item_id));
4790 let query: Query = Query::new();
4791 self.client.request(Method::Post, &path, &query, None).map(|_| ())
4792 }
4793
4794 /// Update agenda item
4795 ///
4796 /// `PUT /events/{eventId}/agenda/items/{itemId}`
4797 ///
4798 /// Updates one item in an existing, unlocked agenda. The item must belong to the event's agenda. Without `before_id` or `after_id`, its order is preserved. To move an item, send its content fields as well: this is not a position-only PATCH. Requires agenda editing access for the event.
4799 ///
4800 /// Use [`Self::update_with`] to pass query parameters.
4801 ///
4802 /// # Example
4803 ///
4804 /// ```
4805 /// # use churchtools_api::*;
4806 /// # use churchtools_api::queries::*;
4807 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4808 /// # let client = churchtools_api::replay::client("put-events-id-agenda-items-id");
4809 /// let body = serde_json::json!({
4810 /// "type": "header"
4811 /// });
4812 /// let result = client.events().agenda().items().update(42, 123, &body)?;
4813 /// println!("{:?}", result);
4814 /// # Ok(())
4815 /// # }
4816 /// ```
4817 pub fn update(&self, event_id: impl Display, item_id: impl Display, body: &serde_json::Value) -> Result<serde_json::Value> {
4818 self.update_with(event_id, item_id, &Default::default(), body)
4819 }
4820
4821 /// Update agenda item
4822 ///
4823 /// Like [`Self::update`], with query parameters.
4824 ///
4825 /// `PUT /events/{eventId}/agenda/items/{itemId}`
4826 ///
4827 /// Updates one item in an existing, unlocked agenda. The item must belong to the event's agenda. Without `before_id` or `after_id`, its order is preserved. To move an item, send its content fields as well: this is not a position-only PATCH. Requires agenda editing access for the event.
4828 pub fn update_with(&self, event_id: impl Display, item_id: impl Display, query: &PutEventsIdAgendaItemsIdQuery, body: &serde_json::Value) -> Result<serde_json::Value> {
4829 let path = format!("/events/{}/agenda/items/{}", seg(event_id), seg(item_id));
4830 let query: Query = query.to_query();
4831 let body = serde_json::to_value(body).expect("request body serializes");
4832 self.client.request_data(Method::Put, &path, &query, Some(&body))
4833 }
4834
4835}
4836
4837/// `client.events().agenda().items().service_groups()`
4838#[derive(Clone, Copy)]
4839pub struct EventsAgendaItemsServiceGroupsResource<'a> {
4840 client: &'a Client,
4841}
4842
4843impl<'a> EventsAgendaItemsServiceGroupsResource<'a> {
4844 /// Delete service group note from agenda item
4845 ///
4846 /// `DELETE /events/{eventId}/agenda/items/{itemId}/servicegroups/{serviceGroupId}`
4847 ///
4848 /// Removes only the note for the service group in the path. If that note is already absent, the request still succeeds with `204`. Other service-group notes and item content are retained. The agenda must be unlocked and the item must belong to it. Requires agenda editing access for the event.
4849 ///
4850 /// # Example
4851 ///
4852 /// ```no_run
4853 /// # use churchtools_api::*;
4854 /// # use churchtools_api::queries::*;
4855 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4856 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4857 /// client.events().agenda().items().service_groups().delete(42, 123, 13)?;
4858 /// # Ok(())
4859 /// # }
4860 /// ```
4861 pub fn delete(&self, event_id: impl Display, item_id: impl Display, service_group_id: impl Display) -> Result<()> {
4862 let path = format!("/events/{}/agenda/items/{}/servicegroups/{}", seg(event_id), seg(item_id), seg(service_group_id));
4863 let query: Query = Query::new();
4864 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
4865 }
4866
4867 /// Add or update service group note for agenda item
4868 ///
4869 /// `PUT /events/{eventId}/agenda/items/{itemId}/servicegroups/{serviceGroupId}`
4870 ///
4871 /// Creates or replaces the note for one service group on an existing agenda item. Other service-group notes and item content are retained. Requires agenda editing access for the event.
4872 ///
4873 /// # Example
4874 ///
4875 /// ```no_run
4876 /// # use churchtools_api::*;
4877 /// # use churchtools_api::queries::*;
4878 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4879 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4880 /// let body = models::AgendaServiceGroupNoteUpdate {
4881 /// note: Some(Some("Remember to bring the sheet music".into())),
4882 /// ..Default::default()
4883 /// };
4884 /// client.events().agenda().items().service_groups().update(42, 123, 13, &body)?;
4885 /// # Ok(())
4886 /// # }
4887 /// ```
4888 pub fn update(&self, event_id: impl Display, item_id: impl Display, service_group_id: impl Display, body: &models::AgendaServiceGroupNoteUpdate) -> Result<()> {
4889 let path = format!("/events/{}/agenda/items/{}/servicegroups/{}", seg(event_id), seg(item_id), seg(service_group_id));
4890 let query: Query = Query::new();
4891 let body = serde_json::to_value(body).expect("request body serializes");
4892 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
4893 }
4894
4895}
4896
4897/// `client.events().event_services()`
4898#[derive(Clone, Copy)]
4899pub struct EventsEventServicesResource<'a> {
4900 client: &'a Client,
4901}
4902
4903impl<'a> EventsEventServicesResource<'a> {
4904 /// Decline service request
4905 ///
4906 /// `DELETE /events/{eventId}/eventservices/{serviceId}`
4907 ///
4908 /// Deprecated alias for `/events/{eventId}/servicerequests/{requestId}/decline`. The path parameter `serviceId` identifies a concrete assignment record (`requestId`), not a reusable service role. Declining invalidates the original record and returns a new unassigned record; assigned persons need `allowDecline` unless another permission grants access.
4909 ///
4910 /// # Example
4911 ///
4912 /// ```no_run
4913 /// # use churchtools_api::*;
4914 /// # use churchtools_api::queries::*;
4915 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4916 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4917 /// let body = models::ServiceRequestAnswer {
4918 /// comment: Some(Some("Hallo zusammen".into())),
4919 /// ..Default::default()
4920 /// };
4921 /// let event_service = client.events().event_services().delete(42, 42, &body)?;
4922 /// println!("{:?}", event_service.name);
4923 /// # Ok(())
4924 /// # }
4925 /// ```
4926 #[deprecated = "DELETE /events/{eventId}/eventservices/{serviceId} is deprecated in the ChurchTools API."]
4927 pub fn delete(&self, event_id: impl Display, service_id: impl Display, body: &models::ServiceRequestAnswer) -> Result<models::ServiceRequest> {
4928 let path = format!("/events/{}/eventservices/{}", seg(event_id), seg(service_id));
4929 let query: Query = Query::new();
4930 let body = serde_json::to_value(body).expect("request body serializes");
4931 self.client.request_data(Method::Delete, &path, &query, Some(&body))
4932 }
4933
4934 /// Update a service assignment
4935 ///
4936 /// `PUT /events/{eventId}/eventservices/{serviceId}`
4937 ///
4938 /// Deprecated alias for `/events/{eventId}/servicerequests/{requestId}`. The path parameter `serviceId` identifies a concrete assignment record (`requestId`), not a reusable service role. Creates a replacement assignment and invalidates the previous active record for the same event, service and slot index. Always use the returned ID for subsequent actions.
4939 ///
4940 /// # Example
4941 ///
4942 /// ```no_run
4943 /// # use churchtools_api::*;
4944 /// # use churchtools_api::queries::*;
4945 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4946 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4947 /// let body = models::ServiceRequestUpdate {
4948 /// name: Some(Some("Guest musician".into())),
4949 /// ..Default::default()
4950 /// };
4951 /// let result = client.events().event_services().update(42, 42, &body)?;
4952 /// println!("{:?}", result.name);
4953 /// # Ok(())
4954 /// # }
4955 /// ```
4956 #[deprecated = "PUT /events/{eventId}/eventservices/{serviceId} is deprecated in the ChurchTools API."]
4957 pub fn update(&self, event_id: impl Display, service_id: impl Display, body: &models::ServiceRequestUpdate) -> Result<models::ServiceRequest> {
4958 let path = format!("/events/{}/eventservices/{}", seg(event_id), seg(service_id));
4959 let query: Query = Query::new();
4960 let body = serde_json::to_value(body).expect("request body serializes");
4961 self.client.request_data(Method::Put, &path, &query, Some(&body))
4962 }
4963
4964 /// Set service slot counts for an event
4965 ///
4966 /// `PUT /events/{eventId}/eventservices`
4967 ///
4968 /// Changes the active slot count only for the listed service roles, in one transaction. Increasing a count creates unassigned slots. Decreasing it removes unassigned slots but retains occupied slots. A failed reduction returns `422` and rolls back the update; changing counts requires event administration or editing access for every affected service.
4969 ///
4970 /// # Example
4971 ///
4972 /// ```no_run
4973 /// # use churchtools_api::*;
4974 /// # use churchtools_api::queries::*;
4975 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
4976 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
4977 /// let body = models::EventServicesUpdate {
4978 /// services: vec![models::EventServiceCountUpdate {
4979 /// count: 3,
4980 /// service_id: 2,
4981 /// ..Default::default()
4982 /// }],
4983 /// ..Default::default()
4984 /// };
4985 /// client.events().event_services().update_all(42, &body)?;
4986 /// # Ok(())
4987 /// # }
4988 /// ```
4989 #[deprecated = "PUT /events/{eventId}/eventservices is deprecated in the ChurchTools API."]
4990 pub fn update_all(&self, event_id: impl Display, body: &models::EventServicesUpdate) -> Result<()> {
4991 let path = format!("/events/{}/eventservices", seg(event_id));
4992 let query: Query = Query::new();
4993 let body = serde_json::to_value(body).expect("request body serializes");
4994 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
4995 }
4996
4997}
4998
4999/// `client.events().facts()`
5000#[derive(Clone, Copy)]
5001pub struct EventsFactsResource<'a> {
5002 client: &'a Client,
5003}
5004
5005impl<'a> EventsFactsResource<'a> {
5006 /// Delete a recorded event fact
5007 ///
5008 /// `DELETE /events/{eventId}/facts/{factId}`
5009 ///
5010 /// Removes the stored value for this event and fact definition, preserving the reusable definition and the event. Requires access to the event and edit permission for the fact definition. Returns `204` even if no value was stored for the pair.
5011 ///
5012 /// # Example
5013 ///
5014 /// ```no_run
5015 /// # use churchtools_api::*;
5016 /// # use churchtools_api::queries::*;
5017 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5018 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5019 /// client.events().facts().delete(42, 1)?;
5020 /// # Ok(())
5021 /// # }
5022 /// ```
5023 pub fn delete(&self, event_id: impl Display, fact_id: impl Display) -> Result<()> {
5024 let path = format!("/events/{}/facts/{}", seg(event_id), seg(fact_id));
5025 let query: Query = Query::new();
5026 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
5027 }
5028
5029 /// Export event facts as a spreadsheet
5030 ///
5031 /// `POST /events/facts/export`
5032 ///
5033 /// Downloads a CSV or XLSX file with one row per visible service-planning event in the selected calendars, including events without recorded fact values. Requires permission to export facts (the "export facts" permission for the service planning domain). Events are filtered by event visibility, and fact columns are limited to definitions the user may view or edit. Rows are ordered by event start time, then event ID.
5034 ///
5035 /// Use [`Self::export_with`] to pass query parameters.
5036 ///
5037 /// # Example
5038 ///
5039 /// ```no_run
5040 /// # use churchtools_api::*;
5041 /// # use churchtools_api::queries::*;
5042 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5043 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5044 /// let body = models::EventFactExportCreate {
5045 /// calendar_ids: vec![42],
5046 /// ..Default::default()
5047 /// };
5048 /// let data = client.events().facts().export(&body)?;
5049 /// std::fs::write("ergebnis.xlsx", &data)?;
5050 /// # Ok(())
5051 /// # }
5052 /// ```
5053 pub fn export(&self, body: &models::EventFactExportCreate) -> Result<Vec<u8>> {
5054 self.export_with(&Default::default(), body)
5055 }
5056
5057 /// Export event facts as a spreadsheet
5058 ///
5059 /// Like [`Self::export`], with query parameters.
5060 ///
5061 /// `POST /events/facts/export`
5062 ///
5063 /// Downloads a CSV or XLSX file with one row per visible service-planning event in the selected calendars, including events without recorded fact values. Requires permission to export facts (the "export facts" permission for the service planning domain). Events are filtered by event visibility, and fact columns are limited to definitions the user may view or edit. Rows are ordered by event start time, then event ID.
5064 pub fn export_with(&self, query: &PostEventsFactsExportQuery, body: &models::EventFactExportCreate) -> Result<Vec<u8>> {
5065 let path = "/events/facts/export".to_owned();
5066 let query: Query = query.to_query();
5067 let body = serde_json::to_value(body).expect("request body serializes");
5068 self.client.request(Method::Post, &path, &query, Some(&body))
5069 }
5070
5071 /// Get a recorded event fact
5072 ///
5073 /// `GET /events/{eventId}/facts/{factId}`
5074 ///
5075 /// Returns the stored value for the event and fact definition identified by the path. Requires access to the event and view or edit permission for the fact definition. Returns `404` when no value has been recorded for this pair; this is distinct from a recorded numeric zero.
5076 ///
5077 /// # Example
5078 ///
5079 /// ```
5080 /// # use churchtools_api::*;
5081 /// # use churchtools_api::queries::*;
5082 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5083 /// # let client = churchtools_api::replay::client("get-events-eventId-facts-factId");
5084 /// let fact = client.events().facts().get(42, 1)?;
5085 /// println!("{}", fact.deprecated);
5086 /// # Ok(())
5087 /// # }
5088 /// ```
5089 pub fn get(&self, event_id: impl Display, fact_id: impl Display) -> Result<models::EventFact> {
5090 let path = format!("/events/{}/facts/{}", seg(event_id), seg(fact_id));
5091 let query: Query = Query::new();
5092 self.client.request_data(Method::Get, &path, &query, None)
5093 }
5094
5095 /// List recorded facts for an event
5096 ///
5097 /// `GET /events/{eventId}/facts`
5098 ///
5099 /// Returns the event's stored fact values whose definitions the user may view or edit. `eventId` identifies the service-planning event, while `factId` identifies a reusable definition from `/facts`. Requires access to the event and at least one fact definition.
5100 ///
5101 /// # Example
5102 ///
5103 /// ```
5104 /// # use churchtools_api::*;
5105 /// # use churchtools_api::queries::*;
5106 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5107 /// # let client = churchtools_api::replay::client("get-events-eventId-facts");
5108 /// for fact in client.events().facts().list(42)? {
5109 /// println!("{}", fact.deprecated);
5110 /// }
5111 /// # Ok(())
5112 /// # }
5113 /// ```
5114 pub fn list(&self, event_id: impl Display) -> Result<Vec<models::EventFact>> {
5115 let path = format!("/events/{}/facts", seg(event_id));
5116 let query: Query = Query::new();
5117 self.client.request_data(Method::Get, &path, &query, None)
5118 }
5119
5120 /// List recorded event facts
5121 ///
5122 /// `GET /events/facts`
5123 ///
5124 /// A fact definition describes a metric or selection (for example attendance or service type). An event fact stores one value for that definition on a service-planning event. `eventId` identifies the event, not its calendar appointment; `factId` identifies the reusable definition from /facts. Returns recorded values ordered by event start date descending, with pagination.
5125 ///
5126 /// Use [`Self::list_all_with`] to pass query parameters.
5127 ///
5128 /// # Example
5129 ///
5130 /// ```
5131 /// # use churchtools_api::*;
5132 /// # use churchtools_api::queries::*;
5133 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5134 /// # let client = churchtools_api::replay::client("get-events-facts");
5135 /// for all in client.events().facts().list_all()? {
5136 /// println!("{}", all.deprecated);
5137 /// }
5138 /// # Ok(())
5139 /// # }
5140 /// ```
5141 pub fn list_all(&self) -> Result<Vec<models::EventFact>> {
5142 self.list_all_with(&Default::default())
5143 }
5144
5145 /// List recorded event facts
5146 ///
5147 /// Like [`Self::list_all`], with query parameters.
5148 ///
5149 /// `GET /events/facts`
5150 ///
5151 /// A fact definition describes a metric or selection (for example attendance or service type). An event fact stores one value for that definition on a service-planning event. `eventId` identifies the event, not its calendar appointment; `factId` identifies the reusable definition from /facts. Returns recorded values ordered by event start date descending, with pagination.
5152 pub fn list_all_with(&self, query: &GetEventsFactsQuery) -> Result<Vec<models::EventFact>> {
5153 let path = "/events/facts".to_owned();
5154 let query: Query = query.to_query();
5155 self.client.collect_pages(&path, query)
5156 }
5157
5158 /// List recorded event facts
5159 ///
5160 /// Like [`Self::list_all_with`], but lazy: each page is fetched only when the iteration reaches it.
5161 /// Breaking off early saves the remaining requests.
5162 pub fn list_all_iter(&self, query: &GetEventsFactsQuery) -> Items<models::EventFact> {
5163 let path = "/events/facts".to_owned();
5164 self.client.items(&path, query.to_query())
5165 }
5166
5167 /// Create or replace an event fact
5168 ///
5169 /// `PUT /events/{eventId}/facts/{factId}`
5170 ///
5171 /// Stores one value for the event and fact definition identified by the path. Returns `200` for both insertion and replacement. Requires access to the event and edit permission for the fact definition. Numeric facts accept JSON numbers or numeric strings and return a JSON number; select facts accept an option configured in the definition.
5172 ///
5173 /// # Example
5174 ///
5175 /// ```no_run
5176 /// # use churchtools_api::*;
5177 /// # use churchtools_api::queries::*;
5178 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5179 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5180 /// let body = models::EventFactUpdate {
5181 /// value: serde_json::json!(1.5),
5182 /// ..Default::default()
5183 /// };
5184 /// let result = client.events().facts().update(42, 1, &body)?;
5185 /// println!("{}", result.deprecated);
5186 /// # Ok(())
5187 /// # }
5188 /// ```
5189 pub fn update(&self, event_id: impl Display, fact_id: impl Display, body: &models::EventFactUpdate) -> Result<models::EventFact> {
5190 let path = format!("/events/{}/facts/{}", seg(event_id), seg(fact_id));
5191 let query: Query = Query::new();
5192 let body = serde_json::to_value(body).expect("request body serializes");
5193 self.client.request_data(Method::Put, &path, &query, Some(&body))
5194 }
5195
5196}
5197
5198/// `client.events().service_requests()`
5199#[derive(Clone, Copy)]
5200pub struct EventsServiceRequestsResource<'a> {
5201 client: &'a Client,
5202}
5203
5204impl<'a> EventsServiceRequestsResource<'a> {
5205 /// Accept service request
5206 ///
5207 /// `POST /events/{eventId}/servicerequests/{requestId}/accept`
5208 ///
5209 /// Accepts an assigned, valid service request. On first acceptance it creates a new confirmed record, invalidates previous records for the slot, adjusts related exchange requests and sends notifications. A comment is stored on first acceptance only if the service allows comments on confirmation. If already accepted, the same record is returned and its comment is updated. Requires permission to update the assignment.
5210 ///
5211 /// # Example
5212 ///
5213 /// ```no_run
5214 /// # use churchtools_api::*;
5215 /// # use churchtools_api::queries::*;
5216 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5217 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5218 /// let body = models::ServiceRequestAnswer {
5219 /// comment: Some(Some("Hallo zusammen".into())),
5220 /// ..Default::default()
5221 /// };
5222 /// let service_request = client.events().service_requests().accept(42, 42, &body)?;
5223 /// println!("{:?}", service_request.name);
5224 /// # Ok(())
5225 /// # }
5226 /// ```
5227 pub fn accept(&self, event_id: impl Display, request_id: impl Display, body: &models::ServiceRequestAnswer) -> Result<models::ServiceRequest> {
5228 let path = format!("/events/{}/servicerequests/{}/accept", seg(event_id), seg(request_id));
5229 let query: Query = Query::new();
5230 let body = serde_json::to_value(body).expect("request body serializes");
5231 self.client.request_data(Method::Post, &path, &query, Some(&body))
5232 }
5233
5234 /// Decline service request
5235 ///
5236 /// `POST /events/{eventId}/servicerequests/{requestId}/decline`
5237 ///
5238 /// Declines the current assignment, invalidates its `requestId` and returns a new unassigned record. Related exchange requests are deleted and notifications are sent. Assigned persons need `allowDecline` unless another permission grants access.
5239 ///
5240 /// # Example
5241 ///
5242 /// ```no_run
5243 /// # use churchtools_api::*;
5244 /// # use churchtools_api::queries::*;
5245 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5246 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5247 /// let body = models::ServiceRequestAnswer {
5248 /// comment: Some(Some("Hallo zusammen".into())),
5249 /// ..Default::default()
5250 /// };
5251 /// let service_request = client.events().service_requests().decline(42, 42, &body)?;
5252 /// println!("{:?}", service_request.name);
5253 /// # Ok(())
5254 /// # }
5255 /// ```
5256 pub fn decline(&self, event_id: impl Display, request_id: impl Display, body: &models::ServiceRequestAnswer) -> Result<models::ServiceRequest> {
5257 let path = format!("/events/{}/servicerequests/{}/decline", seg(event_id), seg(request_id));
5258 let query: Query = Query::new();
5259 let body = serde_json::to_value(body).expect("request body serializes");
5260 self.client.request_data(Method::Post, &path, &query, Some(&body))
5261 }
5262
5263 /// Undo service request
5264 ///
5265 /// `POST /events/{eventId}/servicerequests/{requestId}/undo`
5266 ///
5267 /// Reverts the last acceptance or decline to an outstanding request. Only the assigned person may do this. The legacy history must identify this as the last action and its timestamp must be within the 10-minute undo window; otherwise `400` is returned. For a decline, use the original declined request ID, not the new unassigned record returned by the decline operation.
5268 ///
5269 /// # Example
5270 ///
5271 /// ```no_run
5272 /// # use churchtools_api::*;
5273 /// # use churchtools_api::queries::*;
5274 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5275 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5276 /// let body = models::ServiceRequestUndoCreate {
5277 /// person_id: 42,
5278 /// ..Default::default()
5279 /// };
5280 /// let service_request = client.events().service_requests().undo(42, 42, &body)?;
5281 /// println!("{:?}", service_request.name);
5282 /// # Ok(())
5283 /// # }
5284 /// ```
5285 pub fn undo(&self, event_id: impl Display, request_id: impl Display, body: &models::ServiceRequestUndoCreate) -> Result<models::ServiceRequestUndoResult> {
5286 let path = format!("/events/{}/servicerequests/{}/undo", seg(event_id), seg(request_id));
5287 let query: Query = Query::new();
5288 let body = serde_json::to_value(body).expect("request body serializes");
5289 self.client.request_data(Method::Post, &path, &query, Some(&body))
5290 }
5291
5292 /// Update a service assignment
5293 ///
5294 /// `PUT /events/{eventId}/servicerequests/{requestId}`
5295 ///
5296 /// Creates a replacement assignment and invalidates the previous active record for the same event, service and slot index. Always use the returned ID for subsequent actions. `isAccepted`=`true` confirms it; `false` leaves it awaiting confirmation and does not decline it. Notifications follow the assignment workflow.
5297 ///
5298 /// # Example
5299 ///
5300 /// ```no_run
5301 /// # use churchtools_api::*;
5302 /// # use churchtools_api::queries::*;
5303 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5304 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5305 /// let body = models::ServiceRequestUpdate {
5306 /// name: Some(Some("Guest musician".into())),
5307 /// ..Default::default()
5308 /// };
5309 /// let result = client.events().service_requests().update(42, 42, &body)?;
5310 /// println!("{:?}", result.name);
5311 /// # Ok(())
5312 /// # }
5313 /// ```
5314 pub fn update(&self, event_id: impl Display, request_id: impl Display, body: &models::ServiceRequestUpdate) -> Result<models::ServiceRequest> {
5315 let path = format!("/events/{}/servicerequests/{}", seg(event_id), seg(request_id));
5316 let query: Query = Query::new();
5317 let body = serde_json::to_value(body).expect("request body serializes");
5318 self.client.request_data(Method::Put, &path, &query, Some(&body))
5319 }
5320
5321 /// Set service slot counts for an event
5322 ///
5323 /// `PUT /events/{eventId}/servicerequests`
5324 ///
5325 /// Changes the active slot count only for the listed service roles, in one transaction. Increasing a count creates unassigned slots. Decreasing it removes unassigned slots but retains occupied slots. A failed reduction returns `422` and rolls back the update; changing counts requires event administration or editing access for every affected service.
5326 ///
5327 /// # Example
5328 ///
5329 /// ```no_run
5330 /// # use churchtools_api::*;
5331 /// # use churchtools_api::queries::*;
5332 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5333 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5334 /// let body = models::EventServicesUpdate {
5335 /// services: vec![models::EventServiceCountUpdate {
5336 /// count: 3,
5337 /// service_id: 2,
5338 /// ..Default::default()
5339 /// }],
5340 /// ..Default::default()
5341 /// };
5342 /// client.events().service_requests().update_all(42, &body)?;
5343 /// # Ok(())
5344 /// # }
5345 /// ```
5346 pub fn update_all(&self, event_id: impl Display, body: &models::EventServicesUpdate) -> Result<()> {
5347 let path = format!("/events/{}/servicerequests", seg(event_id));
5348 let query: Query = Query::new();
5349 let body = serde_json::to_value(body).expect("request body serializes");
5350 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
5351 }
5352
5353}
5354
5355/// `client.events().services()`
5356#[derive(Clone, Copy)]
5357pub struct EventsServicesResource<'a> {
5358 client: &'a Client,
5359}
5360
5361impl<'a> EventsServicesResource<'a> {
5362 /// Get service candidates with planning hints
5363 ///
5364 /// `GET /events/{eventId}/services/{serviceId}/possiblepersons`
5365 ///
5366 /// Returns an unpaginated list of persons from active, visible-role memberships in groups connected to this reusable service role, narrowed by connected tags when present. Archived or deceased persons are excluded and hidden-person visibility is respected. Without permission to assign other persons, only the current user can appear. With no connected groups the list is empty.
5367 ///
5368 /// # Example
5369 ///
5370 /// ```
5371 /// # use churchtools_api::*;
5372 /// # use churchtools_api::queries::*;
5373 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5374 /// # let client = churchtools_api::replay::client("get-events-eventId-services-serviceId-possiblepersons");
5375 /// for possible_person in client.events().services().list_possible_persons(42, 2)? {
5376 /// println!("{}", possible_person.partner_services);
5377 /// }
5378 /// # Ok(())
5379 /// # }
5380 /// ```
5381 pub fn list_possible_persons(&self, event_id: impl Display, service_id: impl Display) -> Result<Vec<models::PossibleEventPerson>> {
5382 let path = format!("/events/{}/services/{}/possiblepersons", seg(event_id), seg(service_id));
5383 let query: Query = Query::new();
5384 self.client.request_data(Method::Get, &path, &query, None)
5385 }
5386
5387}
5388
5389/// `client.external_logins()`
5390#[derive(Clone, Copy)]
5391pub struct ExternalLoginsResource<'a> {
5392 client: &'a Client,
5393}
5394
5395impl<'a> ExternalLoginsResource<'a> {
5396 pub fn link(&self) -> ExternalLoginsLinkResource<'a> {
5397 ExternalLoginsLinkResource { client: self.client }
5398 }
5399
5400 pub fn oidc(&self) -> ExternalLoginsOidcResource<'a> {
5401 ExternalLoginsOidcResource { client: self.client }
5402 }
5403
5404 pub fn saml(&self) -> ExternalLoginsSamlResource<'a> {
5405 ExternalLoginsSamlResource { client: self.client }
5406 }
5407
5408 /// Create an external login provider
5409 ///
5410 /// `POST /externallogins`
5411 ///
5412 /// Creates an OAuth, OpenID Connect or SAML provider configuration. Requires "churchcore administer settings" permission; SAML additionally requires the SAML settings feature flag. Logo discovery may contact the provider while saving. Only one provider can be primary.
5413 ///
5414 /// # Example
5415 ///
5416 /// ```no_run
5417 /// # use churchtools_api::*;
5418 /// # use churchtools_api::queries::*;
5419 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5420 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5421 /// let body = models::ExternalLoginCreate {
5422 /// config: serde_json::json!({"accessTokenUrl": "https://identity.example.org/accessTokenUrl", "authorizeUrl": "https://identity.example.org/authorizeUrl", "clientId": "churchtools", "urlResourceOwnerDetails": "https://identity.example.org/urlResourceOwnerDetails"}),
5423 /// create_new_person: true,
5424 /// has_registration: true,
5425 /// name: "Organization login".into(),
5426 /// new_person_campus_id: Some(42),
5427 /// new_person_department_id: Some(42),
5428 /// new_person_status_id: Some(42),
5429 /// r#type: "oauth".into(),
5430 /// update_data_on_login: true,
5431 /// ..Default::default()
5432 /// };
5433 /// let result = client.external_logins().create(&body)?;
5434 /// println!("{}", result.name);
5435 /// # Ok(())
5436 /// # }
5437 /// ```
5438 pub fn create(&self, body: &models::ExternalLoginCreate) -> Result<models::ExternalLogin> {
5439 let path = "/externallogins".to_owned();
5440 let query: Query = Query::new();
5441 let body = serde_json::to_value(body).expect("request body serializes");
5442 self.client.request_data(Method::Post, &path, &query, Some(&body))
5443 }
5444
5445 /// Delete an external login provider
5446 ///
5447 /// `DELETE /externallogins/{externalLoginId}`
5448 ///
5449 /// Deletes the provider configuration and its stored person-identity mappings. Requires "churchcore administer settings" permission; deleting a SAML provider also requires the SAML settings feature flag. ChurchTools persons and sessions at the external provider remain.
5450 ///
5451 /// # Example
5452 ///
5453 /// ```no_run
5454 /// # use churchtools_api::*;
5455 /// # use churchtools_api::queries::*;
5456 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5457 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5458 /// client.external_logins().delete(7)?;
5459 /// # Ok(())
5460 /// # }
5461 /// ```
5462 pub fn delete(&self, external_login_id: impl Display) -> Result<()> {
5463 let path = format!("/externallogins/{}", seg(external_login_id));
5464 let query: Query = Query::new();
5465 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
5466 }
5467
5468 /// Get an external login provider
5469 ///
5470 /// `GET /externallogins/{externalLoginId}`
5471 ///
5472 /// Returns one provider configuration. Requires "churchcore administer settings" permission. Hidden providers remain accessible. Client secrets and SAML SP private keys are not included.
5473 ///
5474 /// # Example
5475 ///
5476 /// ```
5477 /// # use churchtools_api::*;
5478 /// # use churchtools_api::queries::*;
5479 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5480 /// # let client = churchtools_api::replay::client("get-externallogins-id");
5481 /// let external_login = client.external_logins().get(7)?;
5482 /// println!("{}", external_login.name);
5483 /// # Ok(())
5484 /// # }
5485 /// ```
5486 pub fn get(&self, external_login_id: impl Display) -> Result<models::ExternalLogin> {
5487 let path = format!("/externallogins/{}", seg(external_login_id));
5488 let query: Query = Query::new();
5489 self.client.request_data(Method::Get, &path, &query, None)
5490 }
5491
5492 /// List external login providers
5493 ///
5494 /// `GET /externallogins`
5495 ///
5496 /// Returns all external login provider configurations, including hidden providers. Requires "churchcore administer settings" permission. Client secrets and SAML SP private keys are not included.
5497 ///
5498 /// # Example
5499 ///
5500 /// ```
5501 /// # use churchtools_api::*;
5502 /// # use churchtools_api::queries::*;
5503 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5504 /// # let client = churchtools_api::replay::client("get-externallogins");
5505 /// for external_login in client.external_logins().list()? {
5506 /// println!("{}", external_login.name);
5507 /// }
5508 /// # Ok(())
5509 /// # }
5510 /// ```
5511 pub fn list(&self) -> Result<Vec<models::ExternalLogin>> {
5512 let path = "/externallogins".to_owned();
5513 let query: Query = Query::new();
5514 self.client.request_data(Method::Get, &path, &query, None)
5515 }
5516
5517 /// Update an external login provider
5518 ///
5519 /// `PUT /externallogins/{externalLoginId}`
5520 ///
5521 /// Updates an existing provider. Requires "churchcore administer settings" permission; SAML changes additionally require the SAML settings feature flag. The protocol cannot be changed. Logo discovery is repeated, and setting `primaryLogin` does not demote another primary provider.
5522 ///
5523 /// # Example
5524 ///
5525 /// ```no_run
5526 /// # use churchtools_api::*;
5527 /// # use churchtools_api::queries::*;
5528 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5529 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5530 /// let body = models::ExternalLoginUpdate {
5531 /// config: serde_json::json!({"accessTokenUrl": "https://identity.example.org/accessTokenUrl", "authorizeUrl": "https://identity.example.org/authorizeUrl", "clientId": "churchtools", "urlResourceOwnerDetails": "https://identity.example.org/urlResourceOwnerDetails"}),
5532 /// create_new_person: true,
5533 /// has_registration: true,
5534 /// name: "Nextcloud".into(),
5535 /// new_person_campus_id: Some(42),
5536 /// new_person_department_id: Some(42),
5537 /// new_person_status_id: Some(42),
5538 /// r#type: "oauth".into(),
5539 /// update_data_on_login: true,
5540 /// ..Default::default()
5541 /// };
5542 /// let result = client.external_logins().update(7, &body)?;
5543 /// println!("{}", result.name);
5544 /// # Ok(())
5545 /// # }
5546 /// ```
5547 pub fn update(&self, external_login_id: impl Display, body: &models::ExternalLoginUpdate) -> Result<models::ExternalLogin> {
5548 let path = format!("/externallogins/{}", seg(external_login_id));
5549 let query: Query = Query::new();
5550 let body = serde_json::to_value(body).expect("request body serializes");
5551 self.client.request_data(Method::Put, &path, &query, Some(&body))
5552 }
5553
5554}
5555
5556/// `client.external_logins().link()`
5557#[derive(Clone, Copy)]
5558pub struct ExternalLoginsLinkResource<'a> {
5559 client: &'a Client,
5560}
5561
5562impl<'a> ExternalLoginsLinkResource<'a> {
5563 /// Verify and link an external identity
5564 ///
5565 /// `POST /externallogins/{externalLoginId}/link`
5566 ///
5567 /// Completes the verified_user_linking flow after a successful external identity-provider callback requested proof of a ChurchTools account. Requires the same browser session and pending linkToken, a visible provider in verified_user_linking mode, and valid credentials for an active, non-archived person. Tokens expire after 600 seconds; only ten pending links are retained per session. Each attempt clears any previous pending two-factor session. If the account uses two-factor authentication, no identity is linked yet: data.location points to the two-factor screen and POST /login/totp completes linking after verification. Otherwise the external identity is linked and the ChurchTools session is logged in. Navigate to data.location; this endpoint returns JSON rather than an HTTP redirect. The token is consumed after successful login. Credential failures can increment the account’s failed-login counter; the shared login rate limit also applies.
5568 ///
5569 /// # Example
5570 ///
5571 /// ```no_run
5572 /// # use churchtools_api::*;
5573 /// # use churchtools_api::queries::*;
5574 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5575 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5576 /// let body = models::ExternalLoginLinkCreate {
5577 /// link_token: "opaque-session-bound-link-token".into(),
5578 /// password: "geheim".into(),
5579 /// username: "alex@example.org".into(),
5580 /// ..Default::default()
5581 /// };
5582 /// let result = client.external_logins().link().create(7, &body)?;
5583 /// println!("{}", result.location);
5584 /// # Ok(())
5585 /// # }
5586 /// ```
5587 pub fn create(&self, external_login_id: impl Display, body: &models::ExternalLoginLinkCreate) -> Result<models::ExternalLoginLinkResult> {
5588 let path = format!("/externallogins/{}/link", seg(external_login_id));
5589 let query: Query = Query::new();
5590 let body = serde_json::to_value(body).expect("request body serializes");
5591 self.client.request_data(Method::Post, &path, &query, Some(&body))
5592 }
5593
5594 /// Create a person for an external identity
5595 ///
5596 /// `POST /externallogins/{externalLoginId}/link/create-person`
5597 ///
5598 /// Creates a ChurchTools person from a pending verified external identity, links it and establishes the ChurchTools login session. Requires the same browser session and unexpired linkToken, a visible provider in verified_user_linking mode and createNewPerson enabled. Tokens expire after 600 seconds and are consumed after successful login. The external identity must not already be mapped. Person name, email and username come from the saved provider identity; department, campus and status come from the provider configuration. A nonblank last name is required by person creation. Returns JSON data.location for the client to navigate to. Person creation/mapping commit before session login, so a later completion error does not guarantee that no person was created.
5599 ///
5600 /// # Example
5601 ///
5602 /// ```no_run
5603 /// # use churchtools_api::*;
5604 /// # use churchtools_api::queries::*;
5605 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5606 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5607 /// let body = models::ExternalLoginPersonCreate {
5608 /// link_token: "opaque-session-bound-link-token".into(),
5609 /// ..Default::default()
5610 /// };
5611 /// let result = client.external_logins().link().create_person(7, &body)?;
5612 /// println!("{}", result.location);
5613 /// # Ok(())
5614 /// # }
5615 /// ```
5616 pub fn create_person(&self, external_login_id: impl Display, body: &models::ExternalLoginPersonCreate) -> Result<models::ExternalLoginLinkResult> {
5617 let path = format!("/externallogins/{}/link/create-person", seg(external_login_id));
5618 let query: Query = Query::new();
5619 let body = serde_json::to_value(body).expect("request body serializes");
5620 self.client.request_data(Method::Post, &path, &query, Some(&body))
5621 }
5622
5623}
5624
5625/// `client.external_logins().oidc()`
5626#[derive(Clone, Copy)]
5627pub struct ExternalLoginsOidcResource<'a> {
5628 client: &'a Client,
5629}
5630
5631impl<'a> ExternalLoginsOidcResource<'a> {
5632 pub fn test(&self) -> ExternalLoginsOidcTestResource<'a> {
5633 ExternalLoginsOidcTestResource { client: self.client }
5634 }
5635
5636 /// Receive an OIDC back-channel logout
5637 ///
5638 /// `POST /externallogins/oidc/backchannel-logout`
5639 ///
5640 /// Accepts an OIDC Back-Channel Logout token signed by a configured provider. No browser session, CSRF token or API authentication is required. Issuer, audience, signature, lifetime, event and session/subject claims are checked. Matching local OIDC sessions are rejected on their next request. Repeated valid tokens and tokens without a matching local session succeed. Local password sessions remain unaffected. Responses have Cache-Control: no-store.
5641 ///
5642 /// # Example
5643 ///
5644 /// ```no_run
5645 /// # use churchtools_api::*;
5646 /// # use churchtools_api::queries::*;
5647 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5648 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5649 /// client.external_logins().oidc().backchannel_logout()?;
5650 /// # Ok(())
5651 /// # }
5652 /// ```
5653 pub fn backchannel_logout(&self) -> Result<()> {
5654 let path = "/externallogins/oidc/backchannel-logout".to_owned();
5655 let query: Query = Query::new();
5656 self.client.request(Method::Post, &path, &query, None).map(|_| ())
5657 }
5658
5659 /// Complete OIDC login through the stable callback
5660 ///
5661 /// `GET /externallogins/oidc/callback`
5662 ///
5663 /// Browser callback for OIDC Authorization Code login. The state resolves the provider from a pending flow in the same session; no provider ID is needed in this URL. State is consumed once before code exchange and expires after 600 seconds. The server validates the ID token, nonce and configured claim policies, then applies the provider’s person-matching mode. Success redirects to the stored safe local target; verified-user-linking mode can instead redirect to the local account-linking screen. A local matching/login failure can return an HTML 401 page, while protocol/state failures use plain-text 401 with a diagnostic ID. For administrator test flows, it records sanitized diagnostics and returns an HTML popup-completion page without creating/linking/logging in a person; the page itself does not indicate whether the test succeeded. Inspect the test-result endpoint.
5664 ///
5665 /// # Example
5666 ///
5667 /// ```no_run
5668 /// # use churchtools_api::*;
5669 /// # use churchtools_api::queries::*;
5670 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5671 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5672 /// let query = GetExternalloginsOidcCallbackQuery {
5673 /// state: Some("opaque-session-bound-state".into()),
5674 /// ..Default::default()
5675 /// };
5676 /// let data = client.external_logins().oidc().callback(&query)?;
5677 /// std::fs::write("ergebnis.bin", &data)?;
5678 /// # Ok(())
5679 /// # }
5680 /// ```
5681 pub fn callback(&self, query: &GetExternalloginsOidcCallbackQuery) -> Result<Vec<u8>> {
5682 let path = "/externallogins/oidc/callback".to_owned();
5683 let query: Query = query.to_query();
5684 self.client.request(Method::Get, &path, &query, None)
5685 }
5686
5687 /// Complete OIDC login
5688 ///
5689 /// `GET /externallogins/{externalLoginId}/oidc/callback`
5690 ///
5691 /// Compatibility callback containing a provider ID. New flows use /api/externallogins/oidc/callback. The route ID must match the provider recorded for the state. Browser callback for OIDC Authorization Code login. The state resolves the provider from a pending flow in the same session; no provider ID is needed in this URL. State is consumed once before code exchange and expires after 600 seconds. The server validates the ID token, nonce and configured claim policies, then applies the provider’s person-matching mode. Success redirects to the stored safe local target; verified-user-linking mode can instead redirect to the local account-linking screen. A local matching/login failure can return an HTML 401 page, while protocol/state failures use plain-text 401 with a diagnostic ID. For administrator test flows, it records sanitized diagnostics and returns an HTML popup-completion page without creating/linking/logging in a person; the page itself does not indicate whether the test succeeded. Inspect the test-result endpoint.
5692 ///
5693 /// # Example
5694 ///
5695 /// ```no_run
5696 /// # use churchtools_api::*;
5697 /// # use churchtools_api::queries::*;
5698 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5699 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5700 /// let query = GetExternalloginsIdOidcCallbackQuery {
5701 /// state: Some("opaque-session-bound-state".into()),
5702 /// ..Default::default()
5703 /// };
5704 /// let data = client.external_logins().oidc().callback_for(7, &query)?;
5705 /// std::fs::write("ergebnis.bin", &data)?;
5706 /// # Ok(())
5707 /// # }
5708 /// ```
5709 pub fn callback_for(&self, external_login_id: impl Display, query: &GetExternalloginsIdOidcCallbackQuery) -> Result<Vec<u8>> {
5710 let path = format!("/externallogins/{}/oidc/callback", seg(external_login_id));
5711 let query: Query = query.to_query();
5712 self.client.request(Method::Get, &path, &query, None)
5713 }
5714
5715 /// Start a browser-based OpenID Connect login
5716 ///
5717 /// `GET /externallogins/{externalLoginId}/oidc/start`
5718 ///
5719 /// Starts Authorization Code login for a visible OIDC provider using S256 PKCE, state and nonce. No existing ChurchTools login token is required. The pending flow is bound to the current browser session for 600 seconds; keep its cookie through the provider redirect and callback. At most ten pending OIDC authorizations/tests are retained per session, with older entries evicted. The configured issuer is discovered before returning the authorization URL. New flows use the stable /api/externallogins/oidc/callback URL. If the Accept header contains application/json, returns authorization details as JSON; otherwise redirects to the provider. Missing, hidden, wrong-type or unusable providers all use the same 404 text response.
5720 ///
5721 /// Use [`Self::get_start_with`] to pass query parameters.
5722 ///
5723 /// # Example
5724 ///
5725 /// ```no_run
5726 /// # use churchtools_api::*;
5727 /// # use churchtools_api::queries::*;
5728 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5729 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5730 /// let start = client.external_logins().oidc().get_start(7)?;
5731 /// println!("{}", start.expires_at);
5732 /// # Ok(())
5733 /// # }
5734 /// ```
5735 pub fn get_start(&self, external_login_id: impl Display) -> Result<models::ExternalLoginAuthorizationStart> {
5736 self.get_start_with(external_login_id, &Default::default())
5737 }
5738
5739 /// Start a browser-based OpenID Connect login
5740 ///
5741 /// Like [`Self::get_start`], with query parameters.
5742 ///
5743 /// `GET /externallogins/{externalLoginId}/oidc/start`
5744 ///
5745 /// Starts Authorization Code login for a visible OIDC provider using S256 PKCE, state and nonce. No existing ChurchTools login token is required. The pending flow is bound to the current browser session for 600 seconds; keep its cookie through the provider redirect and callback. At most ten pending OIDC authorizations/tests are retained per session, with older entries evicted. The configured issuer is discovered before returning the authorization URL. New flows use the stable /api/externallogins/oidc/callback URL. If the Accept header contains application/json, returns authorization details as JSON; otherwise redirects to the provider. Missing, hidden, wrong-type or unusable providers all use the same 404 text response.
5746 pub fn get_start_with(&self, external_login_id: impl Display, query: &GetExternalloginsIdOidcStartQuery) -> Result<models::ExternalLoginAuthorizationStart> {
5747 let path = format!("/externallogins/{}/oidc/start", seg(external_login_id));
5748 let query: Query = query.to_query();
5749 self.client.request_data(Method::Get, &path, &query, None)
5750 }
5751
5752}
5753
5754/// `client.external_logins().oidc().test()`
5755#[derive(Clone, Copy)]
5756pub struct ExternalLoginsOidcTestResource<'a> {
5757 client: &'a Client,
5758}
5759
5760impl<'a> ExternalLoginsOidcTestResource<'a> {
5761 /// Start OIDC login test
5762 ///
5763 /// `POST /externallogins/{externalLoginId}/oidc/test`
5764 ///
5765 /// Starts an OIDC Authorization Code test using the stored provider configuration. Requires "churchcore administer settings" permission. Hidden OIDC providers can be tested. Returns a URL to open in the same browser session and an opaque state for polling; preserve the session cookie through the provider callback. The pending flow expires after 600 seconds and shares the session limit of ten pending authorizations. This performs issuer discovery and token validation but does not create or link a person or establish a new ChurchTools login. Errors during authorization preparation are returned as data.status=error with HTTP 200; provider lookup errors occur before that conversion.
5766 ///
5767 /// # Example
5768 ///
5769 /// ```no_run
5770 /// # use churchtools_api::*;
5771 /// # use churchtools_api::queries::*;
5772 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5773 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5774 /// let result = client.external_logins().oidc().test().create(7)?;
5775 /// println!("{:?}", result);
5776 /// # Ok(())
5777 /// # }
5778 /// ```
5779 pub fn create(&self, external_login_id: impl Display) -> Result<serde_json::Value> {
5780 let path = format!("/externallogins/{}/oidc/test", seg(external_login_id));
5781 let query: Query = Query::new();
5782 self.client.request_data(Method::Post, &path, &query, None)
5783 }
5784
5785 /// Get OIDC login test result
5786 ///
5787 /// `GET /externallogins/{externalLoginId}/oidc/test/{state}`
5788 ///
5789 /// Polls an OIDC test started by the current administrator for this provider in the same browser session. Requires "churchcore administer settings" permission and an existing OIDC provider; hidden providers are allowed. Returns pending until the callback completes, then success with claim names or error with a sanitized category. Unknown states, another session/administrator/provider, or expired pending authorizations return data.status=expired with HTTP 200. Pending states expire after 600 seconds. Completed results are not consumed by reads; the current implementation only prunes their age when another test result is stored, so expiresAt is not a strict expiry for completed results. No claim values or tokens are exposed.
5790 ///
5791 /// # Example
5792 ///
5793 /// ```
5794 /// # use churchtools_api::*;
5795 /// # use churchtools_api::queries::*;
5796 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5797 /// # let client = churchtools_api::replay::client("get-externallogins-id-oidc-test-state");
5798 /// let test = client.external_logins().oidc().test().get(7, "opaque-session-bound-state")?;
5799 /// println!("{:?}", test.error_code);
5800 /// # Ok(())
5801 /// # }
5802 /// ```
5803 pub fn get(&self, external_login_id: impl Display, state: impl Display) -> Result<models::ExternalLoginOidcTestResult> {
5804 let path = format!("/externallogins/{}/oidc/test/{}", seg(external_login_id), seg(state));
5805 let query: Query = Query::new();
5806 self.client.request_data(Method::Get, &path, &query, None)
5807 }
5808
5809}
5810
5811/// `client.external_logins().saml()`
5812#[derive(Clone, Copy)]
5813pub struct ExternalLoginsSamlResource<'a> {
5814 client: &'a Client,
5815}
5816
5817impl<'a> ExternalLoginsSamlResource<'a> {
5818 pub fn metadata(&self) -> ExternalLoginsSamlMetadataResource<'a> {
5819 ExternalLoginsSamlMetadataResource { client: self.client }
5820 }
5821
5822 pub fn test(&self) -> ExternalLoginsSamlTestResource<'a> {
5823 ExternalLoginsSamlTestResource { client: self.client }
5824 }
5825
5826 /// Consume a SAML authentication response
5827 ///
5828 /// `POST /externallogins/{externalLoginId}/saml/acs`
5829 ///
5830 /// Public assertion-consumer callback for the identity provider’s form POST. Validates the SAML response and maps the external identity to a ChurchTools person. Successful login redirects to the stored destination or the installation landing page; identities needing account linking are redirected into that flow instead. Normal login requires a visible provider. Administrator test flows can use hidden providers and return a small HTML page that closes the popup, without logging the tested identity in. Test failures can also return that 200 HTML page: read the separate test-result endpoint for the outcome. A pending administrator test with missing RelayState also returns the popup page. Normal failures return 401 as localized text or an HTML error page, never the usual JSON error envelope.
5831 ///
5832 /// # Example
5833 ///
5834 /// ```no_run
5835 /// # use churchtools_api::*;
5836 /// # use churchtools_api::queries::*;
5837 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5838 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5839 /// let data = client.external_logins().saml().acs(7)?;
5840 /// std::fs::write("ergebnis.bin", &data)?;
5841 /// # Ok(())
5842 /// # }
5843 /// ```
5844 pub fn acs(&self, external_login_id: impl Display) -> Result<Vec<u8>> {
5845 let path = format!("/externallogins/{}/saml/acs", seg(external_login_id));
5846 let query: Query = Query::new();
5847 self.client.request(Method::Post, &path, &query, None)
5848 }
5849
5850 /// Process a SAML single-logout message
5851 ///
5852 /// `POST /externallogins/{externalLoginId}/saml/sls`
5853 ///
5854 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
5855 ///
5856 /// Use [`Self::create_sls_with`] to pass query parameters.
5857 ///
5858 /// # Example
5859 ///
5860 /// ```no_run
5861 /// # use churchtools_api::*;
5862 /// # use churchtools_api::queries::*;
5863 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5864 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5865 /// client.external_logins().saml().create_sls(7)?;
5866 /// # Ok(())
5867 /// # }
5868 /// ```
5869 pub fn create_sls(&self, external_login_id: impl Display) -> Result<()> {
5870 self.create_sls_with(external_login_id, &Default::default())
5871 }
5872
5873 /// Process a SAML single-logout message
5874 ///
5875 /// Like [`Self::create_sls`], with query parameters.
5876 ///
5877 /// `POST /externallogins/{externalLoginId}/saml/sls`
5878 ///
5879 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
5880 pub fn create_sls_with(&self, external_login_id: impl Display, query: &PostExternalloginsExternalLoginIdSamlSlsQuery) -> Result<()> {
5881 let path = format!("/externallogins/{}/saml/sls", seg(external_login_id));
5882 let query: Query = query.to_query();
5883 self.client.request(Method::Post, &path, &query, None).map(|_| ())
5884 }
5885
5886 /// Process a SAML single-logout message
5887 ///
5888 /// `DELETE /externallogins/{externalLoginId}/saml/sls`
5889 ///
5890 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
5891 ///
5892 /// Use [`Self::delete_sls_with`] to pass query parameters.
5893 ///
5894 /// # Example
5895 ///
5896 /// ```no_run
5897 /// # use churchtools_api::*;
5898 /// # use churchtools_api::queries::*;
5899 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5900 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5901 /// client.external_logins().saml().delete_sls(7)?;
5902 /// # Ok(())
5903 /// # }
5904 /// ```
5905 pub fn delete_sls(&self, external_login_id: impl Display) -> Result<()> {
5906 self.delete_sls_with(external_login_id, &Default::default())
5907 }
5908
5909 /// Process a SAML single-logout message
5910 ///
5911 /// Like [`Self::delete_sls`], with query parameters.
5912 ///
5913 /// `DELETE /externallogins/{externalLoginId}/saml/sls`
5914 ///
5915 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
5916 pub fn delete_sls_with(&self, external_login_id: impl Display, query: &DeleteExternalloginsExternalLoginIdSamlSlsQuery) -> Result<()> {
5917 let path = format!("/externallogins/{}/saml/sls", seg(external_login_id));
5918 let query: Query = query.to_query();
5919 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
5920 }
5921
5922 /// Start a SAML browser login
5923 ///
5924 /// `GET /externallogins/{externalLoginId}/saml/login`
5925 ///
5926 /// Starts the browser-based SAML login for a visible SAML external-login provider. Redirects to the configured identity provider with a SAML authentication request and an opaque RelayState. An optional post-login redirect is saved in the browser session, so the callback must retain that session. Only absolute URLs on this installation’s origin and within its base path are accepted; invalid redirect values are ignored. Missing, hidden or invalid providers and other setup failures produce a localized 404 response. No login or JSON access token is returned by this endpoint itself.
5927 ///
5928 /// Use [`Self::get_login_with`] to pass query parameters.
5929 ///
5930 /// # Example
5931 ///
5932 /// ```no_run
5933 /// # use churchtools_api::*;
5934 /// # use churchtools_api::queries::*;
5935 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5936 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5937 /// client.external_logins().saml().get_login(7)?;
5938 /// # Ok(())
5939 /// # }
5940 /// ```
5941 pub fn get_login(&self, external_login_id: impl Display) -> Result<()> {
5942 self.get_login_with(external_login_id, &Default::default())
5943 }
5944
5945 /// Start a SAML browser login
5946 ///
5947 /// Like [`Self::get_login`], with query parameters.
5948 ///
5949 /// `GET /externallogins/{externalLoginId}/saml/login`
5950 ///
5951 /// Starts the browser-based SAML login for a visible SAML external-login provider. Redirects to the configured identity provider with a SAML authentication request and an opaque RelayState. An optional post-login redirect is saved in the browser session, so the callback must retain that session. Only absolute URLs on this installation’s origin and within its base path are accepted; invalid redirect values are ignored. Missing, hidden or invalid providers and other setup failures produce a localized 404 response. No login or JSON access token is returned by this endpoint itself.
5952 pub fn get_login_with(&self, external_login_id: impl Display, query: &GetExternalloginsExternalLoginIdSamlLoginQuery) -> Result<()> {
5953 let path = format!("/externallogins/{}/saml/login", seg(external_login_id));
5954 let query: Query = query.to_query();
5955 self.client.request(Method::Get, &path, &query, None).map(|_| ())
5956 }
5957
5958 /// Get SAML service-provider metadata
5959 ///
5960 /// `GET /externallogins/{externalLoginId}/saml/metadata`
5961 ///
5962 /// Returns the XML metadata that an identity-provider administrator uses to configure ChurchTools as a SAML service provider. The entity ID, assertion-consumer URL and logout URL refer to this external-login provider. This endpoint is public and also works for a hidden provider, allowing setup before enabling login. Any provider/configuration/metadata-generation failure is returned as 404 with localized text, not a JSON error envelope.
5963 ///
5964 /// # Example
5965 ///
5966 /// ```no_run
5967 /// # use churchtools_api::*;
5968 /// # use churchtools_api::queries::*;
5969 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5970 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5971 /// let data = client.external_logins().saml().get_metadata(7)?;
5972 /// std::fs::write("ergebnis.bin", &data)?;
5973 /// # Ok(())
5974 /// # }
5975 /// ```
5976 pub fn get_metadata(&self, external_login_id: impl Display) -> Result<Vec<u8>> {
5977 let path = format!("/externallogins/{}/saml/metadata", seg(external_login_id));
5978 let query: Query = Query::new();
5979 self.client.request(Method::Get, &path, &query, None)
5980 }
5981
5982 /// Process a SAML single-logout message
5983 ///
5984 /// `GET /externallogins/{externalLoginId}/saml/sls`
5985 ///
5986 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. A redirect does not confirm successful logout.
5987 ///
5988 /// Use [`Self::get_sls_with`] to pass query parameters.
5989 ///
5990 /// # Example
5991 ///
5992 /// ```no_run
5993 /// # use churchtools_api::*;
5994 /// # use churchtools_api::queries::*;
5995 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5996 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
5997 /// client.external_logins().saml().get_sls(7)?;
5998 /// # Ok(())
5999 /// # }
6000 /// ```
6001 pub fn get_sls(&self, external_login_id: impl Display) -> Result<()> {
6002 self.get_sls_with(external_login_id, &Default::default())
6003 }
6004
6005 /// Process a SAML single-logout message
6006 ///
6007 /// Like [`Self::get_sls`], with query parameters.
6008 ///
6009 /// `GET /externallogins/{externalLoginId}/saml/sls`
6010 ///
6011 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. A redirect does not confirm successful logout.
6012 pub fn get_sls_with(&self, external_login_id: impl Display, query: &GetExternalloginsExternalLoginIdSamlSlsQuery) -> Result<()> {
6013 let path = format!("/externallogins/{}/saml/sls", seg(external_login_id));
6014 let query: Query = query.to_query();
6015 self.client.request(Method::Get, &path, &query, None).map(|_| ())
6016 }
6017
6018 /// Process a SAML single-logout message
6019 ///
6020 /// `PATCH /externallogins/{externalLoginId}/saml/sls`
6021 ///
6022 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
6023 ///
6024 /// Use [`Self::patch_sls_with`] to pass query parameters.
6025 ///
6026 /// # Example
6027 ///
6028 /// ```no_run
6029 /// # use churchtools_api::*;
6030 /// # use churchtools_api::queries::*;
6031 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6032 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6033 /// client.external_logins().saml().patch_sls(7)?;
6034 /// # Ok(())
6035 /// # }
6036 /// ```
6037 pub fn patch_sls(&self, external_login_id: impl Display) -> Result<()> {
6038 self.patch_sls_with(external_login_id, &Default::default())
6039 }
6040
6041 /// Process a SAML single-logout message
6042 ///
6043 /// Like [`Self::patch_sls`], with query parameters.
6044 ///
6045 /// `PATCH /externallogins/{externalLoginId}/saml/sls`
6046 ///
6047 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
6048 pub fn patch_sls_with(&self, external_login_id: impl Display, query: &PatchExternalloginsExternalLoginIdSamlSlsQuery) -> Result<()> {
6049 let path = format!("/externallogins/{}/saml/sls", seg(external_login_id));
6050 let query: Query = query.to_query();
6051 self.client.request(Method::Patch, &path, &query, None).map(|_| ())
6052 }
6053
6054 /// Process a SAML single-logout message
6055 ///
6056 /// `PUT /externallogins/{externalLoginId}/saml/sls`
6057 ///
6058 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
6059 ///
6060 /// Use [`Self::update_sls_with`] to pass query parameters.
6061 ///
6062 /// # Example
6063 ///
6064 /// ```no_run
6065 /// # use churchtools_api::*;
6066 /// # use churchtools_api::queries::*;
6067 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6068 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6069 /// client.external_logins().saml().update_sls(7)?;
6070 /// # Ok(())
6071 /// # }
6072 /// ```
6073 pub fn update_sls(&self, external_login_id: impl Display) -> Result<()> {
6074 self.update_sls_with(external_login_id, &Default::default())
6075 }
6076
6077 /// Process a SAML single-logout message
6078 ///
6079 /// Like [`Self::update_sls`], with query parameters.
6080 ///
6081 /// `PUT /externallogins/{externalLoginId}/saml/sls`
6082 ///
6083 /// Processes a signed SAML HTTP-Redirect single-logout message for a visible provider. Prefer the GET binding for new integrations. A redirect does not confirm successful logout.
6084 pub fn update_sls_with(&self, external_login_id: impl Display, query: &PutExternalloginsExternalLoginIdSamlSlsQuery) -> Result<()> {
6085 let path = format!("/externallogins/{}/saml/sls", seg(external_login_id));
6086 let query: Query = query.to_query();
6087 self.client.request(Method::Put, &path, &query, None).map(|_| ())
6088 }
6089
6090}
6091
6092/// `client.external_logins().saml().metadata()`
6093#[derive(Clone, Copy)]
6094pub struct ExternalLoginsSamlMetadataResource<'a> {
6095 client: &'a Client,
6096}
6097
6098impl<'a> ExternalLoginsSamlMetadataResource<'a> {
6099 /// Parse uploaded SAML identity-provider metadata
6100 ///
6101 /// `POST /externallogins/saml/metadata/parse`
6102 ///
6103 /// Parses supplied XML into selectable IdP configuration candidates. Requires "churchcore administer settings" permission. Supports `EntityDescriptor` and `EntitiesDescriptor` documents and HTTP-Redirect SSO/SLO bindings. Parsing does not verify metadata signatures or certificate trust.
6104 ///
6105 /// # Example
6106 ///
6107 /// ```no_run
6108 /// # use churchtools_api::*;
6109 /// # use churchtools_api::queries::*;
6110 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6111 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6112 /// let body = models::SamlMetadataParseCreate {
6113 /// xml: "beispiel".into(),
6114 /// ..Default::default()
6115 /// };
6116 /// let metadata = client.external_logins().saml().metadata().parse(&body)?;
6117 /// println!("{:?}", metadata);
6118 /// # Ok(())
6119 /// # }
6120 /// ```
6121 pub fn parse(&self, body: &models::SamlMetadataParseCreate) -> Result<models::PostExternalloginsSamlMetadataParseData> {
6122 let path = "/externallogins/saml/metadata/parse".to_owned();
6123 let query: Query = Query::new();
6124 let body = serde_json::to_value(body).expect("request body serializes");
6125 self.client.request_data(Method::Post, &path, &query, Some(&body))
6126 }
6127
6128}
6129
6130/// `client.external_logins().saml().test()`
6131#[derive(Clone, Copy)]
6132pub struct ExternalLoginsSamlTestResource<'a> {
6133 client: &'a Client,
6134}
6135
6136impl<'a> ExternalLoginsSamlTestResource<'a> {
6137 /// Start SAML login test
6138 ///
6139 /// `POST /externallogins/{externalLoginId}/saml/test`
6140 ///
6141 /// Starts a SAML round-trip test for the stored provider configuration. Requires "churchcore administer settings" permission; hidden SAML providers can be tested. Open data.url in the same browser session, then poll using data.state. At most five tests are retained per session; older entries are evicted. Tests and completed results expire 600 seconds after creation. The callback validates the SAML response and returns claim-name/mapping diagnostics without creating or linking a ChurchTools person or establishing a new ChurchTools login. A successful test does not guarantee that required identity attributes have usable values or that person matching would succeed. Configuration/URL-generation failures are not converted into an error result by this endpoint.
6142 ///
6143 /// # Example
6144 ///
6145 /// ```no_run
6146 /// # use churchtools_api::*;
6147 /// # use churchtools_api::queries::*;
6148 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6149 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6150 /// let result = client.external_logins().saml().test().create(7)?;
6151 /// println!("{}", result.expires_at);
6152 /// # Ok(())
6153 /// # }
6154 /// ```
6155 pub fn create(&self, external_login_id: impl Display) -> Result<models::ExternalLoginSamlTestStart> {
6156 let path = format!("/externallogins/{}/saml/test", seg(external_login_id));
6157 let query: Query = Query::new();
6158 self.client.request_data(Method::Post, &path, &query, None)
6159 }
6160
6161 /// Get SAML login test result
6162 ///
6163 /// `GET /externallogins/{externalLoginId}/saml/test/{state}`
6164 ///
6165 /// Polls a SAML test for the current administrator, provider and browser session. Requires "churchcore administer settings" permission; hidden SAML providers are allowed. An unknown state, another administrator/provider/session, an evicted test, or a test older than 600 seconds returns status=expired with HTTP 200. Success returns attribute names and all five mapping-presence checks; error returns only its status. Reads do not consume completed results. Provider lookup and SAML configuration are checked again, so deleting the provider or breaking its settings can prevent polling an existing result.
6166 ///
6167 /// # Example
6168 ///
6169 /// ```
6170 /// # use churchtools_api::*;
6171 /// # use churchtools_api::queries::*;
6172 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6173 /// # let client = churchtools_api::replay::client("get-externallogins-id-saml-test-state");
6174 /// let test = client.external_logins().saml().test().get(7, "beispiel")?;
6175 /// println!("{}", test.status);
6176 /// # Ok(())
6177 /// # }
6178 /// ```
6179 pub fn get(&self, external_login_id: impl Display, state: impl Display) -> Result<models::ExternalLoginSamlTestResult> {
6180 let path = format!("/externallogins/{}/saml/test/{}", seg(external_login_id), seg(state));
6181 let query: Query = Query::new();
6182 self.client.request_data(Method::Get, &path, &query, None)
6183 }
6184
6185}
6186
6187/// `client.external_posts()`
6188#[derive(Clone, Copy)]
6189pub struct ExternalPostsResource<'a> {
6190 client: &'a Client,
6191}
6192
6193impl<'a> ExternalPostsResource<'a> {
6194 pub fn instances(&self) -> ExternalPostsInstancesResource<'a> {
6195 ExternalPostsInstancesResource { client: self.client }
6196 }
6197
6198 /// `GET /externalposts`
6199 ///
6200 /// Get a list of external posts. The posts are sorted by the `createdDate` field descending.
6201 ///
6202 /// Use [`Self::list_with`] to pass query parameters.
6203 ///
6204 /// # Example
6205 ///
6206 /// ```
6207 /// # use churchtools_api::*;
6208 /// # use churchtools_api::queries::*;
6209 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6210 /// # let client = churchtools_api::replay::client("get-externalposts");
6211 /// for external_post in client.external_posts().list()? {
6212 /// println!("{}", external_post.title);
6213 /// }
6214 /// # Ok(())
6215 /// # }
6216 /// ```
6217 pub fn list(&self) -> Result<Vec<models::Post>> {
6218 self.list_with(&Default::default())
6219 }
6220
6221 /// `GET /externalposts`
6222 ///
6223 /// Like [`Self::list`], with query parameters.
6224 ///
6225 /// Get a list of external posts. The posts are sorted by the `createdDate` field descending.
6226 pub fn list_with(&self, query: &GetExternalpostsQuery) -> Result<Vec<models::Post>> {
6227 let path = "/externalposts".to_owned();
6228 let query: Query = query.to_query();
6229 self.client.request_data(Method::Get, &path, &query, None)
6230 }
6231
6232}
6233
6234/// `client.external_posts().instances()`
6235#[derive(Clone, Copy)]
6236pub struct ExternalPostsInstancesResource<'a> {
6237 client: &'a Client,
6238}
6239
6240impl<'a> ExternalPostsInstancesResource<'a> {
6241 pub fn channels(&self) -> ExternalPostsInstancesChannelsResource<'a> {
6242 ExternalPostsInstancesChannelsResource { client: self.client }
6243 }
6244
6245}
6246
6247/// `client.external_posts().instances().channels()`
6248#[derive(Clone, Copy)]
6249pub struct ExternalPostsInstancesChannelsResource<'a> {
6250 client: &'a Client,
6251}
6252
6253impl<'a> ExternalPostsInstancesChannelsResource<'a> {
6254 pub fn posts(&self) -> ExternalPostsInstancesChannelsPostsResource<'a> {
6255 ExternalPostsInstancesChannelsPostsResource { client: self.client }
6256 }
6257
6258}
6259
6260/// `client.external_posts().instances().channels().posts()`
6261#[derive(Clone, Copy)]
6262pub struct ExternalPostsInstancesChannelsPostsResource<'a> {
6263 client: &'a Client,
6264}
6265
6266impl<'a> ExternalPostsInstancesChannelsPostsResource<'a> {
6267 /// `GET /externalposts/instances/{instanceGuid}/channels/{channelGuid}/posts/{postGuid}`
6268 ///
6269 /// Get one external Post
6270 ///
6271 /// # Example
6272 ///
6273 /// ```no_run
6274 /// # use churchtools_api::*;
6275 /// # use churchtools_api::queries::*;
6276 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6277 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6278 /// let post = client.external_posts().instances().channels().posts().get("abc123", "abc123", "abc123")?;
6279 /// println!("{}", post.title);
6280 /// # Ok(())
6281 /// # }
6282 /// ```
6283 pub fn get(&self, instance_guid: impl Display, channel_guid: impl Display, post_guid: impl Display) -> Result<models::Post> {
6284 let path = format!("/externalposts/instances/{}/channels/{}/posts/{}", seg(instance_guid), seg(channel_guid), seg(post_guid));
6285 let query: Query = Query::new();
6286 self.client.request_data(Method::Get, &path, &query, None)
6287 }
6288
6289}
6290
6291/// `client.facts()`
6292#[derive(Clone, Copy)]
6293pub struct FactsResource<'a> {
6294 client: &'a Client,
6295}
6296
6297impl<'a> FactsResource<'a> {
6298 /// Create a fact definition
6299 ///
6300 /// `POST /facts`
6301 ///
6302 /// Creates a reusable metric or selection definition. Values for individual events are managed separately. Requires the "edit masterdata" permission for the service planning domain.
6303 ///
6304 /// # Example
6305 ///
6306 /// ```
6307 /// # use churchtools_api::*;
6308 /// # use churchtools_api::queries::*;
6309 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6310 /// # let client = churchtools_api::replay::client("post-facts");
6311 /// let body = serde_json::json!({
6312 /// "name": "Attendance",
6313 /// "type": "number",
6314 /// "unit": "people"
6315 /// });
6316 /// let result = client.facts().create(&body)?;
6317 /// println!("{:?}", result);
6318 /// # Ok(())
6319 /// # }
6320 /// ```
6321 pub fn create(&self, body: &serde_json::Value) -> Result<serde_json::Value> {
6322 let path = "/facts".to_owned();
6323 let query: Query = Query::new();
6324 let body = serde_json::to_value(body).expect("request body serializes");
6325 self.client.request_data(Method::Post, &path, &query, Some(&body))
6326 }
6327
6328 /// Delete a fact definition
6329 ///
6330 /// `DELETE /facts/{id}`
6331 ///
6332 /// Deletes the reusable definition, all values recorded for it on events, its assignments in event templates and its fact-specific permissions. To remove only one recorded value, use `DELETE /events/{eventId}/facts/{factId}`. With `dry_run`=`true`, no deletion is performed and the API returns `409` with a deletion report even when deletable is `true`. A successful actual deletion returns `204`. Requires permission to edit service-planning master data (the "edit masterdata" permission for the service planning domain).
6333 ///
6334 /// Use [`Self::delete_with`] to pass query parameters.
6335 ///
6336 /// # Example
6337 ///
6338 /// ```no_run
6339 /// # use churchtools_api::*;
6340 /// # use churchtools_api::queries::*;
6341 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6342 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6343 /// client.facts().delete(3)?;
6344 /// # Ok(())
6345 /// # }
6346 /// ```
6347 pub fn delete(&self, id: impl Display) -> Result<()> {
6348 self.delete_with(id, &Default::default())
6349 }
6350
6351 /// Delete a fact definition
6352 ///
6353 /// Like [`Self::delete`], with query parameters.
6354 ///
6355 /// `DELETE /facts/{id}`
6356 ///
6357 /// Deletes the reusable definition, all values recorded for it on events, its assignments in event templates and its fact-specific permissions. To remove only one recorded value, use `DELETE /events/{eventId}/facts/{factId}`. With `dry_run`=`true`, no deletion is performed and the API returns `409` with a deletion report even when deletable is `true`. A successful actual deletion returns `204`. Requires permission to edit service-planning master data (the "edit masterdata" permission for the service planning domain).
6358 pub fn delete_with(&self, id: impl Display, query: &DeleteFactsIdQuery) -> Result<()> {
6359 let path = format!("/facts/{}", seg(id));
6360 let query: Query = query.to_query();
6361 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
6362 }
6363
6364 /// Get a fact definition
6365 ///
6366 /// `GET /facts/{id}`
6367 ///
6368 /// Returns the reusable definition, including the numeric unit or available selection labels. This does not return values recorded for events and does not check permission to view those values.
6369 ///
6370 /// # Example
6371 ///
6372 /// ```
6373 /// # use churchtools_api::*;
6374 /// # use churchtools_api::queries::*;
6375 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6376 /// # let client = churchtools_api::replay::client("get-facts-id");
6377 /// let result = client.facts().get(3)?;
6378 /// println!("{:?}", result);
6379 /// # Ok(())
6380 /// # }
6381 /// ```
6382 pub fn get(&self, id: impl Display) -> Result<serde_json::Value> {
6383 let path = format!("/facts/{}", seg(id));
6384 let query: Query = Query::new();
6385 self.client.request_data(Method::Get, &path, &query, None)
6386 }
6387
6388 /// List fact definitions
6389 ///
6390 /// `GET /facts`
6391 ///
6392 /// A fact definition describes a reusable metric (number) or selection (select), such as attendance or service type. It is separate from the value recorded for an individual event. Returns all definitions, ordered by `sortKey` ascending and then name ascending, without pagination. Definitions are not filtered by permissions to view recorded fact values.
6393 ///
6394 /// # Example
6395 ///
6396 /// ```
6397 /// # use churchtools_api::*;
6398 /// # use churchtools_api::queries::*;
6399 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6400 /// # let client = churchtools_api::replay::client("get-facts");
6401 /// for fact in client.facts().list()? {
6402 /// println!("{:?}", fact);
6403 /// }
6404 /// # Ok(())
6405 /// # }
6406 /// ```
6407 pub fn list(&self) -> Result<Vec<serde_json::Value>> {
6408 let path = "/facts".to_owned();
6409 let query: Query = Query::new();
6410 self.client.request_data(Method::Get, &path, &query, None)
6411 }
6412
6413 /// Replace a fact definition
6414 ///
6415 /// `PUT /facts/{id}`
6416 ///
6417 /// Replaces the definition’s name, type, sort order and type-specific settings. Stored event values are not migrated or validated against a changed type or option list. Requires the "edit masterdata" permission for the service planning domain; permission to edit an individual fact value is not sufficient.
6418 ///
6419 /// # Example
6420 ///
6421 /// ```
6422 /// # use churchtools_api::*;
6423 /// # use churchtools_api::queries::*;
6424 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6425 /// # let client = churchtools_api::replay::client("put-facts-id");
6426 /// let body = serde_json::json!({
6427 /// "name": "Attendance",
6428 /// "type": "number",
6429 /// "unit": "people"
6430 /// });
6431 /// let result = client.facts().update(3, &body)?;
6432 /// println!("{:?}", result);
6433 /// # Ok(())
6434 /// # }
6435 /// ```
6436 pub fn update(&self, id: impl Display, body: &serde_json::Value) -> Result<serde_json::Value> {
6437 let path = format!("/facts/{}", seg(id));
6438 let query: Query = Query::new();
6439 let body = serde_json::to_value(body).expect("request body serializes");
6440 self.client.request_data(Method::Put, &path, &query, Some(&body))
6441 }
6442
6443}
6444
6445/// `client.feature_usage()`
6446#[derive(Clone, Copy)]
6447pub struct FeatureUsageResource<'a> {
6448 client: &'a Client,
6449}
6450
6451impl<'a> FeatureUsageResource<'a> {
6452 /// `POST /featureusage`
6453 ///
6454 /// Send feature usage statistics in bulk.
6455 ///
6456 /// # Example
6457 ///
6458 /// ```no_run
6459 /// # use churchtools_api::*;
6460 /// # use churchtools_api::queries::*;
6461 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6462 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6463 /// let body = models::PostFeatureusageBody::default();
6464 /// client.feature_usage().create(&body)?;
6465 /// # Ok(())
6466 /// # }
6467 /// ```
6468 pub fn create(&self, body: &models::PostFeatureusageBody) -> Result<()> {
6469 let path = "/featureusage".to_owned();
6470 let query: Query = Query::new();
6471 let body = serde_json::to_value(body).expect("request body serializes");
6472 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
6473 }
6474
6475}
6476
6477/// `client.fields()`
6478#[derive(Clone, Copy)]
6479pub struct FieldsResource<'a> {
6480 client: &'a Client,
6481}
6482
6483impl<'a> FieldsResource<'a> {
6484 /// Get all fields
6485 ///
6486 /// `GET /fields`
6487 ///
6488 /// Returns an array of all fields defined in ChurchTools.
6489 ///
6490 /// # Example
6491 ///
6492 /// ```
6493 /// # use churchtools_api::*;
6494 /// # use churchtools_api::queries::*;
6495 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6496 /// # let client = churchtools_api::replay::client("get-fields");
6497 /// for field in client.fields().list()? {
6498 /// println!("{:?}", field);
6499 /// }
6500 /// # Ok(())
6501 /// # }
6502 /// ```
6503 #[deprecated = "GET /fields is deprecated in the ChurchTools API."]
6504 pub fn list(&self) -> Result<Vec<std::collections::BTreeMap<String, serde_json::Value>>> {
6505 let path = "/fields".to_owned();
6506 let query: Query = Query::new();
6507 self.client.request_data(Method::Get, &path, &query, None)
6508 }
6509
6510}
6511
6512/// `client.files()`
6513#[derive(Clone, Copy)]
6514pub struct FilesResource<'a> {
6515 client: &'a Client,
6516}
6517
6518impl<'a> FilesResource<'a> {
6519 /// Upload files
6520 ///
6521 /// `POST /files/{domainType}/{domainIdentifier}`
6522 ///
6523 /// Uploads files to a domain object. Requires update permission. The attachment category controls file multiplicity, image dimensions and category-specific processing.
6524 ///
6525 /// Use [`Self::create_with`] to pass query parameters.
6526 ///
6527 /// # Example
6528 ///
6529 /// ```no_run
6530 /// # use churchtools_api::*;
6531 /// # use churchtools_api::queries::*;
6532 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6533 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6534 /// let file = Upload::from_path("gemeindebrief.pdf")?;
6535 /// for file in client.files().create(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &[file])? {
6536 /// println!("{}", file.name);
6537 /// }
6538 /// # Ok(())
6539 /// # }
6540 /// ```
6541 pub fn create(&self, domain_type: impl Display, domain_identifier: impl Display, files: &[Upload]) -> Result<Vec<models::FileUploadResult>> {
6542 self.create_with(domain_type, domain_identifier, files, &Default::default())
6543 }
6544
6545 /// Upload files
6546 ///
6547 /// Like [`Self::create`], with form fields.
6548 ///
6549 /// `POST /files/{domainType}/{domainIdentifier}`
6550 ///
6551 /// Uploads files to a domain object. Requires update permission. The attachment category controls file multiplicity, image dimensions and category-specific processing.
6552 pub fn create_with(&self, domain_type: impl Display, domain_identifier: impl Display, files: &[Upload], form: &PostFilesDomainTypeDomainIdentifierForm) -> Result<Vec<models::FileUploadResult>> {
6553 let path = format!("/files/{}/{}", seg(domain_type), seg(domain_identifier));
6554 let query: Query = Query::new();
6555 let form: Query = form.to_query();
6556 let bytes = self.client.request_multipart(Method::Post, &path, &query, &form, "files[]", files)?;
6557 crate::decode_data(&bytes)
6558 }
6559
6560 /// Delete a file by ID
6561 ///
6562 /// `DELETE /files/{id}`
6563 ///
6564 /// Deletes one file or URL attachment. Requires update permission for its owning object and runs category-specific delete hooks.
6565 ///
6566 /// # Example
6567 ///
6568 /// ```no_run
6569 /// # use churchtools_api::*;
6570 /// # use churchtools_api::queries::*;
6571 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6572 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6573 /// client.files().delete(1)?;
6574 /// # Ok(())
6575 /// # }
6576 /// ```
6577 pub fn delete(&self, id: impl Display) -> Result<()> {
6578 let path = format!("/files/{}", seg(id));
6579 let query: Query = Query::new();
6580 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
6581 }
6582
6583 /// Delete all files for a domain object
6584 ///
6585 /// `DELETE /files/{domainType}/{domainIdentifier}`
6586 ///
6587 /// Deletes every file and URL attachment of the domain object. Requires update permission for the object and runs category-specific delete hooks.
6588 ///
6589 /// # Example
6590 ///
6591 /// ```no_run
6592 /// # use churchtools_api::*;
6593 /// # use churchtools_api::queries::*;
6594 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6595 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6596 /// client.files().delete_for_object(serde_json::json!("agenda_PRO_PRESENTER_6"), "42")?;
6597 /// # Ok(())
6598 /// # }
6599 /// ```
6600 pub fn delete_for_object(&self, domain_type: impl Display, domain_identifier: impl Display) -> Result<()> {
6601 let path = format!("/files/{}/{}", seg(domain_type), seg(domain_identifier));
6602 let query: Query = Query::new();
6603 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
6604 }
6605
6606 /// Get file metadata by ID
6607 ///
6608 /// `GET /files/{id}/meta`
6609 ///
6610 /// Returns normalized metadata for a file or URL attachment. Requires view permission for the file. Anonymous access depends on the attachment category.
6611 ///
6612 /// # Example
6613 ///
6614 /// ```
6615 /// # use churchtools_api::*;
6616 /// # use churchtools_api::queries::*;
6617 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6618 /// # let client = churchtools_api::replay::client("get-files-id-meta");
6619 /// let meta = client.files().get_meta(1)?;
6620 /// println!("{}", meta.name);
6621 /// # Ok(())
6622 /// # }
6623 /// ```
6624 pub fn get_meta(&self, id: impl Display) -> Result<models::CtFile> {
6625 let path = format!("/files/{}/meta", seg(id));
6626 let query: Query = Query::new();
6627 self.client.request_data(Method::Get, &path, &query, None)
6628 }
6629
6630 /// Get legacy file metadata
6631 ///
6632 /// `GET /files/{fileId}/metadata`
6633 ///
6634 /// Returns the raw file database record without a response envelope. Use `GET /files/{id}/meta` for normalized file metadata.
6635 ///
6636 /// # Example
6637 ///
6638 /// ```
6639 /// # use churchtools_api::*;
6640 /// # use churchtools_api::queries::*;
6641 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6642 /// # let client = churchtools_api::replay::client("get-files-id-metadata");
6643 /// let metadata = client.files().get_metadata(42)?;
6644 /// println!("{}", metadata.id);
6645 /// # Ok(())
6646 /// # }
6647 /// ```
6648 #[deprecated = "GET /files/{fileId}/metadata is deprecated in the ChurchTools API. Use `GET /files/{id}/meta` for normalized file metadata."]
6649 pub fn get_metadata(&self, file_id: impl Display) -> Result<models::LegacyFileMetadata> {
6650 let path = format!("/files/{}/metadata", seg(file_id));
6651 let query: Query = Query::new();
6652 self.client.request_json(Method::Get, &path, &query, None)
6653 }
6654
6655 /// Add a link attachment
6656 ///
6657 /// `POST /files/{domainType}/{domainIdentifier}/link`
6658 ///
6659 /// Creates a URL attachment without fetching its target. Requires update permission and runs the selected category's file-save hooks.
6660 ///
6661 /// # Example
6662 ///
6663 /// ```no_run
6664 /// # use churchtools_api::*;
6665 /// # use churchtools_api::queries::*;
6666 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6667 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6668 /// let body = models::FileLinkCreate {
6669 /// url: "https://example.org/service-notes".into(),
6670 /// ..Default::default()
6671 /// };
6672 /// let file = client.files().link(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &body)?;
6673 /// println!("{}", file.name);
6674 /// # Ok(())
6675 /// # }
6676 /// ```
6677 pub fn link(&self, domain_type: impl Display, domain_identifier: impl Display, body: &models::FileLinkCreate) -> Result<models::CtFile> {
6678 let path = format!("/files/{}/{}/link", seg(domain_type), seg(domain_identifier));
6679 let query: Query = Query::new();
6680 let body = serde_json::to_value(body).expect("request body serializes");
6681 self.client.request_data(Method::Post, &path, &query, Some(&body))
6682 }
6683
6684 /// Get all files for a specific domain object
6685 ///
6686 /// `GET /files/{domainType}/{domainIdentifier}`
6687 ///
6688 /// Returns metadata for files and URL attachments of one domain object. Files hidden by view permissions or `showOnlyWhenEditable` are omitted. Anonymous access depends on the selected attachment category.
6689 ///
6690 /// # Example
6691 ///
6692 /// ```
6693 /// # use churchtools_api::*;
6694 /// # use churchtools_api::queries::*;
6695 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6696 /// # let client = churchtools_api::replay::client("get-files-domainType-domainIdentifier");
6697 /// for file in client.files().list(serde_json::json!("agenda_PRO_PRESENTER_6"), "42")? {
6698 /// println!("{}", file.name);
6699 /// }
6700 /// # Ok(())
6701 /// # }
6702 /// ```
6703 pub fn list(&self, domain_type: impl Display, domain_identifier: impl Display) -> Result<Vec<models::CtFile>> {
6704 let path = format!("/files/{}/{}", seg(domain_type), seg(domain_identifier));
6705 let query: Query = Query::new();
6706 self.client.request_data(Method::Get, &path, &query, None)
6707 }
6708
6709 /// Get all files for a domain type
6710 ///
6711 /// `GET /files/{domainType}`
6712 ///
6713 /// Returns file and URL-attachment metadata for one attachment category. Files hidden by view permissions or `showOnlyWhenEditable` are omitted.
6714 ///
6715 /// # Example
6716 ///
6717 /// ```
6718 /// # use churchtools_api::*;
6719 /// # use churchtools_api::queries::*;
6720 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6721 /// # let client = churchtools_api::replay::client("get-files-domainType");
6722 /// let result = client.files().list_for_type(serde_json::json!("agenda_PRO_PRESENTER_6"))?;
6723 /// println!("{:?}", result);
6724 /// # Ok(())
6725 /// # }
6726 /// ```
6727 pub fn list_for_type(&self, domain_type: impl Display) -> Result<serde_json::Value> {
6728 let path = format!("/files/{}", seg(domain_type));
6729 let query: Query = Query::new();
6730 self.client.request_data(Method::Get, &path, &query, None)
6731 }
6732
6733 /// Update file metadata by ID
6734 ///
6735 /// `PATCH /files/{id}`
6736 ///
6737 /// Updates a file's display metadata and optionally copies it to another attachment context. Updating requires source update permission; copying requires source view permission and target update permission.
6738 ///
6739 /// # Example
6740 ///
6741 /// ```no_run
6742 /// # use churchtools_api::*;
6743 /// # use churchtools_api::queries::*;
6744 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6745 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6746 /// let body = models::FileUpdate {
6747 /// name: Some(Some("Service notes.pdf".into())),
6748 /// ..Default::default()
6749 /// };
6750 /// client.files().patch(1, &body)?;
6751 /// # Ok(())
6752 /// # }
6753 /// ```
6754 pub fn patch(&self, id: impl Display, body: &models::FileUpdate) -> Result<()> {
6755 let path = format!("/files/{}", seg(id));
6756 let query: Query = Query::new();
6757 let body = serde_json::to_value(body).expect("request body serializes");
6758 self.client.request(Method::Patch, &path, &query, Some(&body)).map(|_| ())
6759 }
6760
6761 /// Update files for a domain object
6762 ///
6763 /// `PATCH /files/{domainType}/{domainIdentifier}`
6764 ///
6765 /// Updates the display name and sort key of every attachment of the domain object. Requires update permission and runs category-specific metadata hooks for each affected file.
6766 ///
6767 /// # Example
6768 ///
6769 /// ```no_run
6770 /// # use churchtools_api::*;
6771 /// # use churchtools_api::queries::*;
6772 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6773 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6774 /// let body = models::FileDomainUpdate {
6775 /// name: Some(Some("Service notes.pdf".into())),
6776 /// ..Default::default()
6777 /// };
6778 /// client.files().update_for_object(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &body)?;
6779 /// # Ok(())
6780 /// # }
6781 /// ```
6782 pub fn update_for_object(&self, domain_type: impl Display, domain_identifier: impl Display, body: &models::FileDomainUpdate) -> Result<()> {
6783 let path = format!("/files/{}/{}", seg(domain_type), seg(domain_identifier));
6784 let query: Query = Query::new();
6785 let body = serde_json::to_value(body).expect("request body serializes");
6786 self.client.request(Method::Patch, &path, &query, Some(&body)).map(|_| ())
6787 }
6788
6789}
6790
6791/// `client.finance()`
6792#[derive(Clone, Copy)]
6793pub struct FinanceResource<'a> {
6794 client: &'a Client,
6795}
6796
6797impl<'a> FinanceResource<'a> {
6798 pub fn account_classes(&self) -> FinanceAccountClassesResource<'a> {
6799 FinanceAccountClassesResource { client: self.client }
6800 }
6801
6802 pub fn account_groups(&self) -> FinanceAccountGroupsResource<'a> {
6803 FinanceAccountGroupsResource { client: self.client }
6804 }
6805
6806 pub fn account_types(&self) -> FinanceAccountTypesResource<'a> {
6807 FinanceAccountTypesResource { client: self.client }
6808 }
6809
6810 pub fn accounting_periods(&self) -> FinanceAccountingPeriodsResource<'a> {
6811 FinanceAccountingPeriodsResource { client: self.client }
6812 }
6813
6814 pub fn accounts(&self) -> FinanceAccountsResource<'a> {
6815 FinanceAccountsResource { client: self.client }
6816 }
6817
6818 pub fn bills(&self) -> FinanceBillsResource<'a> {
6819 FinanceBillsResource { client: self.client }
6820 }
6821
6822 pub fn cash_discounts(&self) -> FinanceCashDiscountsResource<'a> {
6823 FinanceCashDiscountsResource { client: self.client }
6824 }
6825
6826 pub fn clients(&self) -> FinanceClientsResource<'a> {
6827 FinanceClientsResource { client: self.client }
6828 }
6829
6830 pub fn cost_centers(&self) -> FinanceCostCentersResource<'a> {
6831 FinanceCostCentersResource { client: self.client }
6832 }
6833
6834 pub fn donators(&self) -> FinanceDonatorsResource<'a> {
6835 FinanceDonatorsResource { client: self.client }
6836 }
6837
6838 pub fn eubp(&self) -> FinanceEubpResource<'a> {
6839 FinanceEubpResource { client: self.client }
6840 }
6841
6842 pub fn reports(&self) -> FinanceReportsResource<'a> {
6843 FinanceReportsResource { client: self.client }
6844 }
6845
6846 pub fn split_transactions(&self) -> FinanceSplitTransactionsResource<'a> {
6847 FinanceSplitTransactionsResource { client: self.client }
6848 }
6849
6850 pub fn tax_rates(&self) -> FinanceTaxRatesResource<'a> {
6851 FinanceTaxRatesResource { client: self.client }
6852 }
6853
6854 pub fn tax_types(&self) -> FinanceTaxTypesResource<'a> {
6855 FinanceTaxTypesResource { client: self.client }
6856 }
6857
6858 pub fn templates(&self) -> FinanceTemplatesResource<'a> {
6859 FinanceTemplatesResource { client: self.client }
6860 }
6861
6862 pub fn transaction_purposes(&self) -> FinanceTransactionPurposesResource<'a> {
6863 FinanceTransactionPurposesResource { client: self.client }
6864 }
6865
6866 pub fn transactions(&self) -> FinanceTransactionsResource<'a> {
6867 FinanceTransactionsResource { client: self.client }
6868 }
6869
6870 /// Get finance master data for an accounting period
6871 ///
6872 /// `GET /finance/masterdata`
6873 ///
6874 /// Finance definitions needed for one accounting period. Clients and periods include all entries visible to the caller; account types, classes, groups and tax types are installation-wide. Accounts, cost centers, tax rates, cash discounts and transaction purposes relate to the selected period. The selected accounting period must be visible. Returns data, per-collection counts in meta and top-level UI permissions. Account balances are calculated only with global view/edit accounting period permission; otherwise account values may remain at their uncalculated defaults. Cost-center budgets are calculated independently. Unlike /finance/transactionpurposes, the preset list is restricted by period and, without global period rights, by groups allowing posting.
6875 ///
6876 /// # Example
6877 ///
6878 /// ```
6879 /// # use churchtools_api::*;
6880 /// # use churchtools_api::queries::*;
6881 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6882 /// # let client = churchtools_api::replay::client("get-finance-masterdata");
6883 /// let query = GetFinanceMasterdataQuery {
6884 /// accounting_period_id: Some(1),
6885 /// ..Default::default()
6886 /// };
6887 /// let master_data = client.finance().get_master_data(&query)?;
6888 /// println!("{:?}", master_data);
6889 /// # Ok(())
6890 /// # }
6891 /// ```
6892 pub fn get_master_data(&self, query: &GetFinanceMasterdataQuery) -> Result<models::FinanceMasterData> {
6893 let path = "/finance/masterdata".to_owned();
6894 let query: Query = query.to_query();
6895 self.client.request_data(Method::Get, &path, &query, None)
6896 }
6897
6898}
6899
6900/// `client.finance().account_classes()`
6901#[derive(Clone, Copy)]
6902pub struct FinanceAccountClassesResource<'a> {
6903 client: &'a Client,
6904}
6905
6906impl<'a> FinanceAccountClassesResource<'a> {
6907 /// Create a new account class
6908 ///
6909 /// `POST /finance/accountclasses`
6910 ///
6911 /// Creates finance master data. Account classes group account groups within one account type. The hierarchy is account type → account class → account group → account. Requires finance “edit masterdata”. Names must be unique across this resource. The successful response uses HTTP 200.
6912 ///
6913 /// # Example
6914 ///
6915 /// ```no_run
6916 /// # use churchtools_api::*;
6917 /// # use churchtools_api::queries::*;
6918 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6919 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6920 /// let body = models::AccountClassCreate {
6921 /// account_type_id: 3,
6922 /// name: "Anlagevermögen".into(),
6923 /// ..Default::default()
6924 /// };
6925 /// let result = client.finance().account_classes().create(&body)?;
6926 /// println!("{}", result.name);
6927 /// # Ok(())
6928 /// # }
6929 /// ```
6930 pub fn create(&self, body: &models::AccountClassCreate) -> Result<models::AccountClass> {
6931 let path = "/finance/accountclasses".to_owned();
6932 let query: Query = Query::new();
6933 let body = serde_json::to_value(body).expect("request body serializes");
6934 self.client.request_data(Method::Post, &path, &query, Some(&body))
6935 }
6936
6937 /// Delete an account class
6938 ///
6939 /// `DELETE /finance/accountclasses/{id}`
6940 ///
6941 /// Deletes this definition if no account groups reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, including when deletion would be allowed.
6942 ///
6943 /// Use [`Self::delete_with`] to pass query parameters.
6944 ///
6945 /// # Example
6946 ///
6947 /// ```no_run
6948 /// # use churchtools_api::*;
6949 /// # use churchtools_api::queries::*;
6950 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6951 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
6952 /// client.finance().account_classes().delete(1)?;
6953 /// # Ok(())
6954 /// # }
6955 /// ```
6956 pub fn delete(&self, id: impl Display) -> Result<()> {
6957 self.delete_with(id, &Default::default())
6958 }
6959
6960 /// Delete an account class
6961 ///
6962 /// Like [`Self::delete`], with query parameters.
6963 ///
6964 /// `DELETE /finance/accountclasses/{id}`
6965 ///
6966 /// Deletes this definition if no account groups reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, including when deletion would be allowed.
6967 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceAccountclassesIdQuery) -> Result<()> {
6968 let path = format!("/finance/accountclasses/{}", seg(id));
6969 let query: Query = query.to_query();
6970 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
6971 }
6972
6973 /// Get an account class by ID
6974 ///
6975 /// `GET /finance/accountclasses/{id}`
6976 ///
6977 /// Account classes group account groups within one account type. The hierarchy is account type → account class → account group → account. Returns one definition by ID.
6978 ///
6979 /// # Example
6980 ///
6981 /// ```
6982 /// # use churchtools_api::*;
6983 /// # use churchtools_api::queries::*;
6984 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
6985 /// # let client = churchtools_api::replay::client("get-finance-accountclasses-id");
6986 /// let account_class = client.finance().account_classes().get(1)?;
6987 /// println!("{}", account_class.name);
6988 /// # Ok(())
6989 /// # }
6990 /// ```
6991 pub fn get(&self, id: impl Display) -> Result<models::AccountClass> {
6992 let path = format!("/finance/accountclasses/{}", seg(id));
6993 let query: Query = Query::new();
6994 self.client.request_data(Method::Get, &path, &query, None)
6995 }
6996
6997 /// Get all account classs
6998 ///
6999 /// `GET /finance/accountclasses`
7000 ///
7001 /// Account classes group account groups within one account type. The hierarchy is account type → account class → account group → account. Returns the complete, unpaginated list ordered by sortKey, then name, ascending. meta.count is the number returned.
7002 ///
7003 /// # Example
7004 ///
7005 /// ```
7006 /// # use churchtools_api::*;
7007 /// # use churchtools_api::queries::*;
7008 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7009 /// # let client = churchtools_api::replay::client("get-finance-accountclasses");
7010 /// for account_class in client.finance().account_classes().list()? {
7011 /// println!("{}", account_class.name);
7012 /// }
7013 /// # Ok(())
7014 /// # }
7015 /// ```
7016 pub fn list(&self) -> Result<Vec<models::AccountClass>> {
7017 let path = "/finance/accountclasses".to_owned();
7018 let query: Query = Query::new();
7019 self.client.request_data(Method::Get, &path, &query, None)
7020 }
7021
7022 /// Update an account class
7023 ///
7024 /// `PUT /finance/accountclasses/{id}`
7025 ///
7026 /// Replaces the editable fields of this definition. Requires finance “edit masterdata”. Names must remain unique. Omitted optional fields are reset to their defaults. includeProfitLoss defaults to false and may be enabled on at most one class.
7027 ///
7028 /// # Example
7029 ///
7030 /// ```no_run
7031 /// # use churchtools_api::*;
7032 /// # use churchtools_api::queries::*;
7033 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7034 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7035 /// let body = models::AccountClassUpdate {
7036 /// account_type_id: 3,
7037 /// name: "Anlagevermögen".into(),
7038 /// ..Default::default()
7039 /// };
7040 /// let result = client.finance().account_classes().update(1, &body)?;
7041 /// println!("{}", result.name);
7042 /// # Ok(())
7043 /// # }
7044 /// ```
7045 pub fn update(&self, id: impl Display, body: &models::AccountClassUpdate) -> Result<models::AccountClass> {
7046 let path = format!("/finance/accountclasses/{}", seg(id));
7047 let query: Query = Query::new();
7048 let body = serde_json::to_value(body).expect("request body serializes");
7049 self.client.request_data(Method::Put, &path, &query, Some(&body))
7050 }
7051
7052}
7053
7054/// `client.finance().account_groups()`
7055#[derive(Clone, Copy)]
7056pub struct FinanceAccountGroupsResource<'a> {
7057 client: &'a Client,
7058}
7059
7060impl<'a> FinanceAccountGroupsResource<'a> {
7061 /// Create new account group
7062 ///
7063 /// `POST /finance/accountgroups`
7064 ///
7065 /// Creates finance master data. Account groups collect individual ledger accounts within one account class. isCashAssetAccount identifies groups of cash or bank accounts. Requires finance “edit masterdata”. Names must be unique across this resource. The successful response uses HTTP 200.
7066 ///
7067 /// # Example
7068 ///
7069 /// ```no_run
7070 /// # use churchtools_api::*;
7071 /// # use churchtools_api::queries::*;
7072 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7073 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7074 /// let body = models::AccountGroupCreate {
7075 /// account_class_id: 2,
7076 /// is_cash_asset_account: false,
7077 /// name: "Sachanlagen".into(),
7078 /// ..Default::default()
7079 /// };
7080 /// let result = client.finance().account_groups().create(&body)?;
7081 /// println!("{}", result.name);
7082 /// # Ok(())
7083 /// # }
7084 /// ```
7085 pub fn create(&self, body: &models::AccountGroupCreate) -> Result<models::AccountGroup> {
7086 let path = "/finance/accountgroups".to_owned();
7087 let query: Query = Query::new();
7088 let body = serde_json::to_value(body).expect("request body serializes");
7089 self.client.request_data(Method::Post, &path, &query, Some(&body))
7090 }
7091
7092 /// Delete account group
7093 ///
7094 /// `DELETE /finance/accountgroups/{id}`
7095 ///
7096 /// Deletes this definition if no accounts reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, including when deletion would be allowed.
7097 ///
7098 /// Use [`Self::delete_with`] to pass query parameters.
7099 ///
7100 /// # Example
7101 ///
7102 /// ```no_run
7103 /// # use churchtools_api::*;
7104 /// # use churchtools_api::queries::*;
7105 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7106 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7107 /// client.finance().account_groups().delete(1)?;
7108 /// # Ok(())
7109 /// # }
7110 /// ```
7111 pub fn delete(&self, id: impl Display) -> Result<()> {
7112 self.delete_with(id, &Default::default())
7113 }
7114
7115 /// Delete account group
7116 ///
7117 /// Like [`Self::delete`], with query parameters.
7118 ///
7119 /// `DELETE /finance/accountgroups/{id}`
7120 ///
7121 /// Deletes this definition if no accounts reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, including when deletion would be allowed.
7122 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceAccountgroupsIdQuery) -> Result<()> {
7123 let path = format!("/finance/accountgroups/{}", seg(id));
7124 let query: Query = query.to_query();
7125 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
7126 }
7127
7128 /// Get a account group
7129 ///
7130 /// `GET /finance/accountgroups/{id}`
7131 ///
7132 /// Account groups collect individual ledger accounts within one account class. isCashAssetAccount identifies groups of cash or bank accounts. Returns one definition by ID.
7133 ///
7134 /// # Example
7135 ///
7136 /// ```
7137 /// # use churchtools_api::*;
7138 /// # use churchtools_api::queries::*;
7139 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7140 /// # let client = churchtools_api::replay::client("get-finance-accountgroups-id");
7141 /// let account_group = client.finance().account_groups().get(1)?;
7142 /// println!("{}", account_group.name);
7143 /// # Ok(())
7144 /// # }
7145 /// ```
7146 pub fn get(&self, id: impl Display) -> Result<models::AccountGroup> {
7147 let path = format!("/finance/accountgroups/{}", seg(id));
7148 let query: Query = Query::new();
7149 self.client.request_data(Method::Get, &path, &query, None)
7150 }
7151
7152 /// Get all account groups
7153 ///
7154 /// `GET /finance/accountgroups`
7155 ///
7156 /// Account groups collect individual ledger accounts within one account class. isCashAssetAccount identifies groups of cash or bank accounts. Returns the complete, unpaginated list ordered by sortKey, then name, ascending. meta.count is the number returned.
7157 ///
7158 /// # Example
7159 ///
7160 /// ```
7161 /// # use churchtools_api::*;
7162 /// # use churchtools_api::queries::*;
7163 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7164 /// # let client = churchtools_api::replay::client("get-finance-accountgroups");
7165 /// for account_group in client.finance().account_groups().list()? {
7166 /// println!("{}", account_group.name);
7167 /// }
7168 /// # Ok(())
7169 /// # }
7170 /// ```
7171 pub fn list(&self) -> Result<Vec<models::AccountGroup>> {
7172 let path = "/finance/accountgroups".to_owned();
7173 let query: Query = Query::new();
7174 self.client.request_data(Method::Get, &path, &query, None)
7175 }
7176
7177 /// Update account group
7178 ///
7179 /// `PUT /finance/accountgroups/{id}`
7180 ///
7181 /// Replaces the editable fields of this definition. Requires finance “edit masterdata”. Names must remain unique. Omitted optional fields are reset to their defaults. sortKey defaults to 0.
7182 ///
7183 /// # Example
7184 ///
7185 /// ```no_run
7186 /// # use churchtools_api::*;
7187 /// # use churchtools_api::queries::*;
7188 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7189 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7190 /// let body = models::AccountGroupUpdate {
7191 /// account_class_id: 2,
7192 /// is_cash_asset_account: false,
7193 /// name: "Sachanlagen".into(),
7194 /// ..Default::default()
7195 /// };
7196 /// let result = client.finance().account_groups().update(1, &body)?;
7197 /// println!("{}", result.name);
7198 /// # Ok(())
7199 /// # }
7200 /// ```
7201 pub fn update(&self, id: impl Display, body: &models::AccountGroupUpdate) -> Result<models::AccountGroup> {
7202 let path = format!("/finance/accountgroups/{}", seg(id));
7203 let query: Query = Query::new();
7204 let body = serde_json::to_value(body).expect("request body serializes");
7205 self.client.request_data(Method::Put, &path, &query, Some(&body))
7206 }
7207
7208}
7209
7210/// `client.finance().account_types()`
7211#[derive(Clone, Copy)]
7212pub struct FinanceAccountTypesResource<'a> {
7213 client: &'a Client,
7214}
7215
7216impl<'a> FinanceAccountTypesResource<'a> {
7217 /// Create new account type
7218 ///
7219 /// `POST /finance/accounttypes`
7220 ///
7221 /// Creates finance master data. Account types are the top level of the finance chart of accounts. They distinguish assets, liabilities and profit-and-loss accounts. Each account class belongs to one account type. Requires finance “edit masterdata”. Names must be unique across this resource. The successful response uses HTTP 200.
7222 ///
7223 /// # Example
7224 ///
7225 /// ```no_run
7226 /// # use churchtools_api::*;
7227 /// # use churchtools_api::queries::*;
7228 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7229 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7230 /// let body = models::AccountTypeCreate {
7231 /// name: "Aktiva".into(),
7232 /// ..Default::default()
7233 /// };
7234 /// let result = client.finance().account_types().create(&body)?;
7235 /// println!("{}", result.name);
7236 /// # Ok(())
7237 /// # }
7238 /// ```
7239 pub fn create(&self, body: &models::AccountTypeCreate) -> Result<models::AccountType> {
7240 let path = "/finance/accounttypes".to_owned();
7241 let query: Query = Query::new();
7242 let body = serde_json::to_value(body).expect("request body serializes");
7243 self.client.request_data(Method::Post, &path, &query, Some(&body))
7244 }
7245
7246 /// Delete account type
7247 ///
7248 /// `DELETE /finance/accounttypes/{id}`
7249 ///
7250 /// Deletes this definition if no account classes reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, including when deletion would be allowed.
7251 ///
7252 /// Use [`Self::delete_with`] to pass query parameters.
7253 ///
7254 /// # Example
7255 ///
7256 /// ```no_run
7257 /// # use churchtools_api::*;
7258 /// # use churchtools_api::queries::*;
7259 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7260 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7261 /// client.finance().account_types().delete(1)?;
7262 /// # Ok(())
7263 /// # }
7264 /// ```
7265 pub fn delete(&self, id: impl Display) -> Result<()> {
7266 self.delete_with(id, &Default::default())
7267 }
7268
7269 /// Delete account type
7270 ///
7271 /// Like [`Self::delete`], with query parameters.
7272 ///
7273 /// `DELETE /finance/accounttypes/{id}`
7274 ///
7275 /// Deletes this definition if no account classes reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, including when deletion would be allowed.
7276 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceAccounttypesIdQuery) -> Result<()> {
7277 let path = format!("/finance/accounttypes/{}", seg(id));
7278 let query: Query = query.to_query();
7279 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
7280 }
7281
7282 /// Get a account type
7283 ///
7284 /// `GET /finance/accounttypes/{id}`
7285 ///
7286 /// Account types are the top level of the finance chart of accounts. They distinguish assets, liabilities and profit-and-loss accounts. Each account class belongs to one account type. Returns one definition by ID.
7287 ///
7288 /// # Example
7289 ///
7290 /// ```
7291 /// # use churchtools_api::*;
7292 /// # use churchtools_api::queries::*;
7293 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7294 /// # let client = churchtools_api::replay::client("get-finance-accounttypes-id");
7295 /// let account_type = client.finance().account_types().get(1)?;
7296 /// println!("{}", account_type.name);
7297 /// # Ok(())
7298 /// # }
7299 /// ```
7300 pub fn get(&self, id: impl Display) -> Result<models::AccountType> {
7301 let path = format!("/finance/accounttypes/{}", seg(id));
7302 let query: Query = Query::new();
7303 self.client.request_data(Method::Get, &path, &query, None)
7304 }
7305
7306 /// Get all account types
7307 ///
7308 /// `GET /finance/accounttypes`
7309 ///
7310 /// Account types are the top level of the finance chart of accounts. They distinguish assets, liabilities and profit-and-loss accounts. Each account class belongs to one account type. Returns the complete, unpaginated list ordered by sortKey, then name, ascending. meta.count is the number returned.
7311 ///
7312 /// # Example
7313 ///
7314 /// ```
7315 /// # use churchtools_api::*;
7316 /// # use churchtools_api::queries::*;
7317 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7318 /// # let client = churchtools_api::replay::client("get-finance-accounttypes");
7319 /// for account_type in client.finance().account_types().list()? {
7320 /// println!("{}", account_type.name);
7321 /// }
7322 /// # Ok(())
7323 /// # }
7324 /// ```
7325 pub fn list(&self) -> Result<Vec<models::AccountType>> {
7326 let path = "/finance/accounttypes".to_owned();
7327 let query: Query = Query::new();
7328 self.client.request_data(Method::Get, &path, &query, None)
7329 }
7330
7331 /// Update account type
7332 ///
7333 /// `PUT /finance/accounttypes/{id}`
7334 ///
7335 /// Replaces the editable fields of this definition. Requires finance “edit masterdata”. Names must remain unique. Omitted optional fields are reset to their defaults. Omitting balanceType changes the type to profit-and-loss.
7336 ///
7337 /// # Example
7338 ///
7339 /// ```no_run
7340 /// # use churchtools_api::*;
7341 /// # use churchtools_api::queries::*;
7342 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7343 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7344 /// let body = models::AccountTypeUpdate {
7345 /// name: "Aktiva".into(),
7346 /// ..Default::default()
7347 /// };
7348 /// let result = client.finance().account_types().update(1, &body)?;
7349 /// println!("{}", result.name);
7350 /// # Ok(())
7351 /// # }
7352 /// ```
7353 pub fn update(&self, id: impl Display, body: &models::AccountTypeUpdate) -> Result<models::AccountType> {
7354 let path = format!("/finance/accounttypes/{}", seg(id));
7355 let query: Query = Query::new();
7356 let body = serde_json::to_value(body).expect("request body serializes");
7357 self.client.request_data(Method::Put, &path, &query, Some(&body))
7358 }
7359
7360}
7361
7362/// `client.finance().accounting_periods()`
7363#[derive(Clone, Copy)]
7364pub struct FinanceAccountingPeriodsResource<'a> {
7365 client: &'a Client,
7366}
7367
7368impl<'a> FinanceAccountingPeriodsResource<'a> {
7369 pub fn accounts(&self) -> FinanceAccountingPeriodsAccountsResource<'a> {
7370 FinanceAccountingPeriodsAccountsResource { client: self.client }
7371 }
7372
7373 pub fn statements(&self) -> FinanceAccountingPeriodsStatementsResource<'a> {
7374 FinanceAccountingPeriodsStatementsResource { client: self.client }
7375 }
7376
7377 /// Create new accounting period
7378 ///
7379 /// `POST /finance/accountingperiods`
7380 ///
7381 /// Creates an accounting period and optionally copies master data and transfers opening balances. Requires finance “edit masterdata”. The combination of clientId, startDate and endDate must be unique. Returns HTTP 201. Exceptions during creation, copying or balance transfer are rolled back and reported as HTTP 400, including a missing client.
7382 ///
7383 /// # Example
7384 ///
7385 /// ```no_run
7386 /// # use churchtools_api::*;
7387 /// # use churchtools_api::queries::*;
7388 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7389 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7390 /// let body = models::AccountingPeriodCreate {
7391 /// client_id: 1,
7392 /// end_date: "2026-12-31".parse()?,
7393 /// increment_document_number: true,
7394 /// is_closed: false,
7395 /// start_date: "2026-01-01".parse()?,
7396 /// ..Default::default()
7397 /// };
7398 /// let result = client.finance().accounting_periods().create(&body)?;
7399 /// println!("{}", result.id);
7400 /// # Ok(())
7401 /// # }
7402 /// ```
7403 pub fn create(&self, body: &models::AccountingPeriodCreate) -> Result<models::AccountingPeriod> {
7404 let path = "/finance/accountingperiods".to_owned();
7405 let query: Query = Query::new();
7406 let body = serde_json::to_value(body).expect("request body serializes");
7407 self.client.request_data(Method::Post, &path, &query, Some(&body))
7408 }
7409
7410 /// Delete accounting period
7411 ///
7412 /// `DELETE /finance/accountingperiods/{id}`
7413 ///
7414 /// Deletes a period when its accounts no longer block deletion. Requires finance “edit masterdata”. The last accounting period in the installation cannot be deleted. Cost centers are treated as removable dependencies; associated authorization entries and donation receipts are cleaned up. dry_run=true returns the HTTP 409 conflict report without deleting, including when deletion is allowed.
7415 ///
7416 /// Use [`Self::delete_with`] to pass query parameters.
7417 ///
7418 /// # Example
7419 ///
7420 /// ```no_run
7421 /// # use churchtools_api::*;
7422 /// # use churchtools_api::queries::*;
7423 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7424 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7425 /// client.finance().accounting_periods().delete(1)?;
7426 /// # Ok(())
7427 /// # }
7428 /// ```
7429 pub fn delete(&self, id: impl Display) -> Result<()> {
7430 self.delete_with(id, &Default::default())
7431 }
7432
7433 /// Delete accounting period
7434 ///
7435 /// Like [`Self::delete`], with query parameters.
7436 ///
7437 /// `DELETE /finance/accountingperiods/{id}`
7438 ///
7439 /// Deletes a period when its accounts no longer block deletion. Requires finance “edit masterdata”. The last accounting period in the installation cannot be deleted. Cost centers are treated as removable dependencies; associated authorization entries and donation receipts are cleaned up. dry_run=true returns the HTTP 409 conflict report without deleting, including when deletion is allowed.
7440 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceAccountingperiodsIdQuery) -> Result<()> {
7441 let path = format!("/finance/accountingperiods/{}", seg(id));
7442 let query: Query = query.to_query();
7443 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
7444 }
7445
7446 /// Delete tax rates for accounting period
7447 ///
7448 /// `DELETE /finance/accountingperiods/{id}/taxrates`
7449 ///
7450 /// Deletes all tax rates whose receiving accounts belong to this accounting period. Requires finance “edit masterdata”. The operation first clears the default taxRateId of every account in the period, then deletes its tax rates in one transaction. References from transactions prevent deletion and return 400. An unknown or empty period succeeds without changes. Unlike single deletion, this operation does not support dry_run.
7451 ///
7452 /// # Example
7453 ///
7454 /// ```no_run
7455 /// # use churchtools_api::*;
7456 /// # use churchtools_api::queries::*;
7457 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7458 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7459 /// client.finance().accounting_periods().delete_tax_rates(1)?;
7460 /// # Ok(())
7461 /// # }
7462 /// ```
7463 pub fn delete_tax_rates(&self, id: impl Display) -> Result<()> {
7464 let path = format!("/finance/accountingperiods/{}/taxrates", seg(id));
7465 let query: Query = Query::new();
7466 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
7467 }
7468
7469 /// Get an accounting period
7470 ///
7471 /// `GET /finance/accountingperiods/{id}`
7472 ///
7473 /// Returns one accounting period visible to the caller through global or group-internal finance permissions. A period rejected by the visibility check returns 403 before it is loaded.
7474 ///
7475 /// # Example
7476 ///
7477 /// ```
7478 /// # use churchtools_api::*;
7479 /// # use churchtools_api::queries::*;
7480 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7481 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods-id");
7482 /// let accounting_period = client.finance().accounting_periods().get(1)?;
7483 /// println!("{}", accounting_period.id);
7484 /// # Ok(())
7485 /// # }
7486 /// ```
7487 pub fn get(&self, id: impl Display) -> Result<models::AccountingPeriod> {
7488 let path = format!("/finance/accountingperiods/{}", seg(id));
7489 let query: Query = Query::new();
7490 self.client.request_data(Method::Get, &path, &query, None)
7491 }
7492
7493 /// Get all accounting periods
7494 ///
7495 /// `GET /finance/accountingperiods`
7496 ///
7497 /// An accounting period is the date range for one finance client’s books, usually a financial year. Accounts and cost centers belong to a period. Closing a period prevents ordinary account and transaction changes; it is separate from making individual transactions immutable. Returns an unpaginated list of periods visible through global finance permissions or group-internal cost-center rights, ordered by startDate ascending. Finance master-data editors can see all periods. meta.count is the number returned.
7498 ///
7499 /// # Example
7500 ///
7501 /// ```
7502 /// # use churchtools_api::*;
7503 /// # use churchtools_api::queries::*;
7504 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7505 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods");
7506 /// for accounting_period in client.finance().accounting_periods().list()? {
7507 /// println!("{}", accounting_period.id);
7508 /// }
7509 /// # Ok(())
7510 /// # }
7511 /// ```
7512 pub fn list(&self) -> Result<Vec<models::AccountingPeriod>> {
7513 let path = "/finance/accountingperiods".to_owned();
7514 let query: Query = Query::new();
7515 self.client.request_data(Method::Get, &path, &query, None)
7516 }
7517
7518 /// Get bills for accounting period
7519 ///
7520 /// `GET /finance/accountingperiods/{id}/bills`
7521 ///
7522 /// Returns a page of supporting documents for an accounting period. Requires permission to view or edit the whole accounting period; access to individual transactions alone is insufficient for this list. Explicit order_by=submittedDate sorts by submission date and then bill ID in the same direction. Without order_by no order is guaranteed. The only supported query parameters are pagination and ordering; submitter/date/text filters are not exposed by this endpoint.
7523 ///
7524 /// Use [`Self::list_bills_with`] to pass query parameters.
7525 ///
7526 /// # Example
7527 ///
7528 /// ```
7529 /// # use churchtools_api::*;
7530 /// # use churchtools_api::queries::*;
7531 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7532 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods-id-bills");
7533 /// for bill in client.finance().accounting_periods().list_bills(1)? {
7534 /// println!("{}", bill.id);
7535 /// }
7536 /// # Ok(())
7537 /// # }
7538 /// ```
7539 pub fn list_bills(&self, id: impl Display) -> Result<Vec<models::Bill>> {
7540 self.list_bills_with(id, &Default::default())
7541 }
7542
7543 /// Get bills for accounting period
7544 ///
7545 /// Like [`Self::list_bills`], with query parameters.
7546 ///
7547 /// `GET /finance/accountingperiods/{id}/bills`
7548 ///
7549 /// Returns a page of supporting documents for an accounting period. Requires permission to view or edit the whole accounting period; access to individual transactions alone is insufficient for this list. Explicit order_by=submittedDate sorts by submission date and then bill ID in the same direction. Without order_by no order is guaranteed. The only supported query parameters are pagination and ordering; submitter/date/text filters are not exposed by this endpoint.
7550 pub fn list_bills_with(&self, id: impl Display, query: &GetFinanceAccountingperiodsIdBillsQuery) -> Result<Vec<models::Bill>> {
7551 let path = format!("/finance/accountingperiods/{}/bills", seg(id));
7552 let query: Query = query.to_query();
7553 self.client.collect_pages(&path, query)
7554 }
7555
7556 /// Get bills for accounting period
7557 ///
7558 /// Like [`Self::list_bills_with`], but lazy: each page is fetched only when the iteration reaches it.
7559 /// Breaking off early saves the remaining requests.
7560 pub fn list_bills_iter(&self, id: impl Display, query: &GetFinanceAccountingperiodsIdBillsQuery) -> Items<models::Bill> {
7561 let path = format!("/finance/accountingperiods/{}/bills", seg(id));
7562 self.client.items(&path, query.to_query())
7563 }
7564
7565 /// Get statement suggestion rules
7566 ///
7567 /// `GET /finance/accountingperiods/{id}/userrules`
7568 ///
7569 /// Returns all suggestion rules for an accounting period, ordered by sortKey ascending, without pagination. Both reading and replacing these rules require edit accounting period permission. meta.count is the number returned.
7570 ///
7571 /// # Example
7572 ///
7573 /// ```
7574 /// # use churchtools_api::*;
7575 /// # use churchtools_api::queries::*;
7576 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7577 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods-id-userrules");
7578 /// for user_rule in client.finance().accounting_periods().list_user_rules(1)? {
7579 /// println!("{}", user_rule.id);
7580 /// }
7581 /// # Ok(())
7582 /// # }
7583 /// ```
7584 pub fn list_user_rules(&self, id: impl Display) -> Result<Vec<models::UserRule>> {
7585 let path = format!("/finance/accountingperiods/{}/userrules", seg(id));
7586 let query: Query = Query::new();
7587 self.client.request_data(Method::Get, &path, &query, None)
7588 }
7589
7590 /// Update accounting period
7591 ///
7592 /// `PUT /finance/accountingperiods/{id}`
7593 ///
7594 /// Replaces period dates, client, closed state and document-number behavior. Requires finance “edit masterdata”; ordinary edit accounting period permission alone is insufficient. The date/client combination must remain unique. Optionally transfer opening balances or, when closing, make transactions immutable with setImmutability. Reopening does not make transactions editable again. Period settings are saved before these additional actions execute.
7595 ///
7596 /// # Example
7597 ///
7598 /// ```no_run
7599 /// # use churchtools_api::*;
7600 /// # use churchtools_api::queries::*;
7601 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7602 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7603 /// let body = models::AccountingPeriodUpdate {
7604 /// client_id: 1,
7605 /// end_date: "2026-12-31".parse()?,
7606 /// increment_document_number: true,
7607 /// is_closed: false,
7608 /// start_date: "2026-01-01".parse()?,
7609 /// ..Default::default()
7610 /// };
7611 /// let result = client.finance().accounting_periods().update(1, &body)?;
7612 /// println!("{}", result.id);
7613 /// # Ok(())
7614 /// # }
7615 /// ```
7616 pub fn update(&self, id: impl Display, body: &models::AccountingPeriodUpdate) -> Result<models::AccountingPeriod> {
7617 let path = format!("/finance/accountingperiods/{}", seg(id));
7618 let query: Query = Query::new();
7619 let body = serde_json::to_value(body).expect("request body serializes");
7620 self.client.request_data(Method::Put, &path, &query, Some(&body))
7621 }
7622
7623 /// Replace statement suggestion rules
7624 ///
7625 /// `PUT /finance/accountingperiods/{id}/userrules`
7626 ///
7627 /// Replaces the entire rule set for an accounting period and returns the new records ordered by sortKey. Send rules: \[\] to remove all rules. Existing IDs are discarded and newly inserted rules receive new IDs. Requires edit accounting period permission. This saves rules only; it does not regenerate existing movement suggestions. Deletion and insertion are not enclosed in a single transaction.
7628 ///
7629 /// # Example
7630 ///
7631 /// ```no_run
7632 /// # use churchtools_api::*;
7633 /// # use churchtools_api::queries::*;
7634 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7635 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7636 /// let body = models::UserRulesUpdate {
7637 /// rules: vec![models::UserRuleCreate {
7638 /// account_ids: vec![5],
7639 /// all_accounts: false,
7640 /// is_income: true,
7641 /// operator: "contains".into(),
7642 /// search_string: "Donation".into(),
7643 /// search_type: "purpose".into(),
7644 /// sort_key: 0,
7645 /// suggestion_type: "costCenterId".into(),
7646 /// suggestion_value: "8".into(),
7647 /// ..Default::default()
7648 /// }],
7649 /// ..Default::default()
7650 /// };
7651 /// for accounting_period in client.finance().accounting_periods().update_user_rules(1, &body)? {
7652 /// println!("{}", accounting_period.id);
7653 /// }
7654 /// # Ok(())
7655 /// # }
7656 /// ```
7657 pub fn update_user_rules(&self, id: impl Display, body: &models::UserRulesUpdate) -> Result<Vec<models::UserRule>> {
7658 let path = format!("/finance/accountingperiods/{}/userrules", seg(id));
7659 let query: Query = Query::new();
7660 let body = serde_json::to_value(body).expect("request body serializes");
7661 self.client.request_data(Method::Put, &path, &query, Some(&body))
7662 }
7663
7664}
7665
7666/// `client.finance().accounting_periods().accounts()`
7667#[derive(Clone, Copy)]
7668pub struct FinanceAccountingPeriodsAccountsResource<'a> {
7669 client: &'a Client,
7670}
7671
7672impl<'a> FinanceAccountingPeriodsAccountsResource<'a> {
7673 pub fn statements(&self) -> FinanceAccountingPeriodsAccountsStatementsResource<'a> {
7674 FinanceAccountingPeriodsAccountsStatementsResource { client: self.client }
7675 }
7676
7677 /// Delete accounts for accounting period
7678 ///
7679 /// `DELETE /finance/accountingperiods/{id}/accounts`
7680 ///
7681 /// Deletes all accounts of one accounting period. Requires finance “edit masterdata”. Existing transactions using any of these accounts as account or contra account prevent deletion with HTTP 400. The service removes associated bank statements and transaction purposes, clears account tax-rate links and deletes the period’s tax rates before deleting the accounts in a transaction. This endpoint does not support dry_run. It does not require the period to exist or be open.
7682 ///
7683 /// # Example
7684 ///
7685 /// ```no_run
7686 /// # use churchtools_api::*;
7687 /// # use churchtools_api::queries::*;
7688 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7689 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7690 /// client.finance().accounting_periods().accounts().delete(1)?;
7691 /// # Ok(())
7692 /// # }
7693 /// ```
7694 pub fn delete(&self, id: impl Display) -> Result<()> {
7695 let path = format!("/finance/accountingperiods/{}/accounts", seg(id));
7696 let query: Query = Query::new();
7697 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
7698 }
7699
7700 /// Get all movements of an account
7701 ///
7702 /// `GET /finance/accountingperiods/{id}/accounts/{accountId}/movements`
7703 ///
7704 /// Returns a page of imported movements, ordered by documentDate and then numberInStatement ascending. Requires edit accounting period permission for the actual account. Suggestions are always serialized; include\[\]=bills expands their attached documents. The period ID in the URL is not cross-checked against the account.
7705 ///
7706 /// Use [`Self::list_movements_with`] to pass query parameters.
7707 ///
7708 /// # Example
7709 ///
7710 /// ```
7711 /// # use churchtools_api::*;
7712 /// # use churchtools_api::queries::*;
7713 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7714 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods-id-accounts-id-movements");
7715 /// for movement in client.finance().accounting_periods().accounts().list_movements(1, 42)? {
7716 /// println!("{}", movement.id);
7717 /// }
7718 /// # Ok(())
7719 /// # }
7720 /// ```
7721 pub fn list_movements(&self, id: impl Display, account_id: impl Display) -> Result<Vec<models::StatementMovement>> {
7722 self.list_movements_with(id, account_id, &Default::default())
7723 }
7724
7725 /// Get all movements of an account
7726 ///
7727 /// Like [`Self::list_movements`], with query parameters.
7728 ///
7729 /// `GET /finance/accountingperiods/{id}/accounts/{accountId}/movements`
7730 ///
7731 /// Returns a page of imported movements, ordered by documentDate and then numberInStatement ascending. Requires edit accounting period permission for the actual account. Suggestions are always serialized; include\[\]=bills expands their attached documents. The period ID in the URL is not cross-checked against the account.
7732 pub fn list_movements_with(&self, id: impl Display, account_id: impl Display, query: &GetFinanceAccountingperiodsIdAccountsIdMovementsQuery) -> Result<Vec<models::StatementMovement>> {
7733 let path = format!("/finance/accountingperiods/{}/accounts/{}/movements", seg(id), seg(account_id));
7734 let query: Query = query.to_query();
7735 self.client.collect_pages(&path, query)
7736 }
7737
7738 /// Get all movements of an account
7739 ///
7740 /// Like [`Self::list_movements_with`], but lazy: each page is fetched only when the iteration reaches it.
7741 /// Breaking off early saves the remaining requests.
7742 pub fn list_movements_iter(&self, id: impl Display, account_id: impl Display, query: &GetFinanceAccountingperiodsIdAccountsIdMovementsQuery) -> Items<models::StatementMovement> {
7743 let path = format!("/finance/accountingperiods/{}/accounts/{}/movements", seg(id), seg(account_id));
7744 self.client.items(&path, query.to_query())
7745 }
7746
7747 /// Get per-account statement movement statistics
7748 ///
7749 /// `GET /finance/accountingperiods/{id}/accounts/statements`
7750 ///
7751 /// Returns per-account movement statistics across all imported statements of the accounting period. Only accounts that have at least one statement movement are included. For each account the number of movements is grouped by state (`open`, `booked`, `ignored`); a state key is only present when the account has movements in that state. Requires edit accounting period permission. The response has no outer meta object and no guaranteed account order.
7752 ///
7753 /// # Example
7754 ///
7755 /// ```
7756 /// # use churchtools_api::*;
7757 /// # use churchtools_api::queries::*;
7758 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7759 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods-id-accounts-statements");
7760 /// for statement in client.finance().accounting_periods().accounts().list_statements(1)? {
7761 /// println!("{}", statement.account_id);
7762 /// }
7763 /// # Ok(())
7764 /// # }
7765 /// ```
7766 pub fn list_statements(&self, id: impl Display) -> Result<Vec<models::AccountStatementStatistics>> {
7767 let path = format!("/finance/accountingperiods/{}/accounts/statements", seg(id));
7768 let query: Query = Query::new();
7769 self.client.request_data(Method::Get, &path, &query, None)
7770 }
7771
7772}
7773
7774/// `client.finance().accounting_periods().accounts().statements()`
7775#[derive(Clone, Copy)]
7776pub struct FinanceAccountingPeriodsAccountsStatementsResource<'a> {
7777 client: &'a Client,
7778}
7779
7780impl<'a> FinanceAccountingPeriodsAccountsStatementsResource<'a> {
7781 pub fn movements(&self) -> FinanceAccountingPeriodsAccountsStatementsMovementsResource<'a> {
7782 FinanceAccountingPeriodsAccountsStatementsMovementsResource { client: self.client }
7783 }
7784
7785 /// Get imported statements for an account
7786 ///
7787 /// `GET /finance/accountingperiods/{id}/accounts/{accountId}/statements`
7788 ///
7789 /// Returns all statements for the account, sorted by startDate descending, without pagination. Each statement includes counts for open, booked and ignored movements and their sum. Requires edit accounting period permission. An account outside the path’s accounting period returns HTTP 404.
7790 ///
7791 /// # Example
7792 ///
7793 /// ```
7794 /// # use churchtools_api::*;
7795 /// # use churchtools_api::queries::*;
7796 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7797 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods-id-accounts-id-statements");
7798 /// for statement in client.finance().accounting_periods().accounts().statements().list(1, 5)? {
7799 /// println!("{}", statement.name);
7800 /// }
7801 /// # Ok(())
7802 /// # }
7803 /// ```
7804 pub fn list(&self, id: impl Display, account_id: impl Display) -> Result<Vec<models::AccountStatement>> {
7805 let path = format!("/finance/accountingperiods/{}/accounts/{}/statements", seg(id), seg(account_id));
7806 let query: Query = Query::new();
7807 self.client.request_data(Method::Get, &path, &query, None)
7808 }
7809
7810}
7811
7812/// `client.finance().accounting_periods().accounts().statements().movements()`
7813#[derive(Clone, Copy)]
7814pub struct FinanceAccountingPeriodsAccountsStatementsMovementsResource<'a> {
7815 client: &'a Client,
7816}
7817
7818impl<'a> FinanceAccountingPeriodsAccountsStatementsMovementsResource<'a> {
7819 /// Update the state of a movement
7820 ///
7821 /// `POST /finance/accountingperiods/{id}/accounts/{accountId}/statements/{statementId}/movements/{movementId}`
7822 ///
7823 /// Changes the movement state and returns its associated transaction, or an empty array when none is linked. A transition from any state other than booked to booked creates a new transaction from the current suggestions. Required ordinary-booking fields are documentDate, accountId, contraAccountId and amount, plus documentNumber unless automatic numbering is active. Split suggestions create a split booking and return its first non-tax child. Switching to open or ignored does not undo the existing transaction; booking again can create another transaction. Requires edit accounting period permission for the movement’s actual period; parent IDs in the URL are not cross-checked.
7824 ///
7825 /// # Example
7826 ///
7827 /// ```no_run
7828 /// # use churchtools_api::*;
7829 /// # use churchtools_api::queries::*;
7830 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7831 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7832 /// let body = models::StatementMovementUpdate {
7833 /// state: "booked".into(),
7834 /// ..Default::default()
7835 /// };
7836 /// let result = client.finance().accounting_periods().accounts().statements().movements().create(1, 42, 7, 123, &body)?;
7837 /// println!("{:?}", result);
7838 /// # Ok(())
7839 /// # }
7840 /// ```
7841 pub fn create(&self, id: impl Display, account_id: impl Display, statement_id: impl Display, movement_id: impl Display, body: &models::StatementMovementUpdate) -> Result<serde_json::Value> {
7842 let path = format!("/finance/accountingperiods/{}/accounts/{}/statements/{}/movements/{}", seg(id), seg(account_id), seg(statement_id), seg(movement_id));
7843 let query: Query = Query::new();
7844 let body = serde_json::to_value(body).expect("request body serializes");
7845 self.client.request_data(Method::Post, &path, &query, Some(&body))
7846 }
7847
7848 /// Get all movements of a statement
7849 ///
7850 /// `GET /finance/accountingperiods/{id}/accounts/{accountId}/statements/{statementId}/movements`
7851 ///
7852 /// Returns a page of imported movements, ordered by documentDate and then numberInStatement ascending. Requires edit accounting period permission for the actual account. Suggestions are always serialized; include\[\]=bills expands their attached documents. The statement must belong to the URL period (otherwise HTTP 404); the URL accountId is not cross-checked.
7853 ///
7854 /// Use [`Self::list_with`] to pass query parameters.
7855 ///
7856 /// # Example
7857 ///
7858 /// ```
7859 /// # use churchtools_api::*;
7860 /// # use churchtools_api::queries::*;
7861 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7862 /// # let client = churchtools_api::replay::client("get-finance-accountingperiods-id-accounts-id-statements-id-movements");
7863 /// for movement in client.finance().accounting_periods().accounts().statements().movements().list(1, 42, 7)? {
7864 /// println!("{}", movement.id);
7865 /// }
7866 /// # Ok(())
7867 /// # }
7868 /// ```
7869 pub fn list(&self, id: impl Display, account_id: impl Display, statement_id: impl Display) -> Result<Vec<models::StatementMovement>> {
7870 self.list_with(id, account_id, statement_id, &Default::default())
7871 }
7872
7873 /// Get all movements of a statement
7874 ///
7875 /// Like [`Self::list`], with query parameters.
7876 ///
7877 /// `GET /finance/accountingperiods/{id}/accounts/{accountId}/statements/{statementId}/movements`
7878 ///
7879 /// Returns a page of imported movements, ordered by documentDate and then numberInStatement ascending. Requires edit accounting period permission for the actual account. Suggestions are always serialized; include\[\]=bills expands their attached documents. The statement must belong to the URL period (otherwise HTTP 404); the URL accountId is not cross-checked.
7880 pub fn list_with(&self, id: impl Display, account_id: impl Display, statement_id: impl Display, query: &GetFinanceAccountingperiodsIdAccountsIdStatementsIdMovementsQuery) -> Result<Vec<models::StatementMovement>> {
7881 let path = format!("/finance/accountingperiods/{}/accounts/{}/statements/{}/movements", seg(id), seg(account_id), seg(statement_id));
7882 let query: Query = query.to_query();
7883 self.client.collect_pages(&path, query)
7884 }
7885
7886 /// Get all movements of a statement
7887 ///
7888 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
7889 /// Breaking off early saves the remaining requests.
7890 pub fn list_iter(&self, id: impl Display, account_id: impl Display, statement_id: impl Display, query: &GetFinanceAccountingperiodsIdAccountsIdStatementsIdMovementsQuery) -> Items<models::StatementMovement> {
7891 let path = format!("/finance/accountingperiods/{}/accounts/{}/statements/{}/movements", seg(id), seg(account_id), seg(statement_id));
7892 self.client.items(&path, query.to_query())
7893 }
7894
7895 /// Update movement suggestions
7896 ///
7897 /// `PATCH /finance/accountingperiods/{id}/accounts/{accountId}/statements/{statementId}/movements/{movementId}/suggestions`
7898 ///
7899 /// Applies incremental edits to a movement’s booking suggestions. Matches existing fields by name and splitKey. Non-empty values create or change a suggestion; an empty string removes it. Other suggestions are retained. Modified values receive confidence 100 and userOverwrite=true. Repeating an identical value leaves metadata unchanged. Requires edit accounting period permission for the movement’s actual period. Parent IDs in the URL are not cross-checked. Split keys require the split-booking feature.
7900 ///
7901 /// # Example
7902 ///
7903 /// ```no_run
7904 /// # use churchtools_api::*;
7905 /// # use churchtools_api::queries::*;
7906 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7907 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7908 /// let body = models::MovementSuggestionsUpdate {
7909 /// suggestions: vec![models::MovementSuggestionUpdate {
7910 /// name: "costCenterId".into(),
7911 /// value: "8".into(),
7912 /// ..Default::default()
7913 /// }],
7914 /// ..Default::default()
7915 /// };
7916 /// client.finance().accounting_periods().accounts().statements().movements().patch_suggestions(1, 7, 7, 7, &body)?;
7917 /// # Ok(())
7918 /// # }
7919 /// ```
7920 pub fn patch_suggestions(&self, id: impl Display, account_id: impl Display, statement_id: impl Display, movement_id: impl Display, body: &models::MovementSuggestionsUpdate) -> Result<()> {
7921 let path = format!("/finance/accountingperiods/{}/accounts/{}/statements/{}/movements/{}/suggestions", seg(id), seg(account_id), seg(statement_id), seg(movement_id));
7922 let query: Query = Query::new();
7923 let body = serde_json::to_value(body).expect("request body serializes");
7924 self.client.request(Method::Patch, &path, &query, Some(&body)).map(|_| ())
7925 }
7926
7927}
7928
7929/// `client.finance().accounting_periods().statements()`
7930#[derive(Clone, Copy)]
7931pub struct FinanceAccountingPeriodsStatementsResource<'a> {
7932 client: &'a Client,
7933}
7934
7935impl<'a> FinanceAccountingPeriodsStatementsResource<'a> {
7936 /// Delete a statement
7937 ///
7938 /// `DELETE /finance/accountingperiods/{id}/statements/{statementId}`
7939 ///
7940 /// Deletes an imported statement, its movements, suggestions and source file. Finance transactions already created from the movements remain. Bills linked to deleted suggestions are also deleted. Requires edit accounting period permission for the statement’s actual period; the period ID in the URL is not cross-checked. There is no dry-run mode.
7941 ///
7942 /// # Example
7943 ///
7944 /// ```no_run
7945 /// # use churchtools_api::*;
7946 /// # use churchtools_api::queries::*;
7947 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7948 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7949 /// client.finance().accounting_periods().statements().delete(1, 1)?;
7950 /// # Ok(())
7951 /// # }
7952 /// ```
7953 pub fn delete(&self, id: impl Display, statement_id: impl Display) -> Result<()> {
7954 let path = format!("/finance/accountingperiods/{}/statements/{}", seg(id), seg(statement_id));
7955 let query: Query = Query::new();
7956 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
7957 }
7958
7959 /// Preview an uploaded bank statement file
7960 ///
7961 /// `POST /finance/accountingperiods/{id}/statements`
7962 ///
7963 /// Parses the first uploaded bank statement file and returns a preview without importing it. Send the file in multipart field files\[\]. Supported formats are MT940, CAMT and PayPal CSV; a ZIP can combine top-level files of the same type and account identifier. Requires edit accounting period permission for the path ID. Duplicate comparison is currently performed across all stored accounts in the date range, so the counts can differ from a later account-specific import. To import, upload the file to /files/statement/{accountId}.
7964 ///
7965 /// # Example
7966 ///
7967 /// ```no_run
7968 /// # use churchtools_api::*;
7969 /// # use churchtools_api::queries::*;
7970 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7971 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7972 /// let file = Upload::from_path("kontoauszug.xml")?;
7973 /// let statement = client.finance().accounting_periods().statements().preview(1, &[file])?;
7974 /// println!("{}", statement.duplicates);
7975 /// # Ok(())
7976 /// # }
7977 /// ```
7978 pub fn preview(&self, id: impl Display, files: &[Upload]) -> Result<models::AccountStatementPreview> {
7979 let path = format!("/finance/accountingperiods/{}/statements", seg(id));
7980 let query: Query = Query::new();
7981 let form: Query = Query::new();
7982 let bytes = self.client.request_multipart(Method::Post, &path, &query, &form, "files[]", files)?;
7983 crate::decode_data(&bytes)
7984 }
7985
7986 /// Generate suggestions for a statement
7987 ///
7988 /// `POST /finance/accountingperiods/{id}/statements/{statementId}/suggestions`
7989 ///
7990 /// Runs the configured suggestion generators over every movement of the statement, including movements already booked or ignored. New suggestions are merged with existing ones by field name and split key; an existing suggestion is replaced only by a higher-confidence suggestion, so this is not a complete reset. Invalid account references are removed afterwards. Requires edit accounting period permission for the statement’s actual period. The period ID in the URL is not cross-checked. Returns HTTP 204 without a body.
7991 ///
7992 /// # Example
7993 ///
7994 /// ```no_run
7995 /// # use churchtools_api::*;
7996 /// # use churchtools_api::queries::*;
7997 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
7998 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
7999 /// client.finance().accounting_periods().statements().suggestions(1, 7)?;
8000 /// # Ok(())
8001 /// # }
8002 /// ```
8003 pub fn suggestions(&self, id: impl Display, statement_id: impl Display) -> Result<()> {
8004 let path = format!("/finance/accountingperiods/{}/statements/{}/suggestions", seg(id), seg(statement_id));
8005 let query: Query = Query::new();
8006 self.client.request(Method::Post, &path, &query, None).map(|_| ())
8007 }
8008
8009 /// Rename a statement
8010 ///
8011 /// `PUT /finance/accountingperiods/{id}/statements/{statementId}`
8012 ///
8013 /// Renames an imported statement and returns HTTP 204 without a body. Requires edit accounting period permission for the statement’s actual period. The period ID in the URL is not cross-checked by this operation.
8014 ///
8015 /// # Example
8016 ///
8017 /// ```no_run
8018 /// # use churchtools_api::*;
8019 /// # use churchtools_api::queries::*;
8020 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8021 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8022 /// let body = models::AccountStatementUpdate {
8023 /// name: "September 2026".into(),
8024 /// ..Default::default()
8025 /// };
8026 /// client.finance().accounting_periods().statements().update(1, 1, &body)?;
8027 /// # Ok(())
8028 /// # }
8029 /// ```
8030 pub fn update(&self, id: impl Display, statement_id: impl Display, body: &models::AccountStatementUpdate) -> Result<()> {
8031 let path = format!("/finance/accountingperiods/{}/statements/{}", seg(id), seg(statement_id));
8032 let query: Query = Query::new();
8033 let body = serde_json::to_value(body).expect("request body serializes");
8034 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
8035 }
8036
8037}
8038
8039/// `client.finance().accounts()`
8040#[derive(Clone, Copy)]
8041pub struct FinanceAccountsResource<'a> {
8042 client: &'a Client,
8043}
8044
8045impl<'a> FinanceAccountsResource<'a> {
8046 /// Create or replace accounts in bulk
8047 ///
8048 /// `POST /finance/accounts/bulkcreate`
8049 ///
8050 /// Imports a JSON array of account definitions. Requires finance “edit masterdata”. Existing accounts are matched by account number and accounting period and updated; other entries are created. Optional fields use the same false/null defaults as single creation, also when replacing existing accounts. Repeated raw period/number pairs in the request collapse to the last entry. Returns HTTP 200 and meta.count for the processed entries. Every affected period must be open. The bulk path does not apply the single-update donation-account protection.
8051 ///
8052 /// # Example
8053 ///
8054 /// ```no_run
8055 /// # use churchtools_api::*;
8056 /// # use churchtools_api::queries::*;
8057 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8058 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8059 /// let body: Vec<models::AccountCreate> = vec![models::AccountCreate {
8060 /// account_group_id: 4,
8061 /// name: "Donations".into(),
8062 /// number: "8200".into(),
8063 /// accounting_period_id: 5,
8064 /// ..Default::default()
8065 /// }];
8066 /// for account in client.finance().accounts().bulk_create(&body)? {
8067 /// println!("{}", account.name);
8068 /// }
8069 /// # Ok(())
8070 /// # }
8071 /// ```
8072 pub fn bulk_create(&self, body: &Vec<models::AccountCreate>) -> Result<Vec<models::Account>> {
8073 let path = "/finance/accounts/bulkcreate".to_owned();
8074 let query: Query = Query::new();
8075 let body = serde_json::to_value(body).expect("request body serializes");
8076 self.client.request_data(Method::Post, &path, &query, Some(&body))
8077 }
8078
8079 /// Create new account
8080 ///
8081 /// `POST /finance/accounts`
8082 ///
8083 /// Creates a ledger account in an open accounting period. Requires finance “edit masterdata”. Name and number must each be unique in that period; account number 9999 is reserved. Returns HTTP 200 with the new account, initially with balance 0.
8084 ///
8085 /// # Example
8086 ///
8087 /// ```no_run
8088 /// # use churchtools_api::*;
8089 /// # use churchtools_api::queries::*;
8090 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8091 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8092 /// let body = models::AccountCreate {
8093 /// account_group_id: 4,
8094 /// name: "Donations".into(),
8095 /// number: "8200".into(),
8096 /// accounting_period_id: 5,
8097 /// ..Default::default()
8098 /// };
8099 /// let result = client.finance().accounts().create(&body)?;
8100 /// println!("{}", result.name);
8101 /// # Ok(())
8102 /// # }
8103 /// ```
8104 pub fn create(&self, body: &models::AccountCreate) -> Result<models::Account> {
8105 let path = "/finance/accounts".to_owned();
8106 let query: Query = Query::new();
8107 let body = serde_json::to_value(body).expect("request body serializes");
8108 self.client.request_data(Method::Post, &path, &query, Some(&body))
8109 }
8110
8111 /// Delete account
8112 ///
8113 /// `DELETE /finance/accounts/{id}`
8114 ///
8115 /// Deletes an account if no transactions, transaction purposes, tax rates or cash discounts require it. Requires finance “edit masterdata”. Associated bank statements, account movements and transaction suggestions are removed. dry_run=true returns the HTTP 409 conflict report without deleting, including when deletion is allowed.
8116 ///
8117 /// Use [`Self::delete_with`] to pass query parameters.
8118 ///
8119 /// # Example
8120 ///
8121 /// ```no_run
8122 /// # use churchtools_api::*;
8123 /// # use churchtools_api::queries::*;
8124 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8125 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8126 /// client.finance().accounts().delete(1)?;
8127 /// # Ok(())
8128 /// # }
8129 /// ```
8130 pub fn delete(&self, id: impl Display) -> Result<()> {
8131 self.delete_with(id, &Default::default())
8132 }
8133
8134 /// Delete account
8135 ///
8136 /// Like [`Self::delete`], with query parameters.
8137 ///
8138 /// `DELETE /finance/accounts/{id}`
8139 ///
8140 /// Deletes an account if no transactions, transaction purposes, tax rates or cash discounts require it. Requires finance “edit masterdata”. Associated bank statements, account movements and transaction suggestions are removed. dry_run=true returns the HTTP 409 conflict report without deleting, including when deletion is allowed.
8141 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceAccountsIdQuery) -> Result<()> {
8142 let path = format!("/finance/accounts/{}", seg(id));
8143 let query: Query = query.to_query();
8144 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
8145 }
8146
8147 /// Download an account-import workbook
8148 ///
8149 /// `POST /finance/accounts/exporttemplate`
8150 ///
8151 /// Downloads an XLSX workbook with translated column headings and import instructions. Requires finance “edit masterdata”. Select a finance template, existing accounts by year and optional client, or omit the selection for an empty workbook. Only accounting periods visible to the caller contribute existing accounts.
8152 ///
8153 /// # Example
8154 ///
8155 /// ```no_run
8156 /// # use churchtools_api::*;
8157 /// # use churchtools_api::queries::*;
8158 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8159 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8160 /// let body = models::AccountImportTemplateCreate {
8161 /// client_id: Some(Some(1)),
8162 /// ..Default::default()
8163 /// };
8164 /// let data = client.finance().accounts().export_template(&body)?;
8165 /// std::fs::write("ergebnis.xlsx", &data)?;
8166 /// # Ok(())
8167 /// # }
8168 /// ```
8169 pub fn export_template(&self, body: &models::AccountImportTemplateCreate) -> Result<Vec<u8>> {
8170 let path = "/finance/accounts/exporttemplate".to_owned();
8171 let query: Query = Query::new();
8172 let body = serde_json::to_value(body).expect("request body serializes");
8173 self.client.request(Method::Post, &path, &query, Some(&body))
8174 }
8175
8176 /// Get an account
8177 ///
8178 /// `GET /finance/accounts/{id}`
8179 ///
8180 /// Returns one visible ledger account with calculated balances, preceding-period budget values and posting permission. Visibility follows the same rules as the collection endpoint. An unknown ID returns 404; an existing but inaccessible account returns 403.
8181 ///
8182 /// # Example
8183 ///
8184 /// ```
8185 /// # use churchtools_api::*;
8186 /// # use churchtools_api::queries::*;
8187 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8188 /// # let client = churchtools_api::replay::client("get-finance-accounts-id");
8189 /// let account = client.finance().accounts().get(1)?;
8190 /// println!("{}", account.name);
8191 /// # Ok(())
8192 /// # }
8193 /// ```
8194 pub fn get(&self, id: impl Display) -> Result<models::Account> {
8195 let path = format!("/finance/accounts/{}", seg(id));
8196 let query: Query = Query::new();
8197 self.client.request_data(Method::Get, &path, &query, None)
8198 }
8199
8200 /// Export accounts as CSV
8201 ///
8202 /// `GET /finance/accounts/csv`
8203 ///
8204 /// Downloads visible accounts of one accounting period. Requires global finance “view accounting period” for that period. Columns contain number, name, annotation, budget, account-group name, account function, tax type/rate and identifier. Headings use the installation language. Budgets use formatted major currency units. CSV uses semicolons and a UTF-8 BOM. Returns an attachment without a JSON wrapper.
8205 ///
8206 /// # Example
8207 ///
8208 /// ```no_run
8209 /// # use churchtools_api::*;
8210 /// # use churchtools_api::queries::*;
8211 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8212 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8213 /// let query = GetFinanceAccountsCsvQuery {
8214 /// accounting_period_id: Some(1),
8215 /// ..Default::default()
8216 /// };
8217 /// let data = client.finance().accounts().get_csv(&query)?;
8218 /// std::fs::write("ergebnis.csv", &data)?;
8219 /// # Ok(())
8220 /// # }
8221 /// ```
8222 pub fn get_csv(&self, query: &GetFinanceAccountsCsvQuery) -> Result<Vec<u8>> {
8223 let path = "/finance/accounts/csv".to_owned();
8224 let query: Query = query.to_query();
8225 self.client.request(Method::Get, &path, &query, None)
8226 }
8227
8228 /// Export accounts
8229 ///
8230 /// `GET /finance/accounts/export`
8231 ///
8232 /// Downloads visible accounts of one accounting period. Requires global finance “view accounting period” for that period. Columns contain number, name, annotation, budget, account-group name, account function, tax type/rate and identifier. Headings use the installation language. Budgets use formatted major currency units. CSV uses semicolons and a UTF-8 BOM. Returns an attachment without a JSON wrapper.
8233 ///
8234 /// # Example
8235 ///
8236 /// ```no_run
8237 /// # use churchtools_api::*;
8238 /// # use churchtools_api::queries::*;
8239 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8240 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8241 /// let query = GetFinanceAccountsExportQuery {
8242 /// accounting_period_id: Some(1),
8243 /// ..Default::default()
8244 /// };
8245 /// let data = client.finance().accounts().get_export(&query)?;
8246 /// std::fs::write("ergebnis.xlsx", &data)?;
8247 /// # Ok(())
8248 /// # }
8249 /// ```
8250 pub fn get_export(&self, query: &GetFinanceAccountsExportQuery) -> Result<Vec<u8>> {
8251 let path = "/finance/accounts/export".to_owned();
8252 let query: Query = query.to_query();
8253 self.client.request(Method::Get, &path, &query, None)
8254 }
8255
8256 /// Get visible accounts
8257 ///
8258 /// `GET /finance/accounts`
8259 ///
8260 /// A ledger account belongs to one accounting period and one account group. The group links it to an account class and account type. Transactions post amounts between an account and a contra account. Amounts and budgets use integer minor currency units, for example cents. Returns an unpaginated list filtered by finance master-data permission, accounting-period permissions or access through cost centers and transaction purposes. Accounts are sorted by number across all selected periods, without a separate period sort. meta.count is the number returned. Balances and preceding-period budgets are calculated by default.
8261 ///
8262 /// Use [`Self::list_with`] to pass query parameters.
8263 ///
8264 /// # Example
8265 ///
8266 /// ```
8267 /// # use churchtools_api::*;
8268 /// # use churchtools_api::queries::*;
8269 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8270 /// # let client = churchtools_api::replay::client("get-finance-accounts");
8271 /// for account in client.finance().accounts().list()? {
8272 /// println!("{}", account.name);
8273 /// }
8274 /// # Ok(())
8275 /// # }
8276 /// ```
8277 pub fn list(&self) -> Result<Vec<models::Account>> {
8278 self.list_with(&Default::default())
8279 }
8280
8281 /// Get visible accounts
8282 ///
8283 /// Like [`Self::list`], with query parameters.
8284 ///
8285 /// `GET /finance/accounts`
8286 ///
8287 /// A ledger account belongs to one accounting period and one account group. The group links it to an account class and account type. Transactions post amounts between an account and a contra account. Amounts and budgets use integer minor currency units, for example cents. Returns an unpaginated list filtered by finance master-data permission, accounting-period permissions or access through cost centers and transaction purposes. Accounts are sorted by number across all selected periods, without a separate period sort. meta.count is the number returned. Balances and preceding-period budgets are calculated by default.
8288 pub fn list_with(&self, query: &GetFinanceAccountsQuery) -> Result<Vec<models::Account>> {
8289 let path = "/finance/accounts".to_owned();
8290 let query: Query = query.to_query();
8291 self.client.request_data(Method::Get, &path, &query, None)
8292 }
8293
8294 /// Update account
8295 ///
8296 /// `PUT /finance/accounts/{id}`
8297 ///
8298 /// Replacement values for an account in an open accounting period. The period cannot be changed here. Omitted optional fields reset to false or null. A donation account with existing donation transactions cannot have isDonationAccount disabled through this single-update endpoint. Requires finance “edit masterdata”. Returns recalculated balances and posting permission. isMandatoryEubpLocked cannot be changed by this operation.
8299 ///
8300 /// # Example
8301 ///
8302 /// ```no_run
8303 /// # use churchtools_api::*;
8304 /// # use churchtools_api::queries::*;
8305 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8306 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8307 /// let body = models::AccountUpdate {
8308 /// account_group_id: 4,
8309 /// name: "Donations".into(),
8310 /// number: "8200".into(),
8311 /// ..Default::default()
8312 /// };
8313 /// let result = client.finance().accounts().update(1, &body)?;
8314 /// println!("{}", result.name);
8315 /// # Ok(())
8316 /// # }
8317 /// ```
8318 pub fn update(&self, id: impl Display, body: &models::AccountUpdate) -> Result<models::Account> {
8319 let path = format!("/finance/accounts/{}", seg(id));
8320 let query: Query = Query::new();
8321 let body = serde_json::to_value(body).expect("request body serializes");
8322 self.client.request_data(Method::Put, &path, &query, Some(&body))
8323 }
8324
8325}
8326
8327/// `client.finance().bills()`
8328#[derive(Clone, Copy)]
8329pub struct FinanceBillsResource<'a> {
8330 client: &'a Client,
8331}
8332
8333impl<'a> FinanceBillsResource<'a> {
8334 /// Create new bill
8335 ///
8336 /// `POST /finance/bills`
8337 ///
8338 /// Registers an existing uploaded file as a supporting document. Exactly one booking link is required. The linked transaction, all split components, or the account movement behind a suggestion must belong to accountingPeriodId. Ordinary and split transactions must be mutable and pass booking authorization. The submitting person must be visible. Returns the stored bill including file download metadata.
8339 ///
8340 /// # Example
8341 ///
8342 /// ```no_run
8343 /// # use churchtools_api::*;
8344 /// # use churchtools_api::queries::*;
8345 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8346 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8347 /// let body = serde_json::json!({
8348 /// "accountingPeriodId": 1,
8349 /// "fileId": 21,
8350 /// "submittedDate": "2026-09-14",
8351 /// "submittedPid": 42,
8352 /// "transactionId": 12
8353 /// });
8354 /// let result = client.finance().bills().create(&body)?;
8355 /// println!("{}", result.id);
8356 /// # Ok(())
8357 /// # }
8358 /// ```
8359 pub fn create(&self, body: &serde_json::Value) -> Result<models::Bill> {
8360 let path = "/finance/bills".to_owned();
8361 let query: Query = Query::new();
8362 let body = serde_json::to_value(body).expect("request body serializes");
8363 self.client.request_data(Method::Post, &path, &query, Some(&body))
8364 }
8365
8366 /// Delete bill
8367 ///
8368 /// `DELETE /finance/bills/{id}`
8369 ///
8370 /// Deletes a supporting document and its attached file, leaving the booking itself intact. Requires bill-update permissions and validates the existing booking links; immutable ordinary transactions or split components prevent deletion. dry_run=true performs the same checks and returns HTTP 409 with deletion information without deleting.
8371 ///
8372 /// Use [`Self::delete_with`] to pass query parameters.
8373 ///
8374 /// # Example
8375 ///
8376 /// ```no_run
8377 /// # use churchtools_api::*;
8378 /// # use churchtools_api::queries::*;
8379 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8380 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8381 /// client.finance().bills().delete(1)?;
8382 /// # Ok(())
8383 /// # }
8384 /// ```
8385 pub fn delete(&self, id: impl Display) -> Result<()> {
8386 self.delete_with(id, &Default::default())
8387 }
8388
8389 /// Delete bill
8390 ///
8391 /// Like [`Self::delete`], with query parameters.
8392 ///
8393 /// `DELETE /finance/bills/{id}`
8394 ///
8395 /// Deletes a supporting document and its attached file, leaving the booking itself intact. Requires bill-update permissions and validates the existing booking links; immutable ordinary transactions or split components prevent deletion. dry_run=true performs the same checks and returns HTTP 409 with deletion information without deleting.
8396 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceBillsIdQuery) -> Result<()> {
8397 let path = format!("/finance/bills/{}", seg(id));
8398 let query: Query = query.to_query();
8399 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
8400 }
8401
8402 /// Get a bill
8403 ///
8404 /// `GET /finance/bills/{id}`
8405 ///
8406 /// Returns one supporting document. Access is granted through view/edit permission for its accounting period or visibility of its directly linked ordinary transaction. Split transactions and booking suggestions do not provide this additional individual-access route.
8407 ///
8408 /// # Example
8409 ///
8410 /// ```
8411 /// # use churchtools_api::*;
8412 /// # use churchtools_api::queries::*;
8413 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8414 /// # let client = churchtools_api::replay::client("get-finance-bills-id");
8415 /// let bill = client.finance().bills().get(1)?;
8416 /// println!("{}", bill.id);
8417 /// # Ok(())
8418 /// # }
8419 /// ```
8420 pub fn get(&self, id: impl Display) -> Result<models::Bill> {
8421 let path = format!("/finance/bills/{}", seg(id));
8422 let query: Query = Query::new();
8423 self.client.request_data(Method::Get, &path, &query, None)
8424 }
8425
8426 /// Update bill
8427 ///
8428 /// `PUT /finance/bills/{id}`
8429 ///
8430 /// Updates submission date/person and optionally renames the file or changes its booking link. Requires edit permission for the accounting period or update access to the directly linked ordinary transaction. A directly linked immutable transaction prevents changes. Newly supplied transaction/split links are checked for authorization, immutability and accounting-period consistency. Omitted or null link IDs do not detach the document. Accounting period and file attachment remain fixed.
8431 ///
8432 /// # Example
8433 ///
8434 /// ```no_run
8435 /// # use churchtools_api::*;
8436 /// # use churchtools_api::queries::*;
8437 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8438 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8439 /// let body = models::BillUpdate {
8440 /// submitted_date: "2026-09-14".parse()?,
8441 /// submitted_pid: 42,
8442 /// ..Default::default()
8443 /// };
8444 /// let result = client.finance().bills().update(1, &body)?;
8445 /// println!("{}", result.id);
8446 /// # Ok(())
8447 /// # }
8448 /// ```
8449 pub fn update(&self, id: impl Display, body: &models::BillUpdate) -> Result<models::Bill> {
8450 let path = format!("/finance/bills/{}", seg(id));
8451 let query: Query = Query::new();
8452 let body = serde_json::to_value(body).expect("request body serializes");
8453 self.client.request_data(Method::Put, &path, &query, Some(&body))
8454 }
8455
8456}
8457
8458/// `client.finance().cash_discounts()`
8459#[derive(Clone, Copy)]
8460pub struct FinanceCashDiscountsResource<'a> {
8461 client: &'a Client,
8462}
8463
8464impl<'a> FinanceCashDiscountsResource<'a> {
8465 /// Create a cash discount
8466 ///
8467 /// `POST /finance/cashdiscounts`
8468 ///
8469 /// A cash discount defines a percentage for early-payment discounts and the ledger account to which the discount is posted. Its accounting period is determined by that account. Requires finance “edit masterdata”. Returns HTTP 200 on success.
8470 ///
8471 /// # Example
8472 ///
8473 /// ```no_run
8474 /// # use churchtools_api::*;
8475 /// # use churchtools_api::queries::*;
8476 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8477 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8478 /// let body = models::CashDiscountCreate {
8479 /// account_id: 5,
8480 /// note: "Skonto 2%".into(),
8481 /// rate: 2,
8482 /// ..Default::default()
8483 /// };
8484 /// let result = client.finance().cash_discounts().create(&body)?;
8485 /// println!("{}", result.id);
8486 /// # Ok(())
8487 /// # }
8488 /// ```
8489 pub fn create(&self, body: &models::CashDiscountCreate) -> Result<models::CashDiscount> {
8490 let path = "/finance/cashdiscounts".to_owned();
8491 let query: Query = Query::new();
8492 let body = serde_json::to_value(body).expect("request body serializes");
8493 self.client.request_data(Method::Post, &path, &query, Some(&body))
8494 }
8495
8496 /// Delete cash discount
8497 ///
8498 /// `DELETE /finance/cashdiscounts/{id}`
8499 ///
8500 /// Deletes this cash discount if no transactions reference it. Requires finance “edit masterdata”. dry_run=true returns the HTTP 409 conflict report without deleting, also when deletion is allowed.
8501 ///
8502 /// Use [`Self::delete_with`] to pass query parameters.
8503 ///
8504 /// # Example
8505 ///
8506 /// ```no_run
8507 /// # use churchtools_api::*;
8508 /// # use churchtools_api::queries::*;
8509 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8510 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8511 /// client.finance().cash_discounts().delete(1)?;
8512 /// # Ok(())
8513 /// # }
8514 /// ```
8515 pub fn delete(&self, id: impl Display) -> Result<()> {
8516 self.delete_with(id, &Default::default())
8517 }
8518
8519 /// Delete cash discount
8520 ///
8521 /// Like [`Self::delete`], with query parameters.
8522 ///
8523 /// `DELETE /finance/cashdiscounts/{id}`
8524 ///
8525 /// Deletes this cash discount if no transactions reference it. Requires finance “edit masterdata”. dry_run=true returns the HTTP 409 conflict report without deleting, also when deletion is allowed.
8526 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceCashdiscountsIdQuery) -> Result<()> {
8527 let path = format!("/finance/cashdiscounts/{}", seg(id));
8528 let query: Query = query.to_query();
8529 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
8530 }
8531
8532 /// Get a cash discount
8533 ///
8534 /// `GET /finance/cashdiscounts/{id}`
8535 ///
8536 /// A cash discount defines a percentage for early-payment discounts and the ledger account to which the discount is posted. Its accounting period is determined by that account. Returns one definition by ID.
8537 ///
8538 /// # Example
8539 ///
8540 /// ```
8541 /// # use churchtools_api::*;
8542 /// # use churchtools_api::queries::*;
8543 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8544 /// # let client = churchtools_api::replay::client("get-finance-cashdiscounts-id");
8545 /// let cash_discount = client.finance().cash_discounts().get(1)?;
8546 /// println!("{}", cash_discount.id);
8547 /// # Ok(())
8548 /// # }
8549 /// ```
8550 pub fn get(&self, id: impl Display) -> Result<models::CashDiscount> {
8551 let path = format!("/finance/cashdiscounts/{}", seg(id));
8552 let query: Query = Query::new();
8553 self.client.request_data(Method::Get, &path, &query, None)
8554 }
8555
8556 /// Get all cash discounts
8557 ///
8558 /// `GET /finance/cashdiscounts`
8559 ///
8560 /// A cash discount defines a percentage for early-payment discounts and the ledger account to which the discount is posted. Its accounting period is determined by that account. Returns an unpaginated list. Optionally restrict results to the linked accounts’ accounting period. No result order is guaranteed; an unknown period returns an empty list. meta.count is the number returned.
8561 ///
8562 /// Use [`Self::list_with`] to pass query parameters.
8563 ///
8564 /// # Example
8565 ///
8566 /// ```
8567 /// # use churchtools_api::*;
8568 /// # use churchtools_api::queries::*;
8569 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8570 /// # let client = churchtools_api::replay::client("get-finance-cashdiscounts");
8571 /// for cash_discount in client.finance().cash_discounts().list()? {
8572 /// println!("{}", cash_discount.id);
8573 /// }
8574 /// # Ok(())
8575 /// # }
8576 /// ```
8577 pub fn list(&self) -> Result<Vec<models::CashDiscount>> {
8578 self.list_with(&Default::default())
8579 }
8580
8581 /// Get all cash discounts
8582 ///
8583 /// Like [`Self::list`], with query parameters.
8584 ///
8585 /// `GET /finance/cashdiscounts`
8586 ///
8587 /// A cash discount defines a percentage for early-payment discounts and the ledger account to which the discount is posted. Its accounting period is determined by that account. Returns an unpaginated list. Optionally restrict results to the linked accounts’ accounting period. No result order is guaranteed; an unknown period returns an empty list. meta.count is the number returned.
8588 pub fn list_with(&self, query: &GetFinanceCashdiscountsQuery) -> Result<Vec<models::CashDiscount>> {
8589 let path = "/finance/cashdiscounts".to_owned();
8590 let query: Query = query.to_query();
8591 self.client.request_data(Method::Get, &path, &query, None)
8592 }
8593
8594 /// Update cash discount
8595 ///
8596 /// `PUT /finance/cashdiscounts/{id}`
8597 ///
8598 /// Replaces this cash discount. Requires finance “edit masterdata”. All required creation fields must be supplied again.
8599 ///
8600 /// # Example
8601 ///
8602 /// ```no_run
8603 /// # use churchtools_api::*;
8604 /// # use churchtools_api::queries::*;
8605 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8606 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8607 /// let body = models::CashDiscountUpdate {
8608 /// account_id: 5,
8609 /// note: "Skonto 2%".into(),
8610 /// rate: 2,
8611 /// ..Default::default()
8612 /// };
8613 /// let result = client.finance().cash_discounts().update(1, &body)?;
8614 /// println!("{}", result.id);
8615 /// # Ok(())
8616 /// # }
8617 /// ```
8618 pub fn update(&self, id: impl Display, body: &models::CashDiscountUpdate) -> Result<models::CashDiscount> {
8619 let path = format!("/finance/cashdiscounts/{}", seg(id));
8620 let query: Query = Query::new();
8621 let body = serde_json::to_value(body).expect("request body serializes");
8622 self.client.request_data(Method::Put, &path, &query, Some(&body))
8623 }
8624
8625}
8626
8627/// `client.finance().clients()`
8628#[derive(Clone, Copy)]
8629pub struct FinanceClientsResource<'a> {
8630 client: &'a Client,
8631}
8632
8633impl<'a> FinanceClientsResource<'a> {
8634 /// Create new client
8635 ///
8636 /// `POST /finance/clients`
8637 ///
8638 /// Creates a finance client. Requires finance “edit masterdata” and an available client slot in the installation license. Returns HTTP 201 with the treasurer expanded, if assigned. Optional fields default to null.
8639 ///
8640 /// # Example
8641 ///
8642 /// ```no_run
8643 /// # use churchtools_api::*;
8644 /// # use churchtools_api::queries::*;
8645 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8646 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8647 /// let body = models::ClientCreate {
8648 /// name: "Example congregation".into(),
8649 /// sort_key: 0,
8650 /// ..Default::default()
8651 /// };
8652 /// let result = client.finance().clients().create(&body)?;
8653 /// println!("{}", result.name);
8654 /// # Ok(())
8655 /// # }
8656 /// ```
8657 pub fn create(&self, body: &models::ClientCreate) -> Result<models::Client> {
8658 let path = "/finance/clients".to_owned();
8659 let query: Query = Query::new();
8660 let body = serde_json::to_value(body).expect("request body serializes");
8661 self.client.request_data(Method::Post, &path, &query, Some(&body))
8662 }
8663
8664 /// Delete client
8665 ///
8666 /// `DELETE /finance/clients/{id}`
8667 ///
8668 /// Deletes a finance client if no accounting periods reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, also when deletion would be allowed.
8669 ///
8670 /// Use [`Self::delete_with`] to pass query parameters.
8671 ///
8672 /// # Example
8673 ///
8674 /// ```no_run
8675 /// # use churchtools_api::*;
8676 /// # use churchtools_api::queries::*;
8677 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8678 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8679 /// client.finance().clients().delete(1)?;
8680 /// # Ok(())
8681 /// # }
8682 /// ```
8683 pub fn delete(&self, id: impl Display) -> Result<()> {
8684 self.delete_with(id, &Default::default())
8685 }
8686
8687 /// Delete client
8688 ///
8689 /// Like [`Self::delete`], with query parameters.
8690 ///
8691 /// `DELETE /finance/clients/{id}`
8692 ///
8693 /// Deletes a finance client if no accounting periods reference it. Requires finance “edit masterdata”. With dry_run=true no deletion occurs and HTTP 409 returns the conflict report, also when deletion would be allowed.
8694 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceClientsIdQuery) -> Result<()> {
8695 let path = format!("/finance/clients/{}", seg(id));
8696 let query: Query = query.to_query();
8697 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
8698 }
8699
8700 /// Get a client
8701 ///
8702 /// `GET /finance/clients/{id}`
8703 ///
8704 /// Returns a finance client visible under the same rules as the collection endpoint. An unknown or invisible client returns 404. A finance client is the organizational entity whose books are kept separately, for example a congregation or a charitable organization. Each client owns accounting periods, and those periods own its accounts and cost centers. It is unrelated to an OAuth application client.
8705 ///
8706 /// # Example
8707 ///
8708 /// ```
8709 /// # use churchtools_api::*;
8710 /// # use churchtools_api::queries::*;
8711 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8712 /// # let client = churchtools_api::replay::client("get-finance-clients-id");
8713 /// let item = client.finance().clients().get(1)?;
8714 /// println!("{}", item.name);
8715 /// # Ok(())
8716 /// # }
8717 /// ```
8718 pub fn get(&self, id: impl Display) -> Result<models::Client> {
8719 let path = format!("/finance/clients/{}", seg(id));
8720 let query: Query = Query::new();
8721 self.client.request_data(Method::Get, &path, &query, None)
8722 }
8723
8724 /// Get all clients
8725 ///
8726 /// `GET /finance/clients`
8727 ///
8728 /// A finance client is the organizational entity whose books are kept separately, for example a congregation or a charitable organization. Each client owns accounting periods, and those periods own its accounts and cost centers. It is unrelated to an OAuth application client. Returns an unpaginated list ordered by sortKey. Users with finance “edit masterdata” see all clients; other callers see clients belonging to their visible accounting periods. meta.count is the number returned. The treasurer is expanded to a person domain object.
8729 ///
8730 /// # Example
8731 ///
8732 /// ```
8733 /// # use churchtools_api::*;
8734 /// # use churchtools_api::queries::*;
8735 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8736 /// # let client = churchtools_api::replay::client("get-finance-clients");
8737 /// for item in client.finance().clients().list()? {
8738 /// println!("{}", item.name);
8739 /// }
8740 /// # Ok(())
8741 /// # }
8742 /// ```
8743 pub fn list(&self) -> Result<Vec<models::Client>> {
8744 let path = "/finance/clients".to_owned();
8745 let query: Query = Query::new();
8746 self.client.request_data(Method::Get, &path, &query, None)
8747 }
8748
8749 /// Update client
8750 ///
8751 /// `PUT /finance/clients/{id}`
8752 ///
8753 /// Replacement finance-client data. name and sortKey are required; omitted optional fields are cleared, including contact, DATEV and euBP fields. Requires finance “edit masterdata”. The client name must remain unique.
8754 ///
8755 /// # Example
8756 ///
8757 /// ```no_run
8758 /// # use churchtools_api::*;
8759 /// # use churchtools_api::queries::*;
8760 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8761 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8762 /// let body = models::ClientUpdate {
8763 /// name: "Example congregation".into(),
8764 /// sort_key: 0,
8765 /// ..Default::default()
8766 /// };
8767 /// let result = client.finance().clients().update(1, &body)?;
8768 /// println!("{}", result.name);
8769 /// # Ok(())
8770 /// # }
8771 /// ```
8772 pub fn update(&self, id: impl Display, body: &models::ClientUpdate) -> Result<models::Client> {
8773 let path = format!("/finance/clients/{}", seg(id));
8774 let query: Query = Query::new();
8775 let body = serde_json::to_value(body).expect("request body serializes");
8776 self.client.request_data(Method::Put, &path, &query, Some(&body))
8777 }
8778
8779}
8780
8781/// `client.finance().cost_centers()`
8782#[derive(Clone, Copy)]
8783pub struct FinanceCostCentersResource<'a> {
8784 client: &'a Client,
8785}
8786
8787impl<'a> FinanceCostCentersResource<'a> {
8788 /// Import many cost centers
8789 ///
8790 /// `POST /finance/costcenters/bulkcreate`
8791 ///
8792 /// Creates cost centers in one database transaction and returns HTTP 201. Requires finance “edit masterdata”; every target period must exist and be open. Each item uses the creation fields, including optional annotation. The bulk controller does not run the single-create uniqueness constraint. Results contain stored entities without the expanded group property. meta.count is the number created.
8793 ///
8794 /// # Example
8795 ///
8796 /// ```no_run
8797 /// # use churchtools_api::*;
8798 /// # use churchtools_api::queries::*;
8799 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8800 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8801 /// let body = models::CostCenterBulkCreate {
8802 /// cost_centers: vec![models::CostCenterCreate {
8803 /// accounting_period_id: 1,
8804 /// name: "Kostenstelle Sonstige".into(),
8805 /// number: "802".into(),
8806 /// ..Default::default()
8807 /// }],
8808 /// ..Default::default()
8809 /// };
8810 /// for cost_center in client.finance().cost_centers().bulk_create(&body)? {
8811 /// println!("{:?}", cost_center.name);
8812 /// }
8813 /// # Ok(())
8814 /// # }
8815 /// ```
8816 pub fn bulk_create(&self, body: &models::CostCenterBulkCreate) -> Result<Vec<models::CostCenterStored>> {
8817 let path = "/finance/costcenters/bulkcreate".to_owned();
8818 let query: Query = Query::new();
8819 let body = serde_json::to_value(body).expect("request body serializes");
8820 self.client.request_data(Method::Post, &path, &query, Some(&body))
8821 }
8822
8823 /// Create new cost center
8824 ///
8825 /// `POST /finance/costcenters`
8826 ///
8827 /// Creates a cost center. A cost center assigns income and expenses to a purpose, project or group within one accounting period. Budgets and balances use integer minor currency units (for example cents). Linking a group also enables access through group-internal finance permissions. Requires finance “edit masterdata” and an open accounting period. Name and number must each be unique in that period. Returns HTTP 200. budgetBalance initially equals budget; spent and previous-period values are not yet calculated.
8828 ///
8829 /// # Example
8830 ///
8831 /// ```no_run
8832 /// # use churchtools_api::*;
8833 /// # use churchtools_api::queries::*;
8834 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8835 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8836 /// let body = models::CostCenterCreate {
8837 /// accounting_period_id: 1,
8838 /// name: "Kostenstelle Sonstige".into(),
8839 /// number: "802".into(),
8840 /// ..Default::default()
8841 /// };
8842 /// let result = client.finance().cost_centers().create(&body)?;
8843 /// println!("{:?}", result.name);
8844 /// # Ok(())
8845 /// # }
8846 /// ```
8847 pub fn create(&self, body: &models::CostCenterCreate) -> Result<models::CostCenter> {
8848 let path = "/finance/costcenters".to_owned();
8849 let query: Query = Query::new();
8850 let body = serde_json::to_value(body).expect("request body serializes");
8851 self.client.request_data(Method::Post, &path, &query, Some(&body))
8852 }
8853
8854 /// Delete cost center
8855 ///
8856 /// `DELETE /finance/costcenters/{id}`
8857 ///
8858 /// Deletes a cost center if no transactions or transaction purposes reference it. Requires finance “edit masterdata”. Linked transaction suggestions are removed. dry_run=true returns the HTTP 409 report without deleting, including when deletion would be allowed.
8859 ///
8860 /// Use [`Self::delete_with`] to pass query parameters.
8861 ///
8862 /// # Example
8863 ///
8864 /// ```no_run
8865 /// # use churchtools_api::*;
8866 /// # use churchtools_api::queries::*;
8867 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8868 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8869 /// client.finance().cost_centers().delete(1)?;
8870 /// # Ok(())
8871 /// # }
8872 /// ```
8873 pub fn delete(&self, id: impl Display) -> Result<()> {
8874 self.delete_with(id, &Default::default())
8875 }
8876
8877 /// Delete cost center
8878 ///
8879 /// Like [`Self::delete`], with query parameters.
8880 ///
8881 /// `DELETE /finance/costcenters/{id}`
8882 ///
8883 /// Deletes a cost center if no transactions or transaction purposes reference it. Requires finance “edit masterdata”. Linked transaction suggestions are removed. dry_run=true returns the HTTP 409 report without deleting, including when deletion would be allowed.
8884 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceCostcentersIdQuery) -> Result<()> {
8885 let path = format!("/finance/costcenters/{}", seg(id));
8886 let query: Query = query.to_query();
8887 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
8888 }
8889
8890 /// Get a cost center
8891 ///
8892 /// `GET /finance/costcenters/{id}`
8893 ///
8894 /// Returns one visible cost center and its linked group. Visibility follows the same period and group permissions as the collection endpoint. A missing or invisible ID is rejected with 403 before the entity lookup. Budget values may be null when no budget is configured.
8895 ///
8896 /// # Example
8897 ///
8898 /// ```
8899 /// # use churchtools_api::*;
8900 /// # use churchtools_api::queries::*;
8901 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8902 /// # let client = churchtools_api::replay::client("get-finance-costcenters-id");
8903 /// let cost_center = client.finance().cost_centers().get(1)?;
8904 /// println!("{:?}", cost_center.name);
8905 /// # Ok(())
8906 /// # }
8907 /// ```
8908 pub fn get(&self, id: impl Display) -> Result<models::CostCenter> {
8909 let path = format!("/finance/costcenters/{}", seg(id));
8910 let query: Query = Query::new();
8911 self.client.request_data(Method::Get, &path, &query, None)
8912 }
8913
8914 /// Export cost centers
8915 ///
8916 /// `GET /finance/costcenters/export`
8917 ///
8918 /// Downloads the visible cost centers of one accounting period as CSV or XLSX. Requires global finance “view accounting period” for the selected period. Columns contain ID, number, name, budget and linked group ID. Headings are translated using the installation language. CSV uses semicolons and a UTF-8 BOM; budgets are formatted as major currency units. The response is a file, without a JSON data wrapper.
8919 ///
8920 /// # Example
8921 ///
8922 /// ```no_run
8923 /// # use churchtools_api::*;
8924 /// # use churchtools_api::queries::*;
8925 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8926 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8927 /// let query = GetFinanceCostcentersExportQuery {
8928 /// accounting_period_id: Some(1),
8929 /// ..Default::default()
8930 /// };
8931 /// let data = client.finance().cost_centers().get_export(&query)?;
8932 /// std::fs::write("ergebnis.xlsx", &data)?;
8933 /// # Ok(())
8934 /// # }
8935 /// ```
8936 pub fn get_export(&self, query: &GetFinanceCostcentersExportQuery) -> Result<Vec<u8>> {
8937 let path = "/finance/costcenters/export".to_owned();
8938 let query: Query = query.to_query();
8939 self.client.request(Method::Get, &path, &query, None)
8940 }
8941
8942 /// Get visible cost centers
8943 ///
8944 /// `GET /finance/costcenters`
8945 ///
8946 /// A cost center assigns income and expenses to a purpose, project or group within one accounting period. Budgets and balances use integer minor currency units (for example cents). Linking a group also enables access through group-internal finance permissions. Returns an unpaginated list filtered by global accounting-period rights and group-internal permissions to see cost centers, see budgets or post transactions. Sorted by accounting-period ID, then the numeric value of number, ascending. Previous-period budget values are matched by cost-center number. meta.count is the number returned.
8947 ///
8948 /// Use [`Self::list_with`] to pass query parameters.
8949 ///
8950 /// # Example
8951 ///
8952 /// ```
8953 /// # use churchtools_api::*;
8954 /// # use churchtools_api::queries::*;
8955 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8956 /// # let client = churchtools_api::replay::client("get-finance-costcenters");
8957 /// for cost_center in client.finance().cost_centers().list()? {
8958 /// println!("{:?}", cost_center.name);
8959 /// }
8960 /// # Ok(())
8961 /// # }
8962 /// ```
8963 pub fn list(&self) -> Result<Vec<models::CostCenter>> {
8964 self.list_with(&Default::default())
8965 }
8966
8967 /// Get visible cost centers
8968 ///
8969 /// Like [`Self::list`], with query parameters.
8970 ///
8971 /// `GET /finance/costcenters`
8972 ///
8973 /// A cost center assigns income and expenses to a purpose, project or group within one accounting period. Budgets and balances use integer minor currency units (for example cents). Linking a group also enables access through group-internal finance permissions. Returns an unpaginated list filtered by global accounting-period rights and group-internal permissions to see cost centers, see budgets or post transactions. Sorted by accounting-period ID, then the numeric value of number, ascending. Previous-period budget values are matched by cost-center number. meta.count is the number returned.
8974 pub fn list_with(&self, query: &GetFinanceCostcentersQuery) -> Result<Vec<models::CostCenter>> {
8975 let path = "/finance/costcenters".to_owned();
8976 let query: Query = query.to_query();
8977 self.client.request_data(Method::Get, &path, &query, None)
8978 }
8979
8980 /// Update cost center
8981 ///
8982 /// `PUT /finance/costcenters/{id}`
8983 ///
8984 /// Replacement values for a cost center. number and accountingPeriodId are required; omitted name, annotation, budget and groupId are cleared. The target accounting period must be open. Both name and number must remain unique in that period. Requires finance “edit masterdata”. The returned current-period balance is recalculated; previous-period values are not guaranteed to be refreshed by this update.
8985 ///
8986 /// # Example
8987 ///
8988 /// ```no_run
8989 /// # use churchtools_api::*;
8990 /// # use churchtools_api::queries::*;
8991 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
8992 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
8993 /// let body = models::CostCenterUpdate {
8994 /// accounting_period_id: 1,
8995 /// number: "802".into(),
8996 /// ..Default::default()
8997 /// };
8998 /// let result = client.finance().cost_centers().update(1, &body)?;
8999 /// println!("{:?}", result.name);
9000 /// # Ok(())
9001 /// # }
9002 /// ```
9003 pub fn update(&self, id: impl Display, body: &models::CostCenterUpdate) -> Result<models::CostCenter> {
9004 let path = format!("/finance/costcenters/{}", seg(id));
9005 let query: Query = Query::new();
9006 let body = serde_json::to_value(body).expect("request body serializes");
9007 self.client.request_data(Method::Put, &path, &query, Some(&body))
9008 }
9009
9010}
9011
9012/// `client.finance().donators()`
9013#[derive(Clone, Copy)]
9014pub struct FinanceDonatorsResource<'a> {
9015 client: &'a Client,
9016}
9017
9018impl<'a> FinanceDonatorsResource<'a> {
9019 /// Create donation receipts
9020 ///
9021 /// `POST /finance/donators/receipts`
9022 ///
9023 /// Queues ORIGINAL receipts for all donor households selected through the caller’s visible accounts. Requires accounting-period visibility and valid cover-letter/attachment template identifiers. A period already marked as having generated receipts is rejected. The period is marked when jobs are queued, before they finish. Returns HTTP 202 with job information, or HTTP 200 with total=0 and null job information when there are no households. Poll data.statusUrl before downloading the combined files.
9024 ///
9025 /// # Example
9026 ///
9027 /// ```no_run
9028 /// # use churchtools_api::*;
9029 /// # use churchtools_api::queries::*;
9030 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9031 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9032 /// let body = models::DonationReceiptsCreate {
9033 /// accounting_period_id: 1,
9034 /// donation_receipt_attachment_template_id: "abc123".into(),
9035 /// donation_receipt_letter_template_id: "abc123".into(),
9036 /// ..Default::default()
9037 /// };
9038 /// let result = client.finance().donators().create_receipts(&body)?;
9039 /// println!("{:?}", result.job_group);
9040 /// # Ok(())
9041 /// # }
9042 /// ```
9043 pub fn create_receipts(&self, body: &models::DonationReceiptsCreate) -> Result<models::DonationReceiptJobResult> {
9044 let path = "/finance/donators/receipts".to_owned();
9045 let query: Query = Query::new();
9046 let body = serde_json::to_value(body).expect("request body serializes");
9047 self.client.request_data(Method::Post, &path, &query, Some(&body))
9048 }
9049
9050 /// Create donation receipt PDFs (cover letter and attachment)
9051 ///
9052 /// `POST /finance/donators/{donatorCoupleId}/receipts`
9053 ///
9054 /// Generates cover-letter and attachment PDFs using the default templates. DRAFT produces temporary files and is not persisted. If the accounting period has not ended, or batch receipts were generated before its end, the request is forced to DRAFT. Other types are persisted when no stored receipt exists; if one already exists, it is returned with HTTP 200 instead of generating another. Newly generated files return HTTP 201. Requires visibility of the accounting period.
9055 ///
9056 /// # Example
9057 ///
9058 /// ```no_run
9059 /// # use churchtools_api::*;
9060 /// # use churchtools_api::queries::*;
9061 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9062 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9063 /// let body = models::DonationReceiptCreate {
9064 /// accounting_period_id: 1,
9065 /// ..Default::default()
9066 /// };
9067 /// let result = client.finance().donators().create_receipts_for("42-43", &body)?;
9068 /// println!("{}", result.accounting_period_id);
9069 /// # Ok(())
9070 /// # }
9071 /// ```
9072 pub fn create_receipts_for(&self, donator_couple_id: impl Display, body: &models::DonationReceiptCreate) -> Result<models::DonationReceipt> {
9073 let path = format!("/finance/donators/{}/receipts", seg(donator_couple_id));
9074 let query: Query = Query::new();
9075 let body = serde_json::to_value(body).expect("request body serializes");
9076 self.client.request_data(Method::Post, &path, &query, Some(&body))
9077 }
9078
9079 /// Delete the latest receipt for a donor
9080 ///
9081 /// `DELETE /finance/donators/{donatorCoupleId}/receipts`
9082 ///
9083 /// Deletes only the latest stored receipt for the donor or pair, including its two stored files. Older receipts, if present, remain. Requires visibility of the accounting period. No dry-run is supported; the accounting-period batch-generation marker is not reset.
9084 ///
9085 /// # Example
9086 ///
9087 /// ```no_run
9088 /// # use churchtools_api::*;
9089 /// # use churchtools_api::queries::*;
9090 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9091 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9092 /// let query = DeleteFinanceDonatorsDonatorCoupleIdQuery {
9093 /// accounting_period_id: Some(1),
9094 /// ..Default::default()
9095 /// };
9096 /// client.finance().donators().delete_latest_receipt_for("42-43", &query)?;
9097 /// # Ok(())
9098 /// # }
9099 /// ```
9100 pub fn delete_latest_receipt_for(&self, donator_couple_id: impl Display, query: &DeleteFinanceDonatorsDonatorCoupleIdQuery) -> Result<()> {
9101 let path = format!("/finance/donators/{}/receipts", seg(donator_couple_id));
9102 let query: Query = query.to_query();
9103 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
9104 }
9105
9106 /// Delete all donation receipts
9107 ///
9108 /// `DELETE /finance/donators/receipts`
9109 ///
9110 /// Deletes all stored donation receipts and their files for the accounting period, then clears its batch-generation timestamp so generation can be repeated. Requires finance edit masterdata. Active generation jobs prevent deletion. Processing is synchronous, but the endpoint returns HTTP 202 without a body. Each receipt is deleted in its own transaction.
9111 ///
9112 /// # Example
9113 ///
9114 /// ```no_run
9115 /// # use churchtools_api::*;
9116 /// # use churchtools_api::queries::*;
9117 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9118 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9119 /// let query = DeleteFinanceDonatorsReceiptsQuery {
9120 /// accounting_period_id: Some(1),
9121 /// ..Default::default()
9122 /// };
9123 /// client.finance().donators().delete_receipts(&query)?;
9124 /// # Ok(())
9125 /// # }
9126 /// ```
9127 pub fn delete_receipts(&self, query: &DeleteFinanceDonatorsReceiptsQuery) -> Result<()> {
9128 let path = "/finance/donators/receipts".to_owned();
9129 let query: Query = query.to_query();
9130 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
9131 }
9132
9133 /// Get combined donation receipt PDFs
9134 ///
9135 /// `GET /finance/donators/receipts`
9136 ///
9137 /// Builds combined PDF download files from stored ORIGINAL receipts for the caller’s visible donor households, sorted by postcode, street, last name and first name. Requires accounting-period visibility. An active receipt job group normally returns HTTP 400; receipts must already exist. twofiles returns separate coverLetters and attachments URLs. onefile returns one coverLetters URL containing each household’s letter and attachment. Early-generated batch receipts receive a DRAFT watermark.
9138 ///
9139 /// # Example
9140 ///
9141 /// ```no_run
9142 /// # use churchtools_api::*;
9143 /// # use churchtools_api::queries::*;
9144 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9145 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9146 /// let query = GetFinanceDonatorsReceiptsQuery {
9147 /// accounting_period_id: Some(1),
9148 /// ..Default::default()
9149 /// };
9150 /// let receipt = client.finance().donators().get_receipts(&query)?;
9151 /// println!("{:?}", receipt.attachments);
9152 /// # Ok(())
9153 /// # }
9154 /// ```
9155 pub fn get_receipts(&self, query: &GetFinanceDonatorsReceiptsQuery) -> Result<models::CombinedDonationReceipts> {
9156 let path = "/finance/donators/receipts".to_owned();
9157 let query: Query = query.to_query();
9158 self.client.request_data(Method::Get, &path, &query, None)
9159 }
9160
9161 /// Get existing donation receipt PDFs (cover letter and attachment)
9162 ///
9163 /// `GET /finance/donators/{donatorCoupleId}/receipts`
9164 ///
9165 /// Returns the latest stored receipt for the donor or pair and accounting period. The requested type controls watermarking only; the stored record is selected by creation date regardless of type. DRAFT and DUPLICATE produce temporary watermarked PDFs; ORIGINAL returns the stored files directly. Requires visibility of the accounting period.
9166 ///
9167 /// # Example
9168 ///
9169 /// ```no_run
9170 /// # use churchtools_api::*;
9171 /// # use churchtools_api::queries::*;
9172 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9173 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9174 /// let query = GetFinanceDonatorsDonatorCoupleIdQuery {
9175 /// accounting_period_id: Some(1),
9176 /// ..Default::default()
9177 /// };
9178 /// let receipts_for = client.finance().donators().get_receipts_for("42-43", &query)?;
9179 /// println!("{}", receipts_for.accounting_period_id);
9180 /// # Ok(())
9181 /// # }
9182 /// ```
9183 pub fn get_receipts_for(&self, donator_couple_id: impl Display, query: &GetFinanceDonatorsDonatorCoupleIdQuery) -> Result<models::DonationReceipt> {
9184 let path = format!("/finance/donators/{}/receipts", seg(donator_couple_id));
9185 let query: Query = query.to_query();
9186 self.client.request_data(Method::Get, &path, &query, None)
9187 }
9188
9189 /// Get donor household donation summaries
9190 ///
9191 /// `GET /finance/donators`
9192 ///
9193 /// Returns paginated donation/payback aggregates for one accounting period. Both accounts of each contributing transaction must be visible in the period. Requires explicit view or edit access to the complete accounting period; group-only access is insufficient. Completeness and name search use the single donor or the lower-ID person of a pair. meta.incompleteCount counts incomplete households after applying the current filters, before pagination. Ordering has no additional tie-breaker.
9194 ///
9195 /// # Example
9196 ///
9197 /// ```
9198 /// # use churchtools_api::*;
9199 /// # use churchtools_api::queries::*;
9200 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9201 /// # let client = churchtools_api::replay::client("get-finance-donators");
9202 /// let query = GetFinanceDonatorsQuery {
9203 /// accounting_period_id: Some(1),
9204 /// ..Default::default()
9205 /// };
9206 /// for donator in client.finance().donators().list(&query)? {
9207 /// println!("{}", donator.count);
9208 /// }
9209 /// # Ok(())
9210 /// # }
9211 /// ```
9212 pub fn list(&self, query: &GetFinanceDonatorsQuery) -> Result<Vec<models::Donator>> {
9213 let path = "/finance/donators".to_owned();
9214 let query: Query = query.to_query();
9215 self.client.collect_pages(&path, query)
9216 }
9217
9218 /// Get donor household donation summaries
9219 ///
9220 /// Like [`Self::list`], but lazy: each page is fetched only when the iteration reaches it.
9221 /// Breaking off early saves the remaining requests.
9222 pub fn list_iter(&self, query: &GetFinanceDonatorsQuery) -> Items<models::Donator> {
9223 let path = "/finance/donators".to_owned();
9224 self.client.items(&path, query.to_query())
9225 }
9226
9227}
9228
9229/// `client.finance().eubp()`
9230#[derive(Clone, Copy)]
9231pub struct FinanceEubpResource<'a> {
9232 client: &'a Client,
9233}
9234
9235impl<'a> FinanceEubpResource<'a> {
9236 pub fn submissions(&self) -> FinanceEubpSubmissionsResource<'a> {
9237 FinanceEubpSubmissionsResource { client: self.client }
9238 }
9239
9240 /// Get euBP service health status
9241 ///
9242 /// `GET /finance/eubp/health`
9243 ///
9244 /// Checks the configured eXTra integration service and returns its availability, URL and configured environment. A connection failure is represented by extraServiceAvailable=false with HTTP 200. This does not establish that a submission will be accepted by DRV. Requires finance edit masterdata permission.
9245 ///
9246 /// # Example
9247 ///
9248 /// ```
9249 /// # use churchtools_api::*;
9250 /// # use churchtools_api::queries::*;
9251 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9252 /// # let client = churchtools_api::replay::client("get-finance-eubp-health");
9253 /// let health = client.finance().eubp().get_health()?;
9254 /// println!("{}", health.environment);
9255 /// # Ok(())
9256 /// # }
9257 /// ```
9258 pub fn get_health(&self) -> Result<models::EubpHealthInfo> {
9259 let path = "/finance/eubp/health".to_owned();
9260 let query: Query = Query::new();
9261 self.client.request_data(Method::Get, &path, &query, None)
9262 }
9263
9264}
9265
9266/// `client.finance().eubp().submissions()`
9267#[derive(Clone, Copy)]
9268pub struct FinanceEubpSubmissionsResource<'a> {
9269 client: &'a Client,
9270}
9271
9272impl<'a> FinanceEubpSubmissionsResource<'a> {
9273 pub fn periods(&self) -> FinanceEubpSubmissionsPeriodsResource<'a> {
9274 FinanceEubpSubmissionsPeriodsResource { client: self.client }
9275 }
9276
9277 /// Cancel euBP submission
9278 ///
9279 /// `POST /finance/eubp/submissions/{id}/cancel`
9280 ///
9281 /// Sends an external cancellation request and keeps the local submission. Allowed from pending, sent, accepted, rejected and cancelled; a treasurer and business number are required. A successful result sets cancelled. An eXTra-level rejection can still return HTTP 200 with rejection details in the submission, so inspect the returned status codes. Requires finance edit masterdata permission.
9282 ///
9283 /// # Example
9284 ///
9285 /// ```no_run
9286 /// # use churchtools_api::*;
9287 /// # use churchtools_api::queries::*;
9288 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9289 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9290 /// let submission = client.finance().eubp().submissions().cancel(1)?;
9291 /// println!("{:?}", submission.title);
9292 /// # Ok(())
9293 /// # }
9294 /// ```
9295 pub fn cancel(&self, id: impl Display) -> Result<models::EubpSubmission> {
9296 let path = format!("/finance/eubp/submissions/{}/cancel", seg(id));
9297 let query: Query = Query::new();
9298 self.client.request_data(Method::Post, &path, &query, None)
9299 }
9300
9301 /// Create new euBP submission
9302 ///
9303 /// `POST /finance/eubp/submissions`
9304 ///
9305 /// Creates a draft euBP submission for the inclusive calendar-year range. Main-client treasurer and business number are required. The main client is always included; eligible additional clients receive their own period rows. Each year links the first overlapping CT accounting period, or remains a row without data. Company name/number are snapshotted. No transmission is sent by this endpoint; a delivery deadline within seven days can trigger a notification. Requires finance edit masterdata permission.
9306 ///
9307 /// # Example
9308 ///
9309 /// ```no_run
9310 /// # use churchtools_api::*;
9311 /// # use churchtools_api::queries::*;
9312 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9313 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9314 /// let body = models::EubpSubmissionCreate {
9315 /// client_id: 1,
9316 /// transmission_reason: 1,
9317 /// year_from: 2020,
9318 /// year_to: 2023,
9319 /// ..Default::default()
9320 /// };
9321 /// let result = client.finance().eubp().submissions().create(&body)?;
9322 /// println!("{:?}", result.title);
9323 /// # Ok(())
9324 /// # }
9325 /// ```
9326 pub fn create(&self, body: &models::EubpSubmissionCreate) -> Result<models::EubpSubmission> {
9327 let path = "/finance/eubp/submissions".to_owned();
9328 let query: Query = Query::new();
9329 let body = serde_json::to_value(body).expect("request body serializes");
9330 self.client.request_data(Method::Post, &path, &query, Some(&body))
9331 }
9332
9333 /// Delete euBP submission
9334 ///
9335 /// `DELETE /finance/eubp/submissions/{id}`
9336 ///
9337 /// Deletes the local submission. For every state other than draft, it first sends an external cancellation request and requires a configured treasurer and business number. There is no dry-run mode. This is different from cancel, which retains the local record. Requires finance edit masterdata permission.
9338 ///
9339 /// # Example
9340 ///
9341 /// ```no_run
9342 /// # use churchtools_api::*;
9343 /// # use churchtools_api::queries::*;
9344 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9345 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9346 /// client.finance().eubp().submissions().delete(1)?;
9347 /// # Ok(())
9348 /// # }
9349 /// ```
9350 pub fn delete(&self, id: impl Display) -> Result<()> {
9351 let path = format!("/finance/eubp/submissions/{}", seg(id));
9352 let query: Query = Query::new();
9353 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
9354 }
9355
9356 /// Fetch status from DRV for euBP submission
9357 ///
9358 /// `POST /finance/eubp/submissions/{id}/fetch-status`
9359 ///
9360 /// Fetches remote responses through eXTra, applies status/results locally and confirms received response IDs. Allowed from draft, pending, sent, accepted, rejected and cancelled. This operation can update the stored workflow state and history; it is not just a local read. Requires finance edit masterdata permission.
9361 ///
9362 /// # Example
9363 ///
9364 /// ```no_run
9365 /// # use churchtools_api::*;
9366 /// # use churchtools_api::queries::*;
9367 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9368 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9369 /// let submission = client.finance().eubp().submissions().fetch_status(1)?;
9370 /// println!("{:?}", submission.title);
9371 /// # Ok(())
9372 /// # }
9373 /// ```
9374 pub fn fetch_status(&self, id: impl Display) -> Result<models::EubpSubmission> {
9375 let path = format!("/finance/eubp/submissions/{}/fetch-status", seg(id));
9376 let query: Query = Query::new();
9377 self.client.request_data(Method::Post, &path, &query, None)
9378 }
9379
9380 /// Mark euBP submission as finished
9381 ///
9382 /// `POST /finance/eubp/submissions/{id}/finish`
9383 ///
9384 /// Locally marks an accepted submission as finished and records the change in history. Other starting states return HTTP 400. Does not send another transmission. Requires finance edit masterdata permission.
9385 ///
9386 /// # Example
9387 ///
9388 /// ```no_run
9389 /// # use churchtools_api::*;
9390 /// # use churchtools_api::queries::*;
9391 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9392 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9393 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
9394 /// let submission = client.finance().eubp().submissions().finish(1, &body)?;
9395 /// println!("{:?}", submission.title);
9396 /// # Ok(())
9397 /// # }
9398 /// ```
9399 pub fn finish(&self, id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<models::EubpSubmission> {
9400 let path = format!("/finance/eubp/submissions/{}/finish", seg(id));
9401 let query: Query = Query::new();
9402 let body = serde_json::to_value(body).expect("request body serializes");
9403 self.client.request_data(Method::Post, &path, &query, Some(&body))
9404 }
9405
9406 /// Generate euBP export files
9407 ///
9408 /// `POST /finance/eubp/submissions/{id}/generate`
9409 ///
9410 /// Generates and stores a new ZIP of transmission files and returns its download URL. This updates fileId/downloadUrl but neither sends data nor changes the workflow status. Requires the main client’s treasurer and a business number. File numbers are simulated without reserving transmission numbers. This operation is permitted in any submission state. Requires finance edit masterdata permission.
9411 ///
9412 /// # Example
9413 ///
9414 /// ```no_run
9415 /// # use churchtools_api::*;
9416 /// # use churchtools_api::queries::*;
9417 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9418 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9419 /// let submission = client.finance().eubp().submissions().generate(1)?;
9420 /// println!("{}", submission.download_url);
9421 /// # Ok(())
9422 /// # }
9423 /// ```
9424 pub fn generate(&self, id: impl Display) -> Result<models::PostFinanceEubpSubmissionsIdGenerateData> {
9425 let path = format!("/finance/eubp/submissions/{}/generate", seg(id));
9426 let query: Query = Query::new();
9427 self.client.request_data(Method::Post, &path, &query, None)
9428 }
9429
9430 /// Get euBP submission by ID
9431 ///
9432 /// `GET /finance/eubp/submissions/{id}`
9433 ///
9434 /// Returns the stored submission, including all client/year rows and the most recent transmission statuses. This does not contact DRV to refresh the status. Requires finance edit masterdata permission.
9435 ///
9436 /// # Example
9437 ///
9438 /// ```
9439 /// # use churchtools_api::*;
9440 /// # use churchtools_api::queries::*;
9441 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9442 /// # let client = churchtools_api::replay::client("get-finance-eubp-submissions-id");
9443 /// let submission = client.finance().eubp().submissions().get(1)?;
9444 /// println!("{:?}", submission.title);
9445 /// # Ok(())
9446 /// # }
9447 /// ```
9448 pub fn get(&self, id: impl Display) -> Result<models::EubpSubmission> {
9449 let path = format!("/finance/eubp/submissions/{}", seg(id));
9450 let query: Query = Query::new();
9451 self.client.request_data(Method::Get, &path, &query, None)
9452 }
9453
9454 /// Get preview data for euBP submission
9455 ///
9456 /// `GET /finance/eubp/submissions/{id}/preview`
9457 ///
9458 /// Returns date ranges for all client/year rows and informational warnings for missing accounting periods. It does not generate an export or contact DRV. Multiple clients can produce repeated year entries; preview rows currently contain no client ID. Requires finance edit masterdata permission.
9459 ///
9460 /// # Example
9461 ///
9462 /// ```
9463 /// # use churchtools_api::*;
9464 /// # use churchtools_api::queries::*;
9465 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9466 /// # let client = churchtools_api::replay::client("get-finance-eubp-submissions-id-preview");
9467 /// let preview = client.finance().eubp().submissions().get_preview(1)?;
9468 /// println!("{:?}", preview);
9469 /// # Ok(())
9470 /// # }
9471 /// ```
9472 pub fn get_preview(&self, id: impl Display) -> Result<models::EubpSubmissionPreview> {
9473 let path = format!("/finance/eubp/submissions/{}/preview", seg(id));
9474 let query: Query = Query::new();
9475 self.client.request_data(Method::Get, &path, &query, None)
9476 }
9477
9478 /// Get all euBP submissions
9479 ///
9480 /// `GET /finance/eubp/submissions`
9481 ///
9482 /// Returns all audit submissions, newest ID first, without pagination. client_id matches the main client or any client represented by a submission-period row. An unknown client filter returns an empty list. meta.count is the number returned. Requires finance edit masterdata permission.
9483 ///
9484 /// Use [`Self::list_with`] to pass query parameters.
9485 ///
9486 /// # Example
9487 ///
9488 /// ```
9489 /// # use churchtools_api::*;
9490 /// # use churchtools_api::queries::*;
9491 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9492 /// # let client = churchtools_api::replay::client("get-finance-eubp-submissions");
9493 /// for submission in client.finance().eubp().submissions().list()? {
9494 /// println!("{:?}", submission.title);
9495 /// }
9496 /// # Ok(())
9497 /// # }
9498 /// ```
9499 pub fn list(&self) -> Result<Vec<models::EubpSubmission>> {
9500 self.list_with(&Default::default())
9501 }
9502
9503 /// Get all euBP submissions
9504 ///
9505 /// Like [`Self::list`], with query parameters.
9506 ///
9507 /// `GET /finance/eubp/submissions`
9508 ///
9509 /// Returns all audit submissions, newest ID first, without pagination. client_id matches the main client or any client represented by a submission-period row. An unknown client filter returns an empty list. meta.count is the number returned. Requires finance edit masterdata permission.
9510 pub fn list_with(&self, query: &GetFinanceEubpSubmissionsQuery) -> Result<Vec<models::EubpSubmission>> {
9511 let path = "/finance/eubp/submissions".to_owned();
9512 let query: Query = query.to_query();
9513 self.client.request_data(Method::Get, &path, &query, None)
9514 }
9515
9516 /// Get unified accounts for euBP submission
9517 ///
9518 /// `GET /finance/eubp/submissions/{id}/accounts`
9519 ///
9520 /// Returns accounts with bookings across the submission’s linked accounting periods, merged by exact number|name. Optional client_id restricts the contributing client. Accounts are sorted by account-number length and then lexicographically; years are sorted ascending. This response has no meta wrapper. Requires finance edit masterdata permission.
9521 ///
9522 /// Use [`Self::list_accounts_with`] to pass query parameters.
9523 ///
9524 /// # Example
9525 ///
9526 /// ```
9527 /// # use churchtools_api::*;
9528 /// # use churchtools_api::queries::*;
9529 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9530 /// # let client = churchtools_api::replay::client("get-finance-eubp-submissions-id-accounts");
9531 /// for account in client.finance().eubp().submissions().list_accounts(1)? {
9532 /// println!("{}", account.name);
9533 /// }
9534 /// # Ok(())
9535 /// # }
9536 /// ```
9537 pub fn list_accounts(&self, id: impl Display) -> Result<Vec<models::EubpUnifiedAccount>> {
9538 self.list_accounts_with(id, &Default::default())
9539 }
9540
9541 /// Get unified accounts for euBP submission
9542 ///
9543 /// Like [`Self::list_accounts`], with query parameters.
9544 ///
9545 /// `GET /finance/eubp/submissions/{id}/accounts`
9546 ///
9547 /// Returns accounts with bookings across the submission’s linked accounting periods, merged by exact number|name. Optional client_id restricts the contributing client. Accounts are sorted by account-number length and then lexicographically; years are sorted ascending. This response has no meta wrapper. Requires finance edit masterdata permission.
9548 pub fn list_accounts_with(&self, id: impl Display, query: &GetFinanceEubpSubmissionsIdAccountsQuery) -> Result<Vec<models::EubpUnifiedAccount>> {
9549 let path = format!("/finance/eubp/submissions/{}/accounts", seg(id));
9550 let query: Query = query.to_query();
9551 self.client.request_data(Method::Get, &path, &query, None)
9552 }
9553
9554 /// Reopen finished euBP submission
9555 ///
9556 /// `POST /finance/eubp/submissions/{id}/reopen`
9557 ///
9558 /// Locally changes finished back to accepted and records the change in history. Other starting states return HTTP 400. This does not make the account selection editable, because accepted is not an editable state. Requires finance edit masterdata permission.
9559 ///
9560 /// # Example
9561 ///
9562 /// ```no_run
9563 /// # use churchtools_api::*;
9564 /// # use churchtools_api::queries::*;
9565 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9566 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9567 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
9568 /// let submission = client.finance().eubp().submissions().reopen(1, &body)?;
9569 /// println!("{:?}", submission.title);
9570 /// # Ok(())
9571 /// # }
9572 /// ```
9573 pub fn reopen(&self, id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<models::EubpSubmission> {
9574 let path = format!("/finance/eubp/submissions/{}/reopen", seg(id));
9575 let query: Query = Query::new();
9576 let body = serde_json::to_value(body).expect("request body serializes");
9577 self.client.request_data(Method::Post, &path, &query, Some(&body))
9578 }
9579
9580 /// Send euBP submission to DRV
9581 ///
9582 /// `POST /finance/eubp/submissions/{id}/send`
9583 ///
9584 /// Queues transmission through the eXTra service and returns HTTP 202 with the current submission. Allowed from draft, rejected, response, sent and accepted. Requires a treasurer and business number. The submission is set to pending and old status codes are cleared before the background job is queued. HTTP 202 does not confirm DRV acceptance; read or refresh status afterwards. Requires finance edit masterdata permission.
9585 ///
9586 /// # Example
9587 ///
9588 /// ```no_run
9589 /// # use churchtools_api::*;
9590 /// # use churchtools_api::queries::*;
9591 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9592 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9593 /// client.finance().eubp().submissions().send(1)?;
9594 /// # Ok(())
9595 /// # }
9596 /// ```
9597 pub fn send(&self, id: impl Display) -> Result<()> {
9598 let path = format!("/finance/eubp/submissions/{}/send", seg(id));
9599 let query: Query = Query::new();
9600 self.client.request(Method::Post, &path, &query, None).map(|_| ())
9601 }
9602
9603 /// Update accounts for euBP submission
9604 ///
9605 /// `PUT /finance/eubp/submissions/{id}/accounts`
9606 ///
9607 /// Replaces the optional account selections across linked periods, optionally for one client. Uses exact number|name keys. Unknown keys are ignored and omitted optional selections are removed. Mandatory accounts are not stored as additional selections. Only draft, rejected and response are editable. Returns the resulting merged list of accounts with bookings, without meta. Requires finance edit masterdata permission.
9608 ///
9609 /// # Example
9610 ///
9611 /// ```no_run
9612 /// # use churchtools_api::*;
9613 /// # use churchtools_api::queries::*;
9614 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9615 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9616 /// let body = models::EubpSubmissionAccountsUpdate {
9617 /// account_keys: vec!["1200|Bank".into()],
9618 /// ..Default::default()
9619 /// };
9620 /// for submission in client.finance().eubp().submissions().update_accounts(1, &body)? {
9621 /// println!("{}", submission.name);
9622 /// }
9623 /// # Ok(())
9624 /// # }
9625 /// ```
9626 pub fn update_accounts(&self, id: impl Display, body: &models::EubpSubmissionAccountsUpdate) -> Result<Vec<models::EubpUnifiedAccount>> {
9627 let path = format!("/finance/eubp/submissions/{}/accounts", seg(id));
9628 let query: Query = Query::new();
9629 let body = serde_json::to_value(body).expect("request body serializes");
9630 self.client.request_data(Method::Put, &path, &query, Some(&body))
9631 }
9632
9633}
9634
9635/// `client.finance().eubp().submissions().periods()`
9636#[derive(Clone, Copy)]
9637pub struct FinanceEubpSubmissionsPeriodsResource<'a> {
9638 client: &'a Client,
9639}
9640
9641impl<'a> FinanceEubpSubmissionsPeriodsResource<'a> {
9642 /// Update additional accounts for a submission period
9643 ///
9644 /// `PUT /finance/eubp/submissions/{id}/periods/{periodId}/accounts`
9645 ///
9646 /// Replaces the additional-account selection for one submission-period row. periodId is a row ID from submission.periods, not an accounting-period ID. A row belonging to another submission returns HTTP 400. Only draft, rejected and response are editable. Unknown account IDs are ignored; current code does not enforce that supplied accounts belong to the row’s accounting period. Requires finance edit masterdata permission.
9647 ///
9648 /// # Example
9649 ///
9650 /// ```no_run
9651 /// # use churchtools_api::*;
9652 /// # use churchtools_api::queries::*;
9653 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9654 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9655 /// let body = models::EubpPeriodAccountsUpdate {
9656 /// account_ids: vec![10, 11],
9657 /// ..Default::default()
9658 /// };
9659 /// let result = client.finance().eubp().submissions().periods().update_accounts(1, 1, &body)?;
9660 /// println!("{}", result.id);
9661 /// # Ok(())
9662 /// # }
9663 /// ```
9664 pub fn update_accounts(&self, id: impl Display, period_id: impl Display, body: &models::EubpPeriodAccountsUpdate) -> Result<models::EubpSubmissionPeriod> {
9665 let path = format!("/finance/eubp/submissions/{}/periods/{}/accounts", seg(id), seg(period_id));
9666 let query: Query = Query::new();
9667 let body = serde_json::to_value(body).expect("request body serializes");
9668 self.client.request_data(Method::Put, &path, &query, Some(&body))
9669 }
9670
9671}
9672
9673/// `client.finance().reports()`
9674#[derive(Clone, Copy)]
9675pub struct FinanceReportsResource<'a> {
9676 client: &'a Client,
9677}
9678
9679impl<'a> FinanceReportsResource<'a> {
9680 pub fn statement(&self) -> FinanceReportsStatementResource<'a> {
9681 FinanceReportsStatementResource { client: self.client }
9682 }
9683
9684 /// Create balance report
9685 ///
9686 /// `POST /finance/reports/balance`
9687 ///
9688 /// Creates a balance sheet from balance accounts in the requested document-date range. The configured profit/loss account class can include the period result. Requires finance edit masterdata or explicit view/edit permission for the accounting period; group-level access alone is insufficient. Default format=pdf returns HTTP 201 with data.url. CSV/XLSX return HTTP 200 with the file body. An Accept header whose first value is exactly text/html returns rendered HTML with HTTP 200 and overrides format.
9689 ///
9690 /// # Example
9691 ///
9692 /// ```no_run
9693 /// # use churchtools_api::*;
9694 /// # use churchtools_api::queries::*;
9695 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9696 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9697 /// let body = models::BalanceReportCreate {
9698 /// accounting_period_id: 1,
9699 /// end_date: "2026-12-31".parse()?,
9700 /// start_date: "2026-01-01".parse()?,
9701 /// ..Default::default()
9702 /// };
9703 /// let data = client.finance().reports().balance(&body)?;
9704 /// std::fs::write("ergebnis.xlsx", &data)?;
9705 /// # Ok(())
9706 /// # }
9707 /// ```
9708 pub fn balance(&self, body: &models::BalanceReportCreate) -> Result<Vec<u8>> {
9709 let path = "/finance/reports/balance".to_owned();
9710 let query: Query = Query::new();
9711 let body = serde_json::to_value(body).expect("request body serializes");
9712 self.client.request(Method::Post, &path, &query, Some(&body))
9713 }
9714
9715 /// Create profit and loss report
9716 ///
9717 /// `POST /finance/reports/profit-loss`
9718 ///
9719 /// Creates a profit-and-loss report from accounts whose account type has no balance-sheet classification. Requires finance edit masterdata or explicit view/edit permission for the accounting period; group-level access alone is insufficient. Default format=pdf returns HTTP 201 with data.url. CSV/XLSX return HTTP 200 with the file body. An Accept header whose first value is exactly text/html returns rendered HTML with HTTP 200 and overrides format.
9720 ///
9721 /// # Example
9722 ///
9723 /// ```no_run
9724 /// # use churchtools_api::*;
9725 /// # use churchtools_api::queries::*;
9726 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9727 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9728 /// let body = models::BalanceReportCreate {
9729 /// accounting_period_id: 1,
9730 /// end_date: "2026-12-31".parse()?,
9731 /// start_date: "2026-01-01".parse()?,
9732 /// ..Default::default()
9733 /// };
9734 /// let data = client.finance().reports().profit_loss(&body)?;
9735 /// std::fs::write("ergebnis.xlsx", &data)?;
9736 /// # Ok(())
9737 /// # }
9738 /// ```
9739 pub fn profit_loss(&self, body: &models::BalanceReportCreate) -> Result<Vec<u8>> {
9740 let path = "/finance/reports/profit-loss".to_owned();
9741 let query: Query = Query::new();
9742 let body = serde_json::to_value(body).expect("request body serializes");
9743 self.client.request(Method::Post, &path, &query, Some(&body))
9744 }
9745
9746 /// Create summed balance report
9747 ///
9748 /// `POST /finance/reports/sum-balance`
9749 ///
9750 /// Creates a trial balance (Summen- und Saldenliste) with opening balances, debit/credit totals for the chosen month and cumulative totals from January. accountTypes does not filter this report. Requires finance edit masterdata or explicit view/edit permission for the accounting period; group-level access alone is insufficient. Default format=pdf returns HTTP 201 with data.url. CSV/XLSX return HTTP 200 with the file body. An Accept header whose first value is exactly text/html returns rendered HTML with HTTP 200 and overrides format.
9751 ///
9752 /// # Example
9753 ///
9754 /// ```no_run
9755 /// # use churchtools_api::*;
9756 /// # use churchtools_api::queries::*;
9757 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9758 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9759 /// let body = models::SumBalanceReportCreate {
9760 /// accounting_period_id: 1,
9761 /// month: 9,
9762 /// ..Default::default()
9763 /// };
9764 /// let data = client.finance().reports().sum_balance(&body)?;
9765 /// std::fs::write("ergebnis.xlsx", &data)?;
9766 /// # Ok(())
9767 /// # }
9768 /// ```
9769 pub fn sum_balance(&self, body: &models::SumBalanceReportCreate) -> Result<Vec<u8>> {
9770 let path = "/finance/reports/sum-balance".to_owned();
9771 let query: Query = Query::new();
9772 let body = serde_json::to_value(body).expect("request body serializes");
9773 self.client.request(Method::Post, &path, &query, Some(&body))
9774 }
9775
9776 /// Issue new turnover report
9777 ///
9778 /// `POST /finance/reports/turnover`
9779 ///
9780 /// Creates monthly or quarterly account turnover columns. Columns use the calendar year of the accounting period’s start date; the total reflects the selected accounting period. Requires finance edit masterdata or explicit view/edit permission for the accounting period; group-level access alone is insufficient. Default format=pdf returns HTTP 201 with data.url. CSV/XLSX return HTTP 200 with the file body. An Accept header whose first value is exactly text/html returns rendered HTML with HTTP 200 and overrides format.
9781 ///
9782 /// # Example
9783 ///
9784 /// ```no_run
9785 /// # use churchtools_api::*;
9786 /// # use churchtools_api::queries::*;
9787 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9788 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9789 /// let body = models::TurnoverReportCreate {
9790 /// accounting_period_id: 1,
9791 /// period: "monthly".into(),
9792 /// ..Default::default()
9793 /// };
9794 /// let data = client.finance().reports().turnover(&body)?;
9795 /// std::fs::write("ergebnis.xlsx", &data)?;
9796 /// # Ok(())
9797 /// # }
9798 /// ```
9799 pub fn turnover(&self, body: &models::TurnoverReportCreate) -> Result<Vec<u8>> {
9800 let path = "/finance/reports/turnover".to_owned();
9801 let query: Query = Query::new();
9802 let body = serde_json::to_value(body).expect("request body serializes");
9803 self.client.request(Method::Post, &path, &query, Some(&body))
9804 }
9805
9806}
9807
9808/// `client.finance().reports().statement()`
9809#[derive(Clone, Copy)]
9810pub struct FinanceReportsStatementResource<'a> {
9811 client: &'a Client,
9812}
9813
9814impl<'a> FinanceReportsStatementResource<'a> {
9815 pub fn accounts(&self) -> FinanceReportsStatementAccountsResource<'a> {
9816 FinanceReportsStatementAccountsResource { client: self.client }
9817 }
9818
9819 pub fn cost_centers(&self) -> FinanceReportsStatementCostCentersResource<'a> {
9820 FinanceReportsStatementCostCentersResource { client: self.client }
9821 }
9822
9823}
9824
9825/// `client.finance().reports().statement().accounts()`
9826#[derive(Clone, Copy)]
9827pub struct FinanceReportsStatementAccountsResource<'a> {
9828 client: &'a Client,
9829}
9830
9831impl<'a> FinanceReportsStatementAccountsResource<'a> {
9832 /// Create account statement report
9833 ///
9834 /// `POST /finance/reports/statement/accounts/{accountId}`
9835 ///
9836 /// Creates a ledger report of posted finance transactions for one account, sorted by document date. This is separate from imported bank-statement files. Missing date boundaries default independently to the account’s accounting period. Requires finance edit masterdata or explicit view/edit permission for the accounting period; group-level access alone is insufficient. Default format=pdf returns HTTP 201 with data.url. CSV/XLSX return HTTP 200 with the file body. An Accept header whose first value is exactly text/html returns rendered HTML with HTTP 200 and overrides format.
9837 ///
9838 /// # Example
9839 ///
9840 /// ```no_run
9841 /// # use churchtools_api::*;
9842 /// # use churchtools_api::queries::*;
9843 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9844 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9845 /// let body = models::AccountStatementReportCreate {
9846 /// end_date: Some(Some("2026-12-31".parse()?)),
9847 /// ..Default::default()
9848 /// };
9849 /// let data = client.finance().reports().statement().accounts().create(21, &body)?;
9850 /// std::fs::write("ergebnis.xlsx", &data)?;
9851 /// # Ok(())
9852 /// # }
9853 /// ```
9854 pub fn create(&self, account_id: impl Display, body: &models::AccountStatementReportCreate) -> Result<Vec<u8>> {
9855 let path = format!("/finance/reports/statement/accounts/{}", seg(account_id));
9856 let query: Query = Query::new();
9857 let body = serde_json::to_value(body).expect("request body serializes");
9858 self.client.request(Method::Post, &path, &query, Some(&body))
9859 }
9860
9861}
9862
9863/// `client.finance().reports().statement().cost_centers()`
9864#[derive(Clone, Copy)]
9865pub struct FinanceReportsStatementCostCentersResource<'a> {
9866 client: &'a Client,
9867}
9868
9869impl<'a> FinanceReportsStatementCostCentersResource<'a> {
9870 /// Create cost center statement report
9871 ///
9872 /// `POST /finance/reports/statement/costcenters/{costCenterId}`
9873 ///
9874 /// Creates a ledger report of transactions assigned to one cost center, with income, expenditure and totals. Canceled transactions and their cancellation entries are excluded. Internal rebookings are omitted unless includeRebookings=true. Missing date boundaries default independently to the cost center’s accounting period. Requires finance edit masterdata or explicit view/edit permission for the accounting period; group-level access alone is insufficient. Default format=pdf returns HTTP 201 with data.url. CSV/XLSX return HTTP 200 with the file body. An Accept header whose first value is exactly text/html returns rendered HTML with HTTP 200 and overrides format.
9875 ///
9876 /// # Example
9877 ///
9878 /// ```no_run
9879 /// # use churchtools_api::*;
9880 /// # use churchtools_api::queries::*;
9881 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9882 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9883 /// let body = models::CostCenterStatementReportCreate {
9884 /// end_date: Some(Some("2026-12-31".parse()?)),
9885 /// ..Default::default()
9886 /// };
9887 /// let data = client.finance().reports().statement().cost_centers().create(21, &body)?;
9888 /// std::fs::write("ergebnis.xlsx", &data)?;
9889 /// # Ok(())
9890 /// # }
9891 /// ```
9892 pub fn create(&self, cost_center_id: impl Display, body: &models::CostCenterStatementReportCreate) -> Result<Vec<u8>> {
9893 let path = format!("/finance/reports/statement/costcenters/{}", seg(cost_center_id));
9894 let query: Query = Query::new();
9895 let body = serde_json::to_value(body).expect("request body serializes");
9896 self.client.request(Method::Post, &path, &query, Some(&body))
9897 }
9898
9899}
9900
9901/// `client.finance().split_transactions()`
9902#[derive(Clone, Copy)]
9903pub struct FinanceSplitTransactionsResource<'a> {
9904 client: &'a Client,
9905}
9906
9907impl<'a> FinanceSplitTransactionsResource<'a> {
9908 /// Create new split transaction
9909 ///
9910 /// `POST /finance/splittransactions`
9911 ///
9912 /// Creates a grouped booking from new children or existing standalone booking IDs. Child notes, amounts, accounts and assignments are supplied separately; document date and number come from the parent. New child accounts must allow posting; supplied existing child accounts require period edit permission. Children must meet the shared-account and amount-sum rules. A new child must belong to an open period containing the document date. Generated tax amounts are derived from the gross child inputs. With one child the group is converted to an ordinary booking and HTTP 204 is returned without its ID. For multiple children, returns the split parent with child booking data.
9913 ///
9914 /// Use [`Self::create_with`] to pass query parameters.
9915 ///
9916 /// # Example
9917 ///
9918 /// ```no_run
9919 /// # use churchtools_api::*;
9920 /// # use churchtools_api::queries::*;
9921 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9922 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9923 /// let body = models::SplitTransactionCreate {
9924 /// amount: 30000,
9925 /// document_date: "2026-09-14".parse()?,
9926 /// note: Some("Offering and building fund".into()),
9927 /// split_children: vec![models::SplitTransactionChildCreate {
9928 /// account_id: 10,
9929 /// amount: 7812,
9930 /// contra_account_id: 11,
9931 /// note: Some("Building fund".into()),
9932 /// ..Default::default()
9933 /// }],
9934 /// ..Default::default()
9935 /// };
9936 /// let result = client.finance().split_transactions().create(&body)?;
9937 /// println!("{:?}", result);
9938 /// # Ok(())
9939 /// # }
9940 /// ```
9941 pub fn create(&self, body: &models::SplitTransactionCreate) -> Result<Option<models::SplitTransaction>> {
9942 self.create_with(&Default::default(), body)
9943 }
9944
9945 /// Create new split transaction
9946 ///
9947 /// Like [`Self::create`], with query parameters.
9948 ///
9949 /// `POST /finance/splittransactions`
9950 ///
9951 /// Creates a grouped booking from new children or existing standalone booking IDs. Child notes, amounts, accounts and assignments are supplied separately; document date and number come from the parent. New child accounts must allow posting; supplied existing child accounts require period edit permission. Children must meet the shared-account and amount-sum rules. A new child must belong to an open period containing the document date. Generated tax amounts are derived from the gross child inputs. With one child the group is converted to an ordinary booking and HTTP 204 is returned without its ID. For multiple children, returns the split parent with child booking data.
9952 pub fn create_with(&self, query: &PostFinanceSplittransactionsQuery, body: &models::SplitTransactionCreate) -> Result<Option<models::SplitTransaction>> {
9953 let path = "/finance/splittransactions".to_owned();
9954 let query: Query = query.to_query();
9955 let body = serde_json::to_value(body).expect("request body serializes");
9956 self.client.request_data(Method::Post, &path, &query, Some(&body))
9957 }
9958
9959 /// Delete split transaction
9960 ///
9961 /// `DELETE /finance/splittransactions/{id}`
9962 ///
9963 /// Deletes the entire split parent, its ordinary and generated tax children, related cancellation group, and attached receipts/files. Related statement movements are reset to open and unlinked. Requires edit permission for every child’s period. Each child must be mutable and its period open. dry_run=true returns HTTP 409 with a deletion assessment without deleting, including when deletion is possible.
9964 ///
9965 /// Use [`Self::delete_with`] to pass query parameters.
9966 ///
9967 /// # Example
9968 ///
9969 /// ```no_run
9970 /// # use churchtools_api::*;
9971 /// # use churchtools_api::queries::*;
9972 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9973 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
9974 /// client.finance().split_transactions().delete(1)?;
9975 /// # Ok(())
9976 /// # }
9977 /// ```
9978 pub fn delete(&self, id: impl Display) -> Result<()> {
9979 self.delete_with(id, &Default::default())
9980 }
9981
9982 /// Delete split transaction
9983 ///
9984 /// Like [`Self::delete`], with query parameters.
9985 ///
9986 /// `DELETE /finance/splittransactions/{id}`
9987 ///
9988 /// Deletes the entire split parent, its ordinary and generated tax children, related cancellation group, and attached receipts/files. Related statement movements are reset to open and unlinked. Requires edit permission for every child’s period. Each child must be mutable and its period open. dry_run=true returns HTTP 409 with a deletion assessment without deleting, including when deletion is possible.
9989 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceSplittransactionsIdQuery) -> Result<()> {
9990 let path = format!("/finance/splittransactions/{}", seg(id));
9991 let query: Query = query.to_query();
9992 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
9993 }
9994
9995 /// Duplicate split transaction
9996 ///
9997 /// `POST /finance/splittransactions/{id}/duplicate`
9998 ///
9999 /// Creates a new split group from the source children, regenerating tax bookings and copying parent receipts/files. Requires permission to create each child using its source accounts and cost center; periods must be open and dates valid. Copies the original date, notes, donor assignments, waiver and cash discount. Uses the parent number plus -Kopie and numbered child suffixes, without guaranteeing uniqueness. New children are mutable and non-synced. Unlike ordinary duplicate, child donor/spouse consistency is checked during creation.
10000 ///
10001 /// # Example
10002 ///
10003 /// ```no_run
10004 /// # use churchtools_api::*;
10005 /// # use churchtools_api::queries::*;
10006 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10007 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10008 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
10009 /// let split_transaction = client.finance().split_transactions().duplicate(1, &body)?;
10010 /// println!("{}", split_transaction.id);
10011 /// # Ok(())
10012 /// # }
10013 /// ```
10014 pub fn duplicate(&self, id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<models::SplitTransaction> {
10015 let path = format!("/finance/splittransactions/{}/duplicate", seg(id));
10016 let query: Query = Query::new();
10017 let body = serde_json::to_value(body).expect("request body serializes");
10018 self.client.request_data(Method::Post, &path, &query, Some(&body))
10019 }
10020
10021 /// Get a split transaction
10022 ///
10023 /// `GET /finance/splittransactions/{id}`
10024 ///
10025 /// Returns a split parent with its ordinary child bookings, including generated tax rows. The caller must be allowed to view every child; one inaccessible child rejects the entire request. Donor details and notes are censored per child according to donor visibility. include\[\]=bills adds receipts attached to the parent. The parent note is returned independently of the child notes.
10026 ///
10027 /// Use [`Self::get_with`] to pass query parameters.
10028 ///
10029 /// # Example
10030 ///
10031 /// ```
10032 /// # use churchtools_api::*;
10033 /// # use churchtools_api::queries::*;
10034 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10035 /// # let client = churchtools_api::replay::client("get-finance-splittransactions-id");
10036 /// let split_transaction = client.finance().split_transactions().get(1)?;
10037 /// println!("{}", split_transaction.id);
10038 /// # Ok(())
10039 /// # }
10040 /// ```
10041 pub fn get(&self, id: impl Display) -> Result<models::SplitTransaction> {
10042 self.get_with(id, &Default::default())
10043 }
10044
10045 /// Get a split transaction
10046 ///
10047 /// Like [`Self::get`], with query parameters.
10048 ///
10049 /// `GET /finance/splittransactions/{id}`
10050 ///
10051 /// Returns a split parent with its ordinary child bookings, including generated tax rows. The caller must be allowed to view every child; one inaccessible child rejects the entire request. Donor details and notes are censored per child according to donor visibility. include\[\]=bills adds receipts attached to the parent. The parent note is returned independently of the child notes.
10052 pub fn get_with(&self, id: impl Display, query: &GetFinanceSplittransactionsIdQuery) -> Result<models::SplitTransaction> {
10053 let path = format!("/finance/splittransactions/{}", seg(id));
10054 let query: Query = query.to_query();
10055 self.client.request_data(Method::Get, &path, &query, None)
10056 }
10057
10058 /// Update split transaction, or convert to normal transaction, if only one split child is given,
10059 ///
10060 /// `PUT /finance/splittransactions/{id}`
10061 ///
10062 /// Replaces a split parent and its complete child list. Existing children not included in the request are deleted. Child notes, amounts, accounts and assignments are supplied separately; document date and number come from the parent. New child accounts must allow posting; supplied existing child accounts require period edit permission. Children must meet the shared-account and amount-sum rules. A new child must belong to an open period containing the document date. Generated tax amounts are derived from the gross child inputs. With one child the group is converted to an ordinary booking and HTTP 204 is returned without its ID. For multiple children, returns the split parent with child booking data.
10063 ///
10064 /// Use [`Self::update_with`] to pass query parameters.
10065 ///
10066 /// # Example
10067 ///
10068 /// ```no_run
10069 /// # use churchtools_api::*;
10070 /// # use churchtools_api::queries::*;
10071 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10072 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10073 /// let body = models::SplitTransactionUpdate {
10074 /// amount: 30000,
10075 /// document_date: "2026-09-14".parse()?,
10076 /// note: Some("Offering and building fund".into()),
10077 /// split_children: vec![models::SplitTransactionChildCreate {
10078 /// account_id: 10,
10079 /// amount: 7812,
10080 /// contra_account_id: 11,
10081 /// note: Some("Building fund".into()),
10082 /// ..Default::default()
10083 /// }],
10084 /// ..Default::default()
10085 /// };
10086 /// let result = client.finance().split_transactions().update(1, &body)?;
10087 /// println!("{:?}", result);
10088 /// # Ok(())
10089 /// # }
10090 /// ```
10091 pub fn update(&self, id: impl Display, body: &models::SplitTransactionUpdate) -> Result<Option<models::SplitTransaction>> {
10092 self.update_with(id, &Default::default(), body)
10093 }
10094
10095 /// Update split transaction, or convert to normal transaction, if only one split child is given,
10096 ///
10097 /// Like [`Self::update`], with query parameters.
10098 ///
10099 /// `PUT /finance/splittransactions/{id}`
10100 ///
10101 /// Replaces a split parent and its complete child list. Existing children not included in the request are deleted. Child notes, amounts, accounts and assignments are supplied separately; document date and number come from the parent. New child accounts must allow posting; supplied existing child accounts require period edit permission. Children must meet the shared-account and amount-sum rules. A new child must belong to an open period containing the document date. Generated tax amounts are derived from the gross child inputs. With one child the group is converted to an ordinary booking and HTTP 204 is returned without its ID. For multiple children, returns the split parent with child booking data.
10102 pub fn update_with(&self, id: impl Display, query: &PutFinanceSplittransactionsIdQuery, body: &models::SplitTransactionUpdate) -> Result<Option<models::SplitTransaction>> {
10103 let path = format!("/finance/splittransactions/{}", seg(id));
10104 let query: Query = query.to_query();
10105 let body = serde_json::to_value(body).expect("request body serializes");
10106 self.client.request_data(Method::Put, &path, &query, Some(&body))
10107 }
10108
10109 /// Cancel split transaction
10110 ///
10111 /// `PUT /finance/splittransactions/{id}/storno`
10112 ///
10113 /// Creates and returns one cancellation split parent containing opposite bookings for the original children, including tax bookings. Original records remain and reference their cancellations. Requires edit permission for each child period. Unlike ordinary cancellation, a second cancellation attempt is rejected with 403 if a child already has a cancellation. This operation does not explicitly require an open period. The original document date and amount are retained; the parent document number receives -Storno. The result is one object, not an array.
10114 ///
10115 /// # Example
10116 ///
10117 /// ```no_run
10118 /// # use churchtools_api::*;
10119 /// # use churchtools_api::queries::*;
10120 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10121 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10122 /// let body = models::SplitTransactionStornoCreate {
10123 /// note: "Incorrect allocation".into(),
10124 /// ..Default::default()
10125 /// };
10126 /// let result = client.finance().split_transactions().update_storno(1, &body)?;
10127 /// println!("{}", result.id);
10128 /// # Ok(())
10129 /// # }
10130 /// ```
10131 pub fn update_storno(&self, id: impl Display, body: &models::SplitTransactionStornoCreate) -> Result<models::SplitTransaction> {
10132 let path = format!("/finance/splittransactions/{}/storno", seg(id));
10133 let query: Query = Query::new();
10134 let body = serde_json::to_value(body).expect("request body serializes");
10135 self.client.request_data(Method::Put, &path, &query, Some(&body))
10136 }
10137
10138}
10139
10140/// `client.finance().tax_rates()`
10141#[derive(Clone, Copy)]
10142pub struct FinanceTaxRatesResource<'a> {
10143 client: &'a Client,
10144}
10145
10146impl<'a> FinanceTaxRatesResource<'a> {
10147 /// Create a tax rate
10148 ///
10149 /// `POST /finance/taxrates`
10150 ///
10151 /// A tax rate combines a tax type, a percentage and the ledger account receiving the tax amount. Its accounting period is determined by that account. Requires finance “edit masterdata”. Returns HTTP 200 on success. The combination of taxTypeId, rate and accountId must be unique. The target account must belong to an open accounting period.
10152 ///
10153 /// # Example
10154 ///
10155 /// ```no_run
10156 /// # use churchtools_api::*;
10157 /// # use churchtools_api::queries::*;
10158 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10159 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10160 /// let body = models::TaxRateCreate {
10161 /// account_id: 5,
10162 /// rate: 7.0,
10163 /// tax_type_id: 4,
10164 /// ..Default::default()
10165 /// };
10166 /// let result = client.finance().tax_rates().create(&body)?;
10167 /// println!("{}", result.id);
10168 /// # Ok(())
10169 /// # }
10170 /// ```
10171 pub fn create(&self, body: &models::TaxRateCreate) -> Result<models::TaxRate> {
10172 let path = "/finance/taxrates".to_owned();
10173 let query: Query = Query::new();
10174 let body = serde_json::to_value(body).expect("request body serializes");
10175 self.client.request_data(Method::Post, &path, &query, Some(&body))
10176 }
10177
10178 /// Delete tax rate
10179 ///
10180 /// `DELETE /finance/taxrates/{id}`
10181 ///
10182 /// Deletes this tax rate if no transactions or accounts reference it. Requires finance “edit masterdata”. dry_run=true returns the HTTP 409 conflict report without deleting, also when deletion is allowed.
10183 ///
10184 /// Use [`Self::delete_with`] to pass query parameters.
10185 ///
10186 /// # Example
10187 ///
10188 /// ```no_run
10189 /// # use churchtools_api::*;
10190 /// # use churchtools_api::queries::*;
10191 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10192 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10193 /// client.finance().tax_rates().delete(1)?;
10194 /// # Ok(())
10195 /// # }
10196 /// ```
10197 pub fn delete(&self, id: impl Display) -> Result<()> {
10198 self.delete_with(id, &Default::default())
10199 }
10200
10201 /// Delete tax rate
10202 ///
10203 /// Like [`Self::delete`], with query parameters.
10204 ///
10205 /// `DELETE /finance/taxrates/{id}`
10206 ///
10207 /// Deletes this tax rate if no transactions or accounts reference it. Requires finance “edit masterdata”. dry_run=true returns the HTTP 409 conflict report without deleting, also when deletion is allowed.
10208 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceTaxratesIdQuery) -> Result<()> {
10209 let path = format!("/finance/taxrates/{}", seg(id));
10210 let query: Query = query.to_query();
10211 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
10212 }
10213
10214 /// Get a tax rate
10215 ///
10216 /// `GET /finance/taxrates/{id}`
10217 ///
10218 /// A tax rate combines a tax type, a percentage and the ledger account receiving the tax amount. Its accounting period is determined by that account. Returns one definition by ID.
10219 ///
10220 /// # Example
10221 ///
10222 /// ```
10223 /// # use churchtools_api::*;
10224 /// # use churchtools_api::queries::*;
10225 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10226 /// # let client = churchtools_api::replay::client("get-finance-taxrates-id");
10227 /// let tax_rate = client.finance().tax_rates().get(1)?;
10228 /// println!("{}", tax_rate.id);
10229 /// # Ok(())
10230 /// # }
10231 /// ```
10232 pub fn get(&self, id: impl Display) -> Result<models::TaxRate> {
10233 let path = format!("/finance/taxrates/{}", seg(id));
10234 let query: Query = Query::new();
10235 self.client.request_data(Method::Get, &path, &query, None)
10236 }
10237
10238 /// Get all tax rates
10239 ///
10240 /// `GET /finance/taxrates`
10241 ///
10242 /// A tax rate combines a tax type, a percentage and the ledger account receiving the tax amount. Its accounting period is determined by that account. Returns an unpaginated list. Optionally restrict results to the linked accounts’ accounting period. No result order is guaranteed; an unknown period returns an empty list. meta.count is the number returned.
10243 ///
10244 /// Use [`Self::list_with`] to pass query parameters.
10245 ///
10246 /// # Example
10247 ///
10248 /// ```
10249 /// # use churchtools_api::*;
10250 /// # use churchtools_api::queries::*;
10251 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10252 /// # let client = churchtools_api::replay::client("get-finance-taxrates");
10253 /// for tax_rate in client.finance().tax_rates().list()? {
10254 /// println!("{}", tax_rate.id);
10255 /// }
10256 /// # Ok(())
10257 /// # }
10258 /// ```
10259 pub fn list(&self) -> Result<Vec<models::TaxRate>> {
10260 self.list_with(&Default::default())
10261 }
10262
10263 /// Get all tax rates
10264 ///
10265 /// Like [`Self::list`], with query parameters.
10266 ///
10267 /// `GET /finance/taxrates`
10268 ///
10269 /// A tax rate combines a tax type, a percentage and the ledger account receiving the tax amount. Its accounting period is determined by that account. Returns an unpaginated list. Optionally restrict results to the linked accounts’ accounting period. No result order is guaranteed; an unknown period returns an empty list. meta.count is the number returned.
10270 pub fn list_with(&self, query: &GetFinanceTaxratesQuery) -> Result<Vec<models::TaxRate>> {
10271 let path = "/finance/taxrates".to_owned();
10272 let query: Query = query.to_query();
10273 self.client.request_data(Method::Get, &path, &query, None)
10274 }
10275
10276 /// Update tax rate
10277 ///
10278 /// `PUT /finance/taxrates/{id}`
10279 ///
10280 /// Replaces this tax rate. Requires finance “edit masterdata”. When transactions reference the rate, only note may change; resend the existing rate, taxTypeId and accountId. Omitted note is cleared. The target account must belong to an open accounting period.
10281 ///
10282 /// # Example
10283 ///
10284 /// ```no_run
10285 /// # use churchtools_api::*;
10286 /// # use churchtools_api::queries::*;
10287 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10288 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10289 /// let body = models::TaxRateUpdate {
10290 /// account_id: 5,
10291 /// rate: 7.0,
10292 /// tax_type_id: 4,
10293 /// ..Default::default()
10294 /// };
10295 /// let result = client.finance().tax_rates().update(1, &body)?;
10296 /// println!("{}", result.id);
10297 /// # Ok(())
10298 /// # }
10299 /// ```
10300 pub fn update(&self, id: impl Display, body: &models::TaxRateUpdate) -> Result<models::TaxRate> {
10301 let path = format!("/finance/taxrates/{}", seg(id));
10302 let query: Query = Query::new();
10303 let body = serde_json::to_value(body).expect("request body serializes");
10304 self.client.request_data(Method::Put, &path, &query, Some(&body))
10305 }
10306
10307}
10308
10309/// `client.finance().tax_types()`
10310#[derive(Clone, Copy)]
10311pub struct FinanceTaxTypesResource<'a> {
10312 client: &'a Client,
10313}
10314
10315impl<'a> FinanceTaxTypesResource<'a> {
10316 /// Create a tax type
10317 ///
10318 /// `POST /finance/taxtypes`
10319 ///
10320 /// Tax types group tax rates by their accounting purpose, for example input tax or output tax. The percentage and receiving ledger account are configured on each tax rate. Requires finance “edit masterdata”. Returns HTTP 200 on success. The name must be unique.
10321 ///
10322 /// # Example
10323 ///
10324 /// ```no_run
10325 /// # use churchtools_api::*;
10326 /// # use churchtools_api::queries::*;
10327 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10328 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10329 /// let body = models::TaxTypeCreate {
10330 /// sort_key: 0,
10331 /// ..Default::default()
10332 /// };
10333 /// let result = client.finance().tax_types().create(&body)?;
10334 /// println!("{:?}", result.name);
10335 /// # Ok(())
10336 /// # }
10337 /// ```
10338 pub fn create(&self, body: &models::TaxTypeCreate) -> Result<models::TaxType> {
10339 let path = "/finance/taxtypes".to_owned();
10340 let query: Query = Query::new();
10341 let body = serde_json::to_value(body).expect("request body serializes");
10342 self.client.request_data(Method::Post, &path, &query, Some(&body))
10343 }
10344
10345 /// Delete tax type
10346 ///
10347 /// `DELETE /finance/taxtypes/{id}`
10348 ///
10349 /// Deletes this tax type if no tax rates reference it. Requires finance “edit masterdata”. dry_run=true returns the HTTP 409 conflict report without deleting, also when deletion is allowed.
10350 ///
10351 /// Use [`Self::delete_with`] to pass query parameters.
10352 ///
10353 /// # Example
10354 ///
10355 /// ```no_run
10356 /// # use churchtools_api::*;
10357 /// # use churchtools_api::queries::*;
10358 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10359 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10360 /// client.finance().tax_types().delete(1)?;
10361 /// # Ok(())
10362 /// # }
10363 /// ```
10364 pub fn delete(&self, id: impl Display) -> Result<()> {
10365 self.delete_with(id, &Default::default())
10366 }
10367
10368 /// Delete tax type
10369 ///
10370 /// Like [`Self::delete`], with query parameters.
10371 ///
10372 /// `DELETE /finance/taxtypes/{id}`
10373 ///
10374 /// Deletes this tax type if no tax rates reference it. Requires finance “edit masterdata”. dry_run=true returns the HTTP 409 conflict report without deleting, also when deletion is allowed.
10375 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceTaxtypesIdQuery) -> Result<()> {
10376 let path = format!("/finance/taxtypes/{}", seg(id));
10377 let query: Query = query.to_query();
10378 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
10379 }
10380
10381 /// Get a tax type
10382 ///
10383 /// `GET /finance/taxtypes/{id}`
10384 ///
10385 /// Tax types group tax rates by their accounting purpose, for example input tax or output tax. The percentage and receiving ledger account are configured on each tax rate. Returns one definition by ID.
10386 ///
10387 /// # Example
10388 ///
10389 /// ```
10390 /// # use churchtools_api::*;
10391 /// # use churchtools_api::queries::*;
10392 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10393 /// # let client = churchtools_api::replay::client("get-finance-taxtypes-id");
10394 /// let tax_type = client.finance().tax_types().get(1)?;
10395 /// println!("{:?}", tax_type.name);
10396 /// # Ok(())
10397 /// # }
10398 /// ```
10399 pub fn get(&self, id: impl Display) -> Result<models::TaxType> {
10400 let path = format!("/finance/taxtypes/{}", seg(id));
10401 let query: Query = Query::new();
10402 self.client.request_data(Method::Get, &path, &query, None)
10403 }
10404
10405 /// Get all tax types
10406 ///
10407 /// `GET /finance/taxtypes`
10408 ///
10409 /// Tax types group tax rates by their accounting purpose, for example input tax or output tax. The percentage and receiving ledger account are configured on each tax rate. Returns an unpaginated list. Results are ordered by sortKey, then name, ascending. meta.count is the number returned.
10410 ///
10411 /// # Example
10412 ///
10413 /// ```
10414 /// # use churchtools_api::*;
10415 /// # use churchtools_api::queries::*;
10416 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10417 /// # let client = churchtools_api::replay::client("get-finance-taxtypes");
10418 /// for tax_type in client.finance().tax_types().list()? {
10419 /// println!("{:?}", tax_type.name);
10420 /// }
10421 /// # Ok(())
10422 /// # }
10423 /// ```
10424 pub fn list(&self) -> Result<Vec<models::TaxType>> {
10425 let path = "/finance/taxtypes".to_owned();
10426 let query: Query = Query::new();
10427 self.client.request_data(Method::Get, &path, &query, None)
10428 }
10429
10430 /// Update tax type
10431 ///
10432 /// `PUT /finance/taxtypes/{id}`
10433 ///
10434 /// Replaces this tax type. Requires finance “edit masterdata”. All required creation fields must be supplied again. Omitted name is cleared; names must remain unique.
10435 ///
10436 /// # Example
10437 ///
10438 /// ```no_run
10439 /// # use churchtools_api::*;
10440 /// # use churchtools_api::queries::*;
10441 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10442 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10443 /// let body = models::TaxTypeUpdate {
10444 /// sort_key: 0,
10445 /// ..Default::default()
10446 /// };
10447 /// let result = client.finance().tax_types().update(1, &body)?;
10448 /// println!("{:?}", result.name);
10449 /// # Ok(())
10450 /// # }
10451 /// ```
10452 pub fn update(&self, id: impl Display, body: &models::TaxTypeUpdate) -> Result<models::TaxType> {
10453 let path = format!("/finance/taxtypes/{}", seg(id));
10454 let query: Query = Query::new();
10455 let body = serde_json::to_value(body).expect("request body serializes");
10456 self.client.request_data(Method::Put, &path, &query, Some(&body))
10457 }
10458
10459}
10460
10461/// `client.finance().templates()`
10462#[derive(Clone, Copy)]
10463pub struct FinanceTemplatesResource<'a> {
10464 client: &'a Client,
10465}
10466
10467impl<'a> FinanceTemplatesResource<'a> {
10468 /// Apply finance template
10469 ///
10470 /// `POST /finance/templates/{id}`
10471 ///
10472 /// Applies a stored finance-template file to an existing accounting period with no transactions. Existing accounts and tax rates are removed before the template definitions are added. Existing account types/classes/groups and tax types are reused by normalized name; missing ones are added. Existing cost centers are retained, with additional matching/update rules. Cash-discount definitions are not imported by the current executors. This operation has no dry-run mode and no encompassing transaction; a later failure can leave earlier changes applied. Returns HTTP 204 without a body.
10473 ///
10474 /// # Example
10475 ///
10476 /// ```no_run
10477 /// # use churchtools_api::*;
10478 /// # use churchtools_api::queries::*;
10479 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10480 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10481 /// let query = PostFinanceTemplatesIdQuery {
10482 /// accounting_period_id: Some(1),
10483 /// ..Default::default()
10484 /// };
10485 /// client.finance().templates().create(1, &query)?;
10486 /// # Ok(())
10487 /// # }
10488 /// ```
10489 pub fn create(&self, id: impl Display, query: &PostFinanceTemplatesIdQuery) -> Result<()> {
10490 let path = format!("/finance/templates/{}", seg(id));
10491 let query: Query = query.to_query();
10492 self.client.request(Method::Post, &path, &query, None).map(|_| ())
10493 }
10494
10495 /// Export a finance template
10496 ///
10497 /// `GET /finance/templates/export`
10498 ///
10499 /// Downloads finance master data for an existing, visible accounting period as a portable JSON attachment. The root object contains definition collections directly, without a data wrapper or metadata. Accounts, tax rates, cash discounts and cost centers come from the selected period; account types/classes/groups and tax types are installation-wide. The export follows the caller’s master-data visibility and may therefore contain only a subset.
10500 ///
10501 /// # Example
10502 ///
10503 /// ```
10504 /// # use churchtools_api::*;
10505 /// # use churchtools_api::queries::*;
10506 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10507 /// # let client = churchtools_api::replay::client("get-finance-templates-export");
10508 /// let query = GetFinanceTemplatesExportQuery {
10509 /// accounting_period_id: Some(1),
10510 /// ..Default::default()
10511 /// };
10512 /// let export = client.finance().templates().get_export(&query)?;
10513 /// println!("{:?}", export);
10514 /// # Ok(())
10515 /// # }
10516 /// ```
10517 pub fn get_export(&self, query: &GetFinanceTemplatesExportQuery) -> Result<models::FinanceTemplateExport> {
10518 let path = "/finance/templates/export".to_owned();
10519 let query: Query = query.to_query();
10520 self.client.request_data(Method::Get, &path, &query, None)
10521 }
10522
10523 /// Get all finance templates
10524 ///
10525 /// `GET /finance/templates`
10526 ///
10527 /// Returns stored finance-template files with per-collection definition counts. The list is unpaginated and has no guaranteed order. meta.count is the number returned. Files are selected by the finance_template domain.
10528 ///
10529 /// # Example
10530 ///
10531 /// ```
10532 /// # use churchtools_api::*;
10533 /// # use churchtools_api::queries::*;
10534 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10535 /// # let client = churchtools_api::replay::client("get-finance-templates");
10536 /// for template in client.finance().templates().list()? {
10537 /// println!("{}", template.name);
10538 /// }
10539 /// # Ok(())
10540 /// # }
10541 /// ```
10542 pub fn list(&self) -> Result<Vec<models::FinanceTemplate>> {
10543 let path = "/finance/templates".to_owned();
10544 let query: Query = Query::new();
10545 self.client.request_data(Method::Get, &path, &query, None)
10546 }
10547
10548}
10549
10550/// `client.finance().transaction_purposes()`
10551#[derive(Clone, Copy)]
10552pub struct FinanceTransactionPurposesResource<'a> {
10553 client: &'a Client,
10554}
10555
10556impl<'a> FinanceTransactionPurposesResource<'a> {
10557 /// Create new transaction purpose
10558 ///
10559 /// `POST /finance/transactionpurposes`
10560 ///
10561 /// Creates a transaction purpose and returns HTTP 201. Requires finance “edit masterdata” and an open period for purposeAccountId. When costCenterId is supplied, its period must match the fixed account and all resolved selectable accounts.
10562 ///
10563 /// # Example
10564 ///
10565 /// ```no_run
10566 /// # use churchtools_api::*;
10567 /// # use churchtools_api::queries::*;
10568 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10569 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10570 /// let body = models::TransactionPurposeCreate {
10571 /// account_ids: vec![1, 2],
10572 /// is_income: true,
10573 /// name: "Donations for youth work".into(),
10574 /// purpose_account_id: 3,
10575 /// sort_key: 0,
10576 /// ..Default::default()
10577 /// };
10578 /// let result = client.finance().transaction_purposes().create(&body)?;
10579 /// println!("{}", result.name);
10580 /// # Ok(())
10581 /// # }
10582 /// ```
10583 pub fn create(&self, body: &models::TransactionPurposeCreate) -> Result<models::TransactionPurpose> {
10584 let path = "/finance/transactionpurposes".to_owned();
10585 let query: Query = Query::new();
10586 let body = serde_json::to_value(body).expect("request body serializes");
10587 self.client.request_data(Method::Post, &path, &query, Some(&body))
10588 }
10589
10590 /// Delete transaction purpose
10591 ///
10592 /// `DELETE /finance/transactionpurposes/{id}`
10593 ///
10594 /// Deletes the transaction-purpose preset and its selectable-account links. Requires finance “edit masterdata”. Existing transaction records are not deleted. dry_run=true returns the HTTP 409 report without deleting, also when deletion is allowed.
10595 ///
10596 /// Use [`Self::delete_with`] to pass query parameters.
10597 ///
10598 /// # Example
10599 ///
10600 /// ```no_run
10601 /// # use churchtools_api::*;
10602 /// # use churchtools_api::queries::*;
10603 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10604 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10605 /// client.finance().transaction_purposes().delete(1)?;
10606 /// # Ok(())
10607 /// # }
10608 /// ```
10609 pub fn delete(&self, id: impl Display) -> Result<()> {
10610 self.delete_with(id, &Default::default())
10611 }
10612
10613 /// Delete transaction purpose
10614 ///
10615 /// Like [`Self::delete`], with query parameters.
10616 ///
10617 /// `DELETE /finance/transactionpurposes/{id}`
10618 ///
10619 /// Deletes the transaction-purpose preset and its selectable-account links. Requires finance “edit masterdata”. Existing transaction records are not deleted. dry_run=true returns the HTTP 409 report without deleting, also when deletion is allowed.
10620 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceTransactionpurposesIdQuery) -> Result<()> {
10621 let path = format!("/finance/transactionpurposes/{}", seg(id));
10622 let query: Query = query.to_query();
10623 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
10624 }
10625
10626 /// Get a transaction purpose
10627 ///
10628 /// `GET /finance/transactionpurposes/{id}`
10629 ///
10630 /// Returns one transaction purpose. A transaction purpose is a reusable preset for simplified bookkeeping. It fixes one ledger account, offers a list of accounts for the other side, and can assign a cost center. isIncome selects an income or expense preset; it is not the free-text note of a bank statement. Requires finance “view”; there is no additional period-specific visibility filter in this endpoint.
10631 ///
10632 /// # Example
10633 ///
10634 /// ```
10635 /// # use churchtools_api::*;
10636 /// # use churchtools_api::queries::*;
10637 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10638 /// # let client = churchtools_api::replay::client("get-finance-transactionpurposes-id");
10639 /// let transaction_purpose = client.finance().transaction_purposes().get(1)?;
10640 /// println!("{}", transaction_purpose.name);
10641 /// # Ok(())
10642 /// # }
10643 /// ```
10644 pub fn get(&self, id: impl Display) -> Result<models::TransactionPurpose> {
10645 let path = format!("/finance/transactionpurposes/{}", seg(id));
10646 let query: Query = Query::new();
10647 self.client.request_data(Method::Get, &path, &query, None)
10648 }
10649
10650 /// Get all transaction purposes
10651 ///
10652 /// `GET /finance/transactionpurposes`
10653 ///
10654 /// A transaction purpose is a reusable preset for simplified bookkeeping. It fixes one ledger account, offers a list of accounts for the other side, and can assign a cost center. isIncome selects an income or expense preset; it is not the free-text note of a bank statement. Requires finance “view”. Returns the complete, unpaginated list across periods, ordered by sortKey and then name ascending. This endpoint does not apply the period/group filtering used by /finance/masterdata. meta.count is the number returned.
10655 ///
10656 /// # Example
10657 ///
10658 /// ```
10659 /// # use churchtools_api::*;
10660 /// # use churchtools_api::queries::*;
10661 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10662 /// # let client = churchtools_api::replay::client("get-finance-transactionpurposes");
10663 /// for transaction_purpose in client.finance().transaction_purposes().list()? {
10664 /// println!("{}", transaction_purpose.name);
10665 /// }
10666 /// # Ok(())
10667 /// # }
10668 /// ```
10669 pub fn list(&self) -> Result<Vec<models::TransactionPurpose>> {
10670 let path = "/finance/transactionpurposes".to_owned();
10671 let query: Query = Query::new();
10672 self.client.request_data(Method::Get, &path, &query, None)
10673 }
10674
10675 /// Update transaction purpose
10676 ///
10677 /// `PUT /finance/transactionpurposes/{id}`
10678 ///
10679 /// Replaces a transaction purpose, including the complete list of selectable accounts. Requires finance “edit masterdata” and an open period for the new purposeAccountId. Omitted costCenterId clears it. If a cost center is supplied, all resolved accounts must belong to its period.
10680 ///
10681 /// # Example
10682 ///
10683 /// ```no_run
10684 /// # use churchtools_api::*;
10685 /// # use churchtools_api::queries::*;
10686 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10687 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10688 /// let body = models::TransactionPurposeUpdate {
10689 /// account_ids: vec![1, 2],
10690 /// is_income: true,
10691 /// name: "Donations for youth work".into(),
10692 /// purpose_account_id: 3,
10693 /// sort_key: 0,
10694 /// ..Default::default()
10695 /// };
10696 /// let result = client.finance().transaction_purposes().update(1, &body)?;
10697 /// println!("{}", result.name);
10698 /// # Ok(())
10699 /// # }
10700 /// ```
10701 pub fn update(&self, id: impl Display, body: &models::TransactionPurposeUpdate) -> Result<models::TransactionPurpose> {
10702 let path = format!("/finance/transactionpurposes/{}", seg(id));
10703 let query: Query = Query::new();
10704 let body = serde_json::to_value(body).expect("request body serializes");
10705 self.client.request_data(Method::Put, &path, &query, Some(&body))
10706 }
10707
10708}
10709
10710/// `client.finance().transactions()`
10711#[derive(Clone, Copy)]
10712pub struct FinanceTransactionsResource<'a> {
10713 client: &'a Client,
10714}
10715
10716impl<'a> FinanceTransactionsResource<'a> {
10717 /// Create multiple transactions
10718 ///
10719 /// `POST /finance/transactions/bulkcreate`
10720 ///
10721 /// Creates a non-empty JSON array of bookings in input order and returns the main bookings with meta.count. Each item supplies its own document number and accounts; items may belong to different accounting periods. Both accounts must allow posting and all related finance references within an item must belong to the same period. Periods must be open and contain each documentDate. Input validation runs before creation, followed by a shared database transaction. The optional query flag skips the normal donation-account/donor constraint for all items, but joint-donor consistency still applies. Use actual JSON boolean and integer values.
10722 ///
10723 /// Use [`Self::bulk_create_with`] to pass query parameters.
10724 ///
10725 /// # Example
10726 ///
10727 /// ```no_run
10728 /// # use churchtools_api::*;
10729 /// # use churchtools_api::queries::*;
10730 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10731 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10732 /// let body: Vec<models::TransactionBulkCreateItem> = vec![models::TransactionBulkCreateItem {
10733 /// account_id: 10,
10734 /// amount: 7812,
10735 /// contra_account_id: 11,
10736 /// document_date: "2019-01-14".parse()?,
10737 /// note: "Donation service offering".into(),
10738 /// document_number: "2026-42".into(),
10739 /// ..Default::default()
10740 /// }];
10741 /// for transaction in client.finance().transactions().bulk_create(&body)? {
10742 /// println!("{}", transaction.id);
10743 /// }
10744 /// # Ok(())
10745 /// # }
10746 /// ```
10747 pub fn bulk_create(&self, body: &Vec<models::TransactionBulkCreateItem>) -> Result<Vec<models::Transaction>> {
10748 self.bulk_create_with(&Default::default(), body)
10749 }
10750
10751 /// Create multiple transactions
10752 ///
10753 /// Like [`Self::bulk_create`], with query parameters.
10754 ///
10755 /// `POST /finance/transactions/bulkcreate`
10756 ///
10757 /// Creates a non-empty JSON array of bookings in input order and returns the main bookings with meta.count. Each item supplies its own document number and accounts; items may belong to different accounting periods. Both accounts must allow posting and all related finance references within an item must belong to the same period. Periods must be open and contain each documentDate. Input validation runs before creation, followed by a shared database transaction. The optional query flag skips the normal donation-account/donor constraint for all items, but joint-donor consistency still applies. Use actual JSON boolean and integer values.
10758 pub fn bulk_create_with(&self, query: &PostFinanceTransactionsBulkcreateQuery, body: &Vec<models::TransactionBulkCreateItem>) -> Result<Vec<models::Transaction>> {
10759 let path = "/finance/transactions/bulkcreate".to_owned();
10760 let query: Query = query.to_query();
10761 let body = serde_json::to_value(body).expect("request body serializes");
10762 self.client.request_data(Method::Post, &path, &query, Some(&body))
10763 }
10764
10765 /// Create new transaction
10766 ///
10767 /// `POST /finance/transactions`
10768 ///
10769 /// Creates one booking and, if requested, its tax booking. Requires permission to post on both accounts and either edit permission for the period or a permitted booking purpose matching the accounts and cost center. The accounting period must be open and contain documentDate. Related finance objects must belong to that same period. Unless ignoreDonationConstraint=true is supplied in the query, crediting a donation account from a non-donation account requires a donor. Joint donors must have an existing spouse relationship. Returns the main booking; generated tax booking IDs are included in it.
10770 ///
10771 /// Use [`Self::create_with`] to pass query parameters.
10772 ///
10773 /// # Example
10774 ///
10775 /// ```no_run
10776 /// # use churchtools_api::*;
10777 /// # use churchtools_api::queries::*;
10778 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10779 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10780 /// let body = models::TransactionCreate {
10781 /// account_id: 10,
10782 /// amount: 7812,
10783 /// contra_account_id: 11,
10784 /// document_date: "2019-01-14".parse()?,
10785 /// note: "Donation service offering".into(),
10786 /// ..Default::default()
10787 /// };
10788 /// let result = client.finance().transactions().create(&body)?;
10789 /// println!("{}", result.id);
10790 /// # Ok(())
10791 /// # }
10792 /// ```
10793 pub fn create(&self, body: &models::TransactionCreate) -> Result<models::Transaction> {
10794 self.create_with(&Default::default(), body)
10795 }
10796
10797 /// Create new transaction
10798 ///
10799 /// Like [`Self::create`], with query parameters.
10800 ///
10801 /// `POST /finance/transactions`
10802 ///
10803 /// Creates one booking and, if requested, its tax booking. Requires permission to post on both accounts and either edit permission for the period or a permitted booking purpose matching the accounts and cost center. The accounting period must be open and contain documentDate. Related finance objects must belong to that same period. Unless ignoreDonationConstraint=true is supplied in the query, crediting a donation account from a non-donation account requires a donor. Joint donors must have an existing spouse relationship. Returns the main booking; generated tax booking IDs are included in it.
10804 pub fn create_with(&self, query: &PostFinanceTransactionsQuery, body: &models::TransactionCreate) -> Result<models::Transaction> {
10805 let path = "/finance/transactions".to_owned();
10806 let query: Query = query.to_query();
10807 let body = serde_json::to_value(body).expect("request body serializes");
10808 self.client.request_data(Method::Post, &path, &query, Some(&body))
10809 }
10810
10811 /// Delete transaction
10812 ///
10813 /// `DELETE /finance/transactions/{id}`
10814 ///
10815 /// Deletes a standalone booking and its generated tax and cancellation bookings, together with attached receipts/files. Related statement movements are reset to open and unlinked. Requires edit permission for the accounting period, which must be open. Immutable bookings, generated tax bookings and split children cannot be deleted directly. A cancellation booking can be deleted to remove the cancellation link from its original booking. dry_run=true performs the same eligibility checks without deleting and returns HTTP 409 with the deletion assessment, including when deletion is possible.
10816 ///
10817 /// Use [`Self::delete_with`] to pass query parameters.
10818 ///
10819 /// # Example
10820 ///
10821 /// ```no_run
10822 /// # use churchtools_api::*;
10823 /// # use churchtools_api::queries::*;
10824 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10825 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10826 /// client.finance().transactions().delete(1)?;
10827 /// # Ok(())
10828 /// # }
10829 /// ```
10830 pub fn delete(&self, id: impl Display) -> Result<()> {
10831 self.delete_with(id, &Default::default())
10832 }
10833
10834 /// Delete transaction
10835 ///
10836 /// Like [`Self::delete`], with query parameters.
10837 ///
10838 /// `DELETE /finance/transactions/{id}`
10839 ///
10840 /// Deletes a standalone booking and its generated tax and cancellation bookings, together with attached receipts/files. Related statement movements are reset to open and unlinked. Requires edit permission for the accounting period, which must be open. Immutable bookings, generated tax bookings and split children cannot be deleted directly. A cancellation booking can be deleted to remove the cancellation link from its original booking. dry_run=true performs the same eligibility checks without deleting and returns HTTP 409 with the deletion assessment, including when deletion is possible.
10841 pub fn delete_with(&self, id: impl Display, query: &DeleteFinanceTransactionsIdQuery) -> Result<()> {
10842 let path = format!("/finance/transactions/{}", seg(id));
10843 let query: Query = query.to_query();
10844 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
10845 }
10846
10847 /// Duplicate transaction
10848 ///
10849 /// `POST /finance/transactions/{id}/duplicate`
10850 ///
10851 /// Copies a standalone booking into its original open accounting period. Requires permission to create a booking with the source accounts and cost center. Copies document date, accounts, note, donor assignments, waiver and cash discount; recreates tax bookings and copies attached receipts/files. The document number receives the suffix -Kopie; this does not reserve or generate a unique number. The new booking starts mutable and non-synced and is not linked as a cancellation. Split children cannot be duplicated here. The response contains the new main booking; copied bills can be retrieved with include\[\]=bills.
10852 ///
10853 /// # Example
10854 ///
10855 /// ```no_run
10856 /// # use churchtools_api::*;
10857 /// # use churchtools_api::queries::*;
10858 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10859 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10860 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
10861 /// let transaction = client.finance().transactions().duplicate(1, &body)?;
10862 /// println!("{}", transaction.id);
10863 /// # Ok(())
10864 /// # }
10865 /// ```
10866 pub fn duplicate(&self, id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<models::Transaction> {
10867 let path = format!("/finance/transactions/{}/duplicate", seg(id));
10868 let query: Query = Query::new();
10869 let body = serde_json::to_value(body).expect("request body serializes");
10870 self.client.request_data(Method::Post, &path, &query, Some(&body))
10871 }
10872
10873 /// Get a transaction
10874 ///
10875 /// `GET /finance/transactions/{id}`
10876 ///
10877 /// Returns a single booking, including a child of a split transaction. Requires view or edit permission for its accounting period, or the corresponding group permission for its assigned cost center. Donor visibility is checked separately: a user who may see the booking but not its donors receives censored person placeholders and a null note. Request include\[\]=bills to include attached receipts. Related tax, cancellation and split bookings are referenced by ID.
10878 ///
10879 /// Use [`Self::get_with`] to pass query parameters.
10880 ///
10881 /// # Example
10882 ///
10883 /// ```
10884 /// # use churchtools_api::*;
10885 /// # use churchtools_api::queries::*;
10886 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10887 /// # let client = churchtools_api::replay::client("get-finance-transactions-id");
10888 /// let transaction = client.finance().transactions().get(1)?;
10889 /// println!("{}", transaction.id);
10890 /// # Ok(())
10891 /// # }
10892 /// ```
10893 pub fn get(&self, id: impl Display) -> Result<models::Transaction> {
10894 self.get_with(id, &Default::default())
10895 }
10896
10897 /// Get a transaction
10898 ///
10899 /// Like [`Self::get`], with query parameters.
10900 ///
10901 /// `GET /finance/transactions/{id}`
10902 ///
10903 /// Returns a single booking, including a child of a split transaction. Requires view or edit permission for its accounting period, or the corresponding group permission for its assigned cost center. Donor visibility is checked separately: a user who may see the booking but not its donors receives censored person placeholders and a null note. Request include\[\]=bills to include attached receipts. Related tax, cancellation and split bookings are referenced by ID.
10904 pub fn get_with(&self, id: impl Display, query: &GetFinanceTransactionsIdQuery) -> Result<models::Transaction> {
10905 let path = format!("/finance/transactions/{}", seg(id));
10906 let query: Query = query.to_query();
10907 self.client.request_data(Method::Get, &path, &query, None)
10908 }
10909
10910 /// Export transactions as CSV
10911 ///
10912 /// `GET /finance/transactions/csv`
10913 ///
10914 /// Downloads all matching bookings without pagination or a JSON wrapper. Supports the listed booking filters; page, limit, include, exclude_stornos and exclude_paybacks are not evaluated. Both accounts must be visible. Without an explicit cost-center filter, users without permission for the whole period are restricted to their accessible cost centers. Donor details and notes are censored where required, but the donor-ID filter itself is accepted without the list endpoint’s additional filter-permission check. target selects the column layout. CSV uses semicolons, UTF-8 with BOM, localized column labels and locale-dependent amount formatting in major currency units. Use /finance/transactions/export for new integrations.
10915 ///
10916 /// # Example
10917 ///
10918 /// ```no_run
10919 /// # use churchtools_api::*;
10920 /// # use churchtools_api::queries::*;
10921 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10922 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10923 /// let query = GetFinanceTransactionsCsvQuery {
10924 /// accounting_period_id: Some(1),
10925 /// ..Default::default()
10926 /// };
10927 /// let data = client.finance().transactions().get_csv(&query)?;
10928 /// std::fs::write("ergebnis.csv", &data)?;
10929 /// # Ok(())
10930 /// # }
10931 /// ```
10932 #[deprecated = "GET /finance/transactions/csv is deprecated in the ChurchTools API. Use /finance/transactions/export for new integrations."]
10933 pub fn get_csv(&self, query: &GetFinanceTransactionsCsvQuery) -> Result<Vec<u8>> {
10934 let path = "/finance/transactions/csv".to_owned();
10935 let query: Query = query.to_query();
10936 self.client.request(Method::Get, &path, &query, None)
10937 }
10938
10939 /// Export transactions in DATEV format
10940 ///
10941 /// `GET /finance/transactions/datevexport`
10942 ///
10943 /// Downloads a semicolon-separated DATEV EXTF booking-batch CSV with UTF-8 BOM, a metadata row and a column-header row. Includes all matching bookings without pagination, including cancellation and tax rows. The listed booking filters apply; exclude_stornos and exclude_paybacks are not evaluated. Accounts and default cost-center scope are restricted by permissions. Uses the client’s DATEV consultant/client numbers and the period’s start date. Current output uses EUR and debit indicator S. Choose order_by=date&order_direction=ASC because the header takes the first and last row dates as its range. An empty result currently fails during header creation.
10944 ///
10945 /// # Example
10946 ///
10947 /// ```no_run
10948 /// # use churchtools_api::*;
10949 /// # use churchtools_api::queries::*;
10950 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10951 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10952 /// let query = GetFinanceTransactionsDatevexportQuery {
10953 /// accounting_period_id: Some(1),
10954 /// ..Default::default()
10955 /// };
10956 /// let data = client.finance().transactions().get_datev_export(&query)?;
10957 /// std::fs::write("ergebnis.csv", &data)?;
10958 /// # Ok(())
10959 /// # }
10960 /// ```
10961 pub fn get_datev_export(&self, query: &GetFinanceTransactionsDatevexportQuery) -> Result<Vec<u8>> {
10962 let path = "/finance/transactions/datevexport".to_owned();
10963 let query: Query = query.to_query();
10964 self.client.request(Method::Get, &path, &query, None)
10965 }
10966
10967 /// Check if a document number is available
10968 ///
10969 /// `GET /finance/transactions/documentnumberavailable`
10970 ///
10971 /// Checks whether an ordinary transaction row in the accounting period uses document_number. Returns HTTP 200 without a body when available and HTTP 409 without a body when occupied. Includes synced and cancellation rows and performs a database string comparison. It does not normalize split-parent or copy suffixes as the next-number suggestion does, and does not reserve the number. Requires visibility of the accounting period.
10972 ///
10973 /// # Example
10974 ///
10975 /// ```no_run
10976 /// # use churchtools_api::*;
10977 /// # use churchtools_api::queries::*;
10978 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10979 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
10980 /// let query = GetFinanceTransactionsDocumentnumberavailableQuery {
10981 /// accounting_period_id: Some(1),
10982 /// document_number: Some("2024-001".into()),
10983 /// ..Default::default()
10984 /// };
10985 /// client.finance().transactions().get_document_number_available(&query)?;
10986 /// # Ok(())
10987 /// # }
10988 /// ```
10989 pub fn get_document_number_available(&self, query: &GetFinanceTransactionsDocumentnumberavailableQuery) -> Result<()> {
10990 let path = "/finance/transactions/documentnumberavailable".to_owned();
10991 let query: Query = query.to_query();
10992 self.client.request(Method::Get, &path, &query, None).map(|_| ())
10993 }
10994
10995 /// Export transactions
10996 ///
10997 /// `GET /finance/transactions/export`
10998 ///
10999 /// Downloads all matching bookings without pagination or a JSON wrapper. Supports the listed booking filters; page, limit, include, exclude_stornos and exclude_paybacks are not evaluated. Both accounts must be visible. Without an explicit cost-center filter, users without permission for the whole period are restricted to their accessible cost centers. Donor details and notes are censored where required, but the donor-ID filter itself is accepted without the list endpoint’s additional filter-permission check. target selects the column layout. CSV uses semicolons, UTF-8 with BOM, localized column labels and locale-dependent amount formatting in major currency units. format=xlsx returns an Excel workbook instead of CSV; PDF is not supported.
11000 ///
11001 /// # Example
11002 ///
11003 /// ```no_run
11004 /// # use churchtools_api::*;
11005 /// # use churchtools_api::queries::*;
11006 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11007 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11008 /// let query = GetFinanceTransactionsExportQuery {
11009 /// accounting_period_id: Some(1),
11010 /// ..Default::default()
11011 /// };
11012 /// let data = client.finance().transactions().get_export(&query)?;
11013 /// std::fs::write("ergebnis.xlsx", &data)?;
11014 /// # Ok(())
11015 /// # }
11016 /// ```
11017 pub fn get_export(&self, query: &GetFinanceTransactionsExportQuery) -> Result<Vec<u8>> {
11018 let path = "/finance/transactions/export".to_owned();
11019 let query: Query = query.to_query();
11020 self.client.request(Method::Get, &path, &query, None)
11021 }
11022
11023 /// Get IDs of all transactions
11024 ///
11025 /// `GET /finance/transactions/ids`
11026 ///
11027 /// Returns ordinary transaction IDs for visible accounting periods, including split children, tax bookings and cancellations. With accounting_period_id, data is a flat array of decimal ID strings. Without it, data is an object keyed by accounting-period ID; periods without transactions are omitted and an entirely empty result is serialized as an empty array. Ordering is unspecified. The endpoint checks period visibility and does not apply the transaction list's account or cost-center filters; an ID in this result does not guarantee access to the corresponding transaction. Use the paginated transaction list for that purpose.
11028 ///
11029 /// Use [`Self::get_ids_with`] to pass query parameters.
11030 ///
11031 /// # Example
11032 ///
11033 /// ```
11034 /// # use churchtools_api::*;
11035 /// # use churchtools_api::queries::*;
11036 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11037 /// # let client = churchtools_api::replay::client("get-finance-transactions-ids");
11038 /// let result = client.finance().transactions().get_ids()?;
11039 /// println!("{:?}", result);
11040 /// # Ok(())
11041 /// # }
11042 /// ```
11043 pub fn get_ids(&self) -> Result<serde_json::Value> {
11044 self.get_ids_with(&Default::default())
11045 }
11046
11047 /// Get IDs of all transactions
11048 ///
11049 /// Like [`Self::get_ids`], with query parameters.
11050 ///
11051 /// `GET /finance/transactions/ids`
11052 ///
11053 /// Returns ordinary transaction IDs for visible accounting periods, including split children, tax bookings and cancellations. With accounting_period_id, data is a flat array of decimal ID strings. Without it, data is an object keyed by accounting-period ID; periods without transactions are omitted and an entirely empty result is serialized as an empty array. Ordering is unspecified. The endpoint checks period visibility and does not apply the transaction list's account or cost-center filters; an ID in this result does not guarantee access to the corresponding transaction. Use the paginated transaction list for that purpose.
11054 pub fn get_ids_with(&self, query: &GetFinanceTransactionsIdsQuery) -> Result<serde_json::Value> {
11055 let path = "/finance/transactions/ids".to_owned();
11056 let query: Query = query.to_query();
11057 self.client.request_data(Method::Get, &path, &query, None)
11058 }
11059
11060 /// Get suggestion for next document number
11061 ///
11062 /// `GET /finance/transactions/nextdocumentnumber`
11063 ///
11064 /// Suggests a document number for a new booking. Uses the most recently inserted non-synced, non-cancellation transaction as its base, not the greatest existing number. For split children the child suffix is removed; the copy suffix -Kopie is removed as well. A trailing number is incremented with its zero padding preserved; a base without digits receives -1. Existing normalized non-cancellation numbers are skipped. With no eligible base transaction, returns the string 1. Requires visibility of the accounting period. The suggestion is not reserved and concurrent clients can receive the same number.
11065 ///
11066 /// # Example
11067 ///
11068 /// ```
11069 /// # use churchtools_api::*;
11070 /// # use churchtools_api::queries::*;
11071 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11072 /// # let client = churchtools_api::replay::client("get-finance-transactions-nextdocumentnumber");
11073 /// let query = GetFinanceTransactionsNextdocumentnumberQuery {
11074 /// accounting_period_id: Some(1),
11075 /// ..Default::default()
11076 /// };
11077 /// let result = client.finance().transactions().get_next_document_number(&query)?;
11078 /// println!("{:?}", result);
11079 /// # Ok(())
11080 /// # }
11081 /// ```
11082 pub fn get_next_document_number(&self, query: &GetFinanceTransactionsNextdocumentnumberQuery) -> Result<String> {
11083 let path = "/finance/transactions/nextdocumentnumber".to_owned();
11084 let query: Query = query.to_query();
11085 self.client.request_data(Method::Get, &path, &query, None)
11086 }
11087
11088 /// Calculate a journal summary with previous-year comparison
11089 ///
11090 /// `GET /finance/transactions/summary`
11091 ///
11092 /// Calculates a journal summary for one accounting period. calculation_type selects account debit/credit balances, cost-center income/expense, or net donations. Supplying it also saves the current user’s preference for the combination of account, cost-center and donor filters. If omitted, the saved preference is used; without a preference the first non-empty filter selects accounts, then cost centers, then donors. Without a usable filter/type the request fails. Date limits default to the accounting period boundaries. Previous-year comparison shifts both dates back one year and uses the previous accounting period of the same client. Monetary values are minor currency units. The donor filter is removed unless the caller has view permission for the entire period, even if group donor visibility is available. include_ids, exclude_ids, pagination and exclusion flags are not evaluated by this endpoint.
11093 ///
11094 /// # Example
11095 ///
11096 /// ```
11097 /// # use churchtools_api::*;
11098 /// # use churchtools_api::queries::*;
11099 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11100 /// # let client = churchtools_api::replay::client("get-finance-transactions-summary");
11101 /// let query = GetFinanceTransactionsSummaryQuery {
11102 /// accounting_period_id: Some(1),
11103 /// ..Default::default()
11104 /// };
11105 /// let result = client.finance().transactions().get_summary(&query)?;
11106 /// println!("{:?}", result);
11107 /// # Ok(())
11108 /// # }
11109 /// ```
11110 pub fn get_summary(&self, query: &GetFinanceTransactionsSummaryQuery) -> Result<serde_json::Value> {
11111 let path = "/finance/transactions/summary".to_owned();
11112 let query: Query = query.to_query();
11113 self.client.request_data(Method::Get, &path, &query, None)
11114 }
11115
11116 /// Get all transactions
11117 ///
11118 /// `GET /finance/transactions`
11119 ///
11120 /// Lists bookings in one accounting period, including split children and generated tax or cancellation bookings. Both accounts must be visible to the caller. With no cost_center_ids and no permission for the entire period, the list is limited to accessible cost centers. Donor filtering is silently ignored unless the caller has view permission for the period or a group permission to see donors in cost centers. Donor details are independently censored per booking. All filters are combined; an empty ID array does not restrict results. Send array filters using bracket query syntax, for example account_ids\[\]=10&account_ids\[\]=11. The pagination total describes the filtered result; meta.all ignores the optional filters except exclude_stornos and retains the visibility restrictions.
11121 ///
11122 /// # Example
11123 ///
11124 /// ```
11125 /// # use churchtools_api::*;
11126 /// # use churchtools_api::queries::*;
11127 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11128 /// # let client = churchtools_api::replay::client("get-finance-transactions");
11129 /// let query = GetFinanceTransactionsQuery {
11130 /// accounting_period_id: Some(1),
11131 /// ..Default::default()
11132 /// };
11133 /// for transaction in client.finance().transactions().list(&query)? {
11134 /// println!("{}", transaction.id);
11135 /// }
11136 /// # Ok(())
11137 /// # }
11138 /// ```
11139 pub fn list(&self, query: &GetFinanceTransactionsQuery) -> Result<Vec<models::Transaction>> {
11140 let path = "/finance/transactions".to_owned();
11141 let query: Query = query.to_query();
11142 self.client.collect_pages(&path, query)
11143 }
11144
11145 /// Get all transactions
11146 ///
11147 /// Like [`Self::list`], but lazy: each page is fetched only when the iteration reaches it.
11148 /// Breaking off early saves the remaining requests.
11149 pub fn list_iter(&self, query: &GetFinanceTransactionsQuery) -> Items<models::Transaction> {
11150 let path = "/finance/transactions".to_owned();
11151 self.client.items(&path, query.to_query())
11152 }
11153
11154 /// Finalize or delete a filtered set of bookings
11155 ///
11156 /// `PATCH /finance/transactions`
11157 ///
11158 /// Runs one batch action on bookings selected by a non-empty array of filters. Conditions within each filter are combined with AND and filters with OR. Requires edit permission for every specified accounting period. isImmutable=true finalizes selected bookings and expands the selection to related tax bookings, tax bases and originals of selected cancellations. All children of any affected split booking must be covered, otherwise HTTP 403 is returned. delete=true performs period cleanup: it can delete immutable bookings and does not apply the normal open-period or standalone-booking checks. Deletion removes related records through the deletion service and has no dry-run mode. If both actions are true, finalization wins. Always send a non-empty filters array; the current backend does not safely restrict an empty selection.
11159 ///
11160 /// # Example
11161 ///
11162 /// ```no_run
11163 /// # use churchtools_api::*;
11164 /// # use churchtools_api::queries::*;
11165 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11166 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11167 /// let body = models::TransactionBatchUpdate {
11168 /// changeset: models::TransactionBatchUpdateChangeset::default(),
11169 /// filters: vec![models::TransactionBatchFilter {
11170 /// accounting_period_id: 1,
11171 /// ..Default::default()
11172 /// }],
11173 /// ..Default::default()
11174 /// };
11175 /// let result = client.finance().transactions().patch(&body)?;
11176 /// println!("{:?}", result);
11177 /// # Ok(())
11178 /// # }
11179 /// ```
11180 pub fn patch(&self, body: &models::TransactionBatchUpdate) -> Result<serde_json::Value> {
11181 let path = "/finance/transactions".to_owned();
11182 let query: Query = Query::new();
11183 let body = serde_json::to_value(body).expect("request body serializes");
11184 self.client.request_data(Method::Patch, &path, &query, Some(&body))
11185 }
11186
11187 /// Update transaction
11188 ///
11189 /// `PUT /finance/transactions/{id}`
11190 ///
11191 /// Updates a standalone booking. Requires edit permission for its original accounting period and posting permission on the supplied accounts. The original period must be open and the booking mutable; split children, generated tax bookings and cancellation bookings cannot be edited here. Required fields replace existing values. Missing cost center, donors and tax rate are cleared, while missing cash-discount fields retain their previous values. isImmutable=true finalizes the booking and any tax booking. Joint-donor consistency is checked when either donor ID changes.
11192 ///
11193 /// Use [`Self::update_with`] to pass query parameters.
11194 ///
11195 /// # Example
11196 ///
11197 /// ```no_run
11198 /// # use churchtools_api::*;
11199 /// # use churchtools_api::queries::*;
11200 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11201 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11202 /// let body = models::TransactionUpdate {
11203 /// account_id: 10,
11204 /// amount: 7812,
11205 /// contra_account_id: 11,
11206 /// document_date: "2019-01-14".parse()?,
11207 /// note: "Donation service offering".into(),
11208 /// document_number: "2026-42".into(),
11209 /// ..Default::default()
11210 /// };
11211 /// let result = client.finance().transactions().update(1, &body)?;
11212 /// println!("{}", result.id);
11213 /// # Ok(())
11214 /// # }
11215 /// ```
11216 pub fn update(&self, id: impl Display, body: &models::TransactionUpdate) -> Result<models::Transaction> {
11217 self.update_with(id, &Default::default(), body)
11218 }
11219
11220 /// Update transaction
11221 ///
11222 /// Like [`Self::update`], with query parameters.
11223 ///
11224 /// `PUT /finance/transactions/{id}`
11225 ///
11226 /// Updates a standalone booking. Requires edit permission for its original accounting period and posting permission on the supplied accounts. The original period must be open and the booking mutable; split children, generated tax bookings and cancellation bookings cannot be edited here. Required fields replace existing values. Missing cost center, donors and tax rate are cleared, while missing cash-discount fields retain their previous values. isImmutable=true finalizes the booking and any tax booking. Joint-donor consistency is checked when either donor ID changes.
11227 pub fn update_with(&self, id: impl Display, query: &PutFinanceTransactionsIdQuery, body: &models::TransactionUpdate) -> Result<models::Transaction> {
11228 let path = format!("/finance/transactions/{}", seg(id));
11229 let query: Query = query.to_query();
11230 let body = serde_json::to_value(body).expect("request body serializes");
11231 self.client.request_data(Method::Put, &path, &query, Some(&body))
11232 }
11233
11234 /// Cancel transaction
11235 ///
11236 /// `PUT /finance/transactions/{id}/storno`
11237 ///
11238 /// Cancels a standalone booking by creating an opposite booking with swapped debit and credit accounts, the same amount and document date, and a -Storno document-number suffix. The original remains in place and references its cancellation. A tax booking is cancelled recursively. Requires edit permission for the period; split children must be cancelled through their parent endpoint. This operation does not require a mutable booking or check that the period is open. Repeating it updates the existing cancellation without creating another one; targeting a cancellation itself is a no-op. Returns HTTP 200 without a response body. Retrieve the original afterwards to obtain stornoTransactionId.
11239 ///
11240 /// # Example
11241 ///
11242 /// ```no_run
11243 /// # use churchtools_api::*;
11244 /// # use churchtools_api::queries::*;
11245 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11246 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11247 /// let body = models::TransactionStornoCreate {
11248 /// note: "Incorrect amount".into(),
11249 /// ..Default::default()
11250 /// };
11251 /// client.finance().transactions().update_storno(1, &body)?;
11252 /// # Ok(())
11253 /// # }
11254 /// ```
11255 pub fn update_storno(&self, id: impl Display, body: &models::TransactionStornoCreate) -> Result<()> {
11256 let path = format!("/finance/transactions/{}/storno", seg(id));
11257 let query: Query = Query::new();
11258 let body = serde_json::to_value(body).expect("request body serializes");
11259 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
11260 }
11261
11262}
11263
11264/// `client.followups()`
11265#[derive(Clone, Copy)]
11266pub struct FollowupsResource<'a> {
11267 client: &'a Client,
11268}
11269
11270impl<'a> FollowupsResource<'a> {
11271 /// Complete follow-up
11272 ///
11273 /// `POST /followups/{followUpId}/complete`
11274 ///
11275 /// Sets `doneDate` to the current timestamp and records completion history. The subject person must be visible. Group-associated follow-ups require "churchdb +do followup" permission in that group. A supplied nonzero `successGroupId` adds or updates the subject’s membership in that selected group, including overwriting an existing membership’s role/status. Configured fixed-group/group-type restrictions are checked; a configured group is not selected automatically. Emits a completion event, which can trigger configured continuations or routines. Repeating this operation replaces `doneDate`, writes another history entry and emits another event. Due dates are retained.
11276 ///
11277 /// # Example
11278 ///
11279 /// ```
11280 /// # use churchtools_api::*;
11281 /// # use churchtools_api::queries::*;
11282 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11283 /// # let client = churchtools_api::replay::client("post-followups-followUpId-complete");
11284 /// let body = models::FollowUpCompletionCreate {
11285 /// success_group_id: Some(Some(42)),
11286 /// ..Default::default()
11287 /// };
11288 /// let followup = client.followups().complete(2, &body)?;
11289 /// println!("{}", followup.title);
11290 /// # Ok(())
11291 /// # }
11292 /// ```
11293 pub fn complete(&self, follow_up_id: impl Display, body: &models::FollowUpCompletionCreate) -> Result<models::FollowUp2> {
11294 let path = format!("/followups/{}/complete", seg(follow_up_id));
11295 let query: Query = Query::new();
11296 let body = serde_json::to_value(body).expect("request body serializes");
11297 self.client.request_data(Method::Post, &path, &query, Some(&body))
11298 }
11299
11300 /// Delete follow-up
11301 ///
11302 /// `DELETE /followups/{followUpId}`
11303 ///
11304 /// Deletes the follow-up and records deletion history in a transaction. Its specification is also deleted when it is not shared; a shared specification remains. Deletion requires access to the subject person and, for a group-associated follow-up, follow-up administration rights in that group. No dryRun/dependency-preview behavior is implemented. This removes the follow-up rather than marking it finished; it does not reverse group memberships or routine effects caused by earlier completion.
11305 ///
11306 /// # Example
11307 ///
11308 /// ```no_run
11309 /// # use churchtools_api::*;
11310 /// # use churchtools_api::queries::*;
11311 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11312 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11313 /// client.followups().delete(2)?;
11314 /// # Ok(())
11315 /// # }
11316 /// ```
11317 pub fn delete(&self, follow_up_id: impl Display) -> Result<()> {
11318 let path = format!("/followups/{}", seg(follow_up_id));
11319 let query: Query = Query::new();
11320 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
11321 }
11322
11323 /// Dismiss follow-up
11324 ///
11325 /// `POST /followups/{followUpId}/dismiss`
11326 ///
11327 /// Marks the follow-up as finished by setting `doneDate` to the current timestamp and recording a dismissal history entry. The subject person must be visible. Group-associated follow-ups require "churchdb +do followup" permission in that group. No success-group membership is changed and no completion event is emitted. Completion and dismissal both appear through `doneDate` and differ only in history. Repeating dismissal updates `doneDate` and creates another history entry.
11328 ///
11329 /// # Example
11330 ///
11331 /// ```
11332 /// # use churchtools_api::*;
11333 /// # use churchtools_api::queries::*;
11334 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11335 /// # let client = churchtools_api::replay::client("post-followups-followUpId-dismiss");
11336 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
11337 /// let followup = client.followups().dismiss(2, &body)?;
11338 /// println!("{}", followup.title);
11339 /// # Ok(())
11340 /// # }
11341 /// ```
11342 pub fn dismiss(&self, follow_up_id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<models::FollowUp2> {
11343 let path = format!("/followups/{}/dismiss", seg(follow_up_id));
11344 let query: Query = Query::new();
11345 let body = serde_json::to_value(body).expect("request body serializes");
11346 self.client.request_data(Method::Post, &path, &query, Some(&body))
11347 }
11348
11349 /// Get follow-up
11350 ///
11351 /// `GET /followups/{followUpId}`
11352 ///
11353 /// Returns one follow-up, including its subject person/group context, responsible person, current/original due dates and configured completion group. The current owner may view it; a group-associated follow-up is also visible to users with that group’s follow-up execution or administration rights. This direct check is broader than the list selection: group follow-ups assigned to another person can be read by eligible group staff even when omitted from their list. The response does not include notes or history, nor indicate whether its underlying specification is shared.
11354 ///
11355 /// # Example
11356 ///
11357 /// ```
11358 /// # use churchtools_api::*;
11359 /// # use churchtools_api::queries::*;
11360 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11361 /// # let client = churchtools_api::replay::client("get-followups-followUpId");
11362 /// let followup = client.followups().get(2)?;
11363 /// println!("{}", followup.title);
11364 /// # Ok(())
11365 /// # }
11366 /// ```
11367 pub fn get(&self, follow_up_id: impl Display) -> Result<models::FollowUp2> {
11368 let path = format!("/followups/{}", seg(follow_up_id));
11369 let query: Query = Query::new();
11370 self.client.request_data(Method::Get, &path, &query, None)
11371 }
11372
11373 /// List follow-ups assigned to the current user or eligible groups
11374 ///
11375 /// `GET /followups`
11376 ///
11377 /// Returns follow-ups owned by the current user plus unassigned group follow-ups for groups where the user has follow-up execution or administration rights. This includes personal and membership follow-ups; it is not an unrestricted list of every follow-up for a visible person. Archived subject persons are excluded. Date filters use `effectiveDueDate` and are combined with OR. Results are sorted by doneDate descending, then effectiveDueDate ascending, then ID ascending; finished items can precede open ones. Page/limit slice the result, but meta only contains count for this page, without a total or last page.
11378 ///
11379 /// Use [`Self::list_with`] to pass query parameters.
11380 ///
11381 /// # Example
11382 ///
11383 /// ```
11384 /// # use churchtools_api::*;
11385 /// # use churchtools_api::queries::*;
11386 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11387 /// # let client = churchtools_api::replay::client("get-followups");
11388 /// for followup in client.followups().list()? {
11389 /// println!("{}", followup.title);
11390 /// }
11391 /// # Ok(())
11392 /// # }
11393 /// ```
11394 pub fn list(&self) -> Result<Vec<models::FollowUp2>> {
11395 self.list_with(&Default::default())
11396 }
11397
11398 /// List follow-ups assigned to the current user or eligible groups
11399 ///
11400 /// Like [`Self::list`], with query parameters.
11401 ///
11402 /// `GET /followups`
11403 ///
11404 /// Returns follow-ups owned by the current user plus unassigned group follow-ups for groups where the user has follow-up execution or administration rights. This includes personal and membership follow-ups; it is not an unrestricted list of every follow-up for a visible person. Archived subject persons are excluded. Date filters use `effectiveDueDate` and are combined with OR. Results are sorted by doneDate descending, then effectiveDueDate ascending, then ID ascending; finished items can precede open ones. Page/limit slice the result, but meta only contains count for this page, without a total or last page.
11405 pub fn list_with(&self, query: &GetFollowupsQuery) -> Result<Vec<models::FollowUp2>> {
11406 let path = "/followups".to_owned();
11407 let query: Query = query.to_query();
11408 self.client.collect_pages(&path, query)
11409 }
11410
11411 /// List follow-ups assigned to the current user or eligible groups
11412 ///
11413 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
11414 /// Breaking off early saves the remaining requests.
11415 pub fn list_iter(&self, query: &GetFollowupsQuery) -> Items<models::FollowUp2> {
11416 let path = "/followups".to_owned();
11417 self.client.items(&path, query.to_query())
11418 }
11419
11420 /// Add a note to a follow-up
11421 ///
11422 /// `POST /followups/{followUpId}/notes`
11423 ///
11424 /// Creates a note linked to this follow-up. With `also_apply_to_person=true`, the same note is also linked to the subject person. `commentViewerId` applies only to the person link. The subject person must be visible; group-associated follow-ups require "churchdb +do followup" permission in that group.
11425 ///
11426 /// Use [`Self::notes_with`] to pass query parameters.
11427 ///
11428 /// # Example
11429 ///
11430 /// ```no_run
11431 /// # use churchtools_api::*;
11432 /// # use churchtools_api::queries::*;
11433 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11434 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11435 /// let body = models::FollowUpNoteCreate {
11436 /// comment: "Called Alex; another conversation is planned for next week.".into(),
11437 /// ..Default::default()
11438 /// };
11439 /// client.followups().notes(2, &body)?;
11440 /// # Ok(())
11441 /// # }
11442 /// ```
11443 pub fn notes(&self, follow_up_id: impl Display, body: &models::FollowUpNoteCreate) -> Result<()> {
11444 self.notes_with(follow_up_id, &Default::default(), body)
11445 }
11446
11447 /// Add a note to a follow-up
11448 ///
11449 /// Like [`Self::notes`], with query parameters.
11450 ///
11451 /// `POST /followups/{followUpId}/notes`
11452 ///
11453 /// Creates a note linked to this follow-up. With `also_apply_to_person=true`, the same note is also linked to the subject person. `commentViewerId` applies only to the person link. The subject person must be visible; group-associated follow-ups require "churchdb +do followup" permission in that group.
11454 pub fn notes_with(&self, follow_up_id: impl Display, query: &PostFollowupsFollowUpIdNotesQuery, body: &models::FollowUpNoteCreate) -> Result<()> {
11455 let path = format!("/followups/{}/notes", seg(follow_up_id));
11456 let query: Query = query.to_query();
11457 let body = serde_json::to_value(body).expect("request body serializes");
11458 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
11459 }
11460
11461 /// Postpone follow-up
11462 ///
11463 /// `POST /followups/{followUpId}/postpone`
11464 ///
11465 /// Changes `effectiveDueDate` to a future calendar date and records postponement history. `dueDate` remains the original plan. The subject person must be visible. Group-associated follow-ups require "churchdb +do followup" permission in that group. Today is rejected. The method does not clear `doneDate` or reject already-finished follow-ups, so use reset to reopen one. No completion event or success-group action is performed.
11466 ///
11467 /// # Example
11468 ///
11469 /// ```
11470 /// # use churchtools_api::*;
11471 /// # use churchtools_api::queries::*;
11472 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11473 /// # let client = churchtools_api::replay::client("post-followups-followUpId-postpone");
11474 /// let body = models::FollowUpPostponeCreate {
11475 /// due_date: "2026-12-01".parse()?,
11476 /// ..Default::default()
11477 /// };
11478 /// let followup = client.followups().postpone(2, &body)?;
11479 /// println!("{}", followup.title);
11480 /// # Ok(())
11481 /// # }
11482 /// ```
11483 pub fn postpone(&self, follow_up_id: impl Display, body: &models::FollowUpPostponeCreate) -> Result<models::FollowUp2> {
11484 let path = format!("/followups/{}/postpone", seg(follow_up_id));
11485 let query: Query = Query::new();
11486 let body = serde_json::to_value(body).expect("request body serializes");
11487 self.client.request_data(Method::Post, &path, &query, Some(&body))
11488 }
11489
11490 /// Reset follow-up
11491 ///
11492 /// `POST /followups/{followUpId}/reset`
11493 ///
11494 /// Reopens the follow-up by clearing `doneDate` and records reset history. A supplied future `dueDate` becomes `effectiveDueDate`; otherwise the original `dueDate` is restored as the effective date. The original `dueDate` is unchanged. The subject person must be visible. Group-associated follow-ups require "churchdb +do followup" permission in that group. Reset is also accepted for an already-open follow-up. It does not undo previous completion effects.
11495 ///
11496 /// # Example
11497 ///
11498 /// ```
11499 /// # use churchtools_api::*;
11500 /// # use churchtools_api::queries::*;
11501 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11502 /// # let client = churchtools_api::replay::client("post-followups-followUpId-reset");
11503 /// let body = models::FollowUpResetCreate {
11504 /// due_date: Some(Some("2026-12-01".parse()?)),
11505 /// ..Default::default()
11506 /// };
11507 /// let followup = client.followups().reset(2, &body)?;
11508 /// println!("{}", followup.title);
11509 /// # Ok(())
11510 /// # }
11511 /// ```
11512 pub fn reset(&self, follow_up_id: impl Display, body: &models::FollowUpResetCreate) -> Result<models::FollowUp2> {
11513 let path = format!("/followups/{}/reset", seg(follow_up_id));
11514 let query: Query = Query::new();
11515 let body = serde_json::to_value(body).expect("request body serializes");
11516 self.client.request_data(Method::Post, &path, &query, Some(&body))
11517 }
11518
11519 /// Update follow-up
11520 ///
11521 /// `PUT /followups/{followUpId}`
11522 ///
11523 /// Updates mutable fields of the specified follow-up.
11524 ///
11525 /// # Example
11526 ///
11527 /// ```
11528 /// # use churchtools_api::*;
11529 /// # use churchtools_api::queries::*;
11530 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11531 /// # let client = churchtools_api::replay::client("put-followups-followUpId");
11532 /// let body = serde_json::json!({
11533 /// "title": "Call Peter"
11534 /// });
11535 /// let result = client.followups().update(2, &body)?;
11536 /// println!("{}", result.title);
11537 /// # Ok(())
11538 /// # }
11539 /// ```
11540 pub fn update(&self, follow_up_id: impl Display, body: &serde_json::Value) -> Result<models::FollowUp2> {
11541 let path = format!("/followups/{}", seg(follow_up_id));
11542 let query: Query = Query::new();
11543 let body = serde_json::to_value(body).expect("request body serializes");
11544 self.client.request_data(Method::Put, &path, &query, Some(&body))
11545 }
11546
11547}
11548
11549/// `client.further_links()`
11550#[derive(Clone, Copy)]
11551pub struct FurtherLinksResource<'a> {
11552 client: &'a Client,
11553}
11554
11555impl<'a> FurtherLinksResource<'a> {
11556 /// Create further link
11557 ///
11558 /// `POST /furtherlinks`
11559 ///
11560 /// Create a new further link.
11561 ///
11562 /// # Example
11563 ///
11564 /// ```
11565 /// # use churchtools_api::*;
11566 /// # use churchtools_api::queries::*;
11567 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11568 /// # let client = churchtools_api::replay::client("post-furtherlinks");
11569 /// let body = models::FurtherLinkCreate {
11570 /// description: Some("Our church's NextCloud".into()),
11571 /// image_url: Some("https://example.org".into()),
11572 /// name: "NextCloud".into(),
11573 /// sort_key: 1.5,
11574 /// url: "https://example.org".into(),
11575 /// ..Default::default()
11576 /// };
11577 /// let result = client.further_links().create(&body)?;
11578 /// println!("{}", result.name);
11579 /// # Ok(())
11580 /// # }
11581 /// ```
11582 pub fn create(&self, body: &models::FurtherLinkCreate) -> Result<models::FurtherLink> {
11583 let path = "/furtherlinks".to_owned();
11584 let query: Query = Query::new();
11585 let body = serde_json::to_value(body).expect("request body serializes");
11586 self.client.request_data(Method::Post, &path, &query, Some(&body))
11587 }
11588
11589 /// `DELETE /furtherlinks/{furtherLinkId}`
11590 ///
11591 /// # Example
11592 ///
11593 /// ```no_run
11594 /// # use churchtools_api::*;
11595 /// # use churchtools_api::queries::*;
11596 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11597 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11598 /// client.further_links().delete(1.5)?;
11599 /// # Ok(())
11600 /// # }
11601 /// ```
11602 pub fn delete(&self, further_link_id: impl Display) -> Result<()> {
11603 let path = format!("/furtherlinks/{}", seg(further_link_id));
11604 let query: Query = Query::new();
11605 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
11606 }
11607
11608 /// Get further link.
11609 ///
11610 /// `GET /furtherlinks/{furtherLinkId}`
11611 ///
11612 /// Get the specified further link.
11613 ///
11614 /// # Example
11615 ///
11616 /// ```
11617 /// # use churchtools_api::*;
11618 /// # use churchtools_api::queries::*;
11619 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11620 /// # let client = churchtools_api::replay::client("get-furtherlinks-furtherLinkId");
11621 /// let further_link = client.further_links().get(1.5)?;
11622 /// println!("{}", further_link.name);
11623 /// # Ok(())
11624 /// # }
11625 /// ```
11626 pub fn get(&self, further_link_id: impl Display) -> Result<models::FurtherLink> {
11627 let path = format!("/furtherlinks/{}", seg(further_link_id));
11628 let query: Query = Query::new();
11629 self.client.request_data(Method::Get, &path, &query, None)
11630 }
11631
11632 /// Get further links
11633 ///
11634 /// `GET /furtherlinks`
11635 ///
11636 /// Get all further links.
11637 ///
11638 /// # Example
11639 ///
11640 /// ```
11641 /// # use churchtools_api::*;
11642 /// # use churchtools_api::queries::*;
11643 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11644 /// # let client = churchtools_api::replay::client("get-furtherlinks");
11645 /// for further_link in client.further_links().list()? {
11646 /// println!("{}", further_link.name);
11647 /// }
11648 /// # Ok(())
11649 /// # }
11650 /// ```
11651 pub fn list(&self) -> Result<Vec<models::FurtherLink>> {
11652 let path = "/furtherlinks".to_owned();
11653 let query: Query = Query::new();
11654 self.client.request_data(Method::Get, &path, &query, None)
11655 }
11656
11657 /// Update further link
11658 ///
11659 /// `PUT /furtherlinks/{furtherLinkId}`
11660 ///
11661 /// Update the specified further link.
11662 ///
11663 /// # Example
11664 ///
11665 /// ```
11666 /// # use churchtools_api::*;
11667 /// # use churchtools_api::queries::*;
11668 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11669 /// # let client = churchtools_api::replay::client("put-furtherlinks-furtherLinkId");
11670 /// let body = models::FurtherLinkCreate {
11671 /// description: Some("Our church's NextCloud".into()),
11672 /// image_url: Some("https://example.org".into()),
11673 /// name: "NextCloud".into(),
11674 /// sort_key: 1.5,
11675 /// url: "https://example.org".into(),
11676 /// ..Default::default()
11677 /// };
11678 /// let result = client.further_links().update(1.5, &body)?;
11679 /// println!("{}", result.name);
11680 /// # Ok(())
11681 /// # }
11682 /// ```
11683 pub fn update(&self, further_link_id: impl Display, body: &models::FurtherLinkCreate) -> Result<models::FurtherLink> {
11684 let path = format!("/furtherlinks/{}", seg(further_link_id));
11685 let query: Query = Query::new();
11686 let body = serde_json::to_value(body).expect("request body serializes");
11687 self.client.request_data(Method::Put, &path, &query, Some(&body))
11688 }
11689
11690}
11691
11692/// `client.group()`
11693#[derive(Clone, Copy)]
11694pub struct GroupResource<'a> {
11695 client: &'a Client,
11696}
11697
11698impl<'a> GroupResource<'a> {
11699 pub fn age_groups(&self) -> GroupAgeGroupsResource<'a> {
11700 GroupAgeGroupsResource { client: self.client }
11701 }
11702
11703 pub fn group_categories(&self) -> GroupGroupCategoriesResource<'a> {
11704 GroupGroupCategoriesResource { client: self.client }
11705 }
11706
11707 pub fn group_types(&self) -> GroupGroupTypesResource<'a> {
11708 GroupGroupTypesResource { client: self.client }
11709 }
11710
11711 pub fn meeting_templates(&self) -> GroupMeetingTemplatesResource<'a> {
11712 GroupMeetingTemplatesResource { client: self.client }
11713 }
11714
11715 pub fn roles(&self) -> GroupRolesResource<'a> {
11716 GroupRolesResource { client: self.client }
11717 }
11718
11719 pub fn target_groups(&self) -> GroupTargetGroupsResource<'a> {
11720 GroupTargetGroupsResource { client: self.client }
11721 }
11722
11723 /// Get all group member statuses
11724 ///
11725 /// `GET /group/memberstatus`
11726 ///
11727 /// Returns the fixed membership-status values with their names translated into the current language. A status describes a person's membership state in a group; their role (for example leader or participant) is a separate property.
11728 /// active means an active membership, requested a membership awaiting confirmation, waiting a place on the waiting list, and to_delete a membership pending removal. to_delete is still a stored membership state, not an already deleted record. These values are shared across group types. Use id in API requests and name for display.
11729 /// Requires authentication. This endpoint takes no parameters and returns a plain array, without a data wrapper or meta object. It lists possible statuses, not the transitions that a particular user may perform for a particular membership.
11730 ///
11731 /// # Example
11732 ///
11733 /// ```
11734 /// # use churchtools_api::*;
11735 /// # use churchtools_api::queries::*;
11736 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11737 /// # let client = churchtools_api::replay::client("get-group-memberstatus");
11738 /// for member_statu in client.group().list_member_status()? {
11739 /// println!("{}", member_statu.name);
11740 /// }
11741 /// # Ok(())
11742 /// # }
11743 /// ```
11744 pub fn list_member_status(&self) -> Result<Vec<models::GetGroupMemberstatusResponseItem>> {
11745 let path = "/group/memberstatus".to_owned();
11746 let query: Query = Query::new();
11747 self.client.request_json(Method::Get, &path, &query, None)
11748 }
11749
11750}
11751
11752/// `client.group().age_groups()`
11753#[derive(Clone, Copy)]
11754pub struct GroupAgeGroupsResource<'a> {
11755 client: &'a Client,
11756}
11757
11758impl<'a> GroupAgeGroupsResource<'a> {
11759 /// Create age range
11760 ///
11761 /// `POST /group/agegroups`
11762 ///
11763 /// Creates a age range as shared master data. An age range describes intended participant ages, such as ages 3 to 5. Groups can reference several ranges through information.ageGroupIds. These configured ranges are independent of the calculated ages of current members.
11764 /// Requires the churchgroup permission "edit masterdata". Supply name, sortKey, start and end. Age boundaries are expressed in years. The name is trimmed. The endpoint validates integer boundaries but does not check that start is less than or equal to end; send a meaningful range. Returns the created record with its generated ID and translated display name. Creating this record does not create or assign any groups.
11765 ///
11766 /// # Example
11767 ///
11768 /// ```
11769 /// # use churchtools_api::*;
11770 /// # use churchtools_api::queries::*;
11771 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11772 /// # let client = churchtools_api::replay::client("post-group-agegroups");
11773 /// let body = models::AgeGroupCreate {
11774 /// end: 5,
11775 /// name: "3-5".into(),
11776 /// sort_key: 3,
11777 /// start: 3,
11778 /// ..Default::default()
11779 /// };
11780 /// let result = client.group().age_groups().create(&body)?;
11781 /// println!("{}", result.name);
11782 /// # Ok(())
11783 /// # }
11784 /// ```
11785 pub fn create(&self, body: &models::AgeGroupCreate) -> Result<models::AgeGroup> {
11786 let path = "/group/agegroups".to_owned();
11787 let query: Query = Query::new();
11788 let body = serde_json::to_value(body).expect("request body serializes");
11789 self.client.request_data(Method::Post, &path, &query, Some(&body))
11790 }
11791
11792 /// Delete age range
11793 ///
11794 /// `DELETE /group/agegroups/{ageGroupId}`
11795 ///
11796 /// Deletes a age range. Removing an age range also removes its ID from the ageGroupIds assignments of existing groups. The groups and their memberships remain.
11797 /// Requires the churchgroup permission "edit masterdata". The dryRun query parameter is required: send false to delete or true to inspect the deletion report. A dry run changes no records and returns 409 with the report, even when deletion would be possible. An actual successful deletion returns 204 without a body.
11798 ///
11799 /// # Example
11800 ///
11801 /// ```no_run
11802 /// # use churchtools_api::*;
11803 /// # use churchtools_api::queries::*;
11804 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11805 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11806 /// let query = DeleteGroupAgegroupsAgeGroupIdQuery {
11807 /// dry_run: Some(true),
11808 /// ..Default::default()
11809 /// };
11810 /// client.group().age_groups().delete(2, &query)?;
11811 /// # Ok(())
11812 /// # }
11813 /// ```
11814 pub fn delete(&self, age_group_id: impl Display, query: &DeleteGroupAgegroupsAgeGroupIdQuery) -> Result<()> {
11815 let path = format!("/group/agegroups/{}", seg(age_group_id));
11816 let query: Query = query.to_query();
11817 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
11818 }
11819
11820 /// Get age range
11821 ///
11822 /// `GET /group/agegroups/{ageGroupId}`
11823 ///
11824 /// Returns one age range using its ID from GET /group/agegroups. An age range describes intended participant ages, such as ages 3 to 5. Groups can reference several ranges through information.ageGroupIds. These configured ranges are independent of the calculated ages of current members.
11825 /// Requires authentication, but no master-data editing permission. Returns a single object in data and no list metadata. Returns 404 when the record does not exist.
11826 ///
11827 /// # Example
11828 ///
11829 /// ```
11830 /// # use churchtools_api::*;
11831 /// # use churchtools_api::queries::*;
11832 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11833 /// # let client = churchtools_api::replay::client("get-group-agegroups-ageGroupId");
11834 /// let age_group = client.group().age_groups().get(2)?;
11835 /// println!("{}", age_group.name);
11836 /// # Ok(())
11837 /// # }
11838 /// ```
11839 pub fn get(&self, age_group_id: impl Display) -> Result<models::AgeGroup> {
11840 let path = format!("/group/agegroups/{}", seg(age_group_id));
11841 let query: Query = Query::new();
11842 self.client.request_data(Method::Get, &path, &query, None)
11843 }
11844
11845 /// Get all age ranges
11846 ///
11847 /// `GET /group/agegroups`
11848 ///
11849 /// Returns all age ranges configured in this ChurchTools installation. An age range describes intended participant ages, such as ages 3 to 5. Groups can reference several ranges through information.ageGroupIds. These configured ranges are independent of the calculated ages of current members.
11850 /// Requires authentication, but no master-data editing permission. There are no filter or pagination parameters. Results are ordered by sortKey ascending and then by the stored name ascending; meta.count is the number of returned records. IDs and labels are installation-specific; discover them before assigning them to groups.
11851 ///
11852 /// # Example
11853 ///
11854 /// ```
11855 /// # use churchtools_api::*;
11856 /// # use churchtools_api::queries::*;
11857 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11858 /// # let client = churchtools_api::replay::client("get-group-agegroups");
11859 /// for age_group in client.group().age_groups().list()? {
11860 /// println!("{}", age_group.name);
11861 /// }
11862 /// # Ok(())
11863 /// # }
11864 /// ```
11865 pub fn list(&self) -> Result<Vec<models::AgeGroup>> {
11866 let path = "/group/agegroups".to_owned();
11867 let query: Query = Query::new();
11868 self.client.request_data(Method::Get, &path, &query, None)
11869 }
11870
11871 /// Update age range
11872 ///
11873 /// `PUT /group/agegroups/{ageGroupId}`
11874 ///
11875 /// Updates the shared age range identified by ageGroupId. Existing group assignments continue to reference the same record. This is a full update, not a partial update.
11876 /// Requires the churchgroup permission "edit masterdata". Supply name, sortKey, start and end. Age boundaries are expressed in years. The name is trimmed. The endpoint validates integer boundaries but does not check that start is less than or equal to end; send a meaningful range. The ID comes from the URL; no body id is required. Returns 204 without a response body. Use GET /group/agegroups/{ageGroupId} to read the updated record.
11877 ///
11878 /// # Example
11879 ///
11880 /// ```no_run
11881 /// # use churchtools_api::*;
11882 /// # use churchtools_api::queries::*;
11883 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11884 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11885 /// let body = models::AgeGroupCreate {
11886 /// end: 5,
11887 /// name: "3-5".into(),
11888 /// sort_key: 3,
11889 /// start: 3,
11890 /// ..Default::default()
11891 /// };
11892 /// client.group().age_groups().update(2, &body)?;
11893 /// # Ok(())
11894 /// # }
11895 /// ```
11896 pub fn update(&self, age_group_id: impl Display, body: &models::AgeGroupCreate) -> Result<()> {
11897 let path = format!("/group/agegroups/{}", seg(age_group_id));
11898 let query: Query = Query::new();
11899 let body = serde_json::to_value(body).expect("request body serializes");
11900 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
11901 }
11902
11903}
11904
11905/// `client.group().group_categories()`
11906#[derive(Clone, Copy)]
11907pub struct GroupGroupCategoriesResource<'a> {
11908 client: &'a Client,
11909}
11910
11911impl<'a> GroupGroupCategoriesResource<'a> {
11912 /// Create group category
11913 ///
11914 /// `POST /group/groupcategories`
11915 ///
11916 /// Creates a group category as shared master data. Categories organize groups by theme, for example worship services or community activities. A group references its category through information.groupCategoryId. Its group type separately defines shared settings and membership roles.
11917 /// Requires the churchgroup permission "edit masterdata". Supply name, color and sortKey. description is optional; omitted, null or blank input is stored as null. Text fields are trimmed. Returns the created record with its generated ID and translated display name. Creating this record does not create or assign any groups.
11918 ///
11919 /// # Example
11920 ///
11921 /// ```
11922 /// # use churchtools_api::*;
11923 /// # use churchtools_api::queries::*;
11924 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11925 /// # let client = churchtools_api::replay::client("post-group-groupcategories");
11926 /// let body = models::GroupCategoryCreate {
11927 /// color: "blue".into(),
11928 /// name: "Gottesdienst".into(),
11929 /// sort_key: 5,
11930 /// ..Default::default()
11931 /// };
11932 /// let result = client.group().group_categories().create(&body)?;
11933 /// println!("{}", result.name);
11934 /// # Ok(())
11935 /// # }
11936 /// ```
11937 pub fn create(&self, body: &models::GroupCategoryCreate) -> Result<models::GroupCategory> {
11938 let path = "/group/groupcategories".to_owned();
11939 let query: Query = Query::new();
11940 let body = serde_json::to_value(body).expect("request body serializes");
11941 self.client.request_data(Method::Post, &path, &query, Some(&body))
11942 }
11943
11944 /// Delete group category
11945 ///
11946 /// `DELETE /group/groupcategories/{groupCategoryId}`
11947 ///
11948 /// Deletes a group category. The deletion report includes groups that reference this category. Deleting a category does not delete these groups or their memberships.
11949 /// Requires the churchgroup permission "edit masterdata". The dryRun query parameter is required: send false to delete or true to inspect the deletion report. A dry run changes no records and returns 409 with the report, even when deletion would be possible. An actual successful deletion returns 204 without a body.
11950 ///
11951 /// # Example
11952 ///
11953 /// ```no_run
11954 /// # use churchtools_api::*;
11955 /// # use churchtools_api::queries::*;
11956 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11957 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
11958 /// let query = DeleteGroupGroupcategoriesGroupCategoryIdQuery {
11959 /// dry_run: Some(true),
11960 /// ..Default::default()
11961 /// };
11962 /// client.group().group_categories().delete(2, &query)?;
11963 /// # Ok(())
11964 /// # }
11965 /// ```
11966 pub fn delete(&self, group_category_id: impl Display, query: &DeleteGroupGroupcategoriesGroupCategoryIdQuery) -> Result<()> {
11967 let path = format!("/group/groupcategories/{}", seg(group_category_id));
11968 let query: Query = query.to_query();
11969 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
11970 }
11971
11972 /// Get group category
11973 ///
11974 /// `GET /group/groupcategories/{groupCategoryId}`
11975 ///
11976 /// Returns one group category using its ID from GET /group/groupcategories. Categories organize groups by theme, for example worship services or community activities. A group references its category through information.groupCategoryId. Its group type separately defines shared settings and membership roles.
11977 /// Requires authentication, but no master-data editing permission. Returns a single object in data and no list metadata. Returns 404 when the record does not exist.
11978 ///
11979 /// # Example
11980 ///
11981 /// ```
11982 /// # use churchtools_api::*;
11983 /// # use churchtools_api::queries::*;
11984 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
11985 /// # let client = churchtools_api::replay::client("get-group-groupcategories-groupCategoryId");
11986 /// let group_category = client.group().group_categories().get(2)?;
11987 /// println!("{}", group_category.name);
11988 /// # Ok(())
11989 /// # }
11990 /// ```
11991 pub fn get(&self, group_category_id: impl Display) -> Result<models::GroupCategory> {
11992 let path = format!("/group/groupcategories/{}", seg(group_category_id));
11993 let query: Query = Query::new();
11994 self.client.request_data(Method::Get, &path, &query, None)
11995 }
11996
11997 /// Get all group categories
11998 ///
11999 /// `GET /group/groupcategories`
12000 ///
12001 /// Returns all group categories configured in this ChurchTools installation. Categories organize groups by theme, for example worship services or community activities. A group references its category through information.groupCategoryId. Its group type separately defines shared settings and membership roles.
12002 /// Requires authentication, but no master-data editing permission. There are no filter or pagination parameters. Results are ordered by sortKey ascending and then by the stored name ascending; meta.count is the number of returned records. IDs and labels are installation-specific; discover them before assigning them to groups.
12003 ///
12004 /// # Example
12005 ///
12006 /// ```
12007 /// # use churchtools_api::*;
12008 /// # use churchtools_api::queries::*;
12009 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12010 /// # let client = churchtools_api::replay::client("get-group-groupcategories");
12011 /// for group_category in client.group().group_categories().list()? {
12012 /// println!("{}", group_category.name);
12013 /// }
12014 /// # Ok(())
12015 /// # }
12016 /// ```
12017 pub fn list(&self) -> Result<Vec<models::GroupCategory>> {
12018 let path = "/group/groupcategories".to_owned();
12019 let query: Query = Query::new();
12020 self.client.request_data(Method::Get, &path, &query, None)
12021 }
12022
12023 /// Update group category
12024 ///
12025 /// `PUT /group/groupcategories/{groupCategoryId}`
12026 ///
12027 /// Updates the shared group category identified by groupCategoryId. Existing group assignments continue to reference the same record. This is a full update, not a partial update.
12028 /// Requires the churchgroup permission "edit masterdata". Supply name, color and sortKey. description is optional; omitted, null or blank input is stored as null. Text fields are trimmed. The ID comes from the URL; no body id is required. Returns the updated record in data.
12029 ///
12030 /// # Example
12031 ///
12032 /// ```
12033 /// # use churchtools_api::*;
12034 /// # use churchtools_api::queries::*;
12035 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12036 /// # let client = churchtools_api::replay::client("put-group-groupcategories-groupCategoryId");
12037 /// let body = models::GroupCategoryCreate {
12038 /// color: "blue".into(),
12039 /// name: "Gottesdienst".into(),
12040 /// sort_key: 5,
12041 /// ..Default::default()
12042 /// };
12043 /// let result = client.group().group_categories().update(2, &body)?;
12044 /// println!("{}", result.name);
12045 /// # Ok(())
12046 /// # }
12047 /// ```
12048 pub fn update(&self, group_category_id: impl Display, body: &models::GroupCategoryCreate) -> Result<models::GroupCategory> {
12049 let path = format!("/group/groupcategories/{}", seg(group_category_id));
12050 let query: Query = Query::new();
12051 let body = serde_json::to_value(body).expect("request body serializes");
12052 self.client.request_data(Method::Put, &path, &query, Some(&body))
12053 }
12054
12055}
12056
12057/// `client.group().group_types()`
12058#[derive(Clone, Copy)]
12059pub struct GroupGroupTypesResource<'a> {
12060 client: &'a Client,
12061}
12062
12063impl<'a> GroupGroupTypesResource<'a> {
12064 /// Create group type
12065 ///
12066 /// `POST /group/grouptypes`
12067 ///
12068 /// Creates a group type: shared configuration for groups such as small groups or ministry teams. This creates no groups or memberships. A participant role (the default) and a leader role are created automatically for the new type. Retrieve them with GET /group/roles?group_type_id={id} using the ID returned in data.id.
12069 /// Requires the churchgroup permission "edit masterdata". Supply all required settings; the boolean fields do not have implicit request defaults. description is optional; omitted, null or blank descriptions are stored as null. Text fields are trimmed. Returns the created type with its generated ID, translated names and metadata.
12070 ///
12071 /// # Example
12072 ///
12073 /// ```
12074 /// # use churchtools_api::*;
12075 /// # use churchtools_api::queries::*;
12076 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12077 /// # let client = churchtools_api::replay::client("post-group-grouptypes");
12078 /// let body = models::GroupTypeCreate {
12079 /// available_for_new_person: false,
12080 /// color: "blue".into(),
12081 /// is_leader_necessary: false,
12082 /// name: "Kleingruppe".into(),
12083 /// name_plural: "Kleingruppen".into(),
12084 /// permission_depth: 0,
12085 /// posts_enabled: true,
12086 /// shorty: "KG".into(),
12087 /// sort_key: 2,
12088 /// ..Default::default()
12089 /// };
12090 /// let result = client.group().group_types().create(&body)?;
12091 /// println!("{}", result.name);
12092 /// # Ok(())
12093 /// # }
12094 /// ```
12095 pub fn create(&self, body: &models::GroupTypeCreate) -> Result<models::GroupType> {
12096 let path = "/group/grouptypes".to_owned();
12097 let query: Query = Query::new();
12098 let body = serde_json::to_value(body).expect("request body serializes");
12099 self.client.request_data(Method::Post, &path, &query, Some(&body))
12100 }
12101
12102 /// Delete grouptype
12103 ///
12104 /// `DELETE /group/grouptypes/{groupTypeId}`
12105 ///
12106 /// Deletes a group type, including its role definitions, when no groups still reference it. Requires the churchgroup permission "edit masterdata". Existing groups block deletion; use a dry run to inspect references before making changes.
12107 /// dryRun=true performs the deletion checks without deleting anything and returns a 409 deletion report even when deletion would be possible. A successful actual deletion returns 204 with no response body.
12108 ///
12109 /// Use [`Self::delete_with`] to pass query parameters.
12110 ///
12111 /// # Example
12112 ///
12113 /// ```no_run
12114 /// # use churchtools_api::*;
12115 /// # use churchtools_api::queries::*;
12116 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12117 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12118 /// client.group().group_types().delete(2)?;
12119 /// # Ok(())
12120 /// # }
12121 /// ```
12122 pub fn delete(&self, group_type_id: impl Display) -> Result<()> {
12123 self.delete_with(group_type_id, &Default::default())
12124 }
12125
12126 /// Delete grouptype
12127 ///
12128 /// Like [`Self::delete`], with query parameters.
12129 ///
12130 /// `DELETE /group/grouptypes/{groupTypeId}`
12131 ///
12132 /// Deletes a group type, including its role definitions, when no groups still reference it. Requires the churchgroup permission "edit masterdata". Existing groups block deletion; use a dry run to inspect references before making changes.
12133 /// dryRun=true performs the deletion checks without deleting anything and returns a 409 deletion report even when deletion would be possible. A successful actual deletion returns 204 with no response body.
12134 pub fn delete_with(&self, group_type_id: impl Display, query: &DeleteGroupGrouptypesGroupTypeIdQuery) -> Result<()> {
12135 let path = format!("/group/grouptypes/{}", seg(group_type_id));
12136 let query: Query = query.to_query();
12137 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
12138 }
12139
12140 /// Get grouptype
12141 ///
12142 /// `GET /group/grouptypes/{groupTypeId}`
12143 ///
12144 /// Returns one group type by its installation-specific ID from GET /group/grouptypes. The result describes shared settings, not a concrete group. Use GET /group/roles with group_type_id to retrieve the role definitions belonging to this type. Requires authentication, but no master-data editing permission. Returns 404 when the type does not exist.
12145 ///
12146 /// # Example
12147 ///
12148 /// ```
12149 /// # use churchtools_api::*;
12150 /// # use churchtools_api::queries::*;
12151 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12152 /// # let client = churchtools_api::replay::client("get-group-grouptypes-groupTypeId");
12153 /// let group_type = client.group().group_types().get(2)?;
12154 /// println!("{}", group_type.name);
12155 /// # Ok(())
12156 /// # }
12157 /// ```
12158 pub fn get(&self, group_type_id: impl Display) -> Result<models::GroupType> {
12159 let path = format!("/group/grouptypes/{}", seg(group_type_id));
12160 let query: Query = Query::new();
12161 self.client.request_data(Method::Get, &path, &query, None)
12162 }
12163
12164 /// Get all group types
12165 ///
12166 /// `GET /group/grouptypes`
12167 ///
12168 /// Returns all group types configured in this ChurchTools installation. Group types are shared configuration records (master data), for example "Small group" or "Ministry team". A group is a concrete collection of people, such as "Tuesday evening small group", and references one type through `information.groupTypeId`.
12169 /// Each type defines common settings and has its own membership roles, such as leader or participant. Use `GET /group/roles` to retrieve role definitions and match their `groupTypeId` to the type's `id`. Use `GET /groups` to retrieve actual groups; this endpoint does not return groups or their members.
12170 /// Requires authentication. No master-data editing permission is required. The response is not paginated and accepts no filters. Results are ordered by `sortKey` ascending, then by the stored `name` ascending. `meta.count` is the number of group types returned. IDs and names are installation-specific; integrations should discover them instead of assuming fixed values.
12171 ///
12172 /// # Example
12173 ///
12174 /// ```
12175 /// # use churchtools_api::*;
12176 /// # use churchtools_api::queries::*;
12177 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12178 /// # let client = churchtools_api::replay::client("get-group-grouptypes");
12179 /// for group_type in client.group().group_types().list()? {
12180 /// println!("{}", group_type.name);
12181 /// }
12182 /// # Ok(())
12183 /// # }
12184 /// ```
12185 pub fn list(&self) -> Result<Vec<models::GroupType>> {
12186 let path = "/group/grouptypes".to_owned();
12187 let query: Query = Query::new();
12188 self.client.request_data(Method::Get, &path, &query, None)
12189 }
12190
12191 /// Update GroupType
12192 ///
12193 /// `PUT /group/grouptypes/{groupTypeId}`
12194 ///
12195 /// Updates the shared settings of a group type. Existing groups reference these settings; this endpoint does not create a group or change which type a group belongs to.
12196 /// Requires the churchgroup permission "edit masterdata". Supply all required fields, including unchanged settings; this is not a partial update. The type ID comes from the URL, and no body id is required. Omitting description clears it to null rather than preserving the old text; null or blank text also clears it. Text fields are trimmed. Returns the updated type with translated names and metadata.
12197 ///
12198 /// # Example
12199 ///
12200 /// ```
12201 /// # use churchtools_api::*;
12202 /// # use churchtools_api::queries::*;
12203 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12204 /// # let client = churchtools_api::replay::client("put-group-grouptypes-groupTypeId");
12205 /// let body = models::GroupTypeCreate {
12206 /// available_for_new_person: false,
12207 /// color: "blue".into(),
12208 /// is_leader_necessary: false,
12209 /// name: "Kleingruppe".into(),
12210 /// name_plural: "Kleingruppen".into(),
12211 /// permission_depth: 0,
12212 /// posts_enabled: true,
12213 /// shorty: "KG".into(),
12214 /// sort_key: 2,
12215 /// ..Default::default()
12216 /// };
12217 /// let result = client.group().group_types().update(2, &body)?;
12218 /// println!("{}", result.name);
12219 /// # Ok(())
12220 /// # }
12221 /// ```
12222 pub fn update(&self, group_type_id: impl Display, body: &models::GroupTypeCreate) -> Result<models::GroupType> {
12223 let path = format!("/group/grouptypes/{}", seg(group_type_id));
12224 let query: Query = Query::new();
12225 let body = serde_json::to_value(body).expect("request body serializes");
12226 self.client.request_data(Method::Put, &path, &query, Some(&body))
12227 }
12228
12229}
12230
12231/// `client.group().meeting_templates()`
12232#[derive(Clone, Copy)]
12233pub struct GroupMeetingTemplatesResource<'a> {
12234 client: &'a Client,
12235}
12236
12237impl<'a> GroupMeetingTemplatesResource<'a> {
12238 /// Create group meeting feedback template
12239 ///
12240 /// `POST /group/meetingtemplates`
12241 ///
12242 /// Creates a reusable group-meeting feedback template. A template defines an ordered feedback form for group meetings. It is selected through settings.groupMeeting.templateId on a group. Meeting answers are stored separately in pollResult; the template does not schedule meetings or record attendance.
12243 /// Requires the churchgroup permission "edit masterdata". Send name and the complete template array. Each field requires label and type. select fields also require non-empty options, preferably an array of non-blank strings; legacy comma-separated strings are accepted. Other field types must omit options or use null. An empty template array is allowed. Names and labels are trimmed. Returns the created template with its generated ID and metadata. Creating a template does not assign it to any groups.
12244 ///
12245 /// # Example
12246 ///
12247 /// ```
12248 /// # use churchtools_api::*;
12249 /// # use churchtools_api::queries::*;
12250 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12251 /// # let client = churchtools_api::replay::client("post-group-meetingtemplates");
12252 /// let body = models::MeetingTemplateCreate {
12253 /// name: "Lowlights / Highlights".into(),
12254 /// template: vec![models::MeetingTemplateField {
12255 /// label: "Highlights".into(),
12256 /// r#type: "color".into(),
12257 /// ..Default::default()
12258 /// }],
12259 /// ..Default::default()
12260 /// };
12261 /// let result = client.group().meeting_templates().create(&body)?;
12262 /// println!("{}", result.name);
12263 /// # Ok(())
12264 /// # }
12265 /// ```
12266 pub fn create(&self, body: &models::MeetingTemplateCreate) -> Result<models::MeetingTemplate> {
12267 let path = "/group/meetingtemplates".to_owned();
12268 let query: Query = Query::new();
12269 let body = serde_json::to_value(body).expect("request body serializes");
12270 self.client.request_data(Method::Post, &path, &query, Some(&body))
12271 }
12272
12273 /// Delete group meeting feedback template
12274 ///
12275 /// `DELETE /group/meetingtemplates/{meetingTemplateId}`
12276 ///
12277 /// Deletes a feedback template when no groups still reference it. Requires the churchgroup permission "edit masterdata". Groups using this template block deletion; change their template assignment before deleting it.
12278 /// The dryRun query parameter is required. Send true to inspect deletion dependencies without changing records; the report is returned with 409 even when deletion would be possible. Send false to delete. Successful deletion returns 204 without a response body.
12279 ///
12280 /// # Example
12281 ///
12282 /// ```no_run
12283 /// # use churchtools_api::*;
12284 /// # use churchtools_api::queries::*;
12285 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12286 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12287 /// let query = DeleteGroupMeetingtemplatesMeetingTemplateIdQuery {
12288 /// dry_run: Some(true),
12289 /// ..Default::default()
12290 /// };
12291 /// client.group().meeting_templates().delete(1, &query)?;
12292 /// # Ok(())
12293 /// # }
12294 /// ```
12295 pub fn delete(&self, meeting_template_id: impl Display, query: &DeleteGroupMeetingtemplatesMeetingTemplateIdQuery) -> Result<()> {
12296 let path = format!("/group/meetingtemplates/{}", seg(meeting_template_id));
12297 let query: Query = query.to_query();
12298 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
12299 }
12300
12301 /// Get group meeting feedback template
12302 ///
12303 /// `GET /group/meetingtemplates/{meetingTemplateId}`
12304 ///
12305 /// Returns one feedback template by its ID from GET /group/meetingtemplates. A template defines an ordered feedback form for group meetings. It is selected through settings.groupMeeting.templateId on a group. Meeting answers are stored separately in pollResult; the template does not schedule meetings or record attendance. Requires authentication, but no master-data editing permission. Returns the template in data, including its ordered fields and metadata. An unknown ID returns 404.
12306 ///
12307 /// # Example
12308 ///
12309 /// ```
12310 /// # use churchtools_api::*;
12311 /// # use churchtools_api::queries::*;
12312 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12313 /// # let client = churchtools_api::replay::client("get-group-meetingtemplates-meetingTemplateId");
12314 /// let meeting_template = client.group().meeting_templates().get(1)?;
12315 /// println!("{}", meeting_template.name);
12316 /// # Ok(())
12317 /// # }
12318 /// ```
12319 pub fn get(&self, meeting_template_id: impl Display) -> Result<models::MeetingTemplate> {
12320 let path = format!("/group/meetingtemplates/{}", seg(meeting_template_id));
12321 let query: Query = Query::new();
12322 self.client.request_data(Method::Get, &path, &query, None)
12323 }
12324
12325 /// Get all group meeting feedback templates
12326 ///
12327 /// `GET /group/meetingtemplates`
12328 ///
12329 /// Returns all configured group-meeting feedback templates. A template defines an ordered feedback form for group meetings. It is selected through settings.groupMeeting.templateId on a group. Meeting answers are stored separately in pollResult; the template does not schedule meetings or record attendance.
12330 /// Requires authentication, but no master-data editing permission. Accepts no filter or pagination parameters. Results are sorted by name ascending. meta.count is the number of returned templates.
12331 ///
12332 /// # Example
12333 ///
12334 /// ```
12335 /// # use churchtools_api::*;
12336 /// # use churchtools_api::queries::*;
12337 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12338 /// # let client = churchtools_api::replay::client("get-group-meetingtemplates");
12339 /// for meeting_template in client.group().meeting_templates().list()? {
12340 /// println!("{}", meeting_template.name);
12341 /// }
12342 /// # Ok(())
12343 /// # }
12344 /// ```
12345 pub fn list(&self) -> Result<Vec<models::MeetingTemplate>> {
12346 let path = "/group/meetingtemplates".to_owned();
12347 let query: Query = Query::new();
12348 self.client.request_data(Method::Get, &path, &query, None)
12349 }
12350
12351 /// Update group meeting feedback template
12352 ///
12353 /// `PUT /group/meetingtemplates/{meetingTemplateId}`
12354 ///
12355 /// Replaces the name and complete field list of a feedback template. The template ID comes from the URL; no body id is required. Existing group assignments continue to reference this template.
12356 /// Requires the churchgroup permission "edit masterdata". Send name and the complete template array. Each field requires label and type. select fields also require non-empty options, preferably an array of non-blank strings; legacy comma-separated strings are accepted. Other field types must omit options or use null. An empty template array is allowed. Names and labels are trimmed. Omitted fields in the array are removed from the template. Returns 204 without a response body; retrieve the template again to read its updated contents. When displaying existing feedback, the ChurchTools UI matches saved answers to template fields by label and type, so changing either can affect that display.
12357 ///
12358 /// # Example
12359 ///
12360 /// ```no_run
12361 /// # use churchtools_api::*;
12362 /// # use churchtools_api::queries::*;
12363 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12364 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12365 /// let body = models::MeetingTemplateCreate {
12366 /// name: "Lowlights / Highlights".into(),
12367 /// template: vec![models::MeetingTemplateField {
12368 /// label: "Highlights".into(),
12369 /// r#type: "color".into(),
12370 /// ..Default::default()
12371 /// }],
12372 /// ..Default::default()
12373 /// };
12374 /// client.group().meeting_templates().update(1, &body)?;
12375 /// # Ok(())
12376 /// # }
12377 /// ```
12378 pub fn update(&self, meeting_template_id: impl Display, body: &models::MeetingTemplateCreate) -> Result<()> {
12379 let path = format!("/group/meetingtemplates/{}", seg(meeting_template_id));
12380 let query: Query = Query::new();
12381 let body = serde_json::to_value(body).expect("request body serializes");
12382 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
12383 }
12384
12385}
12386
12387/// `client.group().roles()`
12388#[derive(Clone, Copy)]
12389pub struct GroupRolesResource<'a> {
12390 client: &'a Client,
12391}
12392
12393impl<'a> GroupRolesResource<'a> {
12394 /// Create Role
12395 ///
12396 /// `POST /group/roles`
12397 ///
12398 /// Creates a membership-role definition for the group type identified by groupTypeId. Groups of that type receive their own role settings records, which can be retrieved with GET /groups/{groupId}/roles. This does not add any people to a group.
12399 /// Requires the churchgroup permission "edit masterdata". All listed required fields must be supplied, including growPathId (use null for no growth-path association). Setting isDefault to true removes the default flag from other roles of this type. Returns the created definition, including its generated ID.
12400 ///
12401 /// # Example
12402 ///
12403 /// ```
12404 /// # use churchtools_api::*;
12405 /// # use churchtools_api::queries::*;
12406 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12407 /// # let client = churchtools_api::replay::client("post-group-roles");
12408 /// let body = models::RoleCreate {
12409 /// group_type_id: 2,
12410 /// grow_path_id: Some(4),
12411 /// is_default: false,
12412 /// is_hidden: false,
12413 /// name: "Leiter".into(),
12414 /// shorty: "L".into(),
12415 /// sort_key: 1,
12416 /// r#type: "leader".into(),
12417 /// ..Default::default()
12418 /// };
12419 /// let result = client.group().roles().create(&body)?;
12420 /// println!("{}", result.name);
12421 /// # Ok(())
12422 /// # }
12423 /// ```
12424 pub fn create(&self, body: &models::RoleCreate) -> Result<models::Role> {
12425 let path = "/group/roles".to_owned();
12426 let query: Query = Query::new();
12427 let body = serde_json::to_value(body).expect("request body serializes");
12428 self.client.request_data(Method::Post, &path, &query, Some(&body))
12429 }
12430
12431 /// Delete role
12432 ///
12433 /// `DELETE /group/roles/{roleId}`
12434 ///
12435 /// Deletes a role definition and its group-specific settings, subject to deletion checks. Requires the churchgroup permission "edit masterdata". Another default role must remain for the same group type; otherwise the request fails with 400, including during a dry run. Set another role as default before deleting the current default.
12436 /// Use dryRun=true to inspect deletion dependencies without deleting anything. A dry run returns 409 with the deletion report even when deletion would be possible. Actual successful deletion returns 204 with no response body.
12437 ///
12438 /// Use [`Self::delete_with`] to pass query parameters.
12439 ///
12440 /// # Example
12441 ///
12442 /// ```no_run
12443 /// # use churchtools_api::*;
12444 /// # use churchtools_api::queries::*;
12445 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12446 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12447 /// client.group().roles().delete(16)?;
12448 /// # Ok(())
12449 /// # }
12450 /// ```
12451 pub fn delete(&self, role_id: impl Display) -> Result<()> {
12452 self.delete_with(role_id, &Default::default())
12453 }
12454
12455 /// Delete role
12456 ///
12457 /// Like [`Self::delete`], with query parameters.
12458 ///
12459 /// `DELETE /group/roles/{roleId}`
12460 ///
12461 /// Deletes a role definition and its group-specific settings, subject to deletion checks. Requires the churchgroup permission "edit masterdata". Another default role must remain for the same group type; otherwise the request fails with 400, including during a dry run. Set another role as default before deleting the current default.
12462 /// Use dryRun=true to inspect deletion dependencies without deleting anything. A dry run returns 409 with the deletion report even when deletion would be possible. Actual successful deletion returns 204 with no response body.
12463 pub fn delete_with(&self, role_id: impl Display, query: &DeleteGroupRolesRoleIdQuery) -> Result<()> {
12464 let path = format!("/group/roles/{}", seg(role_id));
12465 let query: Query = query.to_query();
12466 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
12467 }
12468
12469 /// Get role
12470 ///
12471 /// `GET /group/roles/{roleId}`
12472 ///
12473 /// Returns one membership-role definition by its ID from GET /group/roles. This is the definition belonging to a group type. For the settings of a role in an individual group, use GET /groups/{groupId}/roles instead. Requires authentication, but no master-data editing permission. Returns 404 when the role does not exist.
12474 ///
12475 /// # Example
12476 ///
12477 /// ```
12478 /// # use churchtools_api::*;
12479 /// # use churchtools_api::queries::*;
12480 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12481 /// # let client = churchtools_api::replay::client("get-group-roles-roleId");
12482 /// let role = client.group().roles().get(16)?;
12483 /// println!("{}", role.name);
12484 /// # Ok(())
12485 /// # }
12486 /// ```
12487 pub fn get(&self, role_id: impl Display) -> Result<models::Role> {
12488 let path = format!("/group/roles/{}", seg(role_id));
12489 let query: Query = Query::new();
12490 self.client.request_data(Method::Get, &path, &query, None)
12491 }
12492
12493 /// Get roles
12494 ///
12495 /// `GET /group/roles`
12496 ///
12497 /// Returns membership-role definitions shared by groups of a given group type. For example, a small-group type may define leader, co-leader and participant roles. Use group_type_id to select one type; omitting it returns roles for all types. A type with no matching roles returns an empty data array.
12498 /// The default standard format returns full Role objects. domainObject returns compact display references with a string domainIdentifier instead of the full role fields. Use GET /groups/{groupId}/roles for the settings of these roles in a specific group.
12499 /// Requires authentication, but no master-data editing permission. The list is not paginated; meta.count is the number of returned roles. Without a filter, results are sorted by sortKey and name ascending. With group_type_id, they are sorted by type and sortKey ascending.
12500 ///
12501 /// Use [`Self::list_with`] to pass query parameters.
12502 ///
12503 /// # Example
12504 ///
12505 /// ```
12506 /// # use churchtools_api::*;
12507 /// # use churchtools_api::queries::*;
12508 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12509 /// # let client = churchtools_api::replay::client("get-group-roles");
12510 /// let result = client.group().roles().list()?;
12511 /// println!("{:?}", result);
12512 /// # Ok(())
12513 /// # }
12514 /// ```
12515 pub fn list(&self) -> Result<serde_json::Value> {
12516 self.list_with(&Default::default())
12517 }
12518
12519 /// Get roles
12520 ///
12521 /// Like [`Self::list`], with query parameters.
12522 ///
12523 /// `GET /group/roles`
12524 ///
12525 /// Returns membership-role definitions shared by groups of a given group type. For example, a small-group type may define leader, co-leader and participant roles. Use group_type_id to select one type; omitting it returns roles for all types. A type with no matching roles returns an empty data array.
12526 /// The default standard format returns full Role objects. domainObject returns compact display references with a string domainIdentifier instead of the full role fields. Use GET /groups/{groupId}/roles for the settings of these roles in a specific group.
12527 /// Requires authentication, but no master-data editing permission. The list is not paginated; meta.count is the number of returned roles. Without a filter, results are sorted by sortKey and name ascending. With group_type_id, they are sorted by type and sortKey ascending.
12528 pub fn list_with(&self, query: &GetGroupRolesQuery) -> Result<serde_json::Value> {
12529 let path = "/group/roles".to_owned();
12530 let query: Query = query.to_query();
12531 self.client.request_data(Method::Get, &path, &query, None)
12532 }
12533
12534 /// Update Role
12535 ///
12536 /// `PUT /group/roles/{roleId}`
12537 ///
12538 /// Updates the shared role definition identified by roleId. Changes apply to the definition used by groups of its type; use PATCH /groups/{groupId}/roles/{roleId} to change settings for one group instead.
12539 /// Requires the churchgroup permission "edit masterdata". Send all required fields; this is not a partial update. The ID is taken from the URL; no body id is required. groupTypeId is currently required by validation but does not move the role to another group type. Send the existing value.
12540 /// Setting isDefault to true clears the default flag on other roles of the same type. Setting it to false is rejected with 400 if no other default role remains. Returns the updated definition.
12541 ///
12542 /// # Example
12543 ///
12544 /// ```
12545 /// # use churchtools_api::*;
12546 /// # use churchtools_api::queries::*;
12547 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12548 /// # let client = churchtools_api::replay::client("put-group-roles-roleId");
12549 /// let body = models::RoleCreate {
12550 /// group_type_id: 2,
12551 /// grow_path_id: Some(4),
12552 /// is_default: false,
12553 /// is_hidden: false,
12554 /// name: "Leiter".into(),
12555 /// shorty: "L".into(),
12556 /// sort_key: 1,
12557 /// r#type: "leader".into(),
12558 /// ..Default::default()
12559 /// };
12560 /// let result = client.group().roles().update(16, &body)?;
12561 /// println!("{}", result.name);
12562 /// # Ok(())
12563 /// # }
12564 /// ```
12565 pub fn update(&self, role_id: impl Display, body: &models::RoleCreate) -> Result<models::Role> {
12566 let path = format!("/group/roles/{}", seg(role_id));
12567 let query: Query = Query::new();
12568 let body = serde_json::to_value(body).expect("request body serializes");
12569 self.client.request_data(Method::Put, &path, &query, Some(&body))
12570 }
12571
12572}
12573
12574/// `client.group().target_groups()`
12575#[derive(Clone, Copy)]
12576pub struct GroupTargetGroupsResource<'a> {
12577 client: &'a Client,
12578}
12579
12580impl<'a> GroupTargetGroupsResource<'a> {
12581 /// Create target audience
12582 ///
12583 /// `POST /group/targetgroups`
12584 ///
12585 /// Creates a target audience as shared master data. A target audience describes whom a group is intended for, such as families or students. A group references one audience through information.targetGroupId. This endpoint returns audience labels, not people or groups.
12586 /// Requires the churchgroup permission "edit masterdata". Supply both name and sortKey. Use an integer sortKey to control display order. Returns the created record with its generated ID and translated display name. Creating this record does not create or assign any groups.
12587 ///
12588 /// # Example
12589 ///
12590 /// ```
12591 /// # use churchtools_api::*;
12592 /// # use churchtools_api::queries::*;
12593 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12594 /// # let client = churchtools_api::replay::client("post-group-targetgroups");
12595 /// let body = models::TargetGroupCreate {
12596 /// name: "men".into(),
12597 /// sort_key: 2,
12598 /// ..Default::default()
12599 /// };
12600 /// let result = client.group().target_groups().create(&body)?;
12601 /// println!("{}", result.name);
12602 /// # Ok(())
12603 /// # }
12604 /// ```
12605 pub fn create(&self, body: &models::TargetGroupCreate) -> Result<models::TargetGroup> {
12606 let path = "/group/targetgroups".to_owned();
12607 let query: Query = Query::new();
12608 let body = serde_json::to_value(body).expect("request body serializes");
12609 self.client.request_data(Method::Post, &path, &query, Some(&body))
12610 }
12611
12612 /// Delete target audience
12613 ///
12614 /// `DELETE /group/targetgroups/{targetGroupId}`
12615 ///
12616 /// Deletes a target audience. Deleting a target audience clears targetGroupId on groups assigned to it. The groups and their memberships remain.
12617 /// Requires the churchgroup permission "edit masterdata". The dryRun query parameter is required: send false to delete or true to inspect the deletion report. A dry run changes no records and returns 409 with the report, even when deletion would be possible. An actual successful deletion returns 204 without a body.
12618 ///
12619 /// # Example
12620 ///
12621 /// ```no_run
12622 /// # use churchtools_api::*;
12623 /// # use churchtools_api::queries::*;
12624 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12625 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12626 /// let query = DeleteGroupTargetgroupsTargetGroupIdQuery {
12627 /// dry_run: Some(true),
12628 /// ..Default::default()
12629 /// };
12630 /// client.group().target_groups().delete(2, &query)?;
12631 /// # Ok(())
12632 /// # }
12633 /// ```
12634 pub fn delete(&self, target_group_id: impl Display, query: &DeleteGroupTargetgroupsTargetGroupIdQuery) -> Result<()> {
12635 let path = format!("/group/targetgroups/{}", seg(target_group_id));
12636 let query: Query = query.to_query();
12637 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
12638 }
12639
12640 /// Get target audience
12641 ///
12642 /// `GET /group/targetgroups/{targetGroupId}`
12643 ///
12644 /// Returns one target audience using its ID from GET /group/targetgroups. A target audience describes whom a group is intended for, such as families or students. A group references one audience through information.targetGroupId. This endpoint returns audience labels, not people or groups.
12645 /// Requires authentication, but no master-data editing permission. Returns a single object in data and no list metadata. Returns 404 when the record does not exist.
12646 ///
12647 /// # Example
12648 ///
12649 /// ```
12650 /// # use churchtools_api::*;
12651 /// # use churchtools_api::queries::*;
12652 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12653 /// # let client = churchtools_api::replay::client("get-group-targetgroups-targetGroupId");
12654 /// let target_group = client.group().target_groups().get(2)?;
12655 /// println!("{}", target_group.name);
12656 /// # Ok(())
12657 /// # }
12658 /// ```
12659 pub fn get(&self, target_group_id: impl Display) -> Result<models::TargetGroup> {
12660 let path = format!("/group/targetgroups/{}", seg(target_group_id));
12661 let query: Query = Query::new();
12662 self.client.request_data(Method::Get, &path, &query, None)
12663 }
12664
12665 /// Get all target audiences
12666 ///
12667 /// `GET /group/targetgroups`
12668 ///
12669 /// Returns all target audiences configured in this ChurchTools installation. A target audience describes whom a group is intended for, such as families or students. A group references one audience through information.targetGroupId. This endpoint returns audience labels, not people or groups.
12670 /// Requires authentication, but no master-data editing permission. There are no filter or pagination parameters. Results are ordered by sortKey ascending and then by the stored name ascending; meta.count is the number of returned records. IDs and labels are installation-specific; discover them before assigning them to groups.
12671 ///
12672 /// # Example
12673 ///
12674 /// ```
12675 /// # use churchtools_api::*;
12676 /// # use churchtools_api::queries::*;
12677 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12678 /// # let client = churchtools_api::replay::client("get-group-targetgroups");
12679 /// for target_group in client.group().target_groups().list()? {
12680 /// println!("{}", target_group.name);
12681 /// }
12682 /// # Ok(())
12683 /// # }
12684 /// ```
12685 pub fn list(&self) -> Result<Vec<models::TargetGroup>> {
12686 let path = "/group/targetgroups".to_owned();
12687 let query: Query = Query::new();
12688 self.client.request_data(Method::Get, &path, &query, None)
12689 }
12690
12691 /// Update target audience
12692 ///
12693 /// `PUT /group/targetgroups/{targetGroupId}`
12694 ///
12695 /// Updates the shared target audience identified by targetGroupId. Existing group assignments continue to reference the same record. This is a full update, not a partial update.
12696 /// Requires the churchgroup permission "edit masterdata". Supply both name and sortKey. Use an integer sortKey to control display order. The ID comes from the URL; no body id is required. Returns 204 without a response body. Use GET /group/targetgroups/{targetGroupId} to read the updated record.
12697 ///
12698 /// # Example
12699 ///
12700 /// ```no_run
12701 /// # use churchtools_api::*;
12702 /// # use churchtools_api::queries::*;
12703 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12704 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12705 /// let body = models::TargetGroupCreate {
12706 /// name: "men".into(),
12707 /// sort_key: 2,
12708 /// ..Default::default()
12709 /// };
12710 /// client.group().target_groups().update(2, &body)?;
12711 /// # Ok(())
12712 /// # }
12713 /// ```
12714 pub fn update(&self, target_group_id: impl Display, body: &models::TargetGroupCreate) -> Result<()> {
12715 let path = format!("/group/targetgroups/{}", seg(target_group_id));
12716 let query: Query = Query::new();
12717 let body = serde_json::to_value(body).expect("request body serializes");
12718 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
12719 }
12720
12721}
12722
12723/// `client.group_homepages()`
12724#[derive(Clone, Copy)]
12725pub struct GroupHomepagesResource<'a> {
12726 client: &'a Client,
12727}
12728
12729impl<'a> GroupHomepagesResource<'a> {
12730 /// Get a public group homepage by hash
12731 ///
12732 /// `GET /grouphomepages/{hash}`
12733 ///
12734 /// Public page settings, filter catalogs and eligible descendant groups for a group homepage hash. Anonymous access is supported, but signup eligibility and the public-group feature check can depend on whether the caller is signed in. Only enabled homepages are returned. Descendants are loaded through active, non-hidden hierarchy edges, sorted by the page’s configured field/direction, then filtered for public-page eligibility. The parent group itself is not included. An omitted depth uses the stored setting; depth=0 loads no groups, a positive depth limits hierarchy levels, and negative values currently traverse without a depth bound. The override does not change data.depth. Filter options include entire master-data catalogs, even for hidden filters and values unused by these groups. Group notes/places remain in the API even if their corresponding UI display settings hide them. No signup-person list is included here.
12735 ///
12736 /// Use [`Self::get_with`] to pass query parameters.
12737 ///
12738 /// # Example
12739 ///
12740 /// ```
12741 /// # use churchtools_api::*;
12742 /// # use churchtools_api::queries::*;
12743 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12744 /// # let client = churchtools_api::replay::client("get-grouphomepages-hash");
12745 /// let group_homepage = client.group_homepages().get("RNdjTK0tGp1N1afoblczGbFb8ikLfa9b")?;
12746 /// println!("{}", group_homepage.name);
12747 /// # Ok(())
12748 /// # }
12749 /// ```
12750 pub fn get(&self, hash: impl Display) -> Result<models::GroupHomepage> {
12751 self.get_with(hash, &Default::default())
12752 }
12753
12754 /// Get a public group homepage by hash
12755 ///
12756 /// Like [`Self::get`], with query parameters.
12757 ///
12758 /// `GET /grouphomepages/{hash}`
12759 ///
12760 /// Public page settings, filter catalogs and eligible descendant groups for a group homepage hash. Anonymous access is supported, but signup eligibility and the public-group feature check can depend on whether the caller is signed in. Only enabled homepages are returned. Descendants are loaded through active, non-hidden hierarchy edges, sorted by the page’s configured field/direction, then filtered for public-page eligibility. The parent group itself is not included. An omitted depth uses the stored setting; depth=0 loads no groups, a positive depth limits hierarchy levels, and negative values currently traverse without a depth bound. The override does not change data.depth. Filter options include entire master-data catalogs, even for hidden filters and values unused by these groups. Group notes/places remain in the API even if their corresponding UI display settings hide them. No signup-person list is included here.
12761 pub fn get_with(&self, hash: impl Display, query: &GetGrouphomepagesHashQuery) -> Result<models::GroupHomepage> {
12762 let path = format!("/grouphomepages/{}", seg(hash));
12763 let query: Query = query.to_query();
12764 self.client.request_data(Method::Get, &path, &query, None)
12765 }
12766
12767 /// Get all enabled group homepages
12768 ///
12769 /// `GET /grouphomepages`
12770 ///
12771 /// Public directory of every enabled group homepage as lightweight domain objects. No authentication or per-homepage view permission is required. The random page hashes are intentionally returned in apiUrl/frontendUrl and are not secrets suitable for access control. Entries include the owning parent group ID and hierarchy descendant IDs across all depths; this list does not apply the stored page depth or the detailed page’s public-group eligibility filter. Active, non-hidden hierarchy edges are followed, so child IDs can include internal groups and duplicates through multiple paths. There is no pagination or guaranteed ordering of homepage entries.
12772 ///
12773 /// # Example
12774 ///
12775 /// ```
12776 /// # use churchtools_api::*;
12777 /// # use churchtools_api::queries::*;
12778 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12779 /// # let client = churchtools_api::replay::client("get-grouphomepages");
12780 /// for group_homepage in client.group_homepages().list()? {
12781 /// println!("{}", group_homepage.title);
12782 /// }
12783 /// # Ok(())
12784 /// # }
12785 /// ```
12786 pub fn list(&self) -> Result<Vec<models::DomainObjectGrouphomepage>> {
12787 let path = "/grouphomepages".to_owned();
12788 let query: Query = Query::new();
12789 self.client.request_data(Method::Get, &path, &query, None)
12790 }
12791
12792}
12793
12794/// `client.groups()`
12795#[derive(Clone, Copy)]
12796pub struct GroupsResource<'a> {
12797 client: &'a Client,
12798}
12799
12800impl<'a> GroupsResource<'a> {
12801 pub fn checkin(&self) -> GroupsCheckinResource<'a> {
12802 GroupsCheckinResource { client: self.client }
12803 }
12804
12805 pub fn documents(&self) -> GroupsDocumentsResource<'a> {
12806 GroupsDocumentsResource { client: self.client }
12807 }
12808
12809 pub fn followups(&self) -> GroupsFollowupsResource<'a> {
12810 GroupsFollowupsResource { client: self.client }
12811 }
12812
12813 pub fn meetings(&self) -> GroupsMeetingsResource<'a> {
12814 GroupsMeetingsResource { client: self.client }
12815 }
12816
12817 pub fn member_fields(&self) -> GroupsMemberFieldsResource<'a> {
12818 GroupsMemberFieldsResource { client: self.client }
12819 }
12820
12821 pub fn members(&self) -> GroupsMembersResource<'a> {
12822 GroupsMembersResource { client: self.client }
12823 }
12824
12825 pub fn news_letter_integrations(&self) -> GroupsNewsLetterIntegrationsResource<'a> {
12826 GroupsNewsLetterIntegrationsResource { client: self.client }
12827 }
12828
12829 pub fn parents(&self) -> GroupsParentsResource<'a> {
12830 GroupsParentsResource { client: self.client }
12831 }
12832
12833 pub fn qrcode_checkin(&self) -> GroupsQrcodeCheckinResource<'a> {
12834 GroupsQrcodeCheckinResource { client: self.client }
12835 }
12836
12837 pub fn roles(&self) -> GroupsRolesResource<'a> {
12838 GroupsRolesResource { client: self.client }
12839 }
12840
12841 pub fn wiki(&self) -> GroupsWikiResource<'a> {
12842 GroupsWikiResource { client: self.client }
12843 }
12844
12845 /// Start or stop an event chat
12846 ///
12847 /// `POST /groups/{groupId}/chat`
12848 ///
12849 /// # Example
12850 ///
12851 /// ```no_run
12852 /// # use churchtools_api::*;
12853 /// # use churchtools_api::queries::*;
12854 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12855 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12856 /// let body = models::StartStopChat {
12857 /// enabled: true,
12858 /// ..Default::default()
12859 /// };
12860 /// client.groups().chat(42, &body)?;
12861 /// # Ok(())
12862 /// # }
12863 /// ```
12864 pub fn chat(&self, group_id: impl Display, body: &models::StartStopChat) -> Result<()> {
12865 let path = format!("/groups/{}/chat", seg(group_id));
12866 let query: Query = Query::new();
12867 let body = serde_json::to_value(body).expect("request body serializes");
12868 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
12869 }
12870
12871 /// Create Group
12872 ///
12873 /// `POST /groups`
12874 ///
12875 /// Create new group
12876 ///
12877 /// # Example
12878 ///
12879 /// ```
12880 /// # use churchtools_api::*;
12881 /// # use churchtools_api::queries::*;
12882 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12883 /// # let client = churchtools_api::replay::client("post-groups");
12884 /// let body = models::PostGroupsBody {
12885 /// group_status_id: 1,
12886 /// group_type_id: 42,
12887 /// name: "Hauskreis Nord".into(),
12888 /// ..Default::default()
12889 /// };
12890 /// let result = client.groups().create(&body)?;
12891 /// println!("{}", result.name);
12892 /// # Ok(())
12893 /// # }
12894 /// ```
12895 pub fn create(&self, body: &models::PostGroupsBody) -> Result<models::Group> {
12896 let path = "/groups".to_owned();
12897 let query: Query = Query::new();
12898 let body = serde_json::to_value(body).expect("request body serializes");
12899 self.client.request_data(Method::Post, &path, &query, Some(&body))
12900 }
12901
12902 /// Delete a group
12903 ///
12904 /// `DELETE /groups/{groupId}`
12905 ///
12906 /// Delete a group. This will remove all people from this group.
12907 ///
12908 /// Use [`Self::delete_with`] to pass query parameters.
12909 ///
12910 /// # Example
12911 ///
12912 /// ```no_run
12913 /// # use churchtools_api::*;
12914 /// # use churchtools_api::queries::*;
12915 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12916 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12917 /// client.groups().delete(42)?;
12918 /// # Ok(())
12919 /// # }
12920 /// ```
12921 pub fn delete(&self, group_id: impl Display) -> Result<()> {
12922 self.delete_with(group_id, &Default::default())
12923 }
12924
12925 /// Delete a group
12926 ///
12927 /// Like [`Self::delete`], with query parameters.
12928 ///
12929 /// `DELETE /groups/{groupId}`
12930 ///
12931 /// Delete a group. This will remove all people from this group.
12932 pub fn delete_with(&self, group_id: impl Display, query: &DeleteGroupsGroupIdQuery) -> Result<()> {
12933 let path = format!("/groups/{}", seg(group_id));
12934 let query: Query = query.to_query();
12935 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
12936 }
12937
12938 /// Delete a group’s homepage configuration
12939 ///
12940 /// `DELETE /groups/{groupId}/grouphomepage`
12941 ///
12942 /// Permanently removes the homepage configuration attached to this parent group, including its public URL hash. The group, child groups and their memberships are retained. Requires permission to edit the parent group’s basic settings. If that group has no homepage configuration, the request still returns 204. There is no delete-preview workflow; use PUT with isEnabled=false to keep the configuration while disabling the public page.
12943 ///
12944 /// # Example
12945 ///
12946 /// ```no_run
12947 /// # use churchtools_api::*;
12948 /// # use churchtools_api::queries::*;
12949 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12950 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
12951 /// client.groups().delete_group_homepage(42)?;
12952 /// # Ok(())
12953 /// # }
12954 /// ```
12955 pub fn delete_group_homepage(&self, group_id: impl Display) -> Result<()> {
12956 let path = format!("/groups/{}/grouphomepage", seg(group_id));
12957 let query: Query = Query::new();
12958 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
12959 }
12960
12961 /// Duplicate a group with selected related data
12962 ///
12963 /// `POST /groups/{groupId}/duplicate`
12964 ///
12965 /// Creates a pending group with a new ID, GUID and name. Requires permission to create a group with the source group’s type, campus and parent groups. The copy includes both parent and child hierarchy links, tags, membership field definitions, role settings, addresses and the group image. Memberships, role permissions and membership routines are copied only when their flags are enabled. Meetings and the appointment link are cleared. An existing group homepage is cloned with a new URL hash. Supply newName and optional flags in the query or JSON body; query values take precedence. The returned group is not enriched with all copied related data.
12966 ///
12967 /// Use [`Self::duplicate_with`] to pass query parameters.
12968 ///
12969 /// # Example
12970 ///
12971 /// ```
12972 /// # use churchtools_api::*;
12973 /// # use churchtools_api::queries::*;
12974 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
12975 /// # let client = churchtools_api::replay::client("post-groups-id-duplicate");
12976 /// let body = models::GroupDuplicateCreate {
12977 /// copy_members: Some(true),
12978 /// ..Default::default()
12979 /// };
12980 /// let group = client.groups().duplicate(42, &body)?;
12981 /// println!("{}", group.name);
12982 /// # Ok(())
12983 /// # }
12984 /// ```
12985 pub fn duplicate(&self, group_id: impl Display, body: &models::GroupDuplicateCreate) -> Result<models::Group> {
12986 self.duplicate_with(group_id, &Default::default(), body)
12987 }
12988
12989 /// Duplicate a group with selected related data
12990 ///
12991 /// Like [`Self::duplicate`], with query parameters.
12992 ///
12993 /// `POST /groups/{groupId}/duplicate`
12994 ///
12995 /// Creates a pending group with a new ID, GUID and name. Requires permission to create a group with the source group’s type, campus and parent groups. The copy includes both parent and child hierarchy links, tags, membership field definitions, role settings, addresses and the group image. Memberships, role permissions and membership routines are copied only when their flags are enabled. Meetings and the appointment link are cleared. An existing group homepage is cloned with a new URL hash. Supply newName and optional flags in the query or JSON body; query values take precedence. The returned group is not enriched with all copied related data.
12996 pub fn duplicate_with(&self, group_id: impl Display, query: &PostGroupsIdDuplicateQuery, body: &models::GroupDuplicateCreate) -> Result<models::Group> {
12997 let path = format!("/groups/{}/duplicate", seg(group_id));
12998 let query: Query = query.to_query();
12999 let body = serde_json::to_value(body).expect("request body serializes");
13000 self.client.request_data(Method::Post, &path, &query, Some(&body))
13001 }
13002
13003 /// Export groups
13004 ///
13005 /// `POST /groups/export`
13006 ///
13007 /// Downloads selected visible groups as a spreadsheet, sorted by group name. Unknown or invisible IDs are omitted; an empty ids array produces a header-only export. Columns include standard and custom group fields, registration availability, tags, membership statistics, places and direct parent/child groups. Field labels and formatted values use the current language. Group field values pass through field security checks; related groups that are not visible may still appear as bare IDs. CSV uses semicolon-separated UTF-8 text; XLSX returns a workbook. This read-only POST does not create a stored file and does not paginate.
13008 ///
13009 /// Use [`Self::export_with`] to pass query parameters.
13010 ///
13011 /// # Example
13012 ///
13013 /// ```no_run
13014 /// # use churchtools_api::*;
13015 /// # use churchtools_api::queries::*;
13016 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13017 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
13018 /// let body = models::GroupExportCreate {
13019 /// ids: vec![12, 34],
13020 /// ..Default::default()
13021 /// };
13022 /// let data = client.groups().export(&body)?;
13023 /// std::fs::write("ergebnis.xlsx", &data)?;
13024 /// # Ok(())
13025 /// # }
13026 /// ```
13027 pub fn export(&self, body: &models::GroupExportCreate) -> Result<Vec<u8>> {
13028 self.export_with(&Default::default(), body)
13029 }
13030
13031 /// Export groups
13032 ///
13033 /// Like [`Self::export`], with query parameters.
13034 ///
13035 /// `POST /groups/export`
13036 ///
13037 /// Downloads selected visible groups as a spreadsheet, sorted by group name. Unknown or invisible IDs are omitted; an empty ids array produces a header-only export. Columns include standard and custom group fields, registration availability, tags, membership statistics, places and direct parent/child groups. Field labels and formatted values use the current language. Group field values pass through field security checks; related groups that are not visible may still appear as bare IDs. CSV uses semicolon-separated UTF-8 text; XLSX returns a workbook. This read-only POST does not create a stored file and does not paginate.
13038 pub fn export_with(&self, query: &PostGroupsExportQuery, body: &models::GroupExportCreate) -> Result<Vec<u8>> {
13039 let path = "/groups/export".to_owned();
13040 let query: Query = query.to_query();
13041 let body = serde_json::to_value(body).expect("request body serializes");
13042 self.client.request(Method::Post, &path, &query, Some(&body))
13043 }
13044
13045 /// Get a group
13046 ///
13047 /// `GET /groups/{groupId}`
13048 ///
13049 /// Use [`Self::get_with`] to pass query parameters.
13050 ///
13051 /// # Example
13052 ///
13053 /// ```
13054 /// # use churchtools_api::*;
13055 /// # use churchtools_api::queries::*;
13056 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13057 /// # let client = churchtools_api::replay::client("get-groups-groupId");
13058 /// let group = client.groups().get(42)?;
13059 /// println!("{}", group.name);
13060 /// # Ok(())
13061 /// # }
13062 /// ```
13063 pub fn get(&self, group_id: impl Display) -> Result<models::Group> {
13064 self.get_with(group_id, &Default::default())
13065 }
13066
13067 /// Get a group
13068 ///
13069 /// Like [`Self::get`], with query parameters.
13070 ///
13071 /// `GET /groups/{groupId}`
13072 pub fn get_with(&self, group_id: impl Display, query: &GetGroupsGroupIdQuery) -> Result<models::Group> {
13073 let path = format!("/groups/{}", seg(group_id));
13074 let query: Query = query.to_query();
13075 self.client.request_data(Method::Get, &path, &query, None)
13076 }
13077
13078 /// Get a group’s homepage configuration
13079 ///
13080 /// `GET /groups/{groupId}/grouphomepage`
13081 ///
13082 /// Returns the homepage configuration attached to this parent group, including disabled homepages. Requires permission to edit the parent group’s basic settings; ordinary group visibility is insufficient. A group without a homepage returns 404. This settings lookup does not populate the child groups or filter option catalogs: groups is empty and filter entries omit options. For the public page with its child groups and catalogs, use GET /grouphomepages/{hash}. showMap is combined with the global OpenStreetMap setting, so it can be false even when the stored page flag is true.
13083 ///
13084 /// # Example
13085 ///
13086 /// ```
13087 /// # use churchtools_api::*;
13088 /// # use churchtools_api::queries::*;
13089 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13090 /// # let client = churchtools_api::replay::client("get-groups-groupId-grouphomepage");
13091 /// let group_homepage = client.groups().get_group_homepage(42)?;
13092 /// println!("{}", group_homepage.name);
13093 /// # Ok(())
13094 /// # }
13095 /// ```
13096 pub fn get_group_homepage(&self, group_id: impl Display) -> Result<models::GroupHomepage> {
13097 let path = format!("/groups/{}/grouphomepage", seg(group_id));
13098 let query: Query = Query::new();
13099 self.client.request_data(Method::Get, &path, &query, None)
13100 }
13101
13102 /// Get grouped groups
13103 ///
13104 /// `GET /groups/grouped`
13105 ///
13106 /// Returns visible groups grouped by the requested group attribute. Each group contains a preview list limited by `limit` and the total number of matching groups in `all`.
13107 ///
13108 /// # Example
13109 ///
13110 /// ```
13111 /// # use churchtools_api::*;
13112 /// # use churchtools_api::queries::*;
13113 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13114 /// # let client = churchtools_api::replay::client("get-groups-grouped");
13115 /// let query = GetGroupsGroupedQuery {
13116 /// group_by: Some("ageGroup".into()),
13117 /// ..Default::default()
13118 /// };
13119 /// let grouped = client.groups().get_grouped(&query)?;
13120 /// println!("{}", grouped.grouped_by);
13121 /// # Ok(())
13122 /// # }
13123 /// ```
13124 pub fn get_grouped(&self, query: &GetGroupsGroupedQuery) -> Result<models::GroupedGroups> {
13125 let path = "/groups/grouped".to_owned();
13126 let query: Query = query.to_query();
13127 self.client.request_data(Method::Get, &path, &query, None)
13128 }
13129
13130 /// Get stored newsletter consent and synchronization states
13131 ///
13132 /// `GET /groups/{groupId}/optins`
13133 ///
13134 /// Returns active newsletter mappings and local newsletter-person records for the group, keyed by provider:listId and person ID. Requires permission to view the group and its members. The current backend calls the global administer groups check but does not enforce its result. Disabled/unknown providers are absent from newsletter; person records can remain with empty newsletter maps. The data is unpaginated, has no meta envelope and is not a live provider status lookup. Empty maps serialize as \[\].
13135 ///
13136 /// # Example
13137 ///
13138 /// ```
13139 /// # use churchtools_api::*;
13140 /// # use churchtools_api::queries::*;
13141 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13142 /// # let client = churchtools_api::replay::client("get-groups-optins");
13143 /// let optin = client.groups().get_optins(42)?;
13144 /// println!("{:?}", optin);
13145 /// # Ok(())
13146 /// # }
13147 /// ```
13148 pub fn get_optins(&self, group_id: impl Display) -> Result<models::NewsletterOptInData> {
13149 let path = format!("/groups/{}/optins", seg(group_id));
13150 let query: Query = Query::new();
13151 self.client.request_data(Method::Get, &path, &query, None)
13152 }
13153
13154 /// Count published group posts by visibility
13155 ///
13156 /// `GET /groups/{groupId}/poststatistics`
13157 ///
13158 /// Returns one object containing counts for group_intern and group_visible. Only already published, unexpired and non-banned posts are counted, and posts must be enabled for both the group and its group type. Drafts/scheduled posts are excluded. Empty groups and groups with posts disabled return both counters as zero. The current handler requires authentication but ignores the result of its group-edit permission check and does not filter counts by the caller’s post visibility. The response has no pagination or meta.
13159 ///
13160 /// # Example
13161 ///
13162 /// ```
13163 /// # use churchtools_api::*;
13164 /// # use churchtools_api::queries::*;
13165 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13166 /// # let client = churchtools_api::replay::client("get-groups-groupId-poststatistics");
13167 /// let post_statistic = client.groups().get_post_statistics(42)?;
13168 /// println!("{}", post_statistic.group_intern);
13169 /// # Ok(())
13170 /// # }
13171 /// ```
13172 pub fn get_post_statistics(&self, group_id: impl Display) -> Result<models::GroupPostStatistics> {
13173 let path = format!("/groups/{}/poststatistics", seg(group_id));
13174 let query: Query = Query::new();
13175 self.client.request_data(Method::Get, &path, &query, None)
13176 }
13177
13178 /// Get group capacity and visible membership counts
13179 ///
13180 /// `GET /groups/{groupId}/statistics`
13181 ///
13182 /// Returns one statistics object for the group. Requires group visibility. members is a role/status histogram restricted to members and persons visible to the caller; unfiltered contains group-wide capacity counts regardless of individual visibility. Consequently, summing members need not match any unfiltered counter. Roles, workflow status, archive state and seat-counting settings affect the counters differently. A group without visible memberships returns members=\[\]; capacity counters are still present. The response is not paginated and has no meta envelope.
13183 ///
13184 /// # Example
13185 ///
13186 /// ```
13187 /// # use churchtools_api::*;
13188 /// # use churchtools_api::queries::*;
13189 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13190 /// # let client = churchtools_api::replay::client("get-groups-id-statistics");
13191 /// let statistic = client.groups().get_statistics(42)?;
13192 /// println!("{:?}", statistic);
13193 /// # Ok(())
13194 /// # }
13195 /// ```
13196 pub fn get_statistics(&self, group_id: impl Display) -> Result<models::GroupStatistics> {
13197 let path = format!("/groups/{}/statistics", seg(group_id));
13198 let query: Query = Query::new();
13199 self.client.request_data(Method::Get, &path, &query, None)
13200 }
13201
13202 /// Change a group’s type and migrate its roles
13203 ///
13204 /// `POST /groups/{groupId}/grouptype`
13205 ///
13206 /// Changes the group type and applies the supplied role mapping within a database transaction. Requires permission to edit the groupTypeId field of this group. Membership roles, group-role settings and their permissions, the registration override role, membership routines, dynamic-group rules and website role references can be affected. New target-type roles receive default group settings; obsolete role settings and their permissions are removed. Provide a complete mapping from old to new group-type role IDs. Use a different target type with valid target roles; incomplete or inconsistent mappings can fail during migration or leave membership roles inconsistent. Success returns 204 without a response body.
13207 ///
13208 /// # Example
13209 ///
13210 /// ```no_run
13211 /// # use churchtools_api::*;
13212 /// # use churchtools_api::queries::*;
13213 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13214 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
13215 /// let body = models::GroupTypeChangeUpdate {
13216 /// group_type_id: 3,
13217 /// role_mapping: Default::default(),
13218 /// ..Default::default()
13219 /// };
13220 /// client.groups().group_type(42, &body)?;
13221 /// # Ok(())
13222 /// # }
13223 /// ```
13224 pub fn group_type(&self, group_id: impl Display, body: &models::GroupTypeChangeUpdate) -> Result<()> {
13225 let path = format!("/groups/{}/grouptype", seg(group_id));
13226 let query: Query = Query::new();
13227 let body = serde_json::to_value(body).expect("request body serializes");
13228 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
13229 }
13230
13231 /// Get all groups
13232 ///
13233 /// `GET /groups`
13234 ///
13235 /// This endpoint returns an array with all groups the user can see. This includes groups the user
13236 /// is a member of as well as subordinate groups the user is allowed to see.
13237 /// In addition to the documented query parameters, groups can be filtered by all group fields (`=fieldValue`) as query parameters. For group fields with options (e.g. select fields), the format would be `[]=optionId` and can be repeated for serveral ids.
13238 ///
13239 /// Use [`Self::list_with`] to pass query parameters.
13240 ///
13241 /// # Example
13242 ///
13243 /// ```
13244 /// # use churchtools_api::*;
13245 /// # use churchtools_api::queries::*;
13246 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13247 /// # let client = churchtools_api::replay::client("get-groups");
13248 /// for group in client.groups().list()? {
13249 /// println!("{}", group.name);
13250 /// }
13251 /// # Ok(())
13252 /// # }
13253 /// ```
13254 pub fn list(&self) -> Result<Vec<models::Group>> {
13255 self.list_with(&Default::default())
13256 }
13257
13258 /// Get all groups
13259 ///
13260 /// Like [`Self::list`], with query parameters.
13261 ///
13262 /// `GET /groups`
13263 ///
13264 /// This endpoint returns an array with all groups the user can see. This includes groups the user
13265 /// is a member of as well as subordinate groups the user is allowed to see.
13266 /// In addition to the documented query parameters, groups can be filtered by all group fields (`=fieldValue`) as query parameters. For group fields with options (e.g. select fields), the format would be `[]=optionId` and can be repeated for serveral ids.
13267 pub fn list_with(&self, query: &GetGroupsQuery) -> Result<Vec<models::Group>> {
13268 let path = "/groups".to_owned();
13269 let query: Query = query.to_query();
13270 self.client.collect_pages(&path, query)
13271 }
13272
13273 /// Get all groups
13274 ///
13275 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
13276 /// Breaking off early saves the remaining requests.
13277 pub fn list_iter(&self, query: &GetGroupsQuery) -> Items<models::Group> {
13278 let path = "/groups".to_owned();
13279 self.client.items(&path, query.to_query())
13280 }
13281
13282 /// Fetch all absences for persons in a group
13283 ///
13284 /// `GET /groups/{groupId}/absences`
13285 ///
13286 /// Returns absences for active, visible group members. Requires access to the group; member results are additionally restricted by manage absent or the internal group permission to view absences. Returns absences whose start is at or before to and whose end is at or after from. Absences ending exactly at midnight on the from date are also included, even if from specifies a later time that day. Dates use the application time zone; UTC timestamps are converted into it. Without filters the window starts at midnight two weeks ago and ends at midnight two weeks from today. The list is unpaginated and sorted by start; meta.count is the number returned.
13287 ///
13288 /// Use [`Self::list_absences_with`] to pass query parameters.
13289 ///
13290 /// # Example
13291 ///
13292 /// ```
13293 /// # use churchtools_api::*;
13294 /// # use churchtools_api::queries::*;
13295 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13296 /// # let client = churchtools_api::replay::client("get-groups-absences");
13297 /// for absence in client.groups().list_absences(42)? {
13298 /// println!("{}", absence.id);
13299 /// }
13300 /// # Ok(())
13301 /// # }
13302 /// ```
13303 pub fn list_absences(&self, group_id: impl Display) -> Result<Vec<models::Absence>> {
13304 self.list_absences_with(group_id, &Default::default())
13305 }
13306
13307 /// Fetch all absences for persons in a group
13308 ///
13309 /// Like [`Self::list_absences`], with query parameters.
13310 ///
13311 /// `GET /groups/{groupId}/absences`
13312 ///
13313 /// Returns absences for active, visible group members. Requires access to the group; member results are additionally restricted by manage absent or the internal group permission to view absences. Returns absences whose start is at or before to and whose end is at or after from. Absences ending exactly at midnight on the from date are also included, even if from specifies a later time that day. Dates use the application time zone; UTC timestamps are converted into it. Without filters the window starts at midnight two weeks ago and ends at midnight two weeks from today. The list is unpaginated and sorted by start; meta.count is the number returned.
13314 pub fn list_absences_with(&self, group_id: impl Display, query: &GetGroupsAbsencesQuery) -> Result<Vec<models::Absence>> {
13315 let path = format!("/groups/{}/absences", seg(group_id));
13316 let query: Query = query.to_query();
13317 self.client.request_data(Method::Get, &path, &query, None)
13318 }
13319
13320 /// Get child groups
13321 ///
13322 /// `GET /groups/{groupId}/children`
13323 ///
13324 /// Use [`Self::list_children_with`] to pass query parameters.
13325 ///
13326 /// # Example
13327 ///
13328 /// ```
13329 /// # use churchtools_api::*;
13330 /// # use churchtools_api::queries::*;
13331 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13332 /// # let client = churchtools_api::replay::client("get-groups-groupId-children");
13333 /// for children in client.groups().list_children(42)? {
13334 /// println!("{}", children.title);
13335 /// }
13336 /// # Ok(())
13337 /// # }
13338 /// ```
13339 pub fn list_children(&self, group_id: impl Display) -> Result<Vec<models::DomainObjectGroup>> {
13340 self.list_children_with(group_id, &Default::default())
13341 }
13342
13343 /// Get child groups
13344 ///
13345 /// Like [`Self::list_children`], with query parameters.
13346 ///
13347 /// `GET /groups/{groupId}/children`
13348 pub fn list_children_with(&self, group_id: impl Display, query: &GetGroupsGroupIdChildrenQuery) -> Result<Vec<models::DomainObjectGroup>> {
13349 let path = format!("/groups/{}/children", seg(group_id));
13350 let query: Query = query.to_query();
13351 self.client.collect_pages(&path, query)
13352 }
13353
13354 /// Get child groups
13355 ///
13356 /// Like [`Self::list_children_with`], but lazy: each page is fetched only when the iteration reaches it.
13357 /// Breaking off early saves the remaining requests.
13358 pub fn list_children_iter(&self, group_id: impl Display, query: &GetGroupsGroupIdChildrenQuery) -> Items<models::DomainObjectGroup> {
13359 let path = format!("/groups/{}/children", seg(group_id));
13360 self.client.items(&path, query.to_query())
13361 }
13362
13363 /// List membership document templates for the current user
13364 ///
13365 /// `GET /groups/{groupId}/documenttemplates`
13366 ///
13367 /// Lists the document templates assigned to the current user’s role in this group. The current user must have an active membership and that role must be configured in the group; administrative rights do not replace that membership. The result follows the role’s configured template order and is not paginated. An empty list means the role has no assigned templates. This endpoint returns template names only and does not generate PDFs. Unlike document generation, it does not check whether the group itself is active, so a listed template may still be unavailable for download.
13368 ///
13369 /// # Example
13370 ///
13371 /// ```
13372 /// # use churchtools_api::*;
13373 /// # use churchtools_api::queries::*;
13374 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13375 /// # let client = churchtools_api::replay::client("get-groups-groupId-documenttemplates");
13376 /// for document_template in client.groups().list_document_templates(42)? {
13377 /// println!("{}", document_template.name);
13378 /// }
13379 /// # Ok(())
13380 /// # }
13381 /// ```
13382 pub fn list_document_templates(&self, group_id: impl Display) -> Result<Vec<models::HtmlTemplateInfo>> {
13383 let path = format!("/groups/{}/documenttemplates", seg(group_id));
13384 let query: Query = Query::new();
13385 self.client.request_data(Method::Get, &path, &query, None)
13386 }
13387
13388 /// Get all group hierarchies
13389 ///
13390 /// `GET /groups/hierarchies`
13391 ///
13392 /// Returns all group hierarchies. The groups not visible for the user only show ids. Note: You have to pass at least 2 group IDs for the filter to work. If you only want to see the children of a specific group use `GET /groups/{groupId}/children`.
13393 ///
13394 /// Use [`Self::list_hierarchies_with`] to pass query parameters.
13395 ///
13396 /// # Example
13397 ///
13398 /// ```
13399 /// # use churchtools_api::*;
13400 /// # use churchtools_api::queries::*;
13401 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13402 /// # let client = churchtools_api::replay::client("get-groups-hierarchies");
13403 /// for hierarchy in client.groups().list_hierarchies()? {
13404 /// println!("{}", hierarchy.group_id);
13405 /// }
13406 /// # Ok(())
13407 /// # }
13408 /// ```
13409 pub fn list_hierarchies(&self) -> Result<Vec<models::GroupHierarchy>> {
13410 self.list_hierarchies_with(&Default::default())
13411 }
13412
13413 /// Get all group hierarchies
13414 ///
13415 /// Like [`Self::list_hierarchies`], with query parameters.
13416 ///
13417 /// `GET /groups/hierarchies`
13418 ///
13419 /// Returns all group hierarchies. The groups not visible for the user only show ids. Note: You have to pass at least 2 group IDs for the filter to work. If you only want to see the children of a specific group use `GET /groups/{groupId}/children`.
13420 pub fn list_hierarchies_with(&self, query: &GetGroupsHierarchiesQuery) -> Result<Vec<models::GroupHierarchy>> {
13421 let path = "/groups/hierarchies".to_owned();
13422 let query: Query = query.to_query();
13423 self.client.collect_pages(&path, query)
13424 }
13425
13426 /// Get all group hierarchies
13427 ///
13428 /// Like [`Self::list_hierarchies_with`], but lazy: each page is fetched only when the iteration reaches it.
13429 /// Breaking off early saves the remaining requests.
13430 pub fn list_hierarchies_iter(&self, query: &GetGroupsHierarchiesQuery) -> Items<models::GroupHierarchy> {
13431 let path = "/groups/hierarchies".to_owned();
13432 self.client.items(&path, query.to_query())
13433 }
13434
13435 /// Get all group ids
13436 ///
13437 /// `GET /groups/ids`
13438 ///
13439 /// Returns all group ids the user can see. This includes groups the user is a member of as well as subordinate groups the user is allowed to see. Same as `GET /groups` but only returns ids.
13440 ///
13441 /// Use [`Self::list_ids_with`] to pass query parameters.
13442 ///
13443 /// # Example
13444 ///
13445 /// ```
13446 /// # use churchtools_api::*;
13447 /// # use churchtools_api::queries::*;
13448 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13449 /// # let client = churchtools_api::replay::client("get-groups-ids");
13450 /// for id in client.groups().list_ids()? {
13451 /// println!("{:?}", id);
13452 /// }
13453 /// # Ok(())
13454 /// # }
13455 /// ```
13456 pub fn list_ids(&self) -> Result<Vec<i64>> {
13457 self.list_ids_with(&Default::default())
13458 }
13459
13460 /// Get all group ids
13461 ///
13462 /// Like [`Self::list_ids`], with query parameters.
13463 ///
13464 /// `GET /groups/ids`
13465 ///
13466 /// Returns all group ids the user can see. This includes groups the user is a member of as well as subordinate groups the user is allowed to see. Same as `GET /groups` but only returns ids.
13467 pub fn list_ids_with(&self, query: &GetGroupsIdsQuery) -> Result<Vec<i64>> {
13468 let path = "/groups/ids".to_owned();
13469 let query: Query = query.to_query();
13470 self.client.collect_pages(&path, query)
13471 }
13472
13473 /// Get all group ids
13474 ///
13475 /// Like [`Self::list_ids_with`], but lazy: each page is fetched only when the iteration reaches it.
13476 /// Breaking off early saves the remaining requests.
13477 pub fn list_ids_iter(&self, query: &GetGroupsIdsQuery) -> Items<i64> {
13478 let path = "/groups/ids".to_owned();
13479 self.client.items(&path, query.to_query())
13480 }
13481
13482 /// Get person IDs of group members
13483 ///
13484 /// `GET /groups/{groupId}/memberids`
13485 ///
13486 /// Returns the person IDs of all visible memberships matching the filters. These IDs can be used as personId in /groups/{groupId}/members/{personId}; they are not membership record IDs. Results are not paginated, and meta.count is the number of returned IDs. Filters are combined, and visibility restrictions still apply. Additional filters can use a group member field’s reference name or display name (=fieldValue), or a person-field key (person_=fieldValue).
13487 ///
13488 /// Use [`Self::list_member_ids_with`] to pass query parameters.
13489 ///
13490 /// # Example
13491 ///
13492 /// ```
13493 /// # use churchtools_api::*;
13494 /// # use churchtools_api::queries::*;
13495 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13496 /// # let client = churchtools_api::replay::client("get-groups-groupId-memberids");
13497 /// for member_id in client.groups().list_member_ids(42)? {
13498 /// println!("{:?}", member_id);
13499 /// }
13500 /// # Ok(())
13501 /// # }
13502 /// ```
13503 pub fn list_member_ids(&self, group_id: impl Display) -> Result<Vec<i64>> {
13504 self.list_member_ids_with(group_id, &Default::default())
13505 }
13506
13507 /// Get person IDs of group members
13508 ///
13509 /// Like [`Self::list_member_ids`], with query parameters.
13510 ///
13511 /// `GET /groups/{groupId}/memberids`
13512 ///
13513 /// Returns the person IDs of all visible memberships matching the filters. These IDs can be used as personId in /groups/{groupId}/members/{personId}; they are not membership record IDs. Results are not paginated, and meta.count is the number of returned IDs. Filters are combined, and visibility restrictions still apply. Additional filters can use a group member field’s reference name or display name (=fieldValue), or a person-field key (person_=fieldValue).
13514 pub fn list_member_ids_with(&self, group_id: impl Display, query: &GetGroupsGroupIdMemberidsQuery) -> Result<Vec<i64>> {
13515 let path = format!("/groups/{}/memberids", seg(group_id));
13516 let query: Query = query.to_query();
13517 self.client.request_data(Method::Get, &path, &query, None)
13518 }
13519
13520 /// Preview active group members by role
13521 ///
13522 /// `GET /groups/{groupId}/memberpreview`
13523 ///
13524 /// Returns each role of the group’s group type with a limited selection of active, visible members. Roles are ordered by type and sort key, including roles with no matching members. Within each role, persons with an avatar come first, followed by last name and first name. members_per_role limits each role separately; meta.count counts role entries, not members. Use GET /groups/{groupId}/members for the paginated membership list and additional fields.
13525 ///
13526 /// Use [`Self::list_member_preview_with`] to pass query parameters.
13527 ///
13528 /// # Example
13529 ///
13530 /// ```
13531 /// # use churchtools_api::*;
13532 /// # use churchtools_api::queries::*;
13533 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13534 /// # let client = churchtools_api::replay::client("get-groups-groupId-memberpreview");
13535 /// for member_preview in client.groups().list_member_preview(42)? {
13536 /// println!("{:?}", member_preview);
13537 /// }
13538 /// # Ok(())
13539 /// # }
13540 /// ```
13541 pub fn list_member_preview(&self, group_id: impl Display) -> Result<Vec<models::MemberPreview>> {
13542 self.list_member_preview_with(group_id, &Default::default())
13543 }
13544
13545 /// Preview active group members by role
13546 ///
13547 /// Like [`Self::list_member_preview`], with query parameters.
13548 ///
13549 /// `GET /groups/{groupId}/memberpreview`
13550 ///
13551 /// Returns each role of the group’s group type with a limited selection of active, visible members. Roles are ordered by type and sort key, including roles with no matching members. Within each role, persons with an avatar come first, followed by last name and first name. members_per_role limits each role separately; meta.count counts role entries, not members. Use GET /groups/{groupId}/members for the paginated membership list and additional fields.
13552 pub fn list_member_preview_with(&self, group_id: impl Display, query: &GetGroupsGroupIdMemberpreviewQuery) -> Result<Vec<models::MemberPreview>> {
13553 let path = format!("/groups/{}/memberpreview", seg(group_id));
13554 let query: Query = query.to_query();
13555 self.client.request_data(Method::Get, &path, &query, None)
13556 }
13557
13558 /// Get all group members
13559 ///
13560 /// `GET /groups/members`
13561 ///
13562 /// Returns all group members. Only accessible for users with right "administer persons".
13563 ///
13564 /// Use [`Self::list_members_with`] to pass query parameters.
13565 ///
13566 /// # Example
13567 ///
13568 /// ```
13569 /// # use churchtools_api::*;
13570 /// # use churchtools_api::queries::*;
13571 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13572 /// # let client = churchtools_api::replay::client("get-groups-members");
13573 /// for member in client.groups().list_members()? {
13574 /// println!("{}", member.deleted);
13575 /// }
13576 /// # Ok(())
13577 /// # }
13578 /// ```
13579 pub fn list_members(&self) -> Result<Vec<models::GroupMemberShort>> {
13580 self.list_members_with(&Default::default())
13581 }
13582
13583 /// Get all group members
13584 ///
13585 /// Like [`Self::list_members`], with query parameters.
13586 ///
13587 /// `GET /groups/members`
13588 ///
13589 /// Returns all group members. Only accessible for users with right "administer persons".
13590 pub fn list_members_with(&self, query: &GetGroupsMembersQuery) -> Result<Vec<models::GroupMemberShort>> {
13591 let path = "/groups/members".to_owned();
13592 let query: Query = query.to_query();
13593 self.client.request_data(Method::Get, &path, &query, None)
13594 }
13595
13596 /// Get visible posts of a group
13597 ///
13598 /// `GET /groups/{groupId}/posts`
13599 ///
13600 /// Returns published, unexpired and unbanned local posts visible to the current user in this group. Anonymous access is supported and limited by public group and post visibility. Posts must be enabled for both the group and its group type. Group-internal posts require membership; other posts follow group visibility. A missing or inaccessible group returns an empty list. Explicitly selecting a group includes it even when the user has hidden the group from their feed; hidden posts and hidden authors remain excluded. External instances are not queried. Results are ordered by publishedDate and GUID descending. For the next batch, pass the last post’s publishedDate as before and its guid as last_post_identifier. page is ignored; pagination.current stays 1, and total/lastPage describe the remaining cursor-filtered results rather than the complete feed.
13601 ///
13602 /// Use [`Self::list_posts_with`] to pass query parameters.
13603 ///
13604 /// # Example
13605 ///
13606 /// ```
13607 /// # use churchtools_api::*;
13608 /// # use churchtools_api::queries::*;
13609 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13610 /// # let client = churchtools_api::replay::client("get-groups-groupId-posts");
13611 /// for post in client.groups().list_posts(42)? {
13612 /// println!("{}", post.title);
13613 /// }
13614 /// # Ok(())
13615 /// # }
13616 /// ```
13617 pub fn list_posts(&self, group_id: impl Display) -> Result<Vec<models::Post>> {
13618 self.list_posts_with(group_id, &Default::default())
13619 }
13620
13621 /// Get visible posts of a group
13622 ///
13623 /// Like [`Self::list_posts`], with query parameters.
13624 ///
13625 /// `GET /groups/{groupId}/posts`
13626 ///
13627 /// Returns published, unexpired and unbanned local posts visible to the current user in this group. Anonymous access is supported and limited by public group and post visibility. Posts must be enabled for both the group and its group type. Group-internal posts require membership; other posts follow group visibility. A missing or inaccessible group returns an empty list. Explicitly selecting a group includes it even when the user has hidden the group from their feed; hidden posts and hidden authors remain excluded. External instances are not queried. Results are ordered by publishedDate and GUID descending. For the next batch, pass the last post’s publishedDate as before and its guid as last_post_identifier. page is ignored; pagination.current stays 1, and total/lastPage describe the remaining cursor-filtered results rather than the complete feed.
13628 pub fn list_posts_with(&self, group_id: impl Display, query: &GetGroupsGroupIdPostsQuery) -> Result<Vec<models::Post>> {
13629 let path = format!("/groups/{}/posts", seg(group_id));
13630 let query: Query = query.to_query();
13631 self.client.collect_pages(&path, query)
13632 }
13633
13634 /// Get visible posts of a group
13635 ///
13636 /// Like [`Self::list_posts_with`], but lazy: each page is fetched only when the iteration reaches it.
13637 /// Breaking off early saves the remaining requests.
13638 pub fn list_posts_iter(&self, group_id: impl Display, query: &GetGroupsGroupIdPostsQuery) -> Items<models::Post> {
13639 let path = format!("/groups/{}/posts", seg(group_id));
13640 self.client.items(&path, query.to_query())
13641 }
13642
13643 /// Send a group sign-up push notification
13644 ///
13645 /// `POST /groups/{groupId}/notification`
13646 ///
13647 /// Announces a group to potential new members through push notifications. Requires permission to edit the group’s basic settings. Recipients have registered push devices, are not already linked to the group, and have not disabled these notifications. Group age, target-group and category values are compared with notification preferences, not with a person’s age or memberships. Use dry_run to preview the selection count without sending or marking the group as notified. A normal request marks the group as notified even when the count is zero; later requests, including dry runs, return 403. sentToCount measures recipient selection, not successful delivery. The response is returned directly without a data wrapper.
13648 ///
13649 /// Use [`Self::notification_with`] to pass query parameters.
13650 ///
13651 /// # Example
13652 ///
13653 /// ```no_run
13654 /// # use churchtools_api::*;
13655 /// # use churchtools_api::queries::*;
13656 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13657 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
13658 /// let body = models::GroupSignUpNotificationRequest {
13659 /// dry_run: Some(true),
13660 /// ..Default::default()
13661 /// };
13662 /// let group = client.groups().notification(42, &body)?;
13663 /// println!("{}", group.sent_to_count);
13664 /// # Ok(())
13665 /// # }
13666 /// ```
13667 pub fn notification(&self, group_id: impl Display, body: &models::GroupSignUpNotificationRequest) -> Result<models::GroupSignUpNotificationResult> {
13668 self.notification_with(group_id, &Default::default(), body)
13669 }
13670
13671 /// Send a group sign-up push notification
13672 ///
13673 /// Like [`Self::notification`], with query parameters.
13674 ///
13675 /// `POST /groups/{groupId}/notification`
13676 ///
13677 /// Announces a group to potential new members through push notifications. Requires permission to edit the group’s basic settings. Recipients have registered push devices, are not already linked to the group, and have not disabled these notifications. Group age, target-group and category values are compared with notification preferences, not with a person’s age or memberships. Use dry_run to preview the selection count without sending or marking the group as notified. A normal request marks the group as notified even when the count is zero; later requests, including dry runs, return 403. sentToCount measures recipient selection, not successful delivery. The response is returned directly without a data wrapper.
13678 pub fn notification_with(&self, group_id: impl Display, query: &PostGroupsGroupIdNotificationQuery, body: &models::GroupSignUpNotificationRequest) -> Result<models::GroupSignUpNotificationResult> {
13679 let path = format!("/groups/{}/notification", seg(group_id));
13680 let query: Query = query.to_query();
13681 let body = serde_json::to_value(body).expect("request body serializes");
13682 self.client.request_json(Method::Post, &path, &query, Some(&body))
13683 }
13684
13685 /// Update Group
13686 ///
13687 /// `PATCH /groups/{groupId}`
13688 ///
13689 /// Update a group by id. All group fields can be updated here. Use the fields api to get all fields that can be updated here. To link an existing group to an existing appointment (e.g. a sign-up group), set `appointmentId` (and optionally `startDate` to identify a specific occurrence of a repeating appointment). Set `appointmentId` to `null` to remove the link. The current user must have permission to edit both the group and the referenced appointment.
13690 ///
13691 /// Use [`Self::patch_with`] to pass query parameters.
13692 ///
13693 /// # Example
13694 ///
13695 /// ```
13696 /// # use churchtools_api::*;
13697 /// # use churchtools_api::queries::*;
13698 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13699 /// # let client = churchtools_api::replay::client("patch-groups-id");
13700 /// let body = models::PatchGroupsIdBody {
13701 /// appointment_id: Some(Some(42)),
13702 /// ..Default::default()
13703 /// };
13704 /// let result = client.groups().patch(42, &body)?;
13705 /// println!("{}", result.name);
13706 /// # Ok(())
13707 /// # }
13708 /// ```
13709 pub fn patch(&self, group_id: impl Display, body: &models::PatchGroupsIdBody) -> Result<models::Group> {
13710 self.patch_with(group_id, &Default::default(), body)
13711 }
13712
13713 /// Update Group
13714 ///
13715 /// Like [`Self::patch`], with query parameters.
13716 ///
13717 /// `PATCH /groups/{groupId}`
13718 ///
13719 /// Update a group by id. All group fields can be updated here. Use the fields api to get all fields that can be updated here. To link an existing group to an existing appointment (e.g. a sign-up group), set `appointmentId` (and optionally `startDate` to identify a specific occurrence of a repeating appointment). Set `appointmentId` to `null` to remove the link. The current user must have permission to edit both the group and the referenced appointment.
13720 pub fn patch_with(&self, group_id: impl Display, query: &PatchGroupsIdQuery, body: &models::PatchGroupsIdBody) -> Result<models::Group> {
13721 let path = format!("/groups/{}", seg(group_id));
13722 let query: Query = query.to_query();
13723 let body = serde_json::to_value(body).expect("request body serializes");
13724 self.client.request_data(Method::Patch, &path, &query, Some(&body))
13725 }
13726
13727 /// Create or update a group’s homepage configuration
13728 ///
13729 /// `PUT /groups/{groupId}/grouphomepage`
13730 ///
13731 /// Creates the homepage configuration if none exists, otherwise updates it. Requires permission to edit the parent group’s basic settings. Existing URL hashes are preserved; newly created pages receive a random hash. Supply all five enabled/display flags. Omitted header modes and custom text preserve existing values; omitted layout, ordering, collapse and depth settings reset to defaults, and omitted filters disables all filters. Returns 200 with an empty JSON object for both create and update. Read GET /groups/{groupId}/grouphomepage afterwards to obtain the saved configuration and URL hash.
13732 ///
13733 /// # Example
13734 ///
13735 /// ```
13736 /// # use churchtools_api::*;
13737 /// # use churchtools_api::queries::*;
13738 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13739 /// # let client = churchtools_api::replay::client("put-groups-groupId-grouphomepage");
13740 /// let body = models::GroupHomepageUpdate {
13741 /// is_enabled: true,
13742 /// show_filters: true,
13743 /// show_group_images: true,
13744 /// show_leaders: true,
13745 /// show_map: true,
13746 /// ..Default::default()
13747 /// };
13748 /// let result = client.groups().update_group_homepage(42, &body)?;
13749 /// println!("{:?}", result);
13750 /// # Ok(())
13751 /// # }
13752 /// ```
13753 pub fn update_group_homepage(&self, group_id: impl Display, body: &models::GroupHomepageUpdate) -> Result<std::collections::BTreeMap<String, serde_json::Value>> {
13754 let path = format!("/groups/{}/grouphomepage", seg(group_id));
13755 let query: Query = Query::new();
13756 let body = serde_json::to_value(body).expect("request body serializes");
13757 self.client.request_json(Method::Put, &path, &query, Some(&body))
13758 }
13759
13760}
13761
13762/// `client.groups().checkin()`
13763#[derive(Clone, Copy)]
13764pub struct GroupsCheckinResource<'a> {
13765 client: &'a Client,
13766}
13767
13768impl<'a> GroupsCheckinResource<'a> {
13769 /// Check in a person at a group meeting
13770 ///
13771 /// `POST /groups/{groupId}/checkin/{personId}`
13772 ///
13773 /// Marks an existing person present at a group meeting. Requires permission to manage meetings of the path group. Supply either an existing meeting ID belonging to this group or its exact start timestamp; the timestamp variant creates a meeting when necessary. This does not create a group membership. Completed meetings and people already marked present produce 400. An optional ticket is marked used before these checks. printerId requests a name tag; printer warnings do not undo attendance or prevent a success response.
13774 ///
13775 /// # Example
13776 ///
13777 /// ```no_run
13778 /// # use churchtools_api::*;
13779 /// # use churchtools_api::queries::*;
13780 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13781 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
13782 /// let body = models::CheckinCreate {
13783 /// date: Some(Some("2022-10-19T12:00:00Z".parse()?)),
13784 /// ..Default::default()
13785 /// };
13786 /// let result = client.groups().checkin().create(42, 42, &body)?;
13787 /// println!("{}", result.total_checked_in);
13788 /// # Ok(())
13789 /// # }
13790 /// ```
13791 pub fn create(&self, group_id: impl Display, person_id: impl Display, body: &models::CheckinCreate) -> Result<models::Checkin> {
13792 let path = format!("/groups/{}/checkin/{}", seg(group_id), seg(person_id));
13793 let query: Query = Query::new();
13794 let body = serde_json::to_value(body).expect("request body serializes");
13795 self.client.request_data(Method::Post, &path, &query, Some(&body))
13796 }
13797
13798}
13799
13800/// `client.groups().documents()`
13801#[derive(Clone, Copy)]
13802pub struct GroupsDocumentsResource<'a> {
13803 client: &'a Client,
13804}
13805
13806impl<'a> GroupsDocumentsResource<'a> {
13807 /// `GET /groups/{groupId}/documents/{htmlTemplateId}`
13808 ///
13809 /// Get a group document for the current logged in User
13810 ///
13811 /// # Example
13812 ///
13813 /// ```no_run
13814 /// # use churchtools_api::*;
13815 /// # use churchtools_api::queries::*;
13816 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13817 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
13818 /// client.groups().documents().get(42, "abc123")?;
13819 /// # Ok(())
13820 /// # }
13821 /// ```
13822 pub fn get(&self, group_id: impl Display, html_template_id: impl Display) -> Result<()> {
13823 let path = format!("/groups/{}/documents/{}", seg(group_id), seg(html_template_id));
13824 let query: Query = Query::new();
13825 self.client.request(Method::Get, &path, &query, None).map(|_| ())
13826 }
13827
13828}
13829
13830/// `client.groups().followups()`
13831#[derive(Clone, Copy)]
13832pub struct GroupsFollowupsResource<'a> {
13833 client: &'a Client,
13834}
13835
13836impl<'a> GroupsFollowupsResource<'a> {
13837 /// Count follow-ups for a group by due state
13838 ///
13839 /// `GET /groups/{groupId}/followups/statistics`
13840 ///
13841 /// Counts follow-ups in this group assigned to the current user, plus unassigned follow-ups where that user has group follow-up rights. Items assigned to other people and archived subject persons are excluded, matching the group list scope. Requires permission to administer or perform follow-ups in this group. The counters cover all matching records and ignore list pagination and filter parameters. Due states use the effective due date and the server’s current date; dismissed and completed follow-ups share countDone. An empty scope returns all five counters as zero.
13842 ///
13843 /// # Example
13844 ///
13845 /// ```
13846 /// # use churchtools_api::*;
13847 /// # use churchtools_api::queries::*;
13848 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13849 /// # let client = churchtools_api::replay::client("get-groups-groupId-followups-statistics");
13850 /// let statistic = client.groups().followups().get_statistics(42)?;
13851 /// println!("{}", statistic.count_done);
13852 /// # Ok(())
13853 /// # }
13854 /// ```
13855 pub fn get_statistics(&self, group_id: impl Display) -> Result<models::FollowUpStatistics> {
13856 let path = format!("/groups/{}/followups/statistics", seg(group_id));
13857 let query: Query = Query::new();
13858 self.client.request_data(Method::Get, &path, &query, None)
13859 }
13860
13861 /// List follow-ups for group memberships
13862 ///
13863 /// `GET /groups/{groupId}/followups`
13864 ///
13865 /// Returns follow-ups associated with this group, restricted to items assigned to the current user and unassigned items in groups where that user has follow-up rights. Items assigned to other people are omitted even if the current user can view them individually. Requires permission to administer or perform follow-ups in this group. Follow-ups whose subject person is archived are excluded. State filters are combined with OR; omission includes all states. Results are ordered by completion date descending, effective due date ascending, then ID. Pagination returns only meta.count for this page, without a total or last-page value.
13866 ///
13867 /// Use [`Self::list_with`] to pass query parameters.
13868 ///
13869 /// # Example
13870 ///
13871 /// ```
13872 /// # use churchtools_api::*;
13873 /// # use churchtools_api::queries::*;
13874 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13875 /// # let client = churchtools_api::replay::client("get-groups-groupId-followups");
13876 /// for followup in client.groups().followups().list(42)? {
13877 /// println!("{}", followup.title);
13878 /// }
13879 /// # Ok(())
13880 /// # }
13881 /// ```
13882 pub fn list(&self, group_id: impl Display) -> Result<Vec<models::FollowUp2>> {
13883 self.list_with(group_id, &Default::default())
13884 }
13885
13886 /// List follow-ups for group memberships
13887 ///
13888 /// Like [`Self::list`], with query parameters.
13889 ///
13890 /// `GET /groups/{groupId}/followups`
13891 ///
13892 /// Returns follow-ups associated with this group, restricted to items assigned to the current user and unassigned items in groups where that user has follow-up rights. Items assigned to other people are omitted even if the current user can view them individually. Requires permission to administer or perform follow-ups in this group. Follow-ups whose subject person is archived are excluded. State filters are combined with OR; omission includes all states. Results are ordered by completion date descending, effective due date ascending, then ID. Pagination returns only meta.count for this page, without a total or last-page value.
13893 pub fn list_with(&self, group_id: impl Display, query: &GetGroupsGroupIdFollowupsQuery) -> Result<Vec<models::FollowUp2>> {
13894 let path = format!("/groups/{}/followups", seg(group_id));
13895 let query: Query = query.to_query();
13896 self.client.collect_pages(&path, query)
13897 }
13898
13899 /// List follow-ups for group memberships
13900 ///
13901 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
13902 /// Breaking off early saves the remaining requests.
13903 pub fn list_iter(&self, group_id: impl Display, query: &GetGroupsGroupIdFollowupsQuery) -> Items<models::FollowUp2> {
13904 let path = format!("/groups/{}/followups", seg(group_id));
13905 self.client.items(&path, query.to_query())
13906 }
13907
13908}
13909
13910/// `client.groups().meetings()`
13911#[derive(Clone, Copy)]
13912pub struct GroupsMeetingsResource<'a> {
13913 client: &'a Client,
13914}
13915
13916impl<'a> GroupsMeetingsResource<'a> {
13917 pub fn members(&self) -> GroupsMeetingsMembersResource<'a> {
13918 GroupsMeetingsMembersResource { client: self.client }
13919 }
13920
13921 /// Create a group meeting
13922 ///
13923 /// `POST /groups/{groupId}/meetings`
13924 ///
13925 /// Creates one meeting at startDate and initializes attendance for eligible active group members as unsure. Requires authentication, permission to view the group and permission to manage its meetings. Send a UTC timestamp. Only startDate is accepted as meeting timing; endDate does not set a duration. dateFrom is a legacy alias for startDate. A duplicate meeting for the same group and start time returns 400.
13926 ///
13927 /// # Example
13928 ///
13929 /// ```
13930 /// # use churchtools_api::*;
13931 /// # use churchtools_api::queries::*;
13932 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13933 /// # let client = churchtools_api::replay::client("post-groups-id-meetings");
13934 /// let body = models::PostGroupsIdMeetingsBody {
13935 /// start_date: "2026-09-20T08:00:00Z".parse()?,
13936 /// ..Default::default()
13937 /// };
13938 /// let result = client.groups().meetings().create(42, &body)?;
13939 /// println!("{}", result.id);
13940 /// # Ok(())
13941 /// # }
13942 /// ```
13943 pub fn create(&self, group_id: impl Display, body: &models::PostGroupsIdMeetingsBody) -> Result<models::GroupMeeting> {
13944 let path = format!("/groups/{}/meetings", seg(group_id));
13945 let query: Query = Query::new();
13946 let body = serde_json::to_value(body).expect("request body serializes");
13947 self.client.request_data(Method::Post, &path, &query, Some(&body))
13948 }
13949
13950 /// Delete a group meeting
13951 ///
13952 /// `DELETE /groups/{groupId}/meetings/{meetingId}`
13953 ///
13954 /// Permanently deletes the meeting. This differs from setting isCanceled=true, which retains the record. Requires authentication, permission to view the group and permission to manage its meetings. Use a meetingId belonging to the group in the URL. There is no dry-run option. Returns 204 without a response body.
13955 ///
13956 /// # Example
13957 ///
13958 /// ```no_run
13959 /// # use churchtools_api::*;
13960 /// # use churchtools_api::queries::*;
13961 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13962 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
13963 /// client.groups().meetings().delete(42, 120)?;
13964 /// # Ok(())
13965 /// # }
13966 /// ```
13967 pub fn delete(&self, group_id: impl Display, meeting_id: impl Display) -> Result<()> {
13968 let path = format!("/groups/{}/meetings/{}", seg(group_id), seg(meeting_id));
13969 let query: Query = Query::new();
13970 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
13971 }
13972
13973 /// Get a group meeting
13974 ///
13975 /// `GET /groups/{groupId}/meetings/{meetingId}`
13976 ///
13977 /// Returns one meeting with attendance statistics. Requires authentication, permission to view the group and permission to manage its meetings. Use a meetingId belonging to the group in the URL. No include parameters are supported; use the meeting list with include=attendances or the meeting members endpoint for individual attendance.
13978 ///
13979 /// # Example
13980 ///
13981 /// ```
13982 /// # use churchtools_api::*;
13983 /// # use churchtools_api::queries::*;
13984 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
13985 /// # let client = churchtools_api::replay::client("get-groups-groupId-meetings-meetingId");
13986 /// let meeting = client.groups().meetings().get(42, 120)?;
13987 /// println!("{}", meeting.id);
13988 /// # Ok(())
13989 /// # }
13990 /// ```
13991 pub fn get(&self, group_id: impl Display, meeting_id: impl Display) -> Result<models::GroupMeeting> {
13992 let path = format!("/groups/{}/meetings/{}", seg(group_id), seg(meeting_id));
13993 let query: Query = Query::new();
13994 self.client.request_data(Method::Get, &path, &query, None)
13995 }
13996
13997 /// Export group meeting attendance or overview
13998 ///
13999 /// `GET /groups/{groupId}/meetings/export`
14000 ///
14001 /// Exports meetings in the inclusive from / exclusive to date range. Requires authentication and permission to manage group meetings. Defaults to yesterday at midnight through midnight 30 days after today, in the application timezone.
14002 ///
14003 /// meetings_members creates a person-by-meeting attendance matrix, subject to attendance visibility and group-history permissions. meetings_overview creates one row per meeting with status, attendance counts, guest count and comment. Headings and attendance labels are translated.
14004 ///
14005 /// The result is a downloadable CSV (default) or XLSX file, not a JSON response. All matching meetings are exported; page and limit are not supported. The current date-range implementation orders meetings oldest first even when direction=backward is supplied.
14006 ///
14007 /// Use [`Self::get_export_with`] to pass query parameters.
14008 ///
14009 /// # Example
14010 ///
14011 /// ```no_run
14012 /// # use churchtools_api::*;
14013 /// # use churchtools_api::queries::*;
14014 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14015 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14016 /// let data = client.groups().meetings().get_export(42)?;
14017 /// std::fs::write("ergebnis.xlsx", &data)?;
14018 /// # Ok(())
14019 /// # }
14020 /// ```
14021 pub fn get_export(&self, group_id: impl Display) -> Result<Vec<u8>> {
14022 self.get_export_with(group_id, &Default::default())
14023 }
14024
14025 /// Export group meeting attendance or overview
14026 ///
14027 /// Like [`Self::get_export`], with query parameters.
14028 ///
14029 /// `GET /groups/{groupId}/meetings/export`
14030 ///
14031 /// Exports meetings in the inclusive from / exclusive to date range. Requires authentication and permission to manage group meetings. Defaults to yesterday at midnight through midnight 30 days after today, in the application timezone.
14032 ///
14033 /// meetings_members creates a person-by-meeting attendance matrix, subject to attendance visibility and group-history permissions. meetings_overview creates one row per meeting with status, attendance counts, guest count and comment. Headings and attendance labels are translated.
14034 ///
14035 /// The result is a downloadable CSV (default) or XLSX file, not a JSON response. All matching meetings are exported; page and limit are not supported. The current date-range implementation orders meetings oldest first even when direction=backward is supplied.
14036 pub fn get_export_with(&self, group_id: impl Display, query: &GetGroupsGroupIdMeetingsExportQuery) -> Result<Vec<u8>> {
14037 let path = format!("/groups/{}/meetings/export", seg(group_id));
14038 let query: Query = query.to_query();
14039 self.client.request(Method::Get, &path, &query, None)
14040 }
14041
14042 /// Get meetings for a group
14043 ///
14044 /// `GET /groups/{groupId}/meetings`
14045 ///
14046 /// Returns meetings and attendance statistics for a group. Requires authentication, permission to view the group and permission to manage its meetings.
14047 ///
14048 /// Without direction, returns all meetings with startDate >= from and startDate < to, ordered oldest first. page and limit do not restrict this date-range mode. Defaults are yesterday at midnight through midnight 30 days after today, in the application timezone.
14049 ///
14050 /// With direction=forward, returns meetings strictly after from, oldest first. With direction=backward, returns meetings strictly before from, newest first. In this mode to is ignored, and page/limit select a page. The response has no pagination object or total page count.
14051 ///
14052 /// meta.count is the number returned; meta.statistics covers all meetings of the group. In date-range mode, meta.previous and meta.next contain a matching meeting timestamp before from or after to, or null. They are omitted in directional mode. Use include=attendances to add person-level attendance states.
14053 ///
14054 /// Use [`Self::list_with`] to pass query parameters.
14055 ///
14056 /// # Example
14057 ///
14058 /// ```
14059 /// # use churchtools_api::*;
14060 /// # use churchtools_api::queries::*;
14061 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14062 /// # let client = churchtools_api::replay::client("get-groups-id-meetings");
14063 /// for meeting in client.groups().meetings().list(42)? {
14064 /// println!("{}", meeting.id);
14065 /// }
14066 /// # Ok(())
14067 /// # }
14068 /// ```
14069 pub fn list(&self, group_id: impl Display) -> Result<Vec<models::GroupMeeting>> {
14070 self.list_with(group_id, &Default::default())
14071 }
14072
14073 /// Get meetings for a group
14074 ///
14075 /// Like [`Self::list`], with query parameters.
14076 ///
14077 /// `GET /groups/{groupId}/meetings`
14078 ///
14079 /// Returns meetings and attendance statistics for a group. Requires authentication, permission to view the group and permission to manage its meetings.
14080 ///
14081 /// Without direction, returns all meetings with startDate >= from and startDate < to, ordered oldest first. page and limit do not restrict this date-range mode. Defaults are yesterday at midnight through midnight 30 days after today, in the application timezone.
14082 ///
14083 /// With direction=forward, returns meetings strictly after from, oldest first. With direction=backward, returns meetings strictly before from, newest first. In this mode to is ignored, and page/limit select a page. The response has no pagination object or total page count.
14084 ///
14085 /// meta.count is the number returned; meta.statistics covers all meetings of the group. In date-range mode, meta.previous and meta.next contain a matching meeting timestamp before from or after to, or null. They are omitted in directional mode. Use include=attendances to add person-level attendance states.
14086 pub fn list_with(&self, group_id: impl Display, query: &GetGroupsIdMeetingsQuery) -> Result<Vec<models::GroupMeeting>> {
14087 let path = format!("/groups/{}/meetings", seg(group_id));
14088 let query: Query = query.to_query();
14089 self.client.collect_pages(&path, query)
14090 }
14091
14092 /// Get meetings for a group
14093 ///
14094 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
14095 /// Breaking off early saves the remaining requests.
14096 pub fn list_iter(&self, group_id: impl Display, query: &GetGroupsIdMeetingsQuery) -> Items<models::GroupMeeting> {
14097 let path = format!("/groups/{}/meetings", seg(group_id));
14098 self.client.items(&path, query.to_query())
14099 }
14100
14101 /// Update a group meeting
14102 ///
14103 /// `PUT /groups/{groupId}/meetings/{meetingId}`
14104 ///
14105 /// Updates meeting timing, completion, cancellation and feedback. Requires authentication, permission to view the group and permission to manage its meetings. Use a meetingId belonging to the group in the URL.
14106 ///
14107 /// Supply startDate, isCompleted and isCanceled; they have no implicit request defaults. Omitted numGuests, comment and pollResult are cleared to null. This is not a partial update. Blank comments are trimmed to null. endDate is not stored or updated. A duplicate start time for this group returns 400.
14108 ///
14109 /// Setting isCompleted=true locks attendance changes. Send false to reopen the meeting. This operation does not change individual attendance states or hasEditingStarted. Returns the updated meeting in data.
14110 ///
14111 /// # Example
14112 ///
14113 /// ```
14114 /// # use churchtools_api::*;
14115 /// # use churchtools_api::queries::*;
14116 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14117 /// # let client = churchtools_api::replay::client("put-groups-groupId-meetings-meetingId");
14118 /// let body = models::PutGroupsGroupIdMeetingsMeetingIdBody {
14119 /// is_canceled: false,
14120 /// is_completed: false,
14121 /// start_date: "2026-09-20T08:00:00Z".parse()?,
14122 /// ..Default::default()
14123 /// };
14124 /// let result = client.groups().meetings().update(42, 120, &body)?;
14125 /// println!("{}", result.id);
14126 /// # Ok(())
14127 /// # }
14128 /// ```
14129 pub fn update(&self, group_id: impl Display, meeting_id: impl Display, body: &models::PutGroupsGroupIdMeetingsMeetingIdBody) -> Result<models::GroupMeeting> {
14130 let path = format!("/groups/{}/meetings/{}", seg(group_id), seg(meeting_id));
14131 let query: Query = Query::new();
14132 let body = serde_json::to_value(body).expect("request body serializes");
14133 self.client.request_data(Method::Put, &path, &query, Some(&body))
14134 }
14135
14136}
14137
14138/// `client.groups().meetings().members()`
14139#[derive(Clone, Copy)]
14140pub struct GroupsMeetingsMembersResource<'a> {
14141 client: &'a Client,
14142}
14143
14144impl<'a> GroupsMeetingsMembersResource<'a> {
14145 /// Revoke a meeting check-in
14146 ///
14147 /// `DELETE /groups/{groupId}/meetings/{meetingId}/members/{memberId}`
14148 ///
14149 /// Sets one person's attendance to absent (the default) or unsure. This writes an attendance state rather than deleting the person or membership, and sets hasEditingStarted=true. Requires authentication and permission to manage meetings for the group. Completed meetings reject this attendance change with 400; reopen the meeting before editing attendance.
14150 ///
14151 /// The request body is optional. On success the response is 200 with a GroupMeeting directly at the JSON root, without a data wrapper. A meeting belonging to another group or an unknown person returns 404.
14152 ///
14153 /// # Example
14154 ///
14155 /// ```
14156 /// # use churchtools_api::*;
14157 /// # use churchtools_api::queries::*;
14158 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14159 /// # let client = churchtools_api::replay::client("delete-groups-groupId-meetings-meetingId-members-memberId");
14160 /// let body = models::DeleteGroupsGroupIdMeetingsMeetingIdMembersMemberIdBody {
14161 /// status: Some("absent".into()),
14162 /// ..Default::default()
14163 /// };
14164 /// let member = client.groups().meetings().members().delete(42, 120, 17, &body)?;
14165 /// println!("{}", member.id);
14166 /// # Ok(())
14167 /// # }
14168 /// ```
14169 pub fn delete(&self, group_id: impl Display, meeting_id: impl Display, member_id: impl Display, body: &models::DeleteGroupsGroupIdMeetingsMeetingIdMembersMemberIdBody) -> Result<models::GroupMeeting> {
14170 let path = format!("/groups/{}/meetings/{}/members/{}", seg(group_id), seg(meeting_id), seg(member_id));
14171 let query: Query = Query::new();
14172 let body = serde_json::to_value(body).expect("request body serializes");
14173 self.client.request_json(Method::Delete, &path, &query, Some(&body))
14174 }
14175
14176 /// Get attendance for a group meeting
14177 ///
14178 /// `GET /groups/{groupId}/meetings/{meetingId}/members`
14179 ///
14180 /// Returns person-level attendance for the meeting. Requires authentication, permission to view the group and permission to manage its meetings.
14181 ///
14182 /// The list combines recorded attendance with visible group members; membership details are included only for current visible active memberships. Former members may appear when group-history permissions allow it, with member=null. A person without an attendance record receives status=not-in-group. personId identifies the person; isCheckedIn is true only for present.
14183 ///
14184 /// Returns an unpaginated data array with meta.count. It does not return meta.totalCheckedIn. A meeting belonging to another group returns 404.
14185 ///
14186 /// # Example
14187 ///
14188 /// ```
14189 /// # use churchtools_api::*;
14190 /// # use churchtools_api::queries::*;
14191 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14192 /// # let client = churchtools_api::replay::client("get-groups-groupId-meetings-meetingId-members");
14193 /// for member in client.groups().meetings().members().list(42, 120)? {
14194 /// println!("{}", member.is_checked_in);
14195 /// }
14196 /// # Ok(())
14197 /// # }
14198 /// ```
14199 pub fn list(&self, group_id: impl Display, meeting_id: impl Display) -> Result<Vec<models::GroupMeetingMember>> {
14200 let path = format!("/groups/{}/meetings/{}/members", seg(group_id), seg(meeting_id));
14201 let query: Query = Query::new();
14202 self.client.request_data(Method::Get, &path, &query, None)
14203 }
14204
14205 /// Set undecided meeting attendance
14206 ///
14207 /// `POST /groups/{groupId}/meetings/{meetingId}/members/missing`
14208 ///
14209 /// Changes only existing unsure attendance records to the supplied present or absent status. Other attendance records are unchanged, and no new person records are added. Sets hasEditingStarted=true. Requires authentication and permission to manage meetings for the group. Completed meetings reject this attendance change with 400; reopen the meeting before editing attendance. Returns 204 without a response body.
14210 ///
14211 /// # Example
14212 ///
14213 /// ```no_run
14214 /// # use churchtools_api::*;
14215 /// # use churchtools_api::queries::*;
14216 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14217 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14218 /// let body = models::PostGroupsGroupIdMeetingsMeetingIdMembersMissingBody {
14219 /// status: "absent".into(),
14220 /// ..Default::default()
14221 /// };
14222 /// client.groups().meetings().members().missing(42, 120, &body)?;
14223 /// # Ok(())
14224 /// # }
14225 /// ```
14226 pub fn missing(&self, group_id: impl Display, meeting_id: impl Display, body: &models::PostGroupsGroupIdMeetingsMeetingIdMembersMissingBody) -> Result<()> {
14227 let path = format!("/groups/{}/meetings/{}/members/missing", seg(group_id), seg(meeting_id));
14228 let query: Query = Query::new();
14229 let body = serde_json::to_value(body).expect("request body serializes");
14230 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
14231 }
14232
14233 /// Reset meeting attendance
14234 ///
14235 /// `POST /groups/{groupId}/meetings/{meetingId}/members/reset`
14236 ///
14237 /// Resets all existing attendance records for the meeting to unsure, including records previously marked present or absent. Clears hasEditingStarted. This does not remove memberships or clear meeting feedback or guest counts. Requires authentication and permission to manage meetings for the group. Completed meetings reject this attendance change with 400; reopen the meeting before editing attendance. Returns 204 without a response body.
14238 ///
14239 /// # Example
14240 ///
14241 /// ```no_run
14242 /// # use churchtools_api::*;
14243 /// # use churchtools_api::queries::*;
14244 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14245 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14246 /// client.groups().meetings().members().reset(42, 120)?;
14247 /// # Ok(())
14248 /// # }
14249 /// ```
14250 pub fn reset(&self, group_id: impl Display, meeting_id: impl Display) -> Result<()> {
14251 let path = format!("/groups/{}/meetings/{}/members/reset", seg(group_id), seg(meeting_id));
14252 let query: Query = Query::new();
14253 self.client.request(Method::Post, &path, &query, None).map(|_| ())
14254 }
14255
14256}
14257
14258/// `client.groups().member_fields()`
14259#[derive(Clone, Copy)]
14260pub struct GroupsMemberFieldsResource<'a> {
14261 client: &'a Client,
14262}
14263
14264impl<'a> GroupsMemberFieldsResource<'a> {
14265 pub fn group(&self) -> GroupsMemberFieldsGroupResource<'a> {
14266 GroupsMemberFieldsGroupResource { client: self.client }
14267 }
14268
14269 pub fn person(&self) -> GroupsMemberFieldsPersonResource<'a> {
14270 GroupsMemberFieldsPersonResource { client: self.client }
14271 }
14272
14273 /// List configured membership and person fields
14274 ///
14275 /// `GET /groups/{groupId}/memberfields`
14276 ///
14277 /// Returns all configured fields for this group, ordered together by sortKey. type=group describes a field whose values belong to individual memberships; type=person links an existing global person field into the group’s membership/signup UI. The list contains field definitions, not members or their entered values. Requires visibility of the group. Field definitions are not additionally filtered by their securityLevel or useInRegistrationForm flag. Results are not paginated; meta.count is the total number of returned definitions. Anonymous access is possible when the group is publicly visible.
14278 ///
14279 /// # Example
14280 ///
14281 /// ```
14282 /// # use churchtools_api::*;
14283 /// # use churchtools_api::queries::*;
14284 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14285 /// # let client = churchtools_api::replay::client("get-groups-groupId-memberfields");
14286 /// for member_field in client.groups().member_fields().list(42)? {
14287 /// println!("{:?}", member_field);
14288 /// }
14289 /// # Ok(())
14290 /// # }
14291 /// ```
14292 pub fn list(&self, group_id: impl Display) -> Result<Vec<serde_json::Value>> {
14293 let path = format!("/groups/{}/memberfields", seg(group_id));
14294 let query: Query = Query::new();
14295 self.client.request_data(Method::Get, &path, &query, None)
14296 }
14297
14298}
14299
14300/// `client.groups().member_fields().group()`
14301#[derive(Clone, Copy)]
14302pub struct GroupsMemberFieldsGroupResource<'a> {
14303 client: &'a Client,
14304}
14305
14306impl<'a> GroupsMemberFieldsGroupResource<'a> {
14307 /// Create a group-specific membership field
14308 ///
14309 /// `POST /groups/{groupId}/memberfields/group`
14310 ///
14311 /// Creates a field whose values are stored separately for each person’s membership in this group. Requires permission to edit group member fields. name must be unique within the group; referenceName must also be unique and is generated from name when omitted. Choose fieldTypeCode at creation; subsequent field updates cannot change it. Select-like options receive new backend IDs, and defaults are normalized to those IDs. The response is the field definition, without a type wrapper or member values. Existing memberships are not populated with the new default by this endpoint.
14312 ///
14313 /// # Example
14314 ///
14315 /// ```
14316 /// # use churchtools_api::*;
14317 /// # use churchtools_api::queries::*;
14318 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14319 /// # let client = churchtools_api::replay::client("post-groups-groupId-memberfields-group");
14320 /// let body = models::GroupMemberFieldGroupCreate {
14321 /// field_type_code: "text".into(),
14322 /// name: "T-Shirt size".into(),
14323 /// required_in_registration_form: false,
14324 /// security_level: 1,
14325 /// use_in_registration_form: true,
14326 /// ..Default::default()
14327 /// };
14328 /// let result = client.groups().member_fields().group().create(42, &body)?;
14329 /// println!("{}", result.name);
14330 /// # Ok(())
14331 /// # }
14332 /// ```
14333 pub fn create(&self, group_id: impl Display, body: &models::GroupMemberFieldGroupCreate) -> Result<models::GroupMemberFieldGroup> {
14334 let path = format!("/groups/{}/memberfields/group", seg(group_id));
14335 let query: Query = Query::new();
14336 let body = serde_json::to_value(body).expect("request body serializes");
14337 self.client.request_data(Method::Post, &path, &query, Some(&body))
14338 }
14339
14340 /// Delete a membership field and its stored values
14341 ///
14342 /// `DELETE /groups/{groupId}/memberfields/group/{groupMemberFieldId}`
14343 ///
14344 /// Deletes the group-specific field definition, its selection options and all stored member values for that field. Requires permission to edit member fields of the path group. Supply a field belonging to that group. This operation has no delete-preview workflow and returns 204 without a body. Global person fields and person-field values are unaffected.
14345 ///
14346 /// # Example
14347 ///
14348 /// ```no_run
14349 /// # use churchtools_api::*;
14350 /// # use churchtools_api::queries::*;
14351 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14352 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14353 /// client.groups().member_fields().group().delete(42, 42)?;
14354 /// # Ok(())
14355 /// # }
14356 /// ```
14357 pub fn delete(&self, group_id: impl Display, group_member_field_id: impl Display) -> Result<()> {
14358 let path = format!("/groups/{}/memberfields/group/{}", seg(group_id), seg(group_member_field_id));
14359 let query: Query = Query::new();
14360 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
14361 }
14362
14363 /// Partially update a membership field definition
14364 ///
14365 /// `PATCH /groups/{groupId}/memberfields/group/{groupMemberFieldId}`
14366 ///
14367 /// Updates only supplied fields of a field belonging to the path group. Requires permission to edit group member fields. Empty {} is accepted and preserves the definition. fieldTypeCode is ignored; a field’s type cannot be changed here. When updating choices, send the full list with numeric IDs for retained choices; omitted IDs are deleted and removed from all member selections and the default. Use options=\[\] to remove all choices; omit options to preserve it. Avoid options=null because the current implementation reallocates IDs and can clear existing selections. Unlike create and PUT, PATCH does not check uniqueness of the display name, but it checks changed reference names.
14368 ///
14369 /// # Example
14370 ///
14371 /// ```
14372 /// # use churchtools_api::*;
14373 /// # use churchtools_api::queries::*;
14374 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14375 /// # let client = churchtools_api::replay::client("patch-groups-groupId-memberfields-group-groupMemberFieldId");
14376 /// let body = models::GroupMemberFieldGroupPatch {
14377 /// name: Some("T-Shirt size".into()),
14378 /// ..Default::default()
14379 /// };
14380 /// let result = client.groups().member_fields().group().patch(42, 42, &body)?;
14381 /// println!("{}", result.name);
14382 /// # Ok(())
14383 /// # }
14384 /// ```
14385 pub fn patch(&self, group_id: impl Display, group_member_field_id: impl Display, body: &models::GroupMemberFieldGroupPatch) -> Result<models::GroupMemberFieldGroup> {
14386 let path = format!("/groups/{}/memberfields/group/{}", seg(group_id), seg(group_member_field_id));
14387 let query: Query = Query::new();
14388 let body = serde_json::to_value(body).expect("request body serializes");
14389 self.client.request_data(Method::Patch, &path, &query, Some(&body))
14390 }
14391
14392 /// Replace a membership field definition
14393 ///
14394 /// `PUT /groups/{groupId}/memberfields/group/{groupMemberFieldId}`
14395 ///
14396 /// Updates a field belonging to the path group. Requires permission to edit group member fields and the required name/referenceName/securityLevel/registration flags. Unlike PATCH, omitted notes, signup labels and defaultValue are cleared, and sortKey resets to zero. The display name and reference name must be unique within the group. The field type is unchanged. Send the full option list with numeric IDs for retained choices: removed choices are removed from member selections and defaults. Omitting options or sending null currently reallocates existing choice IDs and can clear selections. The returned object is the saved field definition.
14397 ///
14398 /// # Example
14399 ///
14400 /// ```
14401 /// # use churchtools_api::*;
14402 /// # use churchtools_api::queries::*;
14403 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14404 /// # let client = churchtools_api::replay::client("put-groups-groupId-memberfields-group-groupMemberFieldId");
14405 /// let body = models::GroupMemberFieldGroupUpdate {
14406 /// name: "T-Shirt size".into(),
14407 /// reference_name: "t-shirt-size".into(),
14408 /// required_in_registration_form: false,
14409 /// security_level: 1,
14410 /// use_in_registration_form: true,
14411 /// ..Default::default()
14412 /// };
14413 /// let result = client.groups().member_fields().group().update(42, 42, &body)?;
14414 /// println!("{}", result.name);
14415 /// # Ok(())
14416 /// # }
14417 /// ```
14418 pub fn update(&self, group_id: impl Display, group_member_field_id: impl Display, body: &models::GroupMemberFieldGroupUpdate) -> Result<models::GroupMemberFieldGroup> {
14419 let path = format!("/groups/{}/memberfields/group/{}", seg(group_id), seg(group_member_field_id));
14420 let query: Query = Query::new();
14421 let body = serde_json::to_value(body).expect("request body serializes");
14422 self.client.request_data(Method::Put, &path, &query, Some(&body))
14423 }
14424
14425}
14426
14427/// `client.groups().member_fields().person()`
14428#[derive(Clone, Copy)]
14429pub struct GroupsMemberFieldsPersonResource<'a> {
14430 client: &'a Client,
14431}
14432
14433impl<'a> GroupsMemberFieldsPersonResource<'a> {
14434 /// Remove a person field from a group’s member form
14435 ///
14436 /// `DELETE /groups/{groupId}/memberfields/person/{fieldId}`
14437 ///
14438 /// Removes the configuration linking this global person field to the group’s membership/signup UI. The underlying field definition and all values stored on persons are retained. Requires permission to edit group member fields. The lookup is scoped to both the group and dbField.id. Returns 204 on deletion and 404 when no such configuration exists; there is no delete-preview workflow.
14439 ///
14440 /// # Example
14441 ///
14442 /// ```no_run
14443 /// # use churchtools_api::*;
14444 /// # use churchtools_api::queries::*;
14445 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14446 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14447 /// client.groups().member_fields().person().delete(42, 200)?;
14448 /// # Ok(())
14449 /// # }
14450 /// ```
14451 pub fn delete(&self, group_id: impl Display, field_id: impl Display) -> Result<()> {
14452 let path = format!("/groups/{}/memberfields/person/{}", seg(group_id), seg(field_id));
14453 let query: Query = Query::new();
14454 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
14455 }
14456
14457 /// Configure a person field for a group’s member form
14458 ///
14459 /// `PUT /groups/{groupId}/memberfields/person/{fieldId}`
14460 ///
14461 /// Creates or updates the link from an existing global person field to this group’s membership/signup UI. Requires permission to edit group member fields. The path uses dbField.id, not the configuration row ID. Both sortKey and requiredInRegistrationForm must be supplied. The request does not change the global field definition or existing person values. Returns 200 with the saved configuration, including the full underlying dbField, for both create and update.
14462 ///
14463 /// # Example
14464 ///
14465 /// ```no_run
14466 /// # use churchtools_api::*;
14467 /// # use churchtools_api::queries::*;
14468 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14469 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14470 /// let body = models::GroupMemberFieldPersonUpdate {
14471 /// required_in_registration_form: false,
14472 /// sort_key: 20,
14473 /// ..Default::default()
14474 /// };
14475 /// let result = client.groups().member_fields().person().update(42, 200, &body)?;
14476 /// println!("{}", result.id);
14477 /// # Ok(())
14478 /// # }
14479 /// ```
14480 pub fn update(&self, group_id: impl Display, field_id: impl Display, body: &models::GroupMemberFieldPersonUpdate) -> Result<models::GroupMemberFieldPerson> {
14481 let path = format!("/groups/{}/memberfields/person/{}", seg(group_id), seg(field_id));
14482 let query: Query = Query::new();
14483 let body = serde_json::to_value(body).expect("request body serializes");
14484 self.client.request_data(Method::Put, &path, &query, Some(&body))
14485 }
14486
14487}
14488
14489/// `client.groups().members()`
14490#[derive(Clone, Copy)]
14491pub struct GroupsMembersResource<'a> {
14492 client: &'a Client,
14493}
14494
14495impl<'a> GroupsMembersResource<'a> {
14496 pub fn documents(&self) -> GroupsMembersDocumentsResource<'a> {
14497 GroupsMembersDocumentsResource { client: self.client }
14498 }
14499
14500 pub fn followups(&self) -> GroupsMembersFollowupsResource<'a> {
14501 GroupsMembersFollowupsResource { client: self.client }
14502 }
14503
14504 pub fn routines(&self) -> GroupsMembersRoutinesResource<'a> {
14505 GroupsMembersRoutinesResource { client: self.client }
14506 }
14507
14508 /// Export visible group members with selected columns
14509 ///
14510 /// `POST /groups/{groupId}/members/export`
14511 ///
14512 /// Downloads the same membership scope as GET on this path, using an optional JSON config. Omitted/null/empty config uses the default columns; {template: allin} selects the full discovered catalog. For custom columns, send version 10 and ordered pinned/unpinned lists. person.id is always included, prepended when missing. Some person fields expand into multiple columns; pinned columns are frozen in XLSX. Unknown keys and malformed configurations are not reliably validated and may cause 500. Legacy version 9 is migrated internally but has known custom-column migration limitations; new clients should use version 10. The request is read-only and does not save the export configuration.
14513 ///
14514 /// Use [`Self::create_export_with`] to pass query parameters.
14515 ///
14516 /// # Example
14517 ///
14518 /// ```no_run
14519 /// # use churchtools_api::*;
14520 /// # use churchtools_api::queries::*;
14521 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14522 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14523 /// let body = models::GroupMemberExportCreate::default();
14524 /// let data = client.groups().members().create_export(42, &body)?;
14525 /// std::fs::write("ergebnis.xlsx", &data)?;
14526 /// # Ok(())
14527 /// # }
14528 /// ```
14529 pub fn create_export(&self, group_id: impl Display, body: &models::GroupMemberExportCreate) -> Result<Vec<u8>> {
14530 self.create_export_with(group_id, &Default::default(), body)
14531 }
14532
14533 /// Export visible group members with selected columns
14534 ///
14535 /// Like [`Self::create_export`], with query parameters.
14536 ///
14537 /// `POST /groups/{groupId}/members/export`
14538 ///
14539 /// Downloads the same membership scope as GET on this path, using an optional JSON config. Omitted/null/empty config uses the default columns; {template: allin} selects the full discovered catalog. For custom columns, send version 10 and ordered pinned/unpinned lists. person.id is always included, prepended when missing. Some person fields expand into multiple columns; pinned columns are frozen in XLSX. Unknown keys and malformed configurations are not reliably validated and may cause 500. Legacy version 9 is migrated internally but has known custom-column migration limitations; new clients should use version 10. The request is read-only and does not save the export configuration.
14540 pub fn create_export_with(&self, group_id: impl Display, query: &PostGroupsIdMembersExportQuery, body: &models::GroupMemberExportCreate) -> Result<Vec<u8>> {
14541 let path = format!("/groups/{}/members/export", seg(group_id));
14542 let query: Query = query.to_query();
14543 let body = serde_json::to_value(body).expect("request body serializes");
14544 self.client.request(Method::Post, &path, &query, Some(&body))
14545 }
14546
14547 /// Remove a person’s group membership
14548 ///
14549 /// `DELETE /groups/{groupId}/members/{personId}`
14550 ///
14551 /// Removes the membership linking groupId and personId. personId identifies the person, while data.id in membership responses identifies the membership record. The person record is retained. Viewing the group and its members is required, together with permission to delete members unless the current user is allowed to leave the group themselves. For an allowed self-service departure, autoAccept determines the outcome: true removes the membership immediately; false changes its status to to_delete (pending removal) and resets its role to the group type’s default role. After authorization, a missing or invisible membership is ignored and the endpoint still returns 204. A 204 response therefore does not guarantee that a membership was deleted.
14552 ///
14553 /// # Example
14554 ///
14555 /// ```no_run
14556 /// # use churchtools_api::*;
14557 /// # use churchtools_api::queries::*;
14558 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14559 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14560 /// client.groups().members().delete(42, 42)?;
14561 /// # Ok(())
14562 /// # }
14563 /// ```
14564 pub fn delete(&self, group_id: impl Display, person_id: impl Display) -> Result<()> {
14565 let path = format!("/groups/{}/members/{}", seg(group_id), seg(person_id));
14566 let query: Query = Query::new();
14567 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
14568 }
14569
14570 /// Get a person’s group membership
14571 ///
14572 /// `GET /groups/{groupId}/members/{personId}`
14573 ///
14574 /// Returns the visible membership linking groupId and personId. personId is the person’s ID, not the membership record ID returned in data.id. The role and status describe this membership; they do not describe the person’s memberships in other groups. Comments, the end date and additional member fields are subject to field permissions. Returns 404 when the membership does not exist or is not visible to the current user.
14575 ///
14576 /// # Example
14577 ///
14578 /// ```
14579 /// # use churchtools_api::*;
14580 /// # use churchtools_api::queries::*;
14581 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14582 /// # let client = churchtools_api::replay::client("get-groups-groupId-members-personId");
14583 /// let member = client.groups().members().get(42, 42)?;
14584 /// println!("{}", member.id);
14585 /// # Ok(())
14586 /// # }
14587 /// ```
14588 pub fn get(&self, group_id: impl Display, person_id: impl Display) -> Result<models::GroupMember> {
14589 let path = format!("/groups/{}/members/{}", seg(group_id), seg(person_id));
14590 let query: Query = Query::new();
14591 self.client.request_data(Method::Get, &path, &query, None)
14592 }
14593
14594 /// Export visible group members with the default columns
14595 ///
14596 /// `GET /groups/{groupId}/members/export`
14597 ///
14598 /// Downloads visible memberships of this group as CSV or XLSX. Archived persons and members hidden by the current user’s access rules are excluded; all membership workflow statuses are eligible. Default columns include person ID and name, role, membership status, comment, registering person, membership dates, waiting-list position and accessible group-specific member fields. Missing member-field values are represented by their configured defaults. Headers and formatted values use the current language. There is no pagination or explicit sort parameter. CSV is UTF-8 with semicolon separators. Use POST on this path to select columns; query config is ignored. A scope with no visible members yields no member rows.
14599 ///
14600 /// Use [`Self::get_export_with`] to pass query parameters.
14601 ///
14602 /// # Example
14603 ///
14604 /// ```no_run
14605 /// # use churchtools_api::*;
14606 /// # use churchtools_api::queries::*;
14607 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14608 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14609 /// let data = client.groups().members().get_export(42)?;
14610 /// std::fs::write("ergebnis.xlsx", &data)?;
14611 /// # Ok(())
14612 /// # }
14613 /// ```
14614 pub fn get_export(&self, group_id: impl Display) -> Result<Vec<u8>> {
14615 self.get_export_with(group_id, &Default::default())
14616 }
14617
14618 /// Export visible group members with the default columns
14619 ///
14620 /// Like [`Self::get_export`], with query parameters.
14621 ///
14622 /// `GET /groups/{groupId}/members/export`
14623 ///
14624 /// Downloads visible memberships of this group as CSV or XLSX. Archived persons and members hidden by the current user’s access rules are excluded; all membership workflow statuses are eligible. Default columns include person ID and name, role, membership status, comment, registering person, membership dates, waiting-list position and accessible group-specific member fields. Missing member-field values are represented by their configured defaults. Headers and formatted values use the current language. There is no pagination or explicit sort parameter. CSV is UTF-8 with semicolon separators. Use POST on this path to select columns; query config is ignored. A scope with no visible members yields no member rows.
14625 pub fn get_export_with(&self, group_id: impl Display, query: &GetGroupsGroupIdMembersExportQuery) -> Result<Vec<u8>> {
14626 let path = format!("/groups/{}/members/export", seg(group_id));
14627 let query: Query = query.to_query();
14628 self.client.request(Method::Get, &path, &query, None)
14629 }
14630
14631 /// List group memberships
14632 ///
14633 /// `GET /groups/{groupId}/members`
14634 ///
14635 /// Returns one page of visible memberships in this group. Each entry links a person to the group and includes their role and membership status. Memberships in all visible statuses are included unless group_member_statuses filters them. Filters are combined. Additional filters can use a group member field’s reference name or display name (=fieldValue), or a person-field key (person_=fieldValue). meta.count counts entries on the current page, meta.pagination.total counts filtered memberships across all pages, and meta.all counts visible memberships before applying filters. Additional person fields and enrichments must be requested explicitly.
14636 ///
14637 /// Use [`Self::list_with`] to pass query parameters.
14638 ///
14639 /// # Example
14640 ///
14641 /// ```
14642 /// # use churchtools_api::*;
14643 /// # use churchtools_api::queries::*;
14644 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14645 /// # let client = churchtools_api::replay::client("get-groups-id-members");
14646 /// for member in client.groups().members().list(42)? {
14647 /// println!("{}", member.id);
14648 /// }
14649 /// # Ok(())
14650 /// # }
14651 /// ```
14652 pub fn list(&self, group_id: impl Display) -> Result<Vec<models::GroupMember>> {
14653 self.list_with(group_id, &Default::default())
14654 }
14655
14656 /// List group memberships
14657 ///
14658 /// Like [`Self::list`], with query parameters.
14659 ///
14660 /// `GET /groups/{groupId}/members`
14661 ///
14662 /// Returns one page of visible memberships in this group. Each entry links a person to the group and includes their role and membership status. Memberships in all visible statuses are included unless group_member_statuses filters them. Filters are combined. Additional filters can use a group member field’s reference name or display name (=fieldValue), or a person-field key (person_=fieldValue). meta.count counts entries on the current page, meta.pagination.total counts filtered memberships across all pages, and meta.all counts visible memberships before applying filters. Additional person fields and enrichments must be requested explicitly.
14663 pub fn list_with(&self, group_id: impl Display, query: &GetGroupsIdMembersQuery) -> Result<Vec<models::GroupMember>> {
14664 let path = format!("/groups/{}/members", seg(group_id));
14665 let query: Query = query.to_query();
14666 self.client.collect_pages(&path, query)
14667 }
14668
14669 /// List group memberships
14670 ///
14671 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
14672 /// Breaking off early saves the remaining requests.
14673 pub fn list_iter(&self, group_id: impl Display, query: &GetGroupsIdMembersQuery) -> Items<models::GroupMember> {
14674 let path = format!("/groups/{}/members", seg(group_id));
14675 self.client.items(&path, query.to_query())
14676 }
14677
14678 /// List membership history with previous and current values
14679 ///
14680 /// `GET /groups/{groupId}/members/history`
14681 ///
14682 /// Returns legacy membership history for this group, newest entry ID first. Requires view group history or the internal +view history permission. member_id refers to the affected person and actor_id to the person who made the change. Change filters have precedence rather than being combined: new_role_id overrides new_status, which overrides new_fields/has_field_changed. The previous snapshot remains the actual linked predecessor even if it does not match the filters. To fetch older entries, pass the last returned id as offset_id; meta.count counts this batch, without a total or next cursor. Stored historical comments/field values are returned without individual person visibility or field security filtering.
14683 ///
14684 /// Use [`Self::list_history_with`] to pass query parameters.
14685 ///
14686 /// # Example
14687 ///
14688 /// ```
14689 /// # use churchtools_api::*;
14690 /// # use churchtools_api::queries::*;
14691 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14692 /// # let client = churchtools_api::replay::client("get-groups-groupId-members-history");
14693 /// for history in client.groups().members().list_history(42)? {
14694 /// println!("{}", history.id);
14695 /// }
14696 /// # Ok(())
14697 /// # }
14698 /// ```
14699 pub fn list_history(&self, group_id: impl Display) -> Result<Vec<models::GroupMemberHistoryEntry>> {
14700 self.list_history_with(group_id, &Default::default())
14701 }
14702
14703 /// List membership history with previous and current values
14704 ///
14705 /// Like [`Self::list_history`], with query parameters.
14706 ///
14707 /// `GET /groups/{groupId}/members/history`
14708 ///
14709 /// Returns legacy membership history for this group, newest entry ID first. Requires view group history or the internal +view history permission. member_id refers to the affected person and actor_id to the person who made the change. Change filters have precedence rather than being combined: new_role_id overrides new_status, which overrides new_fields/has_field_changed. The previous snapshot remains the actual linked predecessor even if it does not match the filters. To fetch older entries, pass the last returned id as offset_id; meta.count counts this batch, without a total or next cursor. Stored historical comments/field values are returned without individual person visibility or field security filtering.
14710 pub fn list_history_with(&self, group_id: impl Display, query: &GetGroupsGroupIdMembersHistoryQuery) -> Result<Vec<models::GroupMemberHistoryEntry>> {
14711 let path = format!("/groups/{}/members/history", seg(group_id));
14712 let query: Query = query.to_query();
14713 self.client.request_data(Method::Get, &path, &query, None)
14714 }
14715
14716 /// Get group meetings with attendance for one person
14717 ///
14718 /// `GET /groups/{groupId}/members/{personId}/meetings`
14719 ///
14720 /// Returns every meeting of the group, paired with the requested person’s attendance status. Requires permission to view the group and manage its meetings. Meetings without an attendance record are included with status null; canceled and completed meetings are also included. The endpoint does not verify that the person exists or is currently a group member. Results are not paginated and have no guaranteed order. Attendance statistics are not calculated.
14721 ///
14722 /// # Example
14723 ///
14724 /// ```
14725 /// # use churchtools_api::*;
14726 /// # use churchtools_api::queries::*;
14727 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14728 /// # let client = churchtools_api::replay::client("get-groups-groupId-members-personId-meetings");
14729 /// for meeting in client.groups().members().list_meetings(42, 42)? {
14730 /// println!("{:?}", meeting.status);
14731 /// }
14732 /// # Ok(())
14733 /// # }
14734 /// ```
14735 pub fn list_meetings(&self, group_id: impl Display, person_id: impl Display) -> Result<Vec<models::GroupMemberMeeting>> {
14736 let path = format!("/groups/{}/members/{}/meetings", seg(group_id), seg(person_id));
14737 let query: Query = Query::new();
14738 self.client.request_data(Method::Get, &path, &query, None)
14739 }
14740
14741 /// Get field statistics for selected group roles
14742 ///
14743 /// `GET /groups/{groupId}/members/statistics`
14744 ///
14745 /// Aggregates non-archived persons with a membership in this group and one of the requested group-type roles. Membership workflow status is not filtered. Requires permission to view the group and its members. Requested fields are included only if their security level is accessible; unknown or inaccessible fields are silently omitted. Person fields are selected by database field key, custom membership fields by numeric field ID. With no requested fields the result is empty. This is an unpaginated list; meta.count counts returned field statistics, not people. Person date fields return earliest/latest values including the corresponding person; requesting such a field when no non-null value exists currently reaches an unhandled empty-result path.
14746 ///
14747 /// # Example
14748 ///
14749 /// ```
14750 /// # use churchtools_api::*;
14751 /// # use churchtools_api::queries::*;
14752 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14753 /// # let client = churchtools_api::replay::client("get-groups-groupId-members-statistics");
14754 /// let query = GetGroupsGroupIdMembersStatisticsQuery {
14755 /// group_type_role_ids: Some(vec![8, 9]),
14756 /// ..Default::default()
14757 /// };
14758 /// for statistic in client.groups().members().list_statistics(42, &query)? {
14759 /// println!("{}", statistic.field_type);
14760 /// }
14761 /// # Ok(())
14762 /// # }
14763 /// ```
14764 pub fn list_statistics(&self, group_id: impl Display, query: &GetGroupsGroupIdMembersStatisticsQuery) -> Result<Vec<models::GroupMemberStatistic>> {
14765 let path = format!("/groups/{}/members/statistics", seg(group_id));
14766 let query: Query = query.to_query();
14767 self.client.request_data(Method::Get, &path, &query, None)
14768 }
14769
14770 /// Update an existing group membership
14771 ///
14772 /// `PATCH /groups/{groupId}/members/{personId}`
14773 ///
14774 /// Updates the membership linking this group and person; it does not create one. Use PUT to add a person. Requires permission to view group members, to edit changed membership properties and to edit submitted custom fields at their security levels. Omitted properties are preserved. The current backend incompletely checks changes supplied as null. Changes run transactionally, update history and recalculate the person’s growth path. Waiting-list processing is suppressed: set status and position explicitly when both must change. Date-only and UTC start timestamps are accepted, while the response formats the start as a date. An empty object is accepted but still runs update/history processing.
14775 ///
14776 /// # Example
14777 ///
14778 /// ```
14779 /// # use churchtools_api::*;
14780 /// # use churchtools_api::queries::*;
14781 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14782 /// # let client = churchtools_api::replay::client("patch-groups-groupId-members-personId");
14783 /// let body = models::MembershipUpdate {
14784 /// comment: Some(Some("Available on weekends.".into())),
14785 /// ..Default::default()
14786 /// };
14787 /// let result = client.groups().members().patch(42, 42, &body)?;
14788 /// println!("{}", result.id);
14789 /// # Ok(())
14790 /// # }
14791 /// ```
14792 pub fn patch(&self, group_id: impl Display, person_id: impl Display, body: &models::MembershipUpdate) -> Result<models::GroupMember> {
14793 let path = format!("/groups/{}/members/{}", seg(group_id), seg(person_id));
14794 let query: Query = Query::new();
14795 let body = serde_json::to_value(body).expect("request body serializes");
14796 self.client.request_data(Method::Patch, &path, &query, Some(&body))
14797 }
14798
14799 /// Add a person to a group
14800 ///
14801 /// `PUT /groups/{groupId}/members/{personId}`
14802 ///
14803 /// Creates a membership for the person identified in the path. Both creation and legacy updating return 200. Requires permission to view group members and add members; updating an existing membership additionally checks changed membership properties and custom-field security levels. Set only_add=true to reject existing memberships. Updating through PUT is deprecated in the backend; use PATCH for partial changes. The legacy update path clears omitted comments and end dates but preserves omitted status, role, start date and waiting-list position. Creation checks group capacity unless ignoreGroupFull is true; waiting-list capacity has a separate override. Changes update history, trigger membership events and recalculate the growth path. The response includes a legacy duplicate under data\["0"\] and a top-level deprecation mapping; use the regular data properties.
14804 ///
14805 /// # Example
14806 ///
14807 /// ```
14808 /// # use churchtools_api::*;
14809 /// # use churchtools_api::queries::*;
14810 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14811 /// # let client = churchtools_api::replay::client("put-groups-groupId-members-personId");
14812 /// let body = models::MembershipCreate {
14813 /// comment: Some(Some("Available on weekends.".into())),
14814 /// ..Default::default()
14815 /// };
14816 /// let result = client.groups().members().update(42, 42, &body)?;
14817 /// println!("{}", result.id);
14818 /// # Ok(())
14819 /// # }
14820 /// ```
14821 pub fn update(&self, group_id: impl Display, person_id: impl Display, body: &models::MembershipCreate) -> Result<models::PutGroupsGroupIdMembersPersonIdData> {
14822 let path = format!("/groups/{}/members/{}", seg(group_id), seg(person_id));
14823 let query: Query = Query::new();
14824 let body = serde_json::to_value(body).expect("request body serializes");
14825 self.client.request_data(Method::Put, &path, &query, Some(&body))
14826 }
14827
14828}
14829
14830/// `client.groups().members().documents()`
14831#[derive(Clone, Copy)]
14832pub struct GroupsMembersDocumentsResource<'a> {
14833 client: &'a Client,
14834}
14835
14836impl<'a> GroupsMembersDocumentsResource<'a> {
14837 /// `GET /groups/{groupId}/members/{memberId}/documents/{htmlTemplateId}`
14838 ///
14839 /// Get a document for a group member
14840 ///
14841 /// # Example
14842 ///
14843 /// ```no_run
14844 /// # use churchtools_api::*;
14845 /// # use churchtools_api::queries::*;
14846 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14847 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14848 /// client.groups().members().documents().get(42, 42, 2)?;
14849 /// # Ok(())
14850 /// # }
14851 /// ```
14852 pub fn get(&self, group_id: impl Display, member_id: impl Display, html_template_id: impl Display) -> Result<()> {
14853 let path = format!("/groups/{}/members/{}/documents/{}", seg(group_id), seg(member_id), seg(html_template_id));
14854 let query: Query = Query::new();
14855 self.client.request(Method::Get, &path, &query, None).map(|_| ())
14856 }
14857
14858}
14859
14860/// `client.groups().members().followups()`
14861#[derive(Clone, Copy)]
14862pub struct GroupsMembersFollowupsResource<'a> {
14863 client: &'a Client,
14864}
14865
14866impl<'a> GroupsMembersFollowupsResource<'a> {
14867 /// Create a follow-up for a group member
14868 ///
14869 /// `POST /groups/{groupId}/members/{personId}/followups`
14870 ///
14871 /// Creates a task concerning this person in the context of the group. The subject person is distinct from ownerId, which identifies who should handle the task. Requires visibility of the person and permission to administer follow-ups in this group; a configured success group additionally requires permission to add members there, or the corresponding group-type permission. Missing/null ownerId leaves this group-related task unassigned. Dates may be in the past, and no due date is required. A new task specification is created from title and display/success settings. The current backend allows creation without an existing membership, storing a null membershipId; create the membership first so it can be found through the membership list/statistics routes.
14872 ///
14873 /// # Example
14874 ///
14875 /// ```
14876 /// # use churchtools_api::*;
14877 /// # use churchtools_api::queries::*;
14878 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14879 /// # let client = churchtools_api::replay::client("post-groups-id-members-id-followups");
14880 /// let body = models::FollowUpCreate {
14881 /// title: "Call Peter".into(),
14882 /// ..Default::default()
14883 /// };
14884 /// let result = client.groups().members().followups().create(42, 42, &body)?;
14885 /// println!("{}", result.title);
14886 /// # Ok(())
14887 /// # }
14888 /// ```
14889 pub fn create(&self, group_id: impl Display, person_id: impl Display, body: &models::FollowUpCreate) -> Result<models::FollowUp2> {
14890 let path = format!("/groups/{}/members/{}/followups", seg(group_id), seg(person_id));
14891 let query: Query = Query::new();
14892 let body = serde_json::to_value(body).expect("request body serializes");
14893 self.client.request_data(Method::Post, &path, &query, Some(&body))
14894 }
14895
14896 /// Count follow-ups for one membership by due state
14897 ///
14898 /// `GET /groups/{groupId}/members/{personId}/followups/statistics`
14899 ///
14900 /// Counts tasks linked to the current membership record for this group/person pair, excluding person-only tasks and tasks linked to older memberships. Counts follow-ups in this group assigned to the current user, plus unassigned follow-ups where that user has group follow-up rights. Items assigned to other people and archived subject persons are excluded, matching the group list scope. Requires permission to administer or perform follow-ups in this group. The counters cover all matching records and ignore list pagination and filter parameters. Due states use the effective due date and the server’s current date; dismissed and completed follow-ups share countDone. An empty scope returns all five counters as zero. If the membership does not exist, the current backend dereferences null instead of returning zero counters.
14901 ///
14902 /// # Example
14903 ///
14904 /// ```
14905 /// # use churchtools_api::*;
14906 /// # use churchtools_api::queries::*;
14907 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14908 /// # let client = churchtools_api::replay::client("get-groups-id-members-id-followups-statistics");
14909 /// let statistic = client.groups().members().followups().get_statistics(42, 42)?;
14910 /// println!("{}", statistic.count_done);
14911 /// # Ok(())
14912 /// # }
14913 /// ```
14914 pub fn get_statistics(&self, group_id: impl Display, person_id: impl Display) -> Result<models::FollowUpStatistics> {
14915 let path = format!("/groups/{}/members/{}/followups/statistics", seg(group_id), seg(person_id));
14916 let query: Query = Query::new();
14917 self.client.request_data(Method::Get, &path, &query, None)
14918 }
14919
14920 /// List follow-ups for one group membership
14921 ///
14922 /// `GET /groups/{groupId}/members/{personId}/followups`
14923 ///
14924 /// Resolves the current membership linking this group and person, then lists follow-ups linked to that membership record ID. Follow-ups for an older deleted membership or person-only follow-ups are not included. Requires permission to administer or perform follow-ups in this group. Follow-ups whose subject person is archived are excluded. State filters are combined with OR; omission includes all states. Results are ordered by completion date descending, effective due date ascending, then ID. Pagination returns only meta.count for this page, without a total or last-page value. Results are restricted to the current owner and unassigned follow-ups in permitted groups; items assigned to others are omitted. A missing membership currently causes an unhandled null access rather than an empty list.
14925 ///
14926 /// Use [`Self::list_with`] to pass query parameters.
14927 ///
14928 /// # Example
14929 ///
14930 /// ```
14931 /// # use churchtools_api::*;
14932 /// # use churchtools_api::queries::*;
14933 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14934 /// # let client = churchtools_api::replay::client("get-groups-groupId-members-personId-followups");
14935 /// for followup in client.groups().members().followups().list(42, 42)? {
14936 /// println!("{}", followup.title);
14937 /// }
14938 /// # Ok(())
14939 /// # }
14940 /// ```
14941 pub fn list(&self, group_id: impl Display, person_id: impl Display) -> Result<Vec<models::FollowUp2>> {
14942 self.list_with(group_id, person_id, &Default::default())
14943 }
14944
14945 /// List follow-ups for one group membership
14946 ///
14947 /// Like [`Self::list`], with query parameters.
14948 ///
14949 /// `GET /groups/{groupId}/members/{personId}/followups`
14950 ///
14951 /// Resolves the current membership linking this group and person, then lists follow-ups linked to that membership record ID. Follow-ups for an older deleted membership or person-only follow-ups are not included. Requires permission to administer or perform follow-ups in this group. Follow-ups whose subject person is archived are excluded. State filters are combined with OR; omission includes all states. Results are ordered by completion date descending, effective due date ascending, then ID. Pagination returns only meta.count for this page, without a total or last-page value. Results are restricted to the current owner and unassigned follow-ups in permitted groups; items assigned to others are omitted. A missing membership currently causes an unhandled null access rather than an empty list.
14952 pub fn list_with(&self, group_id: impl Display, person_id: impl Display, query: &GetGroupsGroupIdMembersPersonIdFollowupsQuery) -> Result<Vec<models::FollowUp2>> {
14953 let path = format!("/groups/{}/members/{}/followups", seg(group_id), seg(person_id));
14954 let query: Query = query.to_query();
14955 self.client.collect_pages(&path, query)
14956 }
14957
14958 /// List follow-ups for one group membership
14959 ///
14960 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
14961 /// Breaking off early saves the remaining requests.
14962 pub fn list_iter(&self, group_id: impl Display, person_id: impl Display, query: &GetGroupsGroupIdMembersPersonIdFollowupsQuery) -> Items<models::FollowUp2> {
14963 let path = format!("/groups/{}/members/{}/followups", seg(group_id), seg(person_id));
14964 self.client.items(&path, query.to_query())
14965 }
14966
14967}
14968
14969/// `client.groups().members().routines()`
14970#[derive(Clone, Copy)]
14971pub struct GroupsMembersRoutinesResource<'a> {
14972 client: &'a Client,
14973}
14974
14975impl<'a> GroupsMembersRoutinesResource<'a> {
14976 /// Delete a membership routine and its binding
14977 ///
14978 /// `DELETE /groups/{groupId}/members/routines/{roleId}/{groupMemberStatus}`
14979 ///
14980 /// Deletes the binding for this exact group, group-type role and membership status, and also deletes the entire referenced routine and its steps. This is not an unlink-only operation. There is no delete-preview workflow. Requires authentication; this controller/service currently omit the group-specific permission checks used by the regular routine API. Missing bindings currently cause a server error rather than an idempotent 204 or a defined 404.
14981 ///
14982 /// # Example
14983 ///
14984 /// ```no_run
14985 /// # use churchtools_api::*;
14986 /// # use churchtools_api::queries::*;
14987 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14988 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
14989 /// client.groups().members().routines().delete(42, 12, "active")?;
14990 /// # Ok(())
14991 /// # }
14992 /// ```
14993 pub fn delete(&self, group_id: impl Display, role_id: impl Display, group_member_status: impl Display) -> Result<()> {
14994 let path = format!("/groups/{}/members/routines/{}/{}", seg(group_id), seg(role_id), seg(group_member_status));
14995 let query: Query = Query::new();
14996 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
14997 }
14998
14999 /// List routine bindings for membership roles and statuses
15000 ///
15001 /// `GET /groups/{groupId}/members/routines`
15002 ///
15003 /// Lists the routines bound to role/status combinations in this group, including disabled routines and their nested steps. A binding selects which automation applies to matching memberships; it is separate from the execution progress of any individual member. The list is not paginated and has no guaranteed ordering. Requires authentication; the current controller/service do not perform an additional group-specific permission check. A group with no bindings returns an empty list. Action data is converted from its stored form by the registered action handler before being returned.
15004 ///
15005 /// # Example
15006 ///
15007 /// ```
15008 /// # use churchtools_api::*;
15009 /// # use churchtools_api::queries::*;
15010 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15011 /// # let client = churchtools_api::replay::client("get-groups-groupId-members-routines");
15012 /// for routine in client.groups().members().routines().list(42)? {
15013 /// println!("{}", routine.id);
15014 /// }
15015 /// # Ok(())
15016 /// # }
15017 /// ```
15018 pub fn list(&self, group_id: impl Display) -> Result<Vec<models::GroupMembershipRoutine>> {
15019 let path = format!("/groups/{}/members/routines", seg(group_id));
15020 let query: Query = Query::new();
15021 self.client.request_data(Method::Get, &path, &query, None)
15022 }
15023
15024 /// Create a membership routine binding if absent
15025 ///
15026 /// `PUT /groups/{groupId}/members/routines/{roleId}/{groupMemberStatus}`
15027 ///
15028 /// Binds an existing empty routine to this exact group, group-type role and membership status. Create the routine first and provide its ID; a routine with existing steps is rejected with 422. The response includes the binding and nested routine. If the binding already exists, this request returns it unchanged and ignores the submitted routineId. Requires authentication; the current controller/service omit group-specific permission checks. This endpoint does not start executions or change routine steps. Missing/nonexistent routine IDs for a new binding currently cause a server error.
15029 ///
15030 /// # Example
15031 ///
15032 /// ```no_run
15033 /// # use churchtools_api::*;
15034 /// # use churchtools_api::queries::*;
15035 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15036 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15037 /// let body = models::GroupMembershipRoutineUpdate {
15038 /// routine_id: Some(5),
15039 /// ..Default::default()
15040 /// };
15041 /// let result = client.groups().members().routines().update(42, 12, "active", &body)?;
15042 /// println!("{}", result.id);
15043 /// # Ok(())
15044 /// # }
15045 /// ```
15046 pub fn update(&self, group_id: impl Display, role_id: impl Display, group_member_status: impl Display, body: &models::GroupMembershipRoutineUpdate) -> Result<models::GroupMembershipRoutine> {
15047 let path = format!("/groups/{}/members/routines/{}/{}", seg(group_id), seg(role_id), seg(group_member_status));
15048 let query: Query = Query::new();
15049 let body = serde_json::to_value(body).expect("request body serializes");
15050 self.client.request_data(Method::Put, &path, &query, Some(&body))
15051 }
15052
15053}
15054
15055/// `client.groups().news_letter_integrations()`
15056#[derive(Clone, Copy)]
15057pub struct GroupsNewsLetterIntegrationsResource<'a> {
15058 client: &'a Client,
15059}
15060
15061impl<'a> GroupsNewsLetterIntegrationsResource<'a> {
15062 /// Connect a group to an external newsletter list
15063 ///
15064 /// `POST /groups/{groupId}/newsletter-integrations`
15065 ///
15066 /// Creates a stored mapping and immediately starts synchronizing eligible active, non-archived members with email addresses. This request can create an external list, subscribe contacts and send confirmation emails. Requires visibility of the group and members plus the global churchgroup permission administer groups. Select an active provider and use exactly one of listId or createListName. A provider/list pair can belong to only one group. existingMembersHandling controls initial consent handling; optInRequired is retained for later sync. A successful response confirms the mapping was created, but individual contact synchronization can fail and is tracked separately. External provider operations cannot be undone by a local database rollback.
15067 ///
15068 /// # Example
15069 ///
15070 /// ```no_run
15071 /// # use churchtools_api::*;
15072 /// # use churchtools_api::queries::*;
15073 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15074 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15075 /// let body = models::NewsletterIntegrationGroupMappingCreate {
15076 /// opt_in_required: true,
15077 /// provider: "Mailjet".into(),
15078 /// ..Default::default()
15079 /// };
15080 /// let result = client.groups().news_letter_integrations().create(42, &body)?;
15081 /// println!("{}", result.id);
15082 /// # Ok(())
15083 /// # }
15084 /// ```
15085 pub fn create(&self, group_id: impl Display, body: &models::NewsletterIntegrationGroupMappingCreate) -> Result<models::NewsletterIntegrationGroupMapping> {
15086 let path = format!("/groups/{}/newsletter-integrations", seg(group_id));
15087 let query: Query = Query::new();
15088 let body = serde_json::to_value(body).expect("request body serializes");
15089 self.client.request_data(Method::Post, &path, &query, Some(&body))
15090 }
15091
15092 /// Remove a newsletter mapping and unsubscribe its contacts
15093 ///
15094 /// `DELETE /groups/{groupId}/newsletter-integrations/{provider}/{listId}`
15095 ///
15096 /// Removes this group/provider/list mapping and its local newsletter-person records, then unsubscribes their stored email addresses from the external list if the provider is active. The external list itself is retained. Requires visibility of the group and members plus the global churchgroup permission administer groups. A missing mapping is ignored and returns 204. Local deletion is committed before the provider call: a provider error may leave external subscriptions active after the local mapping is gone. When the provider is inactive or unknown, only local records are removed.
15097 ///
15098 /// # Example
15099 ///
15100 /// ```no_run
15101 /// # use churchtools_api::*;
15102 /// # use churchtools_api::queries::*;
15103 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15104 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15105 /// client.groups().news_letter_integrations().delete(42, "Mailjet", "12345")?;
15106 /// # Ok(())
15107 /// # }
15108 /// ```
15109 pub fn delete(&self, group_id: impl Display, provider: impl Display, list_id: impl Display) -> Result<()> {
15110 let path = format!("/groups/{}/newsletter-integrations/{}/{}", seg(group_id), seg(provider), seg(list_id));
15111 let query: Query = Query::new();
15112 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
15113 }
15114
15115 /// List a group’s newsletter list mappings
15116 ///
15117 /// `GET /groups/{groupId}/newsletter-integrations`
15118 ///
15119 /// Returns stored links to external newsletter lists, including disabled/unavailable providers. Requires visibility of the group and members plus the global churchgroup permission administer groups. This request does not contact newsletter providers or refresh list names/status. The unpaginated list has no defined order; meta.count is the number of mappings. An accessible group without mappings returns an empty list.
15120 ///
15121 /// # Example
15122 ///
15123 /// ```
15124 /// # use churchtools_api::*;
15125 /// # use churchtools_api::queries::*;
15126 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15127 /// # let client = churchtools_api::replay::client("get-groups-groupId-newsletter-integrations");
15128 /// for news_letter_integration in client.groups().news_letter_integrations().list(42)? {
15129 /// println!("{}", news_letter_integration.id);
15130 /// }
15131 /// # Ok(())
15132 /// # }
15133 /// ```
15134 pub fn list(&self, group_id: impl Display) -> Result<Vec<models::NewsletterIntegrationGroupMapping>> {
15135 let path = format!("/groups/{}/newsletter-integrations", seg(group_id));
15136 let query: Query = Query::new();
15137 self.client.request_data(Method::Get, &path, &query, None)
15138 }
15139
15140 /// Resend pending newsletter confirmation emails
15141 ///
15142 /// `POST /groups/{groupId}/newsletter-integrations/{provider}/{listId}/resend-optins`
15143 ///
15144 /// Sends ChurchTools confirmation emails again for eligible pending newsletter-person records in this mapping. Requires visibility of the group and members plus the global churchgroup permission "administer groups". Selecting one recipient with `person_id` additionally requires visibility of that person. Candidates must have an active membership, a non-archived person, no successful synchronization, no unsubscribe date and no confirmed double opt-in. Previously sent requests are included; each recipient gets a new token, invalidating the old link. Email addresses already synchronized for the same list are excluded and candidates are grouped by stored email. Without `person_id`, missing mappings and empty candidate sets return `204`. With `person_id`, no eligible candidate returns `404`. No count is returned. The current handler does not check `optInRequired`, provider activation or whether the provider handles double opt-in itself.
15145 ///
15146 /// Use [`Self::resend_optins_with`] to pass query parameters.
15147 ///
15148 /// # Example
15149 ///
15150 /// ```no_run
15151 /// # use churchtools_api::*;
15152 /// # use churchtools_api::queries::*;
15153 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15154 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15155 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
15156 /// client.groups().news_letter_integrations().resend_optins(42, "Mailjet", "12345", &body)?;
15157 /// # Ok(())
15158 /// # }
15159 /// ```
15160 pub fn resend_optins(&self, group_id: impl Display, provider: impl Display, list_id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<()> {
15161 self.resend_optins_with(group_id, provider, list_id, &Default::default(), body)
15162 }
15163
15164 /// Resend pending newsletter confirmation emails
15165 ///
15166 /// Like [`Self::resend_optins`], with query parameters.
15167 ///
15168 /// `POST /groups/{groupId}/newsletter-integrations/{provider}/{listId}/resend-optins`
15169 ///
15170 /// Sends ChurchTools confirmation emails again for eligible pending newsletter-person records in this mapping. Requires visibility of the group and members plus the global churchgroup permission "administer groups". Selecting one recipient with `person_id` additionally requires visibility of that person. Candidates must have an active membership, a non-archived person, no successful synchronization, no unsubscribe date and no confirmed double opt-in. Previously sent requests are included; each recipient gets a new token, invalidating the old link. Email addresses already synchronized for the same list are excluded and candidates are grouped by stored email. Without `person_id`, missing mappings and empty candidate sets return `204`. With `person_id`, no eligible candidate returns `404`. No count is returned. The current handler does not check `optInRequired`, provider activation or whether the provider handles double opt-in itself.
15171 pub fn resend_optins_with(&self, group_id: impl Display, provider: impl Display, list_id: impl Display, query: &PostGroupsGroupIdNewsletterIntegrationsProviderListIdResendOptinsQuery, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<()> {
15172 let path = format!("/groups/{}/newsletter-integrations/{}/{}/resend-optins", seg(group_id), seg(provider), seg(list_id));
15173 let query: Query = query.to_query();
15174 let body = serde_json::to_value(body).expect("request body serializes");
15175 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
15176 }
15177
15178}
15179
15180/// `client.groups().parents()`
15181#[derive(Clone, Copy)]
15182pub struct GroupsParentsResource<'a> {
15183 client: &'a Client,
15184}
15185
15186impl<'a> GroupsParentsResource<'a> {
15187 /// Remove a direct parent-group relationship
15188 ///
15189 /// `DELETE /groups/{groupId}/parents/{parentGroupId}`
15190 ///
15191 /// Removes only the direct hierarchy edge from parentGroupId to groupId; both groups and their memberships remain. Other paths through the hierarchy are unaffected, so the parent may still be an indirect ancestor. Requires global group administration or hierarchy/group editing permission for both endpoints. A missing relationship is ignored and returns 204. Successful processing invalidates the authorization cache because hierarchy changes can affect inherited permissions.
15192 ///
15193 /// # Example
15194 ///
15195 /// ```no_run
15196 /// # use churchtools_api::*;
15197 /// # use churchtools_api::queries::*;
15198 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15199 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15200 /// client.groups().parents().delete(42, 12)?;
15201 /// # Ok(())
15202 /// # }
15203 /// ```
15204 pub fn delete(&self, group_id: impl Display, parent_group_id: impl Display) -> Result<()> {
15205 let path = format!("/groups/{}/parents/{}", seg(group_id), seg(parent_group_id));
15206 let query: Query = Query::new();
15207 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
15208 }
15209
15210 /// Get child groups
15211 ///
15212 /// `GET /groups/{groupId}/parents`
15213 ///
15214 /// Use [`Self::list_with`] to pass query parameters.
15215 ///
15216 /// # Example
15217 ///
15218 /// ```
15219 /// # use churchtools_api::*;
15220 /// # use churchtools_api::queries::*;
15221 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15222 /// # let client = churchtools_api::replay::client("get-groups-groupId-parents");
15223 /// for parent in client.groups().parents().list("abc123")? {
15224 /// println!("{}", parent.title);
15225 /// }
15226 /// # Ok(())
15227 /// # }
15228 /// ```
15229 pub fn list(&self, group_id: impl Display) -> Result<Vec<models::DomainObjectGroup>> {
15230 self.list_with(group_id, &Default::default())
15231 }
15232
15233 /// Get child groups
15234 ///
15235 /// Like [`Self::list`], with query parameters.
15236 ///
15237 /// `GET /groups/{groupId}/parents`
15238 pub fn list_with(&self, group_id: impl Display, query: &GetGroupsGroupIdParentsQuery) -> Result<Vec<models::DomainObjectGroup>> {
15239 let path = format!("/groups/{}/parents", seg(group_id));
15240 let query: Query = query.to_query();
15241 self.client.collect_pages(&path, query)
15242 }
15243
15244 /// Get child groups
15245 ///
15246 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
15247 /// Breaking off early saves the remaining requests.
15248 pub fn list_iter(&self, group_id: impl Display, query: &GetGroupsGroupIdParentsQuery) -> Items<models::DomainObjectGroup> {
15249 let path = format!("/groups/{}/parents", seg(group_id));
15250 self.client.items(&path, query.to_query())
15251 }
15252
15253 /// Add a direct parent-group relationship
15254 ///
15255 /// `PUT /groups/{groupId}/parents/{parentGroupId}`
15256 ///
15257 /// Adds parentGroupId as a direct parent of groupId. Groups can have multiple parents; this adds an edge rather than replacing existing parents, and does not copy memberships. Requires global group administration or hierarchy/group editing permission for both groups. Self-parenting and a relationship that would create a cycle are rejected with 400. An existing direct relationship also returns 400, so repeating a successful PUT is not an idempotent success. Success returns 201 without a JSON body and invalidates the authorization cache because the hierarchy can affect inherited permissions.
15258 ///
15259 /// # Example
15260 ///
15261 /// ```no_run
15262 /// # use churchtools_api::*;
15263 /// # use churchtools_api::queries::*;
15264 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15265 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15266 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
15267 /// client.groups().parents().update(42, 12, &body)?;
15268 /// # Ok(())
15269 /// # }
15270 /// ```
15271 pub fn update(&self, group_id: impl Display, parent_group_id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<()> {
15272 let path = format!("/groups/{}/parents/{}", seg(group_id), seg(parent_group_id));
15273 let query: Query = Query::new();
15274 let body = serde_json::to_value(body).expect("request body serializes");
15275 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
15276 }
15277
15278}
15279
15280/// `client.groups().qrcode_checkin()`
15281#[derive(Clone, Copy)]
15282pub struct GroupsQrcodeCheckinResource<'a> {
15283 client: &'a Client,
15284}
15285
15286impl<'a> GroupsQrcodeCheckinResource<'a> {
15287 /// Get an existing check-in ticket for a person
15288 ///
15289 /// `GET /groups/{groupId}/qrcodecheckin/{personId}`
15290 ///
15291 /// Returns the stored ticket for this person and group, without generating one or recording attendance. The current user may retrieve their own ticket. Retrieving another person’s ticket requires group/group-type membership editing permission or internal edit basic group memberships. Returns 404 when no matching ticket exists. The lookup does not recheck current ticket eligibility, expiry, use or QR-check-in activation; inspect the lifecycle fields separately. No meta envelope is returned.
15292 ///
15293 /// # Example
15294 ///
15295 /// ```
15296 /// # use churchtools_api::*;
15297 /// # use churchtools_api::queries::*;
15298 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15299 /// # let client = churchtools_api::replay::client("get-groups-id-qrcodecheckin-personId");
15300 /// let qrcode_checkin = client.groups().qrcode_checkin().get(42, 42)?;
15301 /// println!("{}", qrcode_checkin.domain_id);
15302 /// # Ok(())
15303 /// # }
15304 /// ```
15305 pub fn get(&self, group_id: impl Display, person_id: impl Display) -> Result<models::GroupQRCodeCheckin> {
15306 let path = format!("/groups/{}/qrcodecheckin/{}", seg(group_id), seg(person_id));
15307 let query: Query = Query::new();
15308 self.client.request_data(Method::Get, &path, &query, None)
15309 }
15310
15311 /// Generate a PDF download link for an existing check-in ticket
15312 ///
15313 /// `GET /groups/{groupId}/qrcodecheckin/{personId}/pdf`
15314 ///
15315 /// Generates a PDF containing the stored ticket’s QR code and returns its absolute download URL as JSON; this endpoint does not stream PDF bytes. The current user may request their own ticket, while another person’s ticket requires group/group-type membership editing permission or internal edit basic group memberships. A matching ticket must already exist; otherwise 404 is returned. Generating the link updates downloadedDate immediately, before any download occurs. This GET therefore writes state and creates a file. The lookup does not recheck QR-check-in activation, current role/membership eligibility or ticket lifecycle validity.
15316 ///
15317 /// # Example
15318 ///
15319 /// ```
15320 /// # use churchtools_api::*;
15321 /// # use churchtools_api::queries::*;
15322 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15323 /// # let client = churchtools_api::replay::client("get-groups-id-qrcodecheckin-personId-pdf");
15324 /// let pdf = client.groups().qrcode_checkin().get_pdf(42, 42)?;
15325 /// println!("{}", pdf.url);
15326 /// # Ok(())
15327 /// # }
15328 /// ```
15329 pub fn get_pdf(&self, group_id: impl Display, person_id: impl Display) -> Result<models::GetGroupsIdQrcodecheckinPersonIdPdfData> {
15330 let path = format!("/groups/{}/qrcodecheckin/{}/pdf", seg(group_id), seg(person_id));
15331 let query: Query = Query::new();
15332 self.client.request_data(Method::Get, &path, &query, None)
15333 }
15334
15335 /// List accessible check-in tickets for a group
15336 ///
15337 /// `GET /groups/{groupId}/qrcodecheckin`
15338 ///
15339 /// Returns existing stored tickets; it does not generate missing tickets or record attendance. Users with one of the group/group-type membership editing permissions or internal edit basic group memberships can retrieve all group tickets. Other authenticated users receive only their own ticket, wrapped in an array, or data=null when they have none. The privileged empty result is \[\] instead. Results are unpaginated and have no defined order or meta envelope. This lookup does not filter ticket expiry/use or recheck current QR-check-in enablement, role eligibility or active membership.
15340 ///
15341 /// # Example
15342 ///
15343 /// ```
15344 /// # use churchtools_api::*;
15345 /// # use churchtools_api::queries::*;
15346 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15347 /// # let client = churchtools_api::replay::client("get-groups-id-qrcodecheckin");
15348 /// let result = client.groups().qrcode_checkin().list(42)?;
15349 /// println!("{:?}", result);
15350 /// # Ok(())
15351 /// # }
15352 /// ```
15353 pub fn list(&self, group_id: impl Display) -> Result<Option<Vec<models::GroupQRCodeCheckin>>> {
15354 let path = format!("/groups/{}/qrcodecheckin", seg(group_id));
15355 let query: Query = Query::new();
15356 self.client.request_data(Method::Get, &path, &query, None)
15357 }
15358
15359 /// Queue an existing check-in ticket for email
15360 ///
15361 /// `POST /groups/{groupId}/qrcodecheckin/{personId}/send`
15362 ///
15363 /// Queues a PDF ticket email and returns the current ticket, normally with isQueued=true while processing is pending. The current user may request their own ticket; sending another person’s ticket requires group/group-type membership editing permission or internal edit basic group memberships. A ticket must already exist. The subject person is preferred as recipient when they have an email and are not archived; otherwise the service attempts the membership’s registeredBy person. Already queued tickets are unchanged. With no eligible recipient this request still returns 200 without queuing. A previously sent ticket can be queued again. The worker generates the attachment and later updates sentDate/isQueued; this response does not confirm delivery. No request body selects recipients or content.
15364 ///
15365 /// # Example
15366 ///
15367 /// ```no_run
15368 /// # use churchtools_api::*;
15369 /// # use churchtools_api::queries::*;
15370 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15371 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15372 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
15373 /// let qrcode_checkin = client.groups().qrcode_checkin().send(42, 42, &body)?;
15374 /// println!("{}", qrcode_checkin.domain_id);
15375 /// # Ok(())
15376 /// # }
15377 /// ```
15378 pub fn send(&self, group_id: impl Display, person_id: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<models::GroupQRCodeCheckin> {
15379 let path = format!("/groups/{}/qrcodecheckin/{}/send", seg(group_id), seg(person_id));
15380 let query: Query = Query::new();
15381 let body = serde_json::to_value(body).expect("request body serializes");
15382 self.client.request_data(Method::Post, &path, &query, Some(&body))
15383 }
15384
15385}
15386
15387/// `client.groups().roles()`
15388#[derive(Clone, Copy)]
15389pub struct GroupsRolesResource<'a> {
15390 client: &'a Client,
15391}
15392
15393impl<'a> GroupsRolesResource<'a> {
15394 /// Get all roles for this group
15395 ///
15396 /// `GET /groups/{groupId}/roles`
15397 ///
15398 /// Returns the roles configured for one group, including inactive roles. Each entry combines a shared role definition from the group's type with settings specific to this group, such as chat access, check-in QR codes and participant capacity.
15399 /// id is the group-specific role settings ID used by PATCH /groups/{groupId}/roles/{roleId}. groupTypeRoleId links to the shared definition from GET /group/roles; do not interchange these IDs. isActive describes whether the role is enabled in this group, not the membership status of any person.
15400 /// Requires authentication and permission to view the group. Accepts its numeric ID or chat GUID. Results are not paginated and are sorted by the shared role's type and sortKey ascending. meta.count includes all returned roles.
15401 ///
15402 /// # Example
15403 ///
15404 /// ```
15405 /// # use churchtools_api::*;
15406 /// # use churchtools_api::queries::*;
15407 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15408 /// # let client = churchtools_api::replay::client("get-groups-id-roles");
15409 /// for role in client.groups().roles().list(serde_json::json!(42))? {
15410 /// println!("{}", role.name);
15411 /// }
15412 /// # Ok(())
15413 /// # }
15414 /// ```
15415 pub fn list(&self, group_id: impl Display) -> Result<Vec<models::GroupRole>> {
15416 let path = format!("/groups/{}/roles", seg(group_id));
15417 let query: Query = Query::new();
15418 self.client.request_data(Method::Get, &path, &query, None)
15419 }
15420
15421 /// Update role settings for a group
15422 ///
15423 /// `PATCH /groups/{groupId}/roles/{roleId}`
15424 ///
15425 /// Updates settings for one role in one group. Use the entry's id from GET /groups/{groupId}/roles as roleId, not its groupTypeRoleId. This does not rename or reclassify the shared role definition.
15426 /// Send only the settings to change. Omitted fields are preserved. growPathId=null clears the growth-path association; htmlTemplateIds=\[\] clears the template list. A supplied template list replaces the previous list. The default role cannot be deactivated. Returns the complete updated GroupRole in data, without meta.
15427 /// Requires authentication and permission to view the group. Chat settings require one of administer groups, edit group, edit groups of grouptype or +admin group chat for this group. The other role settings except htmlTemplateIds require one of administer groups, edit group or edit groups of grouptype. Adding document templates requires one of administer groups, edit group, edit groups of grouptype or +edit group basic settings, plus the churchcore permission use church html templates for each added template. Templates must belong to the group-membership document domain.
15428 ///
15429 /// # Example
15430 ///
15431 /// ```no_run
15432 /// # use churchtools_api::*;
15433 /// # use churchtools_api::queries::*;
15434 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15435 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15436 /// let body = models::GroupRoleUpdate {
15437 /// can_read_chat: Some(true),
15438 /// ..Default::default()
15439 /// };
15440 /// let result = client.groups().roles().patch(42, 1, &body)?;
15441 /// println!("{}", result.name);
15442 /// # Ok(())
15443 /// # }
15444 /// ```
15445 pub fn patch(&self, group_id: impl Display, role_id: impl Display, body: &models::GroupRoleUpdate) -> Result<models::GroupRole> {
15446 let path = format!("/groups/{}/roles/{}", seg(group_id), seg(role_id));
15447 let query: Query = Query::new();
15448 let body = serde_json::to_value(body).expect("request body serializes");
15449 self.client.request_data(Method::Patch, &path, &query, Some(&body))
15450 }
15451
15452}
15453
15454/// `client.groups().wiki()`
15455#[derive(Clone, Copy)]
15456pub struct GroupsWikiResource<'a> {
15457 client: &'a Client,
15458}
15459
15460impl<'a> GroupsWikiResource<'a> {
15461 pub fn categories(&self) -> GroupsWikiCategoriesResource<'a> {
15462 GroupsWikiCategoriesResource { client: self.client }
15463 }
15464
15465}
15466
15467/// `client.groups().wiki().categories()`
15468#[derive(Clone, Copy)]
15469pub struct GroupsWikiCategoriesResource<'a> {
15470 client: &'a Client,
15471}
15472
15473impl<'a> GroupsWikiCategoriesResource<'a> {
15474 /// List wiki categories and recent pages from the current group role
15475 ///
15476 /// `GET /groups/{groupId}/wiki/categories/pages`
15477 ///
15478 /// Requires group visibility and a current active, non-archived membership. Categories are selected from view-category rights attached directly to this membership’s group role and then checked against the current user’s effective wiki permissions. Global wiki access alone does not add categories to this group-specific list; without a matching role/category grant the result is empty. Categories are ordered by sortKey then ID. Each category contains up to limit latest-version pages, sorted by modification date descending then title; total counts eligible pages before that limit. System pages are filtered by the wiki repository rules. Redirect pages are not removed. Page text and previews are omitted. meta.count counts returned categories, not pages; there is no page-number parameter.
15479 ///
15480 /// Use [`Self::list_pages_with`] to pass query parameters.
15481 ///
15482 /// # Example
15483 ///
15484 /// ```
15485 /// # use churchtools_api::*;
15486 /// # use churchtools_api::queries::*;
15487 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15488 /// # let client = churchtools_api::replay::client("get-groups-id-wiki-categories-pages");
15489 /// for page in client.groups().wiki().categories().list_pages(42)? {
15490 /// println!("{}", page.total);
15491 /// }
15492 /// # Ok(())
15493 /// # }
15494 /// ```
15495 pub fn list_pages(&self, group_id: impl Display) -> Result<Vec<models::GroupWikiCategoryPagesItem>> {
15496 self.list_pages_with(group_id, &Default::default())
15497 }
15498
15499 /// List wiki categories and recent pages from the current group role
15500 ///
15501 /// Like [`Self::list_pages`], with query parameters.
15502 ///
15503 /// `GET /groups/{groupId}/wiki/categories/pages`
15504 ///
15505 /// Requires group visibility and a current active, non-archived membership. Categories are selected from view-category rights attached directly to this membership’s group role and then checked against the current user’s effective wiki permissions. Global wiki access alone does not add categories to this group-specific list; without a matching role/category grant the result is empty. Categories are ordered by sortKey then ID. Each category contains up to limit latest-version pages, sorted by modification date descending then title; total counts eligible pages before that limit. System pages are filtered by the wiki repository rules. Redirect pages are not removed. Page text and previews are omitted. meta.count counts returned categories, not pages; there is no page-number parameter.
15506 pub fn list_pages_with(&self, group_id: impl Display, query: &GetGroupsIdWikiCategoriesPagesQuery) -> Result<Vec<models::GroupWikiCategoryPagesItem>> {
15507 let path = format!("/groups/{}/wiki/categories/pages", seg(group_id));
15508 let query: Query = query.to_query();
15509 self.client.request_data(Method::Get, &path, &query, None)
15510 }
15511
15512}
15513
15514/// `client.history()`
15515#[derive(Clone, Copy)]
15516pub struct HistoryResource<'a> {
15517 client: &'a Client,
15518}
15519
15520impl<'a> HistoryResource<'a> {
15521 /// Get History
15522 ///
15523 /// `GET /history`
15524 ///
15525 /// Get history entries with links to domain objects.
15526 ///
15527 /// # Example
15528 ///
15529 /// ```
15530 /// # use churchtools_api::*;
15531 /// # use churchtools_api::queries::*;
15532 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15533 /// # let client = churchtools_api::replay::client("get-history");
15534 /// let query = GetHistoryQuery {
15535 /// domain_types: Some(vec!["beispiel".into()]),
15536 /// domain_identifiers: Some(vec!["beispiel".into()]),
15537 /// ..Default::default()
15538 /// };
15539 /// for history in client.history().list(&query)? {
15540 /// println!("{}", history.id);
15541 /// }
15542 /// # Ok(())
15543 /// # }
15544 /// ```
15545 pub fn list(&self, query: &GetHistoryQuery) -> Result<Vec<models::HistoryEntry>> {
15546 let path = "/history".to_owned();
15547 let query: Query = query.to_query();
15548 self.client.collect_pages(&path, query)
15549 }
15550
15551 /// Get History
15552 ///
15553 /// Like [`Self::list`], but lazy: each page is fetched only when the iteration reaches it.
15554 /// Breaking off early saves the remaining requests.
15555 pub fn list_iter(&self, query: &GetHistoryQuery) -> Items<models::HistoryEntry> {
15556 let path = "/history".to_owned();
15557 self.client.items(&path, query.to_query())
15558 }
15559
15560}
15561
15562/// `client.html_templates()`
15563#[derive(Clone, Copy)]
15564pub struct HtmlTemplatesResource<'a> {
15565 client: &'a Client,
15566}
15567
15568impl<'a> HtmlTemplatesResource<'a> {
15569 /// Create a private or shared HTML template
15570 ///
15571 /// `POST /htmltemplates`
15572 ///
15573 /// Creates metadata and optional independent HTML/MJML files. The current user becomes owner even for a global template. email and bulkletter allow private templates (isGlobal defaults to false); groupmember-document and both donation-receipt types require isGlobal=true. Global creation requires the matching template domain’s administration permission. Neither source is required, so an empty template can be created. Source text is stored without rendering placeholders or compiling MJML. copyAssetsFromId copies only image files after template creation has committed; a copy failure can leave the new template and some assets in place. The current copy path does not check visibility of the source template.
15574 ///
15575 /// # Example
15576 ///
15577 /// ```
15578 /// # use churchtools_api::*;
15579 /// # use churchtools_api::queries::*;
15580 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15581 /// # let client = churchtools_api::replay::client("post-htmltemplates");
15582 /// let body = models::HtmlTemplateCreate {
15583 /// domain_type: "email".into(),
15584 /// name: "Welcome email".into(),
15585 /// ..Default::default()
15586 /// };
15587 /// let result = client.html_templates().create(&body)?;
15588 /// println!("{}", result.name);
15589 /// # Ok(())
15590 /// # }
15591 /// ```
15592 pub fn create(&self, body: &models::HtmlTemplateCreate) -> Result<models::HtmlTemplate> {
15593 let path = "/htmltemplates".to_owned();
15594 let query: Query = Query::new();
15595 let body = serde_json::to_value(body).expect("request body serializes");
15596 self.client.request_data(Method::Post, &path, &query, Some(&body))
15597 }
15598
15599 /// Check dependencies or delete an HTML template
15600 ///
15601 /// `DELETE /htmltemplates/{templateId}`
15602 ///
15603 /// Requires permission to edit the template (ownership or the domain’s global-template editing permission). Send dryRun explicitly. dryRun=true always returns 409 with a dependency report, even when deletion is allowed; it never returns a successful 204 preview. dryRun=false deletes an unblocked template, its HTML/MJML content files and image assets, then returns 204 without a body. References from group membership emails, bulk letters and group-role document configuration can block deletion, along with registered database dependency checks. An already missing template returns 404. Deleting a global template also invalidates cached authorization data.
15604 ///
15605 /// # Example
15606 ///
15607 /// ```no_run
15608 /// # use churchtools_api::*;
15609 /// # use churchtools_api::queries::*;
15610 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15611 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15612 /// let query = DeleteHtmltemplatesTemplateIdQuery {
15613 /// dry_run: Some(true),
15614 /// ..Default::default()
15615 /// };
15616 /// client.html_templates().delete(2, &query)?;
15617 /// # Ok(())
15618 /// # }
15619 /// ```
15620 pub fn delete(&self, template_id: impl Display, query: &DeleteHtmltemplatesTemplateIdQuery) -> Result<()> {
15621 let path = format!("/htmltemplates/{}", seg(template_id));
15622 let query: Query = query.to_query();
15623 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
15624 }
15625
15626 /// Get HTML template metadata
15627 ///
15628 /// `GET /htmltemplates/{templateId}`
15629 ///
15630 /// Returns metadata and content-file IDs for one visible template. Owners may view their own private or global templates; other users need the matching domain’s permission to view a global template. This endpoint does not return HTML/MJML source or asset contents. Use the html/mjml content routes or export for those. A template may exist with both content-file IDs null. Missing templates return 404; an existing inaccessible template returns 403.
15631 ///
15632 /// # Example
15633 ///
15634 /// ```
15635 /// # use churchtools_api::*;
15636 /// # use churchtools_api::queries::*;
15637 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15638 /// # let client = churchtools_api::replay::client("get-htmltemplates-templateId");
15639 /// let html_template = client.html_templates().get(2)?;
15640 /// println!("{}", html_template.name);
15641 /// # Ok(())
15642 /// # }
15643 /// ```
15644 pub fn get(&self, template_id: impl Display) -> Result<models::HtmlTemplate> {
15645 let path = format!("/htmltemplates/{}", seg(template_id));
15646 let query: Query = Query::new();
15647 self.client.request_data(Method::Get, &path, &query, None)
15648 }
15649
15650 /// Create a downloadable template export
15651 ///
15652 /// `GET /htmltemplates/{templateId}/export`
15653 ///
15654 /// Requires the same template visibility as GET /htmltemplates/{templateId}. Generates and stores a JSON export file, then returns its relative download URL in data; the export is not embedded in this response. The file contains name, domainType, html, mjml and assets. Each asset contains its name, fileHash and base64-encoded content. Ownership, global/private state and template metadata are not exported. The export file is scheduled for deletion after 30 days. This GET creates a new stored file on each call; missing content files or asset failures can prevent export.
15655 ///
15656 /// # Example
15657 ///
15658 /// ```
15659 /// # use churchtools_api::*;
15660 /// # use churchtools_api::queries::*;
15661 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15662 /// # let client = churchtools_api::replay::client("get-htmltemplates-templateId-export");
15663 /// let result = client.html_templates().get_export(2)?;
15664 /// println!("{:?}", result);
15665 /// # Ok(())
15666 /// # }
15667 /// ```
15668 pub fn get_export(&self, template_id: impl Display) -> Result<String> {
15669 let path = format!("/htmltemplates/{}/export", seg(template_id));
15670 let query: Query = Query::new();
15671 self.client.request_data(Method::Get, &path, &query, None)
15672 }
15673
15674 /// Read stored HTML template source
15675 ///
15676 /// `GET /htmltemplates/{templateId}/html`
15677 ///
15678 /// Returns the HTML source as a string inside the JSON data property. Requires template ownership or permission to view the global template. No placeholders are rendered, HTML is not sanitized by this read endpoint, and stored MJML is not compiled as a fallback. data=null means no HTML file is attached; an attached but missing file instead results in 404. The response is application/json rather than text/html.
15679 ///
15680 /// # Example
15681 ///
15682 /// ```
15683 /// # use churchtools_api::*;
15684 /// # use churchtools_api::queries::*;
15685 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15686 /// # let client = churchtools_api::replay::client("get-htmltemplates-templateId-html");
15687 /// let result = client.html_templates().get_html(2)?;
15688 /// println!("{:?}", result);
15689 /// # Ok(())
15690 /// # }
15691 /// ```
15692 pub fn get_html(&self, template_id: impl Display) -> Result<Option<String>> {
15693 let path = format!("/htmltemplates/{}/html", seg(template_id));
15694 let query: Query = Query::new();
15695 self.client.request_data(Method::Get, &path, &query, None)
15696 }
15697
15698 /// Read stored MJML template source
15699 ///
15700 /// `GET /htmltemplates/{templateId}/mjml`
15701 ///
15702 /// Returns the MJML editor source as a string inside the JSON data property. Requires template ownership or permission to view the global template. The source is returned unchanged, without compilation, placeholder rendering or validation; no MJML is inferred from an HTML file. data=null means no MJML file is attached. A referenced but missing content file results in 404. The response has no meta envelope.
15703 ///
15704 /// # Example
15705 ///
15706 /// ```
15707 /// # use churchtools_api::*;
15708 /// # use churchtools_api::queries::*;
15709 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15710 /// # let client = churchtools_api::replay::client("get-htmltemplates-templateId-mjml");
15711 /// let result = client.html_templates().get_mjml(2)?;
15712 /// println!("{:?}", result);
15713 /// # Ok(())
15714 /// # }
15715 /// ```
15716 pub fn get_mjml(&self, template_id: impl Display) -> Result<Option<String>> {
15717 let path = format!("/htmltemplates/{}/mjml", seg(template_id));
15718 let query: Query = Query::new();
15719 self.client.request_data(Method::Get, &path, &query, None)
15720 }
15721
15722 /// List visible templates for one purpose
15723 ///
15724 /// `GET /htmltemplates`
15725 ///
15726 /// Lists templates of exactly one required domain type, ordered by name. By default it includes the current user’s own templates and global templates allowed by the corresponding domain policy. Global does not mean public. onlyOwn=true filters by ownership, so it can include global templates owned by the current user. Other users’ private templates are omitted. The response contains metadata and file IDs, not source text or assets. Results are unpaginated; meta.count counts returned templates. domain_type is required unless its deprecated alias type is supplied; there is no default domain.
15727 ///
15728 /// # Example
15729 ///
15730 /// ```
15731 /// # use churchtools_api::*;
15732 /// # use churchtools_api::queries::*;
15733 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15734 /// # let client = churchtools_api::replay::client("get-htmltemplates");
15735 /// let query = GetHtmltemplatesQuery {
15736 /// domain_type: Some("email".into()),
15737 /// ..Default::default()
15738 /// };
15739 /// for html_template in client.html_templates().list(&query)? {
15740 /// println!("{}", html_template.name);
15741 /// }
15742 /// # Ok(())
15743 /// # }
15744 /// ```
15745 pub fn list(&self, query: &GetHtmltemplatesQuery) -> Result<Vec<models::HtmlTemplate>> {
15746 let path = "/htmltemplates".to_owned();
15747 let query: Query = query.to_query();
15748 self.client.request_data(Method::Get, &path, &query, None)
15749 }
15750
15751 /// Update template metadata or replace source content
15752 ///
15753 /// `PATCH /htmltemplates/{templateId}`
15754 ///
15755 /// Requires template editing permission. If the resulting template is global, the domain’s global-template administration permission is additionally required, even when isGlobal is omitted. The template owner is retained when changing visibility. Private templates are allowed only for email/bulkletter; an email template referenced by group membership emails cannot become private. Omitted/null values preserve fields; content cannot be cleared by sending null. HTML and MJML replacements run first. A truthy htmlFileId is processed last, must belong to this template or be the current user’s unbound html_template upload, and replaces the HTML reference while deleting other content files and clearing MJML. Supply either content or htmlFileId to avoid unintentionally replacing just-written files. domainType and owner are not changed by this route.
15756 ///
15757 /// # Example
15758 ///
15759 /// ```
15760 /// # use churchtools_api::*;
15761 /// # use churchtools_api::queries::*;
15762 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15763 /// # let client = churchtools_api::replay::client("patch-htmltemplates-templateId");
15764 /// let body = models::HtmlTemplateUpdate {
15765 /// name: Some(Some("Updated welcome email".into())),
15766 /// ..Default::default()
15767 /// };
15768 /// let result = client.html_templates().patch(2, &body)?;
15769 /// println!("{}", result.name);
15770 /// # Ok(())
15771 /// # }
15772 /// ```
15773 pub fn patch(&self, template_id: impl Display, body: &models::HtmlTemplateUpdate) -> Result<models::HtmlTemplate> {
15774 let path = format!("/htmltemplates/{}", seg(template_id));
15775 let query: Query = Query::new();
15776 let body = serde_json::to_value(body).expect("request body serializes");
15777 self.client.request_data(Method::Patch, &path, &query, Some(&body))
15778 }
15779
15780 /// Upload image assets to a template
15781 ///
15782 /// `POST /htmltemplates/{templateId}/uploadassets`
15783 ///
15784 /// Requires permission to edit the template. Send one or more multipart file parts named files\[\]. The controller accepts client media types beginning with image/; it does not limit uploads to PNG. Files are saved as separate template image assets and returned in input order as editor descriptors. HTML and MJML source are not modified automatically. All client media-type headers are checked before storage, but files are then saved individually; a later storage failure can leave earlier assets persisted. This response has no meta envelope.
15785 ///
15786 /// # Example
15787 ///
15788 /// ```no_run
15789 /// # use churchtools_api::*;
15790 /// # use churchtools_api::queries::*;
15791 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15792 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15793 /// let file = Upload::from_path("logo.png")?;
15794 /// for html_template in client.html_templates().upload_assets(2, &[file])? {
15795 /// println!("{}", html_template.name);
15796 /// }
15797 /// # Ok(())
15798 /// # }
15799 /// ```
15800 pub fn upload_assets(&self, template_id: impl Display, files: &[Upload]) -> Result<Vec<models::HtmlTemplateAssetUpload>> {
15801 let path = format!("/htmltemplates/{}/uploadassets", seg(template_id));
15802 let query: Query = Query::new();
15803 let form: Query = Query::new();
15804 let bytes = self.client.request_multipart(Method::Post, &path, &query, &form, "files[]", files)?;
15805 crate::decode_data(&bytes)
15806 }
15807
15808}
15809
15810/// `client.images()`
15811#[derive(Clone, Copy)]
15812pub struct ImagesResource<'a> {
15813 client: &'a Client,
15814}
15815
15816impl<'a> ImagesResource<'a> {
15817 /// Get a public image
15818 ///
15819 /// `GET /images/{fileId}/{hash}`
15820 ///
15821 /// Returns image bytes for a public image URL and applies Glide transformations. The hash grants access without a login. SVG content is returned without transformation as an attachment.
15822 ///
15823 /// Use [`Self::get_with`] to pass query parameters.
15824 ///
15825 /// # Example
15826 ///
15827 /// ```no_run
15828 /// # use churchtools_api::*;
15829 /// # use churchtools_api::queries::*;
15830 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15831 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15832 /// let data = client.images().get(42, "abc123")?;
15833 /// std::fs::write("ergebnis.bin", &data)?;
15834 /// # Ok(())
15835 /// # }
15836 /// ```
15837 pub fn get(&self, file_id: impl Display, hash: impl Display) -> Result<Vec<u8>> {
15838 self.get_with(file_id, hash, &Default::default())
15839 }
15840
15841 /// Get a public image
15842 ///
15843 /// Like [`Self::get`], with query parameters.
15844 ///
15845 /// `GET /images/{fileId}/{hash}`
15846 ///
15847 /// Returns image bytes for a public image URL and applies Glide transformations. The hash grants access without a login. SVG content is returned without transformation as an attachment.
15848 pub fn get_with(&self, file_id: impl Display, hash: impl Display, query: &GetImagesFileIdHashQuery) -> Result<Vec<u8>> {
15849 let path = format!("/images/{}/{}", seg(file_id), seg(hash));
15850 let query: Query = query.to_query();
15851 self.client.request(Method::Get, &path, &query, None)
15852 }
15853
15854 /// Get a public image with path-encoded parameters
15855 ///
15856 /// `GET /images/{fileId}/{hash}/{queryParams}`
15857 ///
15858 /// Returns a public image with Glide transformations encoded in the final path segment. Image handling is otherwise identical to `GET /images/{fileId}/{hash}`.
15859 ///
15860 /// # Example
15861 ///
15862 /// ```no_run
15863 /// # use churchtools_api::*;
15864 /// # use churchtools_api::queries::*;
15865 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15866 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15867 /// let data = client.images().get_with_params(42, "abc123", "fm%3Dwebp%26q%3D80%26w%3D700%26h%3Dauto")?;
15868 /// std::fs::write("ergebnis.bin", &data)?;
15869 /// # Ok(())
15870 /// # }
15871 /// ```
15872 pub fn get_with_params(&self, file_id: impl Display, hash: impl Display, query_params: impl Display) -> Result<Vec<u8>> {
15873 let path = format!("/images/{}/{}/{}", seg(file_id), seg(hash), seg(query_params));
15874 let query: Query = Query::new();
15875 self.client.request(Method::Get, &path, &query, None)
15876 }
15877
15878 /// Update image metadata
15879 ///
15880 /// `PATCH /images/{id}`
15881 ///
15882 /// Updates image description, attribution, AI flag and crop/focus options. Requires update permission for the owning object. Changing image options clears generated image caches.
15883 ///
15884 /// # Example
15885 ///
15886 /// ```no_run
15887 /// # use churchtools_api::*;
15888 /// # use churchtools_api::queries::*;
15889 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15890 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15891 /// let body = models::ImageUpdate {
15892 /// description: Some(Some("Congregation gathered outside the church.".into())),
15893 /// ..Default::default()
15894 /// };
15895 /// let result = client.images().patch(1, &body)?;
15896 /// println!("{}", result.name);
15897 /// # Ok(())
15898 /// # }
15899 /// ```
15900 pub fn patch(&self, id: impl Display, body: &models::ImageUpdate) -> Result<models::ImageMetadataUpdateResult> {
15901 let path = format!("/images/{}", seg(id));
15902 let query: Query = Query::new();
15903 let body = serde_json::to_value(body).expect("request body serializes");
15904 self.client.request_data(Method::Patch, &path, &query, Some(&body))
15905 }
15906
15907 /// Update image options and metadata
15908 ///
15909 /// `PUT /images/{id}/options`
15910 ///
15911 /// Updates image metadata through the same handler as `PATCH /images/{id}`. Requires update permission for the owning object.
15912 ///
15913 /// # Example
15914 ///
15915 /// ```no_run
15916 /// # use churchtools_api::*;
15917 /// # use churchtools_api::queries::*;
15918 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15919 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15920 /// let body = models::ImageUpdate {
15921 /// description: Some(Some("Congregation gathered outside the church.".into())),
15922 /// ..Default::default()
15923 /// };
15924 /// let result = client.images().update_options(1, &body)?;
15925 /// println!("{}", result.name);
15926 /// # Ok(())
15927 /// # }
15928 /// ```
15929 pub fn update_options(&self, id: impl Display, body: &models::ImageUpdate) -> Result<models::ImageMetadataUpdateResult> {
15930 let path = format!("/images/{}/options", seg(id));
15931 let query: Query = Query::new();
15932 let body = serde_json::to_value(body).expect("request body serializes");
15933 self.client.request_data(Method::Put, &path, &query, Some(&body))
15934 }
15935
15936}
15937
15938/// `client.info()`
15939#[derive(Clone, Copy)]
15940pub struct InfoResource<'a> {
15941 client: &'a Client,
15942}
15943
15944impl<'a> InfoResource<'a> {
15945 /// Information about API
15946 ///
15947 /// `GET /info`
15948 ///
15949 /// The API envoles and dependes on the ChurchTools version. This endpoint provides the build version and CT version.
15950 ///
15951 /// # Example
15952 ///
15953 /// ```
15954 /// # use churchtools_api::*;
15955 /// # use churchtools_api::queries::*;
15956 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15957 /// # let client = churchtools_api::replay::client("get-info");
15958 /// let info = client.info().get()?;
15959 /// println!("{:?}", info.build);
15960 /// # Ok(())
15961 /// # }
15962 /// ```
15963 pub fn get(&self) -> Result<models::GetInfoResponse> {
15964 let path = "/info".to_owned();
15965 let query: Query = Query::new();
15966 self.client.request_json(Method::Get, &path, &query, None)
15967 }
15968
15969}
15970
15971/// `client.installation_sync()`
15972#[derive(Clone, Copy)]
15973pub struct InstallationSyncResource<'a> {
15974 client: &'a Client,
15975}
15976
15977impl<'a> InstallationSyncResource<'a> {
15978 /// Synchronize Directory-managed OIDC configuration
15979 ///
15980 /// `POST /installation-sync/oidc`
15981 ///
15982 /// Applies a Directory-signed OIDC configuration to the dedicated ChurchTools Identity provider. This public endpoint trusts only locally provisioned signing keys and uses monotonic revisions.
15983 ///
15984 /// # Example
15985 ///
15986 /// ```no_run
15987 /// # use churchtools_api::*;
15988 /// # use churchtools_api::queries::*;
15989 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
15990 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
15991 /// let body = models::PostInstallationSyncOidcBody {
15992 /// configuration_token: "abc123".into(),
15993 /// ..Default::default()
15994 /// };
15995 /// let installation_sync = client.installation_sync().oidc(&body)?;
15996 /// println!("{:?}", installation_sync.external_login_id);
15997 /// # Ok(())
15998 /// # }
15999 /// ```
16000 pub fn oidc(&self, body: &models::PostInstallationSyncOidcBody) -> Result<models::PostInstallationSyncOidcData> {
16001 let path = "/installation-sync/oidc".to_owned();
16002 let query: Query = Query::new();
16003 let body = serde_json::to_value(body).expect("request body serializes");
16004 self.client.request_data(Method::Post, &path, &query, Some(&body))
16005 }
16006
16007}
16008
16009/// `client.job_log()`
16010#[derive(Clone, Copy)]
16011pub struct JobLogResource<'a> {
16012 client: &'a Client,
16013}
16014
16015impl<'a> JobLogResource<'a> {
16016 /// Get diagnostic entries for a job
16017 ///
16018 /// `GET /joblog`
16019 ///
16020 /// Returns log entries for an exact job identifier. An unknown identifier returns an empty array. Results are not paginated or ordered.
16021 ///
16022 /// # Example
16023 ///
16024 /// ```
16025 /// # use churchtools_api::*;
16026 /// # use churchtools_api::queries::*;
16027 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16028 /// # let client = churchtools_api::replay::client("get-joblog");
16029 /// let query = GetJoblogQuery {
16030 /// guid: Some("d038d398-c8e1-4c95-a3ad-c725dc6d4537-unchanged".into()),
16031 /// ..Default::default()
16032 /// };
16033 /// for job_log in client.job_log().list(&query)? {
16034 /// println!("{}", job_log.element_id);
16035 /// }
16036 /// # Ok(())
16037 /// # }
16038 /// ```
16039 pub fn list(&self, query: &GetJoblogQuery) -> Result<Vec<models::JobLogEntry>> {
16040 let path = "/joblog".to_owned();
16041 let query: Query = query.to_query();
16042 self.client.request_json(Method::Get, &path, &query, None)
16043 }
16044
16045}
16046
16047/// `client.jobs()`
16048#[derive(Clone, Copy)]
16049pub struct JobsResource<'a> {
16050 client: &'a Client,
16051}
16052
16053impl<'a> JobsResource<'a> {
16054 /// List background jobs
16055 ///
16056 /// `GET /jobs`
16057 ///
16058 /// Lists persisted background jobs, newest creation time first. Requires "administer settings" permission in `churchcore`. All supplied filters are combined with AND; status/domain ID lists match any contained value. Empty lists add no restriction. No pagination or result limit is implemented.
16059 ///
16060 /// Use [`Self::list_with`] to pass query parameters.
16061 ///
16062 /// # Example
16063 ///
16064 /// ```
16065 /// # use churchtools_api::*;
16066 /// # use churchtools_api::queries::*;
16067 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16068 /// # let client = churchtools_api::replay::client("get-jobs");
16069 /// for job in client.jobs().list()? {
16070 /// println!("{}", job.name);
16071 /// }
16072 /// # Ok(())
16073 /// # }
16074 /// ```
16075 pub fn list(&self) -> Result<Vec<models::Job>> {
16076 self.list_with(&Default::default())
16077 }
16078
16079 /// List background jobs
16080 ///
16081 /// Like [`Self::list`], with query parameters.
16082 ///
16083 /// `GET /jobs`
16084 ///
16085 /// Lists persisted background jobs, newest creation time first. Requires "administer settings" permission in `churchcore`. All supplied filters are combined with AND; status/domain ID lists match any contained value. Empty lists add no restriction. No pagination or result limit is implemented.
16086 pub fn list_with(&self, query: &GetJobsQuery) -> Result<Vec<models::Job>> {
16087 let path = "/jobs".to_owned();
16088 let query: Query = query.to_query();
16089 self.client.request_data(Method::Get, &path, &query, None)
16090 }
16091
16092 /// Append a background-job log message
16093 ///
16094 /// `POST /jobs/{identifier}/logs`
16095 ///
16096 /// Appends an application log entry for an existing background job. Requires "administer settings" permission in `churchcore`. Returns no response body.
16097 ///
16098 /// # Example
16099 ///
16100 /// ```no_run
16101 /// # use churchtools_api::*;
16102 /// # use churchtools_api::queries::*;
16103 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16104 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16105 /// let body = models::JobLogCreate {
16106 /// log_message: "Processed 25 records.".into(),
16107 /// ..Default::default()
16108 /// };
16109 /// client.jobs().logs("1a9e9b86-78ee-4c8a-bf58-51e653073a0c", &body)?;
16110 /// # Ok(())
16111 /// # }
16112 /// ```
16113 pub fn logs(&self, identifier: impl Display, body: &models::JobLogCreate) -> Result<()> {
16114 let path = format!("/jobs/{}/logs", seg(identifier));
16115 let query: Query = Query::new();
16116 let body = serde_json::to_value(body).expect("request body serializes");
16117 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
16118 }
16119
16120 /// Update a background-job status
16121 ///
16122 /// `PUT /jobs/{identifier}/status`
16123 ///
16124 /// Updates the stored job status. For `sync_job` jobs, "view" permission in `churchsync` is required; other jobs require "administer settings" permission in `churchcore`. This endpoint does not start or stop a worker.
16125 ///
16126 /// # Example
16127 ///
16128 /// ```no_run
16129 /// # use churchtools_api::*;
16130 /// # use churchtools_api::queries::*;
16131 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16132 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16133 /// let body = models::JobStatusUpdate {
16134 /// status: "QUEUED".into(),
16135 /// ..Default::default()
16136 /// };
16137 /// client.jobs().update_status("1a9e9b86-78ee-4c8a-bf58-51e653073a0c", &body)?;
16138 /// # Ok(())
16139 /// # }
16140 /// ```
16141 pub fn update_status(&self, identifier: impl Display, body: &models::JobStatusUpdate) -> Result<()> {
16142 let path = format!("/jobs/{}/status", seg(identifier));
16143 let query: Query = Query::new();
16144 let body = serde_json::to_value(body).expect("request body serializes");
16145 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
16146 }
16147
16148}
16149
16150/// `client.labels()`
16151#[derive(Clone, Copy)]
16152pub struct LabelsResource<'a> {
16153 client: &'a Client,
16154}
16155
16156impl<'a> LabelsResource<'a> {
16157 /// Create an address-label PDF
16158 ///
16159 /// `POST /labels`
16160 ///
16161 /// Generates and stores a PDF of address labels, returning an absolute download URL. Labels use the configured German address formatter and one of three A4 layouts. Only visible selected persons are included; individual printable fields are checked against security levels. Incomplete addresses are still included. With combineSpouses=true, selected visible spouses may share a label even when their addresses differ; the first spouse with a complete address is preferred. Birthday sorting forces separate labels. PDF files are scheduled to expire after one day. The generation handler checks person visibility but has no explicit create print labels permission check; the labels file-download handler checks that permission. Input is currently read without the shared request validator, so malformed input can cause server errors.
16162 ///
16163 /// # Example
16164 ///
16165 /// ```no_run
16166 /// # use churchtools_api::*;
16167 /// # use churchtools_api::queries::*;
16168 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16169 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16170 /// let body = models::LabelCreate {
16171 /// person_ids: serde_json::json!([42]),
16172 /// r#type: "AveryLabels3475".into(),
16173 /// ..Default::default()
16174 /// };
16175 /// let result = client.labels().create(&body)?;
16176 /// println!("{}", result.pdf);
16177 /// # Ok(())
16178 /// # }
16179 /// ```
16180 pub fn create(&self, body: &models::LabelCreate) -> Result<models::PostLabelsData> {
16181 let path = "/labels".to_owned();
16182 let query: Query = Query::new();
16183 let body = serde_json::to_value(body).expect("request body serializes");
16184 self.client.request_data(Method::Post, &path, &query, Some(&body))
16185 }
16186
16187 /// Count address labels
16188 ///
16189 /// `POST /labels/totals`
16190 ///
16191 /// Calculates four label counts for visible selected persons without generating a PDF. ignoreAddress includes incomplete addresses; onlyCompleteAddress requires street, postal code and city, but not country or address addition. Each contains the count with separate persons and after spouse grouping. Both spouses must be in the visible selection, but their addresses need not match. These counts do not take sortpolicy or layout into account; birthday PDF sorting always uses separate labels. Stored field completeness is checked before any printable-field security filtering.
16192 ///
16193 /// # Example
16194 ///
16195 /// ```
16196 /// # use churchtools_api::*;
16197 /// # use churchtools_api::queries::*;
16198 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16199 /// # let client = churchtools_api::replay::client("post-labels-totals");
16200 /// let body = models::LabelTotalsRequest {
16201 /// person_ids: serde_json::json!([42]),
16202 /// ..Default::default()
16203 /// };
16204 /// let label = client.labels().totals(&body)?;
16205 /// println!("{:?}", label);
16206 /// # Ok(())
16207 /// # }
16208 /// ```
16209 pub fn totals(&self, body: &models::LabelTotalsRequest) -> Result<models::LabelTotals> {
16210 let path = "/labels/totals".to_owned();
16211 let query: Query = Query::new();
16212 let body = serde_json::to_value(body).expect("request body serializes");
16213 self.client.request_data(Method::Post, &path, &query, Some(&body))
16214 }
16215
16216}
16217
16218/// `client.languages()`
16219#[derive(Clone, Copy)]
16220pub struct LanguagesResource<'a> {
16221 client: &'a Client,
16222}
16223
16224impl<'a> LanguagesResource<'a> {
16225 /// Get all languages
16226 ///
16227 /// `GET /languages`
16228 ///
16229 /// The response is a list of all languages
16230 ///
16231 /// Use [`Self::list_with`] to pass query parameters.
16232 ///
16233 /// # Example
16234 ///
16235 /// ```
16236 /// # use churchtools_api::*;
16237 /// # use churchtools_api::queries::*;
16238 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16239 /// # let client = churchtools_api::replay::client("get-languages");
16240 /// for language in client.languages().list()? {
16241 /// println!("{}", language.name);
16242 /// }
16243 /// # Ok(())
16244 /// # }
16245 /// ```
16246 pub fn list(&self) -> Result<Vec<models::Language>> {
16247 self.list_with(&Default::default())
16248 }
16249
16250 /// Get all languages
16251 ///
16252 /// Like [`Self::list`], with query parameters.
16253 ///
16254 /// `GET /languages`
16255 ///
16256 /// The response is a list of all languages
16257 pub fn list_with(&self, query: &GetLanguagesQuery) -> Result<Vec<models::Language>> {
16258 let path = "/languages".to_owned();
16259 let query: Query = query.to_query();
16260 self.client.request_data(Method::Get, &path, &query, None)
16261 }
16262
16263}
16264
16265/// `client.license()`
16266#[derive(Clone, Copy)]
16267pub struct LicenseResource<'a> {
16268 client: &'a Client,
16269}
16270
16271impl<'a> LicenseResource<'a> {
16272 /// Fetch license information
16273 ///
16274 /// `GET /license/fetch`
16275 ///
16276 /// Fetches and stores the current license information.
16277 ///
16278 /// # Example
16279 ///
16280 /// ```no_run
16281 /// # use churchtools_api::*;
16282 /// # use churchtools_api::queries::*;
16283 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16284 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16285 /// client.license().get_fetch()?;
16286 /// # Ok(())
16287 /// # }
16288 /// ```
16289 pub fn get_fetch(&self) -> Result<()> {
16290 let path = "/license/fetch".to_owned();
16291 let query: Query = Query::new();
16292 self.client.request(Method::Get, &path, &query, None).map(|_| ())
16293 }
16294
16295}
16296
16297/// `client.login()`
16298#[derive(Clone, Copy)]
16299pub struct LoginResource<'a> {
16300 client: &'a Client,
16301}
16302
16303impl<'a> LoginResource<'a> {
16304 pub fn two_factor(&self) -> LoginTwoFactorResource<'a> {
16305 LoginTwoFactorResource { client: self.client }
16306 }
16307
16308 /// Start password-based login
16309 ///
16310 /// `POST /login`
16311 ///
16312 /// Verifies a username/email and password, using configured LDAP authentication before local credentials. The configured default-login policy is enforced. HTTP 200 may mean login succeeded or that a second step is required; inspect data.status. With totp, submit the code and personId to POST /login/totp. With twoFactorSetup, initialize and activate two-factor setup before login is completed. Preserve cookies across all steps. rememberMe controls persistent browser login. Invalid credentials and locked accounts return 400, not 401. Failed local attempts increment account counters. All login steps share the configured login rate limit.
16313 ///
16314 /// # Example
16315 ///
16316 /// ```no_run
16317 /// # use churchtools_api::*;
16318 /// # use churchtools_api::queries::*;
16319 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16320 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16321 /// let body = models::LoginCreate {
16322 /// password: "example-password".into(),
16323 /// username: "alex@example.org".into(),
16324 /// ..Default::default()
16325 /// };
16326 /// let result = client.login().create(&body)?;
16327 /// println!("{:?}", result.location);
16328 /// # Ok(())
16329 /// # }
16330 /// ```
16331 pub fn create(&self, body: &models::LoginCreate) -> Result<models::LoginResult> {
16332 let path = "/login".to_owned();
16333 let query: Query = Query::new();
16334 let body = serde_json::to_value(body).expect("request body serializes");
16335 self.client.request_data(Method::Post, &path, &query, Some(&body))
16336 }
16337
16338 /// Get or create a persistent login token
16339 ///
16340 /// `POST /login/token`
16341 ///
16342 /// Verifies username/email and password and returns the person’s existing persistent login token, creating one only if none exists. No browser login is completed by this operation. The configured default-login policy applies. Accounts with activated two-factor authentication are rejected with 400. Token retrieval is blocked during non-support simulation. The returned credential has no expiry field and remains independent of logout. Failed credential checks can increment local account error counters. This route shares the configured login rate limit with the other login steps.
16343 ///
16344 /// # Example
16345 ///
16346 /// ```no_run
16347 /// # use churchtools_api::*;
16348 /// # use churchtools_api::queries::*;
16349 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16350 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16351 /// let body = models::LoginCredentials {
16352 /// password: "example-password".into(),
16353 /// username: "alex@example.org".into(),
16354 /// ..Default::default()
16355 /// };
16356 /// let login = client.login().token(&body)?;
16357 /// println!("{}", login.person_id);
16358 /// # Ok(())
16359 /// # }
16360 /// ```
16361 pub fn token(&self, body: &models::LoginCredentials) -> Result<models::LoginTokenResult> {
16362 let path = "/login/token".to_owned();
16363 let query: Query = Query::new();
16364 let body = serde_json::to_value(body).expect("request body serializes");
16365 self.client.request_data(Method::Post, &path, &query, Some(&body))
16366 }
16367
16368 /// Complete login with an authenticator code
16369 ///
16370 /// `POST /login/totp`
16371 ///
16372 /// Verifies the authenticator code for the person bound to the pending password-verified session. Retain the same session cookie from POST /login; this operation does not use ordinary API authentication to select a person. On success the code is temporarily blacklisted, login is completed and the pending session is removed. A pending external-account link is completed instead when that context exists. If two-factor authentication was disabled or its secret disappeared after the password step, the legacy normal-login branch returns success without redirectTo and without completing login; clients should restart the login flow. Invalid or reused codes, missing pending session and person mismatch return 400. Shares the login rate limit.
16373 ///
16374 /// # Example
16375 ///
16376 /// ```no_run
16377 /// # use churchtools_api::*;
16378 /// # use churchtools_api::queries::*;
16379 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16380 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16381 /// let body = models::LoginTotpVerify {
16382 /// code: "012345".into(),
16383 /// person_id: 42,
16384 /// ..Default::default()
16385 /// };
16386 /// let login = client.login().totp(&body)?;
16387 /// println!("{:?}", login.redirect_to);
16388 /// # Ok(())
16389 /// # }
16390 /// ```
16391 pub fn totp(&self, body: &models::LoginTotpVerify) -> Result<models::TwoFactorLoginResult> {
16392 let path = "/login/totp".to_owned();
16393 let query: Query = Query::new();
16394 let body = serde_json::to_value(body).expect("request body serializes");
16395 self.client.request_data(Method::Post, &path, &query, Some(&body))
16396 }
16397
16398}
16399
16400/// `client.login().two_factor()`
16401#[derive(Clone, Copy)]
16402pub struct LoginTwoFactorResource<'a> {
16403 client: &'a Client,
16404}
16405
16406impl<'a> LoginTwoFactorResource<'a> {
16407 pub fn setup(&self) -> LoginTwoFactorSetupResource<'a> {
16408 LoginTwoFactorSetupResource { client: self.client }
16409 }
16410
16411}
16412
16413/// `client.login().two_factor().setup()`
16414#[derive(Clone, Copy)]
16415pub struct LoginTwoFactorSetupResource<'a> {
16416 client: &'a Client,
16417}
16418
16419impl<'a> LoginTwoFactorSetupResource<'a> {
16420 /// Activate authenticator and complete required setup
16421 ///
16422 /// `POST /login/twofactor/setup/activate`
16423 ///
16424 /// Verifies a code from the secret initialized through POST /login/twofactor/setup in the same pending login session. The session identifies the person. On success, blacklists the code, enables two-factor authentication, completes browser login using the original rememberMe choice, and clears the pending session. The response includes a navigation target from that session. Invalid/reused codes, missing secret or missing setup session return 400. Activation is saved before browser login finishes, so a later failure can leave two-factor authentication enabled. This endpoint is not an idempotent status-setting operation; after success the pending session is gone. Shares the login rate limit.
16425 ///
16426 /// # Example
16427 ///
16428 /// ```no_run
16429 /// # use churchtools_api::*;
16430 /// # use churchtools_api::queries::*;
16431 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16432 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16433 /// let body = models::TwoFactorSetupActivate {
16434 /// code: "012345".into(),
16435 /// ..Default::default()
16436 /// };
16437 /// let setup = client.login().two_factor().setup().activate(&body)?;
16438 /// println!("{}", setup.redirect_to);
16439 /// # Ok(())
16440 /// # }
16441 /// ```
16442 pub fn activate(&self, body: &models::TwoFactorSetupActivate) -> Result<models::PostLoginTwofactorSetupActivateData> {
16443 let path = "/login/twofactor/setup/activate".to_owned();
16444 let query: Query = Query::new();
16445 let body = serde_json::to_value(body).expect("request body serializes");
16446 self.client.request_data(Method::Post, &path, &query, Some(&body))
16447 }
16448
16449 /// Initialize required authenticator setup
16450 ///
16451 /// `POST /login/twofactor/setup`
16452 ///
16453 /// Starts authenticator enrollment for the person in a pending twoFactorSetup login session. Use the same cookies as the password step. Creates and stores a new secret and sets the enabled flag to false. Returns the secret and its QR-code image as a data URI. Repeating this request replaces the previous secret and invalidates its QR code, so do not use it as a read-only setup-status request. Submit a code generated from this secret to POST /login/twofactor/setup/activate. A missing or unsuitable pending session returns 400. Shares the login rate limit.
16454 ///
16455 /// # Example
16456 ///
16457 /// ```no_run
16458 /// # use churchtools_api::*;
16459 /// # use churchtools_api::queries::*;
16460 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16461 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16462 /// let result = client.login().two_factor().setup().create()?;
16463 /// println!("{}", result.qrcode);
16464 /// # Ok(())
16465 /// # }
16466 /// ```
16467 pub fn create(&self) -> Result<models::TwoFactorSetupSecret> {
16468 let path = "/login/twofactor/setup".to_owned();
16469 let query: Query = Query::new();
16470 self.client.request_data(Method::Post, &path, &query, None)
16471 }
16472
16473}
16474
16475/// `client.logout()`
16476#[derive(Clone, Copy)]
16477pub struct LogoutResource<'a> {
16478 client: &'a Client,
16479}
16480
16481impl<'a> LogoutResource<'a> {
16482 /// End the current browser session
16483 ///
16484 /// `POST /logout`
16485 ///
16486 /// Deletes the current session cookie, destroys the server-side session and resets the current user to anonymous. Also usable to leave a pending two-factor login. This affects the current session only; it does not revoke persistent login tokens or OAuth tokens. A subsequent request still carrying such an Authorization header may authenticate again. An unauthenticated request without an applicable session may be rejected by authentication middleware.
16487 ///
16488 /// # Example
16489 ///
16490 /// ```no_run
16491 /// # use churchtools_api::*;
16492 /// # use churchtools_api::queries::*;
16493 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16494 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16495 /// client.logout().create()?;
16496 /// # Ok(())
16497 /// # }
16498 /// ```
16499 pub fn create(&self) -> Result<()> {
16500 let path = "/logout".to_owned();
16501 let query: Query = Query::new();
16502 self.client.request(Method::Post, &path, &query, None).map(|_| ())
16503 }
16504
16505}
16506
16507/// `client.logs()`
16508#[derive(Clone, Copy)]
16509pub struct LogsResource<'a> {
16510 client: &'a Client,
16511}
16512
16513impl<'a> LogsResource<'a> {
16514 pub fn statistics(&self) -> LogsStatisticsResource<'a> {
16515 LogsStatisticsResource { client: self.client }
16516 }
16517
16518 /// Get a log message
16519 ///
16520 /// `GET /logs/{id}`
16521 ///
16522 /// Fetch one specific log message by its ID.
16523 ///
16524 /// # Example
16525 ///
16526 /// ```
16527 /// # use churchtools_api::*;
16528 /// # use churchtools_api::queries::*;
16529 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16530 /// # let client = churchtools_api::replay::client("get-logs-id");
16531 /// let log = client.logs().get(1)?;
16532 /// println!("{}", log.id);
16533 /// # Ok(())
16534 /// # }
16535 /// ```
16536 pub fn get(&self, id: impl Display) -> Result<models::Log> {
16537 let path = format!("/logs/{}", seg(id));
16538 let query: Query = Query::new();
16539 self.client.request_data(Method::Get, &path, &query, None)
16540 }
16541
16542 /// Get all log messages
16543 ///
16544 /// `GET /logs`
16545 ///
16546 /// The response is a collection of all log messages you may see and is limited to a specific number of messages. You can use the `page` parameter to browse the list of log messages. The logs are ordered by date.
16547 ///
16548 /// Use [`Self::list_with`] to pass query parameters.
16549 ///
16550 /// # Example
16551 ///
16552 /// ```
16553 /// # use churchtools_api::*;
16554 /// # use churchtools_api::queries::*;
16555 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16556 /// # let client = churchtools_api::replay::client("get-logs");
16557 /// for log in client.logs().list()? {
16558 /// println!("{}", log.id);
16559 /// }
16560 /// # Ok(())
16561 /// # }
16562 /// ```
16563 pub fn list(&self) -> Result<Vec<models::Log>> {
16564 self.list_with(&Default::default())
16565 }
16566
16567 /// Get all log messages
16568 ///
16569 /// Like [`Self::list`], with query parameters.
16570 ///
16571 /// `GET /logs`
16572 ///
16573 /// The response is a collection of all log messages you may see and is limited to a specific number of messages. You can use the `page` parameter to browse the list of log messages. The logs are ordered by date.
16574 pub fn list_with(&self, query: &GetLogsQuery) -> Result<Vec<models::Log>> {
16575 let path = "/logs".to_owned();
16576 let query: Query = query.to_query();
16577 self.client.collect_pages(&path, query)
16578 }
16579
16580 /// Get all log messages
16581 ///
16582 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
16583 /// Breaking off early saves the remaining requests.
16584 pub fn list_iter(&self, query: &GetLogsQuery) -> Items<models::Log> {
16585 let path = "/logs".to_owned();
16586 self.client.items(&path, query.to_query())
16587 }
16588
16589}
16590
16591/// `client.logs().statistics()`
16592#[derive(Clone, Copy)]
16593pub struct LogsStatisticsResource<'a> {
16594 client: &'a Client,
16595}
16596
16597impl<'a> LogsStatisticsResource<'a> {
16598 /// `GET /logs/statistics/login`
16599 ///
16600 /// Get statistics about login counts of users.
16601 ///
16602 /// Use [`Self::list_login_with`] to pass query parameters.
16603 ///
16604 /// # Example
16605 ///
16606 /// ```
16607 /// # use churchtools_api::*;
16608 /// # use churchtools_api::queries::*;
16609 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16610 /// # let client = churchtools_api::replay::client("get-logs-statistics-login");
16611 /// for login in client.logs().statistics().list_login()? {
16612 /// println!("{}", login.last_login);
16613 /// }
16614 /// # Ok(())
16615 /// # }
16616 /// ```
16617 pub fn list_login(&self) -> Result<Vec<models::GetLogsStatisticsLoginDataItem>> {
16618 self.list_login_with(&Default::default())
16619 }
16620
16621 /// `GET /logs/statistics/login`
16622 ///
16623 /// Like [`Self::list_login`], with query parameters.
16624 ///
16625 /// Get statistics about login counts of users.
16626 pub fn list_login_with(&self, query: &GetLogsStatisticsLoginQuery) -> Result<Vec<models::GetLogsStatisticsLoginDataItem>> {
16627 let path = "/logs/statistics/login".to_owned();
16628 let query: Query = query.to_query();
16629 self.client.collect_pages(&path, query)
16630 }
16631
16632 /// `GET /logs/statistics/login`
16633 ///
16634 /// Like [`Self::list_login_with`], but lazy: each page is fetched only when the iteration reaches it.
16635 /// Breaking off early saves the remaining requests.
16636 pub fn list_login_iter(&self, query: &GetLogsStatisticsLoginQuery) -> Items<models::GetLogsStatisticsLoginDataItem> {
16637 let path = "/logs/statistics/login".to_owned();
16638 self.client.items(&path, query.to_query())
16639 }
16640
16641}
16642
16643/// `client.markdown()`
16644#[derive(Clone, Copy)]
16645pub struct MarkdownResource<'a> {
16646 client: &'a Client,
16647}
16648
16649impl<'a> MarkdownResource<'a> {
16650 /// Validate Markdown string
16651 ///
16652 /// `POST /markdown/check`
16653 ///
16654 /// Check if the provided Markdown content is valid for the specified scope
16655 ///
16656 /// # Example
16657 ///
16658 /// ```
16659 /// # use churchtools_api::*;
16660 /// # use churchtools_api::queries::*;
16661 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16662 /// # let client = churchtools_api::replay::client("post-markdown-check");
16663 /// let body = models::PostMarkdownCheckBody {
16664 /// input_scope: "description".into(),
16665 /// markdown: "Hallo zusammen".into(),
16666 /// ..Default::default()
16667 /// };
16668 /// let markdown = client.markdown().check(&body)?;
16669 /// println!("{}", markdown.is_valid);
16670 /// # Ok(())
16671 /// # }
16672 /// ```
16673 pub fn check(&self, body: &models::PostMarkdownCheckBody) -> Result<models::PostMarkdownCheckData> {
16674 let path = "/markdown/check".to_owned();
16675 let query: Query = Query::new();
16676 let body = serde_json::to_value(body).expect("request body serializes");
16677 self.client.request_data(Method::Post, &path, &query, Some(&body))
16678 }
16679
16680 /// Convert Markdown to HTML etc.
16681 ///
16682 /// `POST /markdown/convert`
16683 ///
16684 /// convert a set of markdown strings
16685 ///
16686 /// # Example
16687 ///
16688 /// ```no_run
16689 /// # use churchtools_api::*;
16690 /// # use churchtools_api::queries::*;
16691 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16692 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16693 /// let body = models::MarkdownRequest {
16694 /// sources: vec![models::MarkdownRequestSourcesItem {
16695 /// input_scope: "description".into(),
16696 /// markdown: "Hallo zusammen".into(),
16697 /// output_formats: vec!["html".into()],
16698 /// output_scopes: vec!["description".into()],
16699 /// short_name: "Hauskreis Nord".into(),
16700 /// ..Default::default()
16701 /// }],
16702 /// ..Default::default()
16703 /// };
16704 /// let markdown = client.markdown().convert(&body)?;
16705 /// println!("{:?}", markdown.current_config_file);
16706 /// # Ok(())
16707 /// # }
16708 /// ```
16709 pub fn convert(&self, body: &models::MarkdownRequest) -> Result<models::Config> {
16710 let path = "/markdown/convert".to_owned();
16711 let query: Query = Query::new();
16712 let body = serde_json::to_value(body).expect("request body serializes");
16713 self.client.request_json(Method::Post, &path, &query, Some(&body))
16714 }
16715
16716}
16717
16718/// `client.master_data()`
16719#[derive(Clone, Copy)]
16720pub struct MasterDataResource<'a> {
16721 client: &'a Client,
16722}
16723
16724impl<'a> MasterDataResource<'a> {
16725 /// Fetch all master data for the module "People & Groups"
16726 ///
16727 /// `GET /masterdata/person`
16728 ///
16729 /// Deprecated alias of `GET /person/masterdata`. Use `/person/masterdata` for new integrations.
16730 ///
16731 /// # Example
16732 ///
16733 /// ```
16734 /// # use churchtools_api::*;
16735 /// # use churchtools_api::queries::*;
16736 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16737 /// # let client = churchtools_api::replay::client("get-masterdata-person");
16738 /// let person = client.master_data().get_person()?;
16739 /// println!("{:?}", person);
16740 /// # Ok(())
16741 /// # }
16742 /// ```
16743 #[deprecated = "GET /masterdata/person is deprecated in the ChurchTools API. Use `/person/masterdata` for new integrations."]
16744 pub fn get_person(&self) -> Result<models::PersonMasterData> {
16745 let path = "/masterdata/person".to_owned();
16746 let query: Query = Query::new();
16747 self.client.request_data(Method::Get, &path, &query, None)
16748 }
16749
16750}
16751
16752/// `client.meeting_requests()`
16753#[derive(Clone, Copy)]
16754pub struct MeetingRequestsResource<'a> {
16755 client: &'a Client,
16756}
16757
16758impl<'a> MeetingRequestsResource<'a> {
16759 /// Handle ICS reply for meeting requests
16760 ///
16761 /// `POST /meetingrequests/reply`
16762 ///
16763 /// Processes an external calendar reply using the invitation reply token. ACCEPTED and DECLINED replies can notify the inviter.
16764 ///
16765 /// # Example
16766 ///
16767 /// ```no_run
16768 /// # use churchtools_api::*;
16769 /// # use churchtools_api::queries::*;
16770 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16771 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16772 /// let body = models::MeetingRequestIcsReply {
16773 /// ics_content: "Hallo zusammen".into(),
16774 /// partstat: "ACCEPTED".into(),
16775 /// token: "example-reply-token".into(),
16776 /// ..Default::default()
16777 /// };
16778 /// client.meeting_requests().reply(&body)?;
16779 /// # Ok(())
16780 /// # }
16781 /// ```
16782 pub fn reply(&self, body: &models::MeetingRequestIcsReply) -> Result<()> {
16783 let path = "/meetingrequests/reply".to_owned();
16784 let query: Query = Query::new();
16785 let body = serde_json::to_value(body).expect("request body serializes");
16786 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
16787 }
16788
16789}
16790
16791/// `client.menu()`
16792#[derive(Clone, Copy)]
16793pub struct MenuResource<'a> {
16794 client: &'a Client,
16795}
16796
16797impl<'a> MenuResource<'a> {
16798 /// Get the CT-Menu
16799 ///
16800 /// `GET /menu`
16801 ///
16802 /// # Example
16803 ///
16804 /// ```
16805 /// # use churchtools_api::*;
16806 /// # use churchtools_api::queries::*;
16807 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16808 /// # let client = churchtools_api::replay::client("get-menu");
16809 /// let menu = client.menu().get()?;
16810 /// println!("{:?}", menu.current_station);
16811 /// # Ok(())
16812 /// # }
16813 /// ```
16814 pub fn get(&self) -> Result<models::GetMenuResponse> {
16815 let path = "/menu".to_owned();
16816 let query: Query = Query::new();
16817 self.client.request_json(Method::Get, &path, &query, None)
16818 }
16819
16820}
16821
16822/// `client.news_letter_integrations()`
16823#[derive(Clone, Copy)]
16824pub struct NewsLetterIntegrationsResource<'a> {
16825 client: &'a Client,
16826}
16827
16828impl<'a> NewsLetterIntegrationsResource<'a> {
16829 /// Get newsletter integration options
16830 ///
16831 /// `GET /newsletter-integrations`
16832 ///
16833 /// Lists active configured newsletter providers, their capabilities and available remote lists. Requires administer groups in churchgroup; this is not a public endpoint. Queries the providers and marks lists already mapped to any group with isAssigned, including groups outside the caller’s individual visibility. Assigned lists are not removed from the result. A caught provider exception is logged and represented as an empty lists array, with HTTP 200 and no per-provider error field. No providers yields data: \[\] and meta.count: 0. Results follow provider registration order and are not paginated.
16834 ///
16835 /// # Example
16836 ///
16837 /// ```
16838 /// # use churchtools_api::*;
16839 /// # use churchtools_api::queries::*;
16840 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16841 /// # let client = churchtools_api::replay::client("get-newsletter-integrations");
16842 /// for news_letter_integration in client.news_letter_integrations().list()? {
16843 /// println!("{}", news_letter_integration.can_create_lists);
16844 /// }
16845 /// # Ok(())
16846 /// # }
16847 /// ```
16848 pub fn list(&self) -> Result<Vec<models::NewsletterIntegrationOptions>> {
16849 let path = "/newsletter-integrations".to_owned();
16850 let query: Query = Query::new();
16851 self.client.request_data(Method::Get, &path, &query, None)
16852 }
16853
16854}
16855
16856/// `client.notes()`
16857#[derive(Clone, Copy)]
16858pub struct NotesResource<'a> {
16859 client: &'a Client,
16860}
16861
16862impl<'a> NotesResource<'a> {
16863 /// Create a note attached to an object
16864 ///
16865 /// `POST /notes/{domainType}/{domainId}`
16866 ///
16867 /// Creates a note linked to the object in the URL. Group notes require an existing group and group-note editing rights. Arrangement notes require "edit songcategory" permission for the parent song’s category. Person notes require person visibility, permission for the selected comment-viewer category, and person write or applicable group-member field-edit permission. Direct creation for `follow_up` is rejected; use the follow-up note API.
16868 ///
16869 /// # Example
16870 ///
16871 /// ```
16872 /// # use churchtools_api::*;
16873 /// # use churchtools_api::queries::*;
16874 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16875 /// # let client = churchtools_api::replay::client("post-notes-domainType-domainId");
16876 /// let body = models::NoteCreate {
16877 /// text: "Please follow up next week.".into(),
16878 /// ..Default::default()
16879 /// };
16880 /// let result = client.notes().create("group", 35, &body)?;
16881 /// println!("{}", result.id);
16882 /// # Ok(())
16883 /// # }
16884 /// ```
16885 pub fn create(&self, domain_type: impl Display, domain_id: impl Display, body: &models::NoteCreate) -> Result<models::Note> {
16886 let path = format!("/notes/{}/{}", seg(domain_type), seg(domain_id));
16887 let query: Query = Query::new();
16888 let body = serde_json::to_value(body).expect("request body serializes");
16889 self.client.request_data(Method::Post, &path, &query, Some(&body))
16890 }
16891
16892 /// Delete a note and all its links
16893 ///
16894 /// `DELETE /notes/{noteId}`
16895 ///
16896 /// Deletes the note from every linked business object. Authors can delete their notes without a fresh object-access check. Non-authors need global `churchdb` write access, and the first stored link must be a person link; person and comment visibility are not checked. Other domains do not allow non-author deletion. `DELETE /notes/{domainType}/{domainId}/{noteId}` is an equivalent alias whose domain path fields are ignored.
16897 ///
16898 /// # Example
16899 ///
16900 /// ```no_run
16901 /// # use churchtools_api::*;
16902 /// # use churchtools_api::queries::*;
16903 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16904 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16905 /// client.notes().delete(101)?;
16906 /// # Ok(())
16907 /// # }
16908 /// ```
16909 pub fn delete(&self, note_id: impl Display) -> Result<()> {
16910 let path = format!("/notes/{}", seg(note_id));
16911 let query: Query = Query::new();
16912 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
16913 }
16914
16915 /// Delete a note and all its links
16916 ///
16917 /// `DELETE /notes/{domainType}/{domainId}/{noteId}`
16918 ///
16919 /// Deletes the note and all its links, not only the link named in the URL. The handler ignores `domainType` and `domainId`. Authors can delete their notes without a fresh domain-access check. Non-authors need global `churchdb` write access, and the first stored link must be a person link; person and comment visibility are not checked. Other domains do not allow non-author deletion. `DELETE /notes/{noteId}` calls the same handler.
16920 ///
16921 /// # Example
16922 ///
16923 /// ```no_run
16924 /// # use churchtools_api::*;
16925 /// # use churchtools_api::queries::*;
16926 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16927 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
16928 /// client.notes().delete_for_object("group", "42", 101)?;
16929 /// # Ok(())
16930 /// # }
16931 /// ```
16932 pub fn delete_for_object(&self, domain_type: impl Display, domain_id: impl Display, note_id: impl Display) -> Result<()> {
16933 let path = format!("/notes/{}/{}/{}", seg(domain_type), seg(domain_id), seg(note_id));
16934 let query: Query = Query::new();
16935 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
16936 }
16937
16938 /// List visible notes attached to an object
16939 ///
16940 /// `GET /notes/{domainType}/{domainId}`
16941 ///
16942 /// Lists notes linked to the requested object, newest creation date first, without pagination. Group notes require group visibility and a sufficient security level, person notes require comment-viewer permission, arrangement notes require parent-song visibility, and follow-up notes require access to the follow-up. Authors bypass the group security-level or person comment-category filter after the initial domain check. Person notes do not check the requested person’s visibility or existence. Each note includes all links and uses its first stored link for top-level domain fields.
16943 ///
16944 /// # Example
16945 ///
16946 /// ```
16947 /// # use churchtools_api::*;
16948 /// # use churchtools_api::queries::*;
16949 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16950 /// # let client = churchtools_api::replay::client("get-notes");
16951 /// for note in client.notes().get("group", 35)? {
16952 /// println!("{}", note.id);
16953 /// }
16954 /// # Ok(())
16955 /// # }
16956 /// ```
16957 pub fn get(&self, domain_type: impl Display, domain_id: impl Display) -> Result<Vec<models::Note>> {
16958 let path = format!("/notes/{}/{}", seg(domain_type), seg(domain_id));
16959 let query: Query = Query::new();
16960 self.client.request_data(Method::Get, &path, &query, None)
16961 }
16962
16963 /// Replace an authored note’s text and visibility
16964 ///
16965 /// `PUT /notes/{domainType}/{domainId}/{noteId}`
16966 ///
16967 /// Updates a note owned by the current author. Only `noteId` selects the note; `domainId` does not verify its association. The shared text changes for every linked context, while visibility changes only on the first link matching `domainType`. No fresh domain or comment-category permission check is performed.
16968 ///
16969 /// # Example
16970 ///
16971 /// ```
16972 /// # use churchtools_api::*;
16973 /// # use churchtools_api::queries::*;
16974 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
16975 /// # let client = churchtools_api::replay::client("put-notes-domainType-domainId-id");
16976 /// let body = models::NoteUpdate {
16977 /// text: "Please follow up next week.".into(),
16978 /// ..Default::default()
16979 /// };
16980 /// let result = client.notes().update("group", 35, 101, &body)?;
16981 /// println!("{}", result.id);
16982 /// # Ok(())
16983 /// # }
16984 /// ```
16985 pub fn update(&self, domain_type: impl Display, domain_id: impl Display, note_id: impl Display, body: &models::NoteUpdate) -> Result<models::Note> {
16986 let path = format!("/notes/{}/{}/{}", seg(domain_type), seg(domain_id), seg(note_id));
16987 let query: Query = Query::new();
16988 let body = serde_json::to_value(body).expect("request body serializes");
16989 self.client.request_data(Method::Put, &path, &query, Some(&body))
16990 }
16991
16992}
16993
16994/// `client.notifications()`
16995#[derive(Clone, Copy)]
16996pub struct NotificationsResource<'a> {
16997 client: &'a Client,
16998}
16999
17000impl<'a> NotificationsResource<'a> {
17001 /// Send a test push notification to my devices
17002 ///
17003 /// `POST /notifications/test`
17004 ///
17005 /// Sends a localized test push notification to the authenticated person’s registered push-capable devices. No request body or target person is needed. The response has no body. A 201 response does not confirm delivery: it is also returned when no device is registered, Safe Mode suppresses sending, or a handled proxy/network error occurs.
17006 ///
17007 /// # Example
17008 ///
17009 /// ```no_run
17010 /// # use churchtools_api::*;
17011 /// # use churchtools_api::queries::*;
17012 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17013 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17014 /// client.notifications().test()?;
17015 /// # Ok(())
17016 /// # }
17017 /// ```
17018 pub fn test(&self) -> Result<()> {
17019 let path = "/notifications/test".to_owned();
17020 let query: Query = Query::new();
17021 self.client.request(Method::Post, &path, &query, None).map(|_| ())
17022 }
17023
17024}
17025
17026/// `client.nps()`
17027#[derive(Clone, Copy)]
17028pub struct NpsResource<'a> {
17029 client: &'a Client,
17030}
17031
17032impl<'a> NpsResource<'a> {
17033 /// Save NPS score
17034 ///
17035 /// `POST /nps`
17036 ///
17037 /// # Example
17038 ///
17039 /// ```no_run
17040 /// # use churchtools_api::*;
17041 /// # use churchtools_api::queries::*;
17042 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17043 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17044 /// let body = models::PostNpsBody {
17045 /// score: 42,
17046 /// ..Default::default()
17047 /// };
17048 /// let result = client.nps().create(&body)?;
17049 /// println!("{:?}", result.date);
17050 /// # Ok(())
17051 /// # }
17052 /// ```
17053 pub fn create(&self, body: &models::PostNpsBody) -> Result<models::PostNpsResponse> {
17054 let path = "/nps".to_owned();
17055 let query: Query = Query::new();
17056 let body = serde_json::to_value(body).expect("request body serializes");
17057 self.client.request_json(Method::Post, &path, &query, Some(&body))
17058 }
17059
17060}
17061
17062/// `client.oauth_clients()`
17063#[derive(Clone, Copy)]
17064pub struct OauthClientsResource<'a> {
17065 client: &'a Client,
17066}
17067
17068impl<'a> OauthClientsResource<'a> {
17069 /// Register an OAuth client
17070 ///
17071 /// `POST /oauthclients`
17072 ///
17073 /// Registers a visible OAuth client for an application that uses ChurchTools as its authorization server. Requires "churchcore administer settings" permission. The name must be unique, including hidden clients. Confidential clients receive a generated secret exactly once. Logo discovery can contact the redirect origin or configured metadata service.
17074 ///
17075 /// # Example
17076 ///
17077 /// ```
17078 /// # use churchtools_api::*;
17079 /// # use churchtools_api::queries::*;
17080 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17081 /// # let client = churchtools_api::replay::client("post-oauthclients");
17082 /// let body = models::OAuthClientCreate {
17083 /// name: "Parish website".into(),
17084 /// redirect_uri: "https://parish.example.org/oauth/callback".into(),
17085 /// ..Default::default()
17086 /// };
17087 /// let result = client.oauth_clients().create(&body)?;
17088 /// println!("{}", result.name);
17089 /// # Ok(())
17090 /// # }
17091 /// ```
17092 pub fn create(&self, body: &models::OAuthClientCreate) -> Result<models::OAuthClientCreated> {
17093 let path = "/oauthclients".to_owned();
17094 let query: Query = Query::new();
17095 let body = serde_json::to_value(body).expect("request body serializes");
17096 self.client.request_data(Method::Post, &path, &query, Some(&body))
17097 }
17098
17099 /// Delete an OAuth client
17100 ///
17101 /// `DELETE /oauthclients/{identifier}`
17102 ///
17103 /// Permanently deletes a visible OAuth client. Requires "churchcore administer settings" permission. Database cascades remove associated authorization codes, access tokens and consents. Hidden clients cannot be managed through this endpoint.
17104 ///
17105 /// # Example
17106 ///
17107 /// ```no_run
17108 /// # use churchtools_api::*;
17109 /// # use churchtools_api::queries::*;
17110 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17111 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17112 /// client.oauth_clients().delete("abc123")?;
17113 /// # Ok(())
17114 /// # }
17115 /// ```
17116 pub fn delete(&self, identifier: impl Display) -> Result<()> {
17117 let path = format!("/oauthclients/{}", seg(identifier));
17118 let query: Query = Query::new();
17119 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
17120 }
17121
17122 /// List registered OAuth clients
17123 ///
17124 /// `GET /oauthclients`
17125 ///
17126 /// Lists visible OAuth clients registered in this ChurchTools installation, without pagination or an explicit sort order. Requires "churchcore administer settings" permission. Client secrets and hashes are not included.
17127 ///
17128 /// # Example
17129 ///
17130 /// ```
17131 /// # use churchtools_api::*;
17132 /// # use churchtools_api::queries::*;
17133 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17134 /// # let client = churchtools_api::replay::client("get-oauthclients");
17135 /// for oauth_client in client.oauth_clients().list()? {
17136 /// println!("{}", oauth_client.name);
17137 /// }
17138 /// # Ok(())
17139 /// # }
17140 /// ```
17141 pub fn list(&self) -> Result<Vec<models::OAuthClient>> {
17142 let path = "/oauthclients".to_owned();
17143 let query: Query = Query::new();
17144 self.client.request_data(Method::Get, &path, &query, None)
17145 }
17146
17147 /// Update an OAuth client
17148 ///
17149 /// `PUT /oauthclients/{identifier}`
17150 ///
17151 /// Replaces the name and registered redirect URI of a visible OAuth client. Requires "churchcore administer settings" permission. The URI replaces all previously registered URI entries. The name must remain unique across visible and hidden clients. Logo discovery runs again from the new URI origin.
17152 ///
17153 /// # Example
17154 ///
17155 /// ```
17156 /// # use churchtools_api::*;
17157 /// # use churchtools_api::queries::*;
17158 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17159 /// # let client = churchtools_api::replay::client("put-oauthclients-identifier");
17160 /// let body = models::OAuthClientUpdate {
17161 /// name: "Parish website".into(),
17162 /// redirect_uri: "https://parish.example.org/oauth/callback".into(),
17163 /// ..Default::default()
17164 /// };
17165 /// let result = client.oauth_clients().update("abc123", &body)?;
17166 /// println!("{}", result.name);
17167 /// # Ok(())
17168 /// # }
17169 /// ```
17170 pub fn update(&self, identifier: impl Display, body: &models::OAuthClientUpdate) -> Result<models::OAuthClient> {
17171 let path = format!("/oauthclients/{}", seg(identifier));
17172 let query: Query = Query::new();
17173 let body = serde_json::to_value(body).expect("request body serializes");
17174 self.client.request_data(Method::Put, &path, &query, Some(&body))
17175 }
17176
17177}
17178
17179/// `client.permissions()`
17180#[derive(Clone, Copy)]
17181pub struct PermissionsResource<'a> {
17182 client: &'a Client,
17183}
17184
17185impl<'a> PermissionsResource<'a> {
17186 pub fn global(&self) -> PermissionsGlobalResource<'a> {
17187 PermissionsGlobalResource { client: self.client }
17188 }
17189
17190 pub fn internal(&self) -> PermissionsInternalResource<'a> {
17191 PermissionsInternalResource { client: self.client }
17192 }
17193
17194 pub fn origins(&self) -> PermissionsOriginsResource<'a> {
17195 PermissionsOriginsResource { client: self.client }
17196 }
17197
17198 /// Apply multiple raw permission changes atomically
17199 ///
17200 /// `POST /permissions/bulk`
17201 ///
17202 /// Applies raw permission changes atomically, including changes for different source owners. All entries are validated and authorized against the state before any writes. The authorization and locked-permission rules of the corresponding single-assignment operations apply to each entry. Any failure leaves all assignments unchanged. Duplicate owner/authId/inheritance keys are rejected. Permission caches are invalidated after commit. `save` is additive and an empty dataId list writes a null-data row; `replace` replaces the complete selection and an empty list removes it; `delete` removes exact selections or the whole assignment when no selections are specified. Validation errors identify fields such as `changes.2.authId`.
17203 ///
17204 /// # Example
17205 ///
17206 /// ```no_run
17207 /// # use churchtools_api::*;
17208 /// # use churchtools_api::queries::*;
17209 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17210 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17211 /// let body = models::PostPermissionsBulkBody {
17212 /// changes: vec![models::PermissionBulkChange {
17213 /// domain_id: 7,
17214 /// domain_type: "group_type_role".into(),
17215 /// ..Default::default()
17216 /// }],
17217 /// ..Default::default()
17218 /// };
17219 /// client.permissions().bulk(&body)?;
17220 /// # Ok(())
17221 /// # }
17222 /// ```
17223 pub fn bulk(&self, body: &models::PostPermissionsBulkBody) -> Result<()> {
17224 let path = "/permissions/bulk".to_owned();
17225 let query: Query = Query::new();
17226 let body = serde_json::to_value(body).expect("request body serializes");
17227 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
17228 }
17229
17230 /// Delete a raw permission assignment
17231 ///
17232 /// `DELETE /permissions/{domainType}/{domainId}`
17233 ///
17234 /// Deletes stored assignment rows for the owner in the path, authId and inheritance mode. Requires administer persons in churchcore, or specifically a group_role assignment for authId 10130/10131 plus churchdb +admin posts in that role’s actual group. Locked selections may only be changed by an authorized person. Omitting dataId, null or \[\] removes all selection rows in the chosen inheritance mode; a nonempty list deletes exact selections. -1 does not expand to concrete rows. type/reason do not filter deletion, so both grants and revocations matching the key are removed. Other assignment sources remain effective. Missing rows are harmless. The generic admin path does not verify the owner or permission definition exists, except obsolete authId=10127 returns 410. status/person disallow authId>=10000 and inheritance. The current deletion path does not explicitly invalidate the permission cache.
17235 ///
17236 /// # Example
17237 ///
17238 /// ```no_run
17239 /// # use churchtools_api::*;
17240 /// # use churchtools_api::queries::*;
17241 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17242 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17243 /// let body = models::PermissionDelete {
17244 /// auth_id: 10130,
17245 /// ..Default::default()
17246 /// };
17247 /// client.permissions().delete("group_role", 1, &body)?;
17248 /// # Ok(())
17249 /// # }
17250 /// ```
17251 pub fn delete(&self, domain_type: impl Display, domain_id: impl Display, body: &models::PermissionDelete) -> Result<()> {
17252 let path = format!("/permissions/{}/{}", seg(domain_type), seg(domain_id));
17253 let query: Query = Query::new();
17254 let body = serde_json::to_value(body).expect("request body serializes");
17255 self.client.request(Method::Delete, &path, &query, Some(&body)).map(|_| ())
17256 }
17257
17258 /// List permission definitions
17259 ///
17260 /// `GET /permissions/definitions`
17261 ///
17262 /// Returns registered permission definitions grouped by module. Requires administer persons in churchcore. global selects keys without a leading +; internal selects group-internal keys beginning with +; all includes both. Definitions explain assignable keys, not the current user’s effective permissions. Modules follow application ordering and modules without matching definitions are omitted. For data-field permissions, selections starts with dataId=-1 for unrestricted access to current and future values. Other selections come from the configured catalog without per-object visibility filtering. name and description currently contain the same text, and assignmentDomains is a fixed generic list. The response is not paginated.
17263 ///
17264 /// Use [`Self::get_definitions_with`] to pass query parameters.
17265 ///
17266 /// # Example
17267 ///
17268 /// ```
17269 /// # use churchtools_api::*;
17270 /// # use churchtools_api::queries::*;
17271 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17272 /// # let client = churchtools_api::replay::client("get-permissions-definitions");
17273 /// let definition = client.permissions().get_definitions()?;
17274 /// println!("{:?}", definition);
17275 /// # Ok(())
17276 /// # }
17277 /// ```
17278 pub fn get_definitions(&self) -> Result<models::GetPermissionsDefinitionsData> {
17279 self.get_definitions_with(&Default::default())
17280 }
17281
17282 /// List permission definitions
17283 ///
17284 /// Like [`Self::get_definitions`], with query parameters.
17285 ///
17286 /// `GET /permissions/definitions`
17287 ///
17288 /// Returns registered permission definitions grouped by module. Requires administer persons in churchcore. global selects keys without a leading +; internal selects group-internal keys beginning with +; all includes both. Definitions explain assignable keys, not the current user’s effective permissions. Modules follow application ordering and modules without matching definitions are omitted. For data-field permissions, selections starts with dataId=-1 for unrestricted access to current and future values. Other selections come from the configured catalog without per-object visibility filtering. name and description currently contain the same text, and assignmentDomains is a fixed generic list. The response is not paginated.
17289 pub fn get_definitions_with(&self, query: &GetPermissionsDefinitionsQuery) -> Result<models::GetPermissionsDefinitionsData> {
17290 let path = "/permissions/definitions".to_owned();
17291 let query: Query = query.to_query();
17292 self.client.request_data(Method::Get, &path, &query, None)
17293 }
17294
17295 /// List locked permissions
17296 ///
17297 /// `GET /permissions/locked`
17298 ///
17299 /// Lists all stored permission locks, ordered by permission ID and selection ID. Requires administer persons in churchcore, but the caller need not be an authorized contact person. A lock restricts assigning or removing the selected permission across assignment domains; it does not revoke existing grants or disable their use. Only authorized persons may change locked assignments. Locks can refer to global or group-internal permission keys. The response includes whether the current person is on the installation’s authorized-person list. Stored locks are returned without filtering inactive/obsolete definitions, and the result is not paginated.
17300 ///
17301 /// # Example
17302 ///
17303 /// ```
17304 /// # use churchtools_api::*;
17305 /// # use churchtools_api::queries::*;
17306 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17307 /// # let client = churchtools_api::replay::client("get-permissions-locked");
17308 /// let locked = client.permissions().get_locked()?;
17309 /// println!("{}", locked.is_current_user_authorized_person);
17310 /// # Ok(())
17311 /// # }
17312 /// ```
17313 pub fn get_locked(&self) -> Result<models::LockedPermissionState> {
17314 let path = "/permissions/locked".to_owned();
17315 let query: Query = Query::new();
17316 self.client.request_data(Method::Get, &path, &query, None)
17317 }
17318
17319 /// List permissions for a domain object
17320 ///
17321 /// `GET /permissions/{domainType}/{domainId}`
17322 ///
17323 /// Lists raw assignments for one source object. status/person address a person-status or person ID; group_type_role/group_role address their role IDs. group_type collects role-template assignments of that group type; group combines concrete group-role and associated group-type-role assignments, preserving each row’s actual owner domain and ID. Only permission IDs in the currently loaded active definition table are returned. No pagination, explicit ordering, or object-existence check is applied; an unknown owner normally returns an empty list. Intended access is administer persons in churchcore, with a restricted post-administration fallback. The current fallback passes an incomplete key to a boolean permission check and ignores its result; enabled assertions may fail the request. Otherwise direct-domain views restrict authIds to 10130/10131, but combined group/group_type views omit that restriction. This defect must not be treated as an authorization guarantee.
17324 ///
17325 /// # Example
17326 ///
17327 /// ```
17328 /// # use churchtools_api::*;
17329 /// # use churchtools_api::queries::*;
17330 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17331 /// # let client = churchtools_api::replay::client("get-permissions-permissionDomainType-permissionDomainId");
17332 /// for permission in client.permissions().list("person", 1)? {
17333 /// println!("{}", permission.auth_id);
17334 /// }
17335 /// # Ok(())
17336 /// # }
17337 /// ```
17338 pub fn list(&self, domain_type: impl Display, domain_id: impl Display) -> Result<Vec<models::Permission>> {
17339 let path = format!("/permissions/{}/{}", seg(domain_type), seg(domain_id));
17340 let query: Query = Query::new();
17341 self.client.request_data(Method::Get, &path, &query, None)
17342 }
17343
17344 /// Search selectable permission assignment targets
17345 ///
17346 /// `GET /permissions/assignment-targets`
17347 ///
17348 /// Requires "administer persons" in churchcore. Lists statuses, group-type role templates, concrete group roles, and persons, independently of existing assignments. Archived and inactive targets are included. Without query, lists all targets. Every whitespace-separated search word must match part of the name or its group/group-type context, irrespective of word order. SQL wildcard characters are treated literally. Results use one global pagination, ordered by category (status, group_type_role, group_role, person), name, context name, and domainId. Later categories can therefore start on later pages. Selection does not authorize assigning a specific permission; write endpoints check that separately. Group and role context is returned only for role targets.
17349 ///
17350 /// Use [`Self::list_assignment_targets_with`] to pass query parameters.
17351 ///
17352 /// # Example
17353 ///
17354 /// ```
17355 /// # use churchtools_api::*;
17356 /// # use churchtools_api::queries::*;
17357 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17358 /// # let client = churchtools_api::replay::client("get-permissions-assignment-targets");
17359 /// for assignment_target in client.permissions().list_assignment_targets()? {
17360 /// println!("{}", assignment_target.domain_id);
17361 /// }
17362 /// # Ok(())
17363 /// # }
17364 /// ```
17365 pub fn list_assignment_targets(&self) -> Result<Vec<models::PermissionAssignmentTarget>> {
17366 self.list_assignment_targets_with(&Default::default())
17367 }
17368
17369 /// Search selectable permission assignment targets
17370 ///
17371 /// Like [`Self::list_assignment_targets`], with query parameters.
17372 ///
17373 /// `GET /permissions/assignment-targets`
17374 ///
17375 /// Requires "administer persons" in churchcore. Lists statuses, group-type role templates, concrete group roles, and persons, independently of existing assignments. Archived and inactive targets are included. Without query, lists all targets. Every whitespace-separated search word must match part of the name or its group/group-type context, irrespective of word order. SQL wildcard characters are treated literally. Results use one global pagination, ordered by category (status, group_type_role, group_role, person), name, context name, and domainId. Later categories can therefore start on later pages. Selection does not authorize assigning a specific permission; write endpoints check that separately. Group and role context is returned only for role targets.
17376 pub fn list_assignment_targets_with(&self, query: &GetPermissionsAssignmentTargetsQuery) -> Result<Vec<models::PermissionAssignmentTarget>> {
17377 let path = "/permissions/assignment-targets".to_owned();
17378 let query: Query = query.to_query();
17379 self.client.collect_pages(&path, query)
17380 }
17381
17382 /// Search selectable permission assignment targets
17383 ///
17384 /// Like [`Self::list_assignment_targets_with`], but lazy: each page is fetched only when the iteration reaches it.
17385 /// Breaking off early saves the remaining requests.
17386 pub fn list_assignment_targets_iter(&self, query: &GetPermissionsAssignmentTargetsQuery) -> Items<models::PermissionAssignmentTarget> {
17387 let path = "/permissions/assignment-targets".to_owned();
17388 self.client.items(&path, query.to_query())
17389 }
17390
17391 /// List permissions for a domain type
17392 ///
17393 /// `GET /permissions/{domainType}`
17394 ///
17395 /// Lists stored permission assignments in one source domain; these are raw grants/revocations, not effective permissions. Optional domainId filters a specific assignment owner. group_type and group are combined read views and require domainId even on this short route; omitting it returns a validation error. group_type lists its role-template assignments, while group combines concrete group-role and corresponding group-type-role assignments. Returned rows retain their actual role domain/ID. Only authIds present in the currently loaded active definition table are included. No pagination, object-existence check or explicit ordering is applied. Intended access is administer persons in churchcore, with a limited post-administration fallback. That fallback currently uses an incomplete permission key and ignores its boolean result; with assertions enabled it may fail, and otherwise combined views are not restricted to the two post-creation authIds. Do not rely on this behavior as an authorization guarantee.
17396 ///
17397 /// Use [`Self::list_for_type_with`] to pass query parameters.
17398 ///
17399 /// # Example
17400 ///
17401 /// ```
17402 /// # use churchtools_api::*;
17403 /// # use churchtools_api::queries::*;
17404 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17405 /// # let client = churchtools_api::replay::client("get-permissions-permissionDomainType");
17406 /// for for_type in client.permissions().list_for_type("person")? {
17407 /// println!("{}", for_type.auth_id);
17408 /// }
17409 /// # Ok(())
17410 /// # }
17411 /// ```
17412 pub fn list_for_type(&self, domain_type: impl Display) -> Result<Vec<models::Permission>> {
17413 self.list_for_type_with(domain_type, &Default::default())
17414 }
17415
17416 /// List permissions for a domain type
17417 ///
17418 /// Like [`Self::list_for_type`], with query parameters.
17419 ///
17420 /// `GET /permissions/{domainType}`
17421 ///
17422 /// Lists stored permission assignments in one source domain; these are raw grants/revocations, not effective permissions. Optional domainId filters a specific assignment owner. group_type and group are combined read views and require domainId even on this short route; omitting it returns a validation error. group_type lists its role-template assignments, while group combines concrete group-role and corresponding group-type-role assignments. Returned rows retain their actual role domain/ID. Only authIds present in the currently loaded active definition table are included. No pagination, object-existence check or explicit ordering is applied. Intended access is administer persons in churchcore, with a limited post-administration fallback. That fallback currently uses an incomplete permission key and ignores its boolean result; with assertions enabled it may fail, and otherwise combined views are not restricted to the two post-creation authIds. Do not rely on this behavior as an authorization guarantee.
17423 pub fn list_for_type_with(&self, domain_type: impl Display, query: &GetPermissionsPermissionDomainTypeQuery) -> Result<Vec<models::Permission>> {
17424 let path = format!("/permissions/{}", seg(domain_type));
17425 let query: Query = query.to_query();
17426 self.client.request_data(Method::Get, &path, &query, None)
17427 }
17428
17429 /// Save a raw permission assignment
17430 ///
17431 /// `PUT /permissions/{domainType}/{domainId}`
17432 ///
17433 /// Adds or updates raw permission assignments for the source owner in the path. Requires administer persons in churchcore, or a group_role assignment for authId 10130/10131 and churchdb +admin posts in that role’s actual group. Locked selections additionally require an authorized person. type defaults to grant; revoke is only supported for group_role. Only role domains allow inheritance and internal authIds; status/person require authId<10000. Obsolete authId=10127 returns 410. dataId is an additive list: other existing selections remain. Omission, null or \[\] writes a null-data row, not an unrestricted grant; use \[-1\] for unrestricted selections. Currently any existing -1 row for the key/inheritance mode causes a nonempty-list update to be silently ignored, including reason/type changes. The general admin path does not validate owner, permission-definition or selection existence. Success returns 204 without a representation; it does not necessarily mean a row changed.
17434 ///
17435 /// # Example
17436 ///
17437 /// ```no_run
17438 /// # use churchtools_api::*;
17439 /// # use churchtools_api::queries::*;
17440 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17441 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17442 /// let body = models::PermissionUpdate {
17443 /// auth_id: 10130,
17444 /// ..Default::default()
17445 /// };
17446 /// client.permissions().update("group_role", 1, &body)?;
17447 /// # Ok(())
17448 /// # }
17449 /// ```
17450 pub fn update(&self, domain_type: impl Display, domain_id: impl Display, body: &models::PermissionUpdate) -> Result<()> {
17451 let path = format!("/permissions/{}/{}", seg(domain_type), seg(domain_id));
17452 let query: Query = Query::new();
17453 let body = serde_json::to_value(body).expect("request body serializes");
17454 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
17455 }
17456
17457 /// Update locked permissions
17458 ///
17459 /// `PUT /permissions/locked`
17460 ///
17461 /// Adds and removes permission locks in one transaction. Requires both administer persons in churchcore and membership in the installation’s authorized-person list. Both add and remove are required; empty lists are allowed. Duplicates are collapsed, existing additions and missing removals are harmless, but the same normalized pair in both lists returns 400. This is a delta update, not full replacement. Each authId must exist in the definition table loaded for the request. Boolean permissions require omitted/null dataId; selectable permissions require a non-null dataId. Concrete selection existence and range are currently not checked. Locks may concern internal or global permissions; -1 locks all values. Existing grants are not revoked. Returns the complete resulting list under data.permissions, without the authorization flag returned by GET.
17462 ///
17463 /// # Example
17464 ///
17465 /// ```no_run
17466 /// # use churchtools_api::*;
17467 /// # use churchtools_api::queries::*;
17468 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17469 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17470 /// let body = models::LockedPermissionUpdate {
17471 /// add: vec![models::LockedPermissionChange {
17472 /// auth_id: 1,
17473 /// ..Default::default()
17474 /// }],
17475 /// remove: vec![models::LockedPermissionChange {
17476 /// auth_id: 1,
17477 /// ..Default::default()
17478 /// }],
17479 /// ..Default::default()
17480 /// };
17481 /// let result = client.permissions().update_locked(&body)?;
17482 /// println!("{:?}", result);
17483 /// # Ok(())
17484 /// # }
17485 /// ```
17486 pub fn update_locked(&self, body: &models::LockedPermissionUpdate) -> Result<models::PutPermissionsLockedData> {
17487 let path = "/permissions/locked".to_owned();
17488 let query: Query = Query::new();
17489 let body = serde_json::to_value(body).expect("request body serializes");
17490 self.client.request_data(Method::Put, &path, &query, Some(&body))
17491 }
17492
17493 /// Replace a raw permission assignment
17494 ///
17495 /// `PUT /permissions/{domainType}/{domainId}/replace`
17496 ///
17497 /// Atomically replaces all raw assignment rows for the source owner, authId and inheritance mode. A nonempty dataId list becomes the complete selection; an empty list removes the assignment. The authorization, domain and locked-permission restrictions are the same as for updating and deleting the corresponding raw assignment.
17498 ///
17499 /// # Example
17500 ///
17501 /// ```no_run
17502 /// # use churchtools_api::*;
17503 /// # use churchtools_api::queries::*;
17504 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17505 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
17506 /// let body = models::PermissionReplace {
17507 /// auth_id: 10130,
17508 /// data_id: vec![1, 2],
17509 /// ..Default::default()
17510 /// };
17511 /// client.permissions().update_replace("group_role", 1, &body)?;
17512 /// # Ok(())
17513 /// # }
17514 /// ```
17515 pub fn update_replace(&self, domain_type: impl Display, domain_id: impl Display, body: &models::PermissionReplace) -> Result<()> {
17516 let path = format!("/permissions/{}/{}/replace", seg(domain_type), seg(domain_id));
17517 let query: Query = Query::new();
17518 let body = serde_json::to_value(body).expect("request body serializes");
17519 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
17520 }
17521
17522}
17523
17524/// `client.permissions().global_()`
17525#[derive(Clone, Copy)]
17526pub struct PermissionsGlobalResource<'a> {
17527 client: &'a Client,
17528}
17529
17530impl<'a> PermissionsGlobalResource<'a> {
17531 pub fn auths(&self) -> PermissionsGlobalAuthsResource<'a> {
17532 PermissionsGlobalAuthsResource { client: self.client }
17533 }
17534
17535 /// Get the current user’s global permissions
17536 ///
17537 /// `GET /permissions/global`
17538 ///
17539 /// Returns effective global permission values for the authenticated user, grouped by active module. No permission-administration grant is required. Includes registered keys even without a grant: boolean flags are false and selection arrays are empty. A maximum-level permission is represented by a one-element array with the effective maximum; unrestricted maximum access uses 99999. Multi-selection grants expand unrestricted access into currently available IDs, so this response cannot distinguish unrestricted access from explicit grants to all current values. Inactive modules are absent; compatibility aliases in churchdb can be null when their source in churchgroup is absent. Use the definitions and origins endpoints for value semantics and assignment provenance. Group-internal permissions and additional object policies are not combined here.
17540 ///
17541 /// # Example
17542 ///
17543 /// ```
17544 /// # use churchtools_api::*;
17545 /// # use churchtools_api::queries::*;
17546 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17547 /// # let client = churchtools_api::replay::client("get-permissions-global");
17548 /// let item = client.permissions().global().get()?;
17549 /// println!("{:?}", item);
17550 /// # Ok(())
17551 /// # }
17552 /// ```
17553 pub fn get(&self) -> Result<models::GlobalPermissions> {
17554 let path = "/permissions/global".to_owned();
17555 let query: Query = Query::new();
17556 self.client.request_data(Method::Get, &path, &query, None)
17557 }
17558
17559 /// Summarize Persons with Global Permissions
17560 ///
17561 /// `GET /permissions/global/person-summary`
17562 ///
17563 /// Returns every registered global permission of active modules with per-selection counts across non-archived persons. Requires administer persons in churchcore; this administrative overview has no additional person-visibility filter and does not generally exclude system users. Includes zero-count selections. Boolean permissions have one dataId=null selection. Data-field permissions start with unrestricted dataId=-1, followed by configured IDs in ascending order. Maximum grants count toward every configured level up to the effective maximum; unrestricted counts only include grants covering future values. Preview arrays contain the first three matching person IDs in ascending order. Permissions follow definition order. Counts across selections can overlap. No pagination or full person lists are returned; load /permissions/global/auths/{authId}/persons for one selection.
17564 ///
17565 /// # Example
17566 ///
17567 /// ```
17568 /// # use churchtools_api::*;
17569 /// # use churchtools_api::queries::*;
17570 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17571 /// # let client = churchtools_api::replay::client("get-permissions-global-person-summary");
17572 /// let person_summary = client.permissions().global().get_person_summary()?;
17573 /// println!("{:?}", person_summary);
17574 /// # Ok(())
17575 /// # }
17576 /// ```
17577 pub fn get_person_summary(&self) -> Result<models::GetPermissionsGlobalPersonSummaryData> {
17578 let path = "/permissions/global/person-summary".to_owned();
17579 let query: Query = Query::new();
17580 self.client.request_data(Method::Get, &path, &query, None)
17581 }
17582
17583}
17584
17585/// `client.permissions().global_().auths()`
17586#[derive(Clone, Copy)]
17587pub struct PermissionsGlobalAuthsResource<'a> {
17588 client: &'a Client,
17589}
17590
17591impl<'a> PermissionsGlobalAuthsResource<'a> {
17592 /// Summarize assignments of a global permission
17593 ///
17594 /// `GET /permissions/global/auths/{authId}/assignment-summary`
17595 ///
17596 /// Summarizes assignment sources for one global permission selection across non-archived persons. Requires administer persons in churchcore; does not filter the population to persons individually visible to the caller. data_id is required for selectable permissions and forbidden for boolean permissions; -1 selects genuinely unrestricted grants. Status, group-type-role, group-role and direct-person assignments are grouped into separate lists. Counts are distinct within one entry and can overlap across entries. Logged-in defaults, public-user rights and super-admin status count toward effectivePersonCount but have no breakdown entries, so the total need not match the sum even without overlapping assignments. Revoked sources are excluded. Unknown, inactive or group-internal authId values return 404. The result is not paginated.
17597 ///
17598 /// Use [`Self::get_assignment_summary_with`] to pass query parameters.
17599 ///
17600 /// # Example
17601 ///
17602 /// ```
17603 /// # use churchtools_api::*;
17604 /// # use churchtools_api::queries::*;
17605 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17606 /// # let client = churchtools_api::replay::client("get-permissions-global-auths-authId-assignment-summary");
17607 /// let assignment_summary = client.permissions().global().auths().get_assignment_summary(125)?;
17608 /// println!("{}", assignment_summary.auth_id);
17609 /// # Ok(())
17610 /// # }
17611 /// ```
17612 pub fn get_assignment_summary(&self, auth_id: impl Display) -> Result<models::PermissionAssignmentSummary> {
17613 self.get_assignment_summary_with(auth_id, &Default::default())
17614 }
17615
17616 /// Summarize assignments of a global permission
17617 ///
17618 /// Like [`Self::get_assignment_summary`], with query parameters.
17619 ///
17620 /// `GET /permissions/global/auths/{authId}/assignment-summary`
17621 ///
17622 /// Summarizes assignment sources for one global permission selection across non-archived persons. Requires administer persons in churchcore; does not filter the population to persons individually visible to the caller. data_id is required for selectable permissions and forbidden for boolean permissions; -1 selects genuinely unrestricted grants. Status, group-type-role, group-role and direct-person assignments are grouped into separate lists. Counts are distinct within one entry and can overlap across entries. Logged-in defaults, public-user rights and super-admin status count toward effectivePersonCount but have no breakdown entries, so the total need not match the sum even without overlapping assignments. Revoked sources are excluded. Unknown, inactive or group-internal authId values return 404. The result is not paginated.
17623 pub fn get_assignment_summary_with(&self, auth_id: impl Display, query: &GetPermissionsGlobalAuthsAuthIdAssignmentSummaryQuery) -> Result<models::PermissionAssignmentSummary> {
17624 let path = format!("/permissions/global/auths/{}/assignment-summary", seg(auth_id));
17625 let query: Query = query.to_query();
17626 self.client.request_data(Method::Get, &path, &query, None)
17627 }
17628
17629 /// List Persons with a Global Permission
17630 ///
17631 /// `GET /permissions/global/auths/{authId}/persons`
17632 ///
17633 /// Lists non-archived persons with one effective global permission selection, in ascending numeric ID order. Requires administer persons in churchcore; there is no additional person-visibility filter or general exclusion of system users. Contributions from direct assignments, status, group roles, public-user rights, logged-in defaults and super-admin status are combined. For selectable permissions, data_id is required: a configured ID selects that value and -1 selects genuinely unrestricted access to current and future values. Maximum permissions match when their effective maximum reaches the requested value. For boolean permissions data_id must be omitted, and the selection has dataId=null. Unknown, inactive or internal authId values return 404; invalid/missing selections return 400. By default all matching IDs are returned. Supplying page, limit OR include=origins enables pagination, defaulting to page 1 and limit 50. include=origins adds contributing, non-revoked sources for each person on that page. Pagination metadata is inside data.meta.
17634 ///
17635 /// Use [`Self::get_persons_with`] to pass query parameters.
17636 ///
17637 /// # Example
17638 ///
17639 /// ```
17640 /// # use churchtools_api::*;
17641 /// # use churchtools_api::queries::*;
17642 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17643 /// # let client = churchtools_api::replay::client("get-permissions-global-auths-authId-persons");
17644 /// let person = client.permissions().global().auths().get_persons(125)?;
17645 /// println!("{}", person.auth_id);
17646 /// # Ok(())
17647 /// # }
17648 /// ```
17649 pub fn get_persons(&self, auth_id: impl Display) -> Result<models::PermissionPersons> {
17650 self.get_persons_with(auth_id, &Default::default())
17651 }
17652
17653 /// List Persons with a Global Permission
17654 ///
17655 /// Like [`Self::get_persons`], with query parameters.
17656 ///
17657 /// `GET /permissions/global/auths/{authId}/persons`
17658 ///
17659 /// Lists non-archived persons with one effective global permission selection, in ascending numeric ID order. Requires administer persons in churchcore; there is no additional person-visibility filter or general exclusion of system users. Contributions from direct assignments, status, group roles, public-user rights, logged-in defaults and super-admin status are combined. For selectable permissions, data_id is required: a configured ID selects that value and -1 selects genuinely unrestricted access to current and future values. Maximum permissions match when their effective maximum reaches the requested value. For boolean permissions data_id must be omitted, and the selection has dataId=null. Unknown, inactive or internal authId values return 404; invalid/missing selections return 400. By default all matching IDs are returned. Supplying page, limit OR include=origins enables pagination, defaulting to page 1 and limit 50. include=origins adds contributing, non-revoked sources for each person on that page. Pagination metadata is inside data.meta.
17660 pub fn get_persons_with(&self, auth_id: impl Display, query: &GetPermissionsGlobalAuthsAuthIdPersonsQuery) -> Result<models::PermissionPersons> {
17661 let path = format!("/permissions/global/auths/{}/persons", seg(auth_id));
17662 let query: Query = query.to_query();
17663 self.client.request_data(Method::Get, &path, &query, None)
17664 }
17665
17666}
17667
17668/// `client.permissions().internal()`
17669#[derive(Clone, Copy)]
17670pub struct PermissionsInternalResource<'a> {
17671 client: &'a Client,
17672}
17673
17674impl<'a> PermissionsInternalResource<'a> {
17675 pub fn events(&self) -> PermissionsInternalEventsResource<'a> {
17676 PermissionsInternalEventsResource { client: self.client }
17677 }
17678
17679 pub fn groups(&self) -> PermissionsInternalGroupsResource<'a> {
17680 PermissionsInternalGroupsResource { client: self.client }
17681 }
17682
17683 pub fn persons(&self) -> PermissionsInternalPersonsResource<'a> {
17684 PermissionsInternalPersonsResource { client: self.client }
17685 }
17686
17687}
17688
17689/// `client.permissions().internal().events()`
17690#[derive(Clone, Copy)]
17691pub struct PermissionsInternalEventsResource<'a> {
17692 client: &'a Client,
17693}
17694
17695impl<'a> PermissionsInternalEventsResource<'a> {
17696 /// Lookup event-related internal permissions
17697 ///
17698 /// `GET /permissions/internal/events/{eventId}`
17699 ///
17700 /// Calculates internal group permissions for the currently logged-in person from groups connected to service roles. internalPerms contains event-level grants, while serviceGroups and services are maps keyed by master-data IDs. Only granted keys appear and their values are `true`; an empty area is returned as \[\]. Role and service-group grants are collected across connected roles and do not require an assignment in this event.
17701 ///
17702 /// # Example
17703 ///
17704 /// ```
17705 /// # use churchtools_api::*;
17706 /// # use churchtools_api::queries::*;
17707 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17708 /// # let client = churchtools_api::replay::client("get-permissions-internal-events-eventId");
17709 /// let event = client.permissions().internal().events().get(42)?;
17710 /// println!("{:?}", event);
17711 /// # Ok(())
17712 /// # }
17713 /// ```
17714 pub fn get(&self, event_id: impl Display) -> Result<models::InternalEventPermissions> {
17715 let path = format!("/permissions/internal/events/{}", seg(event_id));
17716 let query: Query = Query::new();
17717 self.client.request_data(Method::Get, &path, &query, None)
17718 }
17719
17720}
17721
17722/// `client.permissions().internal().groups()`
17723#[derive(Clone, Copy)]
17724pub struct PermissionsInternalGroupsResource<'a> {
17725 client: &'a Client,
17726}
17727
17728impl<'a> PermissionsInternalGroupsResource<'a> {
17729 pub fn auths(&self) -> PermissionsInternalGroupsAuthsResource<'a> {
17730 PermissionsInternalGroupsAuthsResource { client: self.client }
17731 }
17732
17733 /// Get the current user’s internal permissions for a group
17734 ///
17735 /// `GET /permissions/internal/groups/{groupId}`
17736 ///
17737 /// Calculates the authenticated user’s group-internal permissions for the target group, including inherited grants from superior groups. Values are grouped by active module. Registered flags without grants are false; level/selection values without grants are 0. Maximum-level grants are integers (99999 for unrestricted), while multiple selections are integer arrays. No permission-administration grant or group-visibility check is performed, and the group is not loaded: an unknown group ID returns the default permission structure rather than 404. Global grants and object policies are separate, so this response is not a complete authorization decision. Unlike the all-groups endpoint, this response includes legacy +create posts, derived as the conjunction of internal and visible post-creation grants.
17738 ///
17739 /// # Example
17740 ///
17741 /// ```
17742 /// # use churchtools_api::*;
17743 /// # use churchtools_api::queries::*;
17744 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17745 /// # let client = churchtools_api::replay::client("get-permissions-internal-groups-groupId");
17746 /// let group = client.permissions().internal().groups().get(42)?;
17747 /// println!("{:?}", group);
17748 /// # Ok(())
17749 /// # }
17750 /// ```
17751 pub fn get(&self, group_id: impl Display) -> Result<models::InternalGroupPermissions> {
17752 let path = format!("/permissions/internal/groups/{}", seg(group_id));
17753 let query: Query = Query::new();
17754 self.client.request_data(Method::Get, &path, &query, None)
17755 }
17756
17757 /// Get the current user’s internal permissions by group
17758 ///
17759 /// `GET /permissions/internal/groups`
17760 ///
17761 /// Calculates the authenticated user’s group-internal permissions from active memberships, role assignments and inheritance through the group hierarchy. Returns an unpaginated map keyed by target group ID, or \[\] when there are no calculated groups. Values are grouped by active module, including false/0 defaults for registered keys without grants. This is an internal-permission calculation, not a list of visible groups or a complete authorization decision: global grants and object policies are separate. No permission-administration grant is required. The legacy +create posts flag is derived only by the single-group endpoint, not here.
17762 ///
17763 /// # Example
17764 ///
17765 /// ```
17766 /// # use churchtools_api::*;
17767 /// # use churchtools_api::queries::*;
17768 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17769 /// # let client = churchtools_api::replay::client("get-permissions-internal-groups");
17770 /// let result = client.permissions().internal().groups().list()?;
17771 /// println!("{:?}", result);
17772 /// # Ok(())
17773 /// # }
17774 /// ```
17775 pub fn list(&self) -> Result<serde_json::Value> {
17776 let path = "/permissions/internal/groups".to_owned();
17777 let query: Query = Query::new();
17778 self.client.request_data(Method::Get, &path, &query, None)
17779 }
17780
17781}
17782
17783/// `client.permissions().internal().groups().auths()`
17784#[derive(Clone, Copy)]
17785pub struct PermissionsInternalGroupsAuthsResource<'a> {
17786 client: &'a Client,
17787}
17788
17789impl<'a> PermissionsInternalGroupsAuthsResource<'a> {
17790 /// List Persons with a Group-Internal Permission
17791 ///
17792 /// `GET /permissions/internal/groups/{groupId}/auths/{authId}/persons`
17793 ///
17794 /// Lists non-archived persons with one effective group-internal permission in the target group, combining direct and inherited grants and excluding revoked contributions. Requires administer persons in churchcore. The group must exist, but no additional group/person visibility check is performed. For selectable permissions data_id is required: a configured ID yields one selection, while -1 yields one selection for each currently configured value in ascending order, possibly none. Unlike the global endpoint, -1 does not mean only persons with unrestricted grants. Maximum permissions match every requested level up to the effective maximum. For boolean permissions omit data_id; the single selection then has dataId=null. Person IDs are sorted numerically. No pagination or include=origins option is implemented here. Unknown groups and unknown, inactive or global authId values return 404; invalid selection combinations return 400.
17795 ///
17796 /// Use [`Self::get_persons_with`] to pass query parameters.
17797 ///
17798 /// # Example
17799 ///
17800 /// ```
17801 /// # use churchtools_api::*;
17802 /// # use churchtools_api::queries::*;
17803 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17804 /// # let client = churchtools_api::replay::client("get-permissions-internal-groups-groupId-auths-authId-persons");
17805 /// let person = client.permissions().internal().groups().auths().get_persons(42, 125)?;
17806 /// println!("{}", person.auth_id);
17807 /// # Ok(())
17808 /// # }
17809 /// ```
17810 pub fn get_persons(&self, group_id: impl Display, auth_id: impl Display) -> Result<models::PermissionPersons> {
17811 self.get_persons_with(group_id, auth_id, &Default::default())
17812 }
17813
17814 /// List Persons with a Group-Internal Permission
17815 ///
17816 /// Like [`Self::get_persons`], with query parameters.
17817 ///
17818 /// `GET /permissions/internal/groups/{groupId}/auths/{authId}/persons`
17819 ///
17820 /// Lists non-archived persons with one effective group-internal permission in the target group, combining direct and inherited grants and excluding revoked contributions. Requires administer persons in churchcore. The group must exist, but no additional group/person visibility check is performed. For selectable permissions data_id is required: a configured ID yields one selection, while -1 yields one selection for each currently configured value in ascending order, possibly none. Unlike the global endpoint, -1 does not mean only persons with unrestricted grants. Maximum permissions match every requested level up to the effective maximum. For boolean permissions omit data_id; the single selection then has dataId=null. Person IDs are sorted numerically. No pagination or include=origins option is implemented here. Unknown groups and unknown, inactive or global authId values return 404; invalid selection combinations return 400.
17821 pub fn get_persons_with(&self, group_id: impl Display, auth_id: impl Display, query: &GetPermissionsInternalGroupsGroupIdAuthsAuthIdPersonsQuery) -> Result<models::PermissionPersons> {
17822 let path = format!("/permissions/internal/groups/{}/auths/{}/persons", seg(group_id), seg(auth_id));
17823 let query: Query = query.to_query();
17824 self.client.request_data(Method::Get, &path, &query, None)
17825 }
17826
17827}
17828
17829/// `client.permissions().internal().persons()`
17830#[derive(Clone, Copy)]
17831pub struct PermissionsInternalPersonsResource<'a> {
17832 client: &'a Client,
17833}
17834
17835impl<'a> PermissionsInternalPersonsResource<'a> {
17836 /// Get the current user’s internal permissions toward a person
17837 ///
17838 /// `GET /permissions/internal/persons/{personId}`
17839 ///
17840 /// Calculates what the authenticated user is granted through group-internal permissions toward the target person. It does not return that person’s own grants. The target groups come from the person’s memberships in non-archived groups, currently including requested, waiting and to-delete memberships. The caller’s effective internal grants across those groups are combined by maximum value for person-related keys. Missing flags are false and missing levels are 0; unrestricted levels use 99999. No person-visibility or existence check is performed, so an unknown person ID returns default values rather than 404. Global grants and additional person policies are not included. +edit persons is a deprecated boolean derived from the modern person-field level. Service-module keys are absent when that module is inactive.
17841 ///
17842 /// # Example
17843 ///
17844 /// ```
17845 /// # use churchtools_api::*;
17846 /// # use churchtools_api::queries::*;
17847 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17848 /// # let client = churchtools_api::replay::client("get-permissions-internal-persons-id");
17849 /// let person = client.permissions().internal().persons().get(42)?;
17850 /// println!("{:?}", person);
17851 /// # Ok(())
17852 /// # }
17853 /// ```
17854 pub fn get(&self, person_id: impl Display) -> Result<models::InternalPersonPermissions> {
17855 let path = format!("/permissions/internal/persons/{}", seg(person_id));
17856 let query: Query = Query::new();
17857 self.client.request_data(Method::Get, &path, &query, None)
17858 }
17859
17860}
17861
17862/// `client.permissions().origins()`
17863#[derive(Clone, Copy)]
17864pub struct PermissionsOriginsResource<'a> {
17865 client: &'a Client,
17866}
17867
17868impl<'a> PermissionsOriginsResource<'a> {
17869 pub fn global(&self) -> PermissionsOriginsGlobalResource<'a> {
17870 PermissionsOriginsGlobalResource { client: self.client }
17871 }
17872
17873 pub fn internal(&self) -> PermissionsOriginsInternalResource<'a> {
17874 PermissionsOriginsInternalResource { client: self.client }
17875 }
17876
17877}
17878
17879/// `client.permissions().origins().global_()`
17880#[derive(Clone, Copy)]
17881pub struct PermissionsOriginsGlobalResource<'a> {
17882 client: &'a Client,
17883}
17884
17885impl<'a> PermissionsOriginsGlobalResource<'a> {
17886 pub fn persons(&self) -> PermissionsOriginsGlobalPersonsResource<'a> {
17887 PermissionsOriginsGlobalPersonsResource { client: self.client }
17888 }
17889
17890}
17891
17892/// `client.permissions().origins().global_().persons()`
17893#[derive(Clone, Copy)]
17894pub struct PermissionsOriginsGlobalPersonsResource<'a> {
17895 client: &'a Client,
17896}
17897
17898impl<'a> PermissionsOriginsGlobalPersonsResource<'a> {
17899 /// Explain Global Permissions of a Person
17900 ///
17901 /// `GET /permissions/origins/global/persons/{personId}`
17902 ///
17903 /// Explains global permission sources for the person specified in the path. Requires administer persons in churchcore even for the caller’s own ID. Sources include logged-in defaults, public-user rights, person status, direct person assignments, direct group/group-type roles and super-admin status. Only active memberships in groups that grant permissions contribute; archived persons have no normal origin data. No person-visibility or existence check is performed: unknown or archived IDs return the requested personId with an empty permissions array rather than 404. Entries follow active permission-definition order; each origin carries its own contribution and the entry carries the combined value. Global maximum-level values are integers here, unlike the arrays used by /permissions/global. No pagination is applied.
17904 ///
17905 /// # Example
17906 ///
17907 /// ```
17908 /// # use churchtools_api::*;
17909 /// # use churchtools_api::queries::*;
17910 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17911 /// # let client = churchtools_api::replay::client("get-permissions-origins-global-persons-personId");
17912 /// let person = client.permissions().origins().global().persons().get(42)?;
17913 /// println!("{}", person.person_id);
17914 /// # Ok(())
17915 /// # }
17916 /// ```
17917 pub fn get(&self, person_id: impl Display) -> Result<models::GetPermissionsOriginsGlobalPersonsPersonIdData> {
17918 let path = format!("/permissions/origins/global/persons/{}", seg(person_id));
17919 let query: Query = Query::new();
17920 self.client.request_data(Method::Get, &path, &query, None)
17921 }
17922
17923}
17924
17925/// `client.permissions().origins().internal()`
17926#[derive(Clone, Copy)]
17927pub struct PermissionsOriginsInternalResource<'a> {
17928 client: &'a Client,
17929}
17930
17931impl<'a> PermissionsOriginsInternalResource<'a> {
17932 pub fn persons(&self) -> PermissionsOriginsInternalPersonsResource<'a> {
17933 PermissionsOriginsInternalPersonsResource { client: self.client }
17934 }
17935
17936}
17937
17938/// `client.permissions().origins().internal().persons()`
17939#[derive(Clone, Copy)]
17940pub struct PermissionsOriginsInternalPersonsResource<'a> {
17941 client: &'a Client,
17942}
17943
17944impl<'a> PermissionsOriginsInternalPersonsResource<'a> {
17945 /// Explain Group Internal Permissions of a Person
17946 ///
17947 /// `GET /permissions/origins/internal/persons/{personId}`
17948 ///
17949 /// Explains the specified person’s group-internal (+) permission origins, grouped by target group. Requires administer persons in churchcore; no additional person/group visibility check is performed. Origins are group-role and group-type-role assignments from active memberships. inherited=true identifies a grant reaching the target through a superior group; origin.groupId is the donor group, while the outer groupId is the target. revokedByGroupRoleId marks a contribution canceled by that group role. Entries with only revoked contributions are still returned with false, 0 or \[\] as effectiveValue, so presence alone does not mean access is granted. Omit group_ids to inspect all targets; an explicit empty array selects none. Unknown target IDs and targets without recorded contributions are omitted. Unknown or archived person IDs return the requested personId and an empty groups array. Permissions follow definition order; no explicit group ordering or pagination is applied.
17950 ///
17951 /// Use [`Self::get_with`] to pass query parameters.
17952 ///
17953 /// # Example
17954 ///
17955 /// ```
17956 /// # use churchtools_api::*;
17957 /// # use churchtools_api::queries::*;
17958 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17959 /// # let client = churchtools_api::replay::client("get-permissions-origins-internal-persons-personId");
17960 /// let person = client.permissions().origins().internal().persons().get(42)?;
17961 /// println!("{}", person.person_id);
17962 /// # Ok(())
17963 /// # }
17964 /// ```
17965 pub fn get(&self, person_id: impl Display) -> Result<models::GetPermissionsOriginsInternalPersonsPersonIdData> {
17966 self.get_with(person_id, &Default::default())
17967 }
17968
17969 /// Explain Group Internal Permissions of a Person
17970 ///
17971 /// Like [`Self::get`], with query parameters.
17972 ///
17973 /// `GET /permissions/origins/internal/persons/{personId}`
17974 ///
17975 /// Explains the specified person’s group-internal (+) permission origins, grouped by target group. Requires administer persons in churchcore; no additional person/group visibility check is performed. Origins are group-role and group-type-role assignments from active memberships. inherited=true identifies a grant reaching the target through a superior group; origin.groupId is the donor group, while the outer groupId is the target. revokedByGroupRoleId marks a contribution canceled by that group role. Entries with only revoked contributions are still returned with false, 0 or \[\] as effectiveValue, so presence alone does not mean access is granted. Omit group_ids to inspect all targets; an explicit empty array selects none. Unknown target IDs and targets without recorded contributions are omitted. Unknown or archived person IDs return the requested personId and an empty groups array. Permissions follow definition order; no explicit group ordering or pagination is applied.
17976 pub fn get_with(&self, person_id: impl Display, query: &GetPermissionsOriginsInternalPersonsPersonIdQuery) -> Result<models::GetPermissionsOriginsInternalPersonsPersonIdData> {
17977 let path = format!("/permissions/origins/internal/persons/{}", seg(person_id));
17978 let query: Query = query.to_query();
17979 self.client.request_data(Method::Get, &path, &query, None)
17980 }
17981
17982}
17983
17984/// `client.person()`
17985#[derive(Clone, Copy)]
17986pub struct PersonResource<'a> {
17987 client: &'a Client,
17988}
17989
17990impl<'a> PersonResource<'a> {
17991 pub fn comment_viewers(&self) -> PersonCommentViewersResource<'a> {
17992 PersonCommentViewersResource { client: self.client }
17993 }
17994
17995 pub fn grow_paths(&self) -> PersonGrowPathsResource<'a> {
17996 PersonGrowPathsResource { client: self.client }
17997 }
17998
17999 pub fn relationship_types(&self) -> PersonRelationshipTypesResource<'a> {
18000 PersonRelationshipTypesResource { client: self.client }
18001 }
18002
18003 pub fn sexes(&self) -> PersonSexesResource<'a> {
18004 PersonSexesResource { client: self.client }
18005 }
18006
18007 /// Get People & Groups reference catalogs
18008 ///
18009 /// `GET /person/masterdata`
18010 ///
18011 /// Returns complete reference catalogs for People & Groups, including membership roles, group and person classifications, campuses, relationship types and meeting feedback templates. These are reference definitions, not person records or group memberships. Roles are ordered by type and `sortKey`; campuses by `sortKey`.
18012 ///
18013 /// # Example
18014 ///
18015 /// ```
18016 /// # use churchtools_api::*;
18017 /// # use churchtools_api::queries::*;
18018 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18019 /// # let client = churchtools_api::replay::client("get-person-masterdata");
18020 /// let master_data = client.person().get_master_data()?;
18021 /// println!("{:?}", master_data);
18022 /// # Ok(())
18023 /// # }
18024 /// ```
18025 pub fn get_master_data(&self) -> Result<models::PersonMasterData> {
18026 let path = "/person/masterdata".to_owned();
18027 let query: Query = Query::new();
18028 self.client.request_data(Method::Get, &path, &query, None)
18029 }
18030
18031}
18032
18033/// `client.person().comment_viewers()`
18034#[derive(Clone, Copy)]
18035pub struct PersonCommentViewersResource<'a> {
18036 client: &'a Client,
18037}
18038
18039impl<'a> PersonCommentViewersResource<'a> {
18040 /// Create a person-comment visibility category
18041 ///
18042 /// `POST /person/commentviewers`
18043 ///
18044 /// Creates a visibility category for person comments and person-linked notes. Requires edit masterdata in churchdb. name is trimmed and must contain 1–50 characters; duplicate names are allowed. sortKey defaults to 0. The returned category has a generated ID and a translated display name. Creating a category does not assign view comments permissions to any person or role.
18045 ///
18046 /// # Example
18047 ///
18048 /// ```
18049 /// # use churchtools_api::*;
18050 /// # use churchtools_api::queries::*;
18051 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18052 /// # let client = churchtools_api::replay::client("post-person-commentviewers");
18053 /// let body = models::CommentViewerCreate {
18054 /// name: "Pastoral team".into(),
18055 /// ..Default::default()
18056 /// };
18057 /// let result = client.person().comment_viewers().create(&body)?;
18058 /// println!("{}", result.name);
18059 /// # Ok(())
18060 /// # }
18061 /// ```
18062 pub fn create(&self, body: &models::CommentViewerCreate) -> Result<models::CommentViewer> {
18063 let path = "/person/commentviewers".to_owned();
18064 let query: Query = Query::new();
18065 let body = serde_json::to_value(body).expect("request body serializes");
18066 self.client.request_data(Method::Post, &path, &query, Some(&body))
18067 }
18068
18069 /// Delete a person-comment visibility category
18070 ///
18071 /// `DELETE /person/commentviewers/{id}`
18072 ///
18073 /// Deletes an unused visibility category. Requires edit masterdata in churchdb. Legacy person comments and note links referencing this category block deletion with 409. Successful deletion also removes explicit churchdb view comments assignments for this category and invalidates the permission cache. dry_run=true only checks references and returns 409 with the deletion report even when deletion would be allowed; it never returns 204. A missing category is not explicitly loaded before deletion, so a real delete can return 204 without having removed a row.
18074 ///
18075 /// Use [`Self::delete_with`] to pass query parameters.
18076 ///
18077 /// # Example
18078 ///
18079 /// ```no_run
18080 /// # use churchtools_api::*;
18081 /// # use churchtools_api::queries::*;
18082 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18083 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18084 /// client.person().comment_viewers().delete(1)?;
18085 /// # Ok(())
18086 /// # }
18087 /// ```
18088 pub fn delete(&self, id: impl Display) -> Result<()> {
18089 self.delete_with(id, &Default::default())
18090 }
18091
18092 /// Delete a person-comment visibility category
18093 ///
18094 /// Like [`Self::delete`], with query parameters.
18095 ///
18096 /// `DELETE /person/commentviewers/{id}`
18097 ///
18098 /// Deletes an unused visibility category. Requires edit masterdata in churchdb. Legacy person comments and note links referencing this category block deletion with 409. Successful deletion also removes explicit churchdb view comments assignments for this category and invalidates the permission cache. dry_run=true only checks references and returns 409 with the deletion report even when deletion would be allowed; it never returns 204. A missing category is not explicitly loaded before deletion, so a real delete can return 204 without having removed a row.
18099 pub fn delete_with(&self, id: impl Display, query: &DeletePersonCommentviewersIdQuery) -> Result<()> {
18100 let path = format!("/person/commentviewers/{}", seg(id));
18101 let query: Query = query.to_query();
18102 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18103 }
18104
18105 /// Get a person-comment visibility category
18106 ///
18107 /// `GET /person/commentviewers/{id}`
18108 ///
18109 /// Returns one category used to classify the visibility of person comments and person-linked notes. Requires authentication; no master-data-edit or view-comments grant for this category is checked. Reading this catalog entry does not authorize reading comments assigned to it. Includes its stored name, translated display name and sort key. Unknown IDs return 404.
18110 ///
18111 /// # Example
18112 ///
18113 /// ```
18114 /// # use churchtools_api::*;
18115 /// # use churchtools_api::queries::*;
18116 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18117 /// # let client = churchtools_api::replay::client("get-person-commentviewers-id");
18118 /// let comment_viewer = client.person().comment_viewers().get(1)?;
18119 /// println!("{}", comment_viewer.name);
18120 /// # Ok(())
18121 /// # }
18122 /// ```
18123 pub fn get(&self, id: impl Display) -> Result<models::CommentViewer> {
18124 let path = format!("/person/commentviewers/{}", seg(id));
18125 let query: Query = Query::new();
18126 self.client.request_data(Method::Get, &path, &query, None)
18127 }
18128
18129 /// List person-comment visibility categories
18130 ///
18131 /// `GET /person/commentviewers`
18132 ///
18133 /// Lists all configured visibility categories for person comments and person-linked notes. A category is not a user group: assign churchdb view comments for its ID to control who may see matching content, subject to the content endpoint’s additional rules. Requires authentication, but no master-data-edit or per-category view-comments permission is checked here. The catalog is unpaginated and includes categories the caller cannot use to read content. Results are sorted by sortKey, then the stored name, both ascending.
18134 ///
18135 /// # Example
18136 ///
18137 /// ```
18138 /// # use churchtools_api::*;
18139 /// # use churchtools_api::queries::*;
18140 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18141 /// # let client = churchtools_api::replay::client("get-person-commentviewers");
18142 /// for comment_viewer in client.person().comment_viewers().list()? {
18143 /// println!("{}", comment_viewer.name);
18144 /// }
18145 /// # Ok(())
18146 /// # }
18147 /// ```
18148 pub fn list(&self) -> Result<Vec<models::CommentViewer>> {
18149 let path = "/person/commentviewers".to_owned();
18150 let query: Query = Query::new();
18151 self.client.request_data(Method::Get, &path, &query, None)
18152 }
18153
18154 /// Update a person-comment visibility category
18155 ///
18156 /// `PUT /person/commentviewers/{id}`
18157 ///
18158 /// Updates a category’s name and optionally its sort key. Requires edit masterdata in churchdb. The ID is taken from the path; no duplicate ID is required in the body. name is required, trimmed to 1–50 characters, and need not be unique. Unlike create, an omitted sortKey preserves the existing value. Explicit null currently passes validation but fails the integer setter, so omit the field to preserve it. Existing comment/note assignments and permission selections keep referencing the same category ID. Unknown IDs return 404.
18159 ///
18160 /// # Example
18161 ///
18162 /// ```
18163 /// # use churchtools_api::*;
18164 /// # use churchtools_api::queries::*;
18165 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18166 /// # let client = churchtools_api::replay::client("put-person-commentviewers-id");
18167 /// let body = models::CommentViewerUpdate {
18168 /// name: "Pastoral team".into(),
18169 /// ..Default::default()
18170 /// };
18171 /// let result = client.person().comment_viewers().update(1, &body)?;
18172 /// println!("{}", result.name);
18173 /// # Ok(())
18174 /// # }
18175 /// ```
18176 pub fn update(&self, id: impl Display, body: &models::CommentViewerUpdate) -> Result<models::CommentViewer> {
18177 let path = format!("/person/commentviewers/{}", seg(id));
18178 let query: Query = Query::new();
18179 let body = serde_json::to_value(body).expect("request body serializes");
18180 self.client.request_data(Method::Put, &path, &query, Some(&body))
18181 }
18182
18183}
18184
18185/// `client.person().grow_paths()`
18186#[derive(Clone, Copy)]
18187pub struct PersonGrowPathsResource<'a> {
18188 client: &'a Client,
18189}
18190
18191impl<'a> PersonGrowPathsResource<'a> {
18192 /// Create a growth-path stage
18193 ///
18194 /// `POST /person/growpaths`
18195 ///
18196 /// Creates a stage in the growth-path catalog. Requires edit masterdata in churchdb. name is trimmed to 1–100 characters and need not be unique. color must be one of the accepted CTColor keys. sortKey is optional and defaults to 0; it controls both display ordering and precedence when deriving a person’s stage. The new stage is not automatically assigned to a role or person. Returns 201 with the generated ID, translated name and metadata.
18197 ///
18198 /// # Example
18199 ///
18200 /// ```
18201 /// # use churchtools_api::*;
18202 /// # use churchtools_api::queries::*;
18203 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18204 /// # let client = churchtools_api::replay::client("post-person-growpaths");
18205 /// let body = models::GrowPathCreate {
18206 /// color: serde_json::json!("accent"),
18207 /// name: "New Believer".into(),
18208 /// ..Default::default()
18209 /// };
18210 /// let result = client.person().grow_paths().create(&body)?;
18211 /// println!("{}", result.name);
18212 /// # Ok(())
18213 /// # }
18214 /// ```
18215 pub fn create(&self, body: &models::GrowPathCreate) -> Result<models::GrowPath> {
18216 let path = "/person/growpaths".to_owned();
18217 let query: Query = Query::new();
18218 let body = serde_json::to_value(body).expect("request body serializes");
18219 self.client.request_data(Method::Post, &path, &query, Some(&body))
18220 }
18221
18222 /// Delete a growth-path stage
18223 ///
18224 /// `DELETE /person/growpaths/{id}`
18225 ///
18226 /// Deletes an unused growth-path stage. Requires edit masterdata in churchdb. References from group-type roles and concrete group roles block deletion with 409. Use dryRun=true to inspect deletion dependencies without deleting anything; the report also uses 409 when there are no blockers. The snake_case dry_run parameter used by other endpoints is not the flag read here. The stage is not loaded before deletion, so an unknown ID can return 204 without removing a row.
18227 ///
18228 /// Use [`Self::delete_with`] to pass query parameters.
18229 ///
18230 /// # Example
18231 ///
18232 /// ```no_run
18233 /// # use churchtools_api::*;
18234 /// # use churchtools_api::queries::*;
18235 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18236 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18237 /// client.person().grow_paths().delete(1)?;
18238 /// # Ok(())
18239 /// # }
18240 /// ```
18241 pub fn delete(&self, id: impl Display) -> Result<()> {
18242 self.delete_with(id, &Default::default())
18243 }
18244
18245 /// Delete a growth-path stage
18246 ///
18247 /// Like [`Self::delete`], with query parameters.
18248 ///
18249 /// `DELETE /person/growpaths/{id}`
18250 ///
18251 /// Deletes an unused growth-path stage. Requires edit masterdata in churchdb. References from group-type roles and concrete group roles block deletion with 409. Use dryRun=true to inspect deletion dependencies without deleting anything; the report also uses 409 when there are no blockers. The snake_case dry_run parameter used by other endpoints is not the flag read here. The stage is not loaded before deletion, so an unknown ID can return 204 without removing a row.
18252 pub fn delete_with(&self, id: impl Display, query: &DeletePersonGrowpathsIdQuery) -> Result<()> {
18253 let path = format!("/person/growpaths/{}", seg(id));
18254 let query: Query = query.to_query();
18255 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18256 }
18257
18258 /// Get a growth-path stage
18259 ///
18260 /// `GET /person/growpaths/{id}`
18261 ///
18262 /// Returns one configured growth-path stage, including translated name, display color, ordering/priority and metadata. Requires view in churchdb. The ID identifies a stage referenced by group roles and person growPathId values; this is not the history or progression of a particular person. Unknown IDs return 404.
18263 ///
18264 /// # Example
18265 ///
18266 /// ```
18267 /// # use churchtools_api::*;
18268 /// # use churchtools_api::queries::*;
18269 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18270 /// # let client = churchtools_api::replay::client("get-person-growpaths-id");
18271 /// let grow_path = client.person().grow_paths().get(1)?;
18272 /// println!("{}", grow_path.name);
18273 /// # Ok(())
18274 /// # }
18275 /// ```
18276 pub fn get(&self, id: impl Display) -> Result<models::GrowPath> {
18277 let path = format!("/person/growpaths/{}", seg(id));
18278 let query: Query = Query::new();
18279 self.client.request_data(Method::Get, &path, &query, None)
18280 }
18281
18282 /// List growth-path stages
18283 ///
18284 /// `GET /person/growpaths`
18285 ///
18286 /// Lists the configured growth-path stages, ordered by sortKey and stored name ascending. Requires view in churchdb. Stages are assigned to group-type roles or concrete group roles; ChurchTools derives a person’s stage from active memberships in active or finished groups, using the highest matching stage sortKey. A concrete group-role stage overrides the group-type-role stage for that membership. This endpoint returns the complete unpaginated stage catalog, not people or their progress history. Each stage includes translated display text, color and creation/modification metadata.
18287 ///
18288 /// # Example
18289 ///
18290 /// ```
18291 /// # use churchtools_api::*;
18292 /// # use churchtools_api::queries::*;
18293 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18294 /// # let client = churchtools_api::replay::client("get-person-growpaths");
18295 /// for grow_path in client.person().grow_paths().list()? {
18296 /// println!("{}", grow_path.name);
18297 /// }
18298 /// # Ok(())
18299 /// # }
18300 /// ```
18301 pub fn list(&self) -> Result<Vec<models::GrowPath>> {
18302 let path = "/person/growpaths".to_owned();
18303 let query: Query = Query::new();
18304 self.client.request_data(Method::Get, &path, &query, None)
18305 }
18306
18307 /// Update a growth-path stage
18308 ///
18309 /// `PUT /person/growpaths/{id}`
18310 ///
18311 /// Updates a stage’s name, color and ordering/priority. Requires edit masterdata in churchdb. ID comes from the path; name and color are required. sortKey is optional but defaults to 0 on every update, so send its current value to retain it. This differs from comment-viewer updates, which preserve an omitted sort key. sortKey affects both display order and which stage wins when calculating a person’s growth path. This handler only persists the stage; it does not trigger recalculation of all already stored person growPathId values. Equal priorities have no explicit tie-breaker in person calculation. Unknown IDs return 404.
18312 ///
18313 /// # Example
18314 ///
18315 /// ```
18316 /// # use churchtools_api::*;
18317 /// # use churchtools_api::queries::*;
18318 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18319 /// # let client = churchtools_api::replay::client("put-person-growpaths-id");
18320 /// let body = models::GrowPathUpdate {
18321 /// color: serde_json::json!("accent"),
18322 /// name: "New Believer".into(),
18323 /// ..Default::default()
18324 /// };
18325 /// let result = client.person().grow_paths().update(1, &body)?;
18326 /// println!("{}", result.name);
18327 /// # Ok(())
18328 /// # }
18329 /// ```
18330 pub fn update(&self, id: impl Display, body: &models::GrowPathUpdate) -> Result<models::GrowPath> {
18331 let path = format!("/person/growpaths/{}", seg(id));
18332 let query: Query = Query::new();
18333 let body = serde_json::to_value(body).expect("request body serializes");
18334 self.client.request_data(Method::Put, &path, &query, Some(&body))
18335 }
18336
18337}
18338
18339/// `client.person().relationship_types()`
18340#[derive(Clone, Copy)]
18341pub struct PersonRelationshipTypesResource<'a> {
18342 client: &'a Client,
18343}
18344
18345impl<'a> PersonRelationshipTypesResource<'a> {
18346 /// Create a person relationship type
18347 ///
18348 /// `POST /person/relationshiptypes`
18349 ///
18350 /// Creates a relationship-type catalog definition. Requires "edit masterdata" permission in `churchdb`.
18351 ///
18352 /// # Example
18353 ///
18354 /// ```
18355 /// # use churchtools_api::*;
18356 /// # use churchtools_api::queries::*;
18357 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18358 /// # let client = churchtools_api::replay::client("post-person-relationshiptypes");
18359 /// let body = models::RelationshipTypeCreate {
18360 /// degree_name_a: "Parent".into(),
18361 /// degree_name_b: "Child".into(),
18362 /// security_level_id: 1,
18363 /// ..Default::default()
18364 /// };
18365 /// let result = client.person().relationship_types().create(&body)?;
18366 /// println!("{:?}", result.name);
18367 /// # Ok(())
18368 /// # }
18369 /// ```
18370 pub fn create(&self, body: &models::RelationshipTypeCreate) -> Result<models::RelationshipType> {
18371 let path = "/person/relationshiptypes".to_owned();
18372 let query: Query = Query::new();
18373 let body = serde_json::to_value(body).expect("request body serializes");
18374 self.client.request_data(Method::Post, &path, &query, Some(&body))
18375 }
18376
18377 /// Delete a relationship type and its person relationships
18378 ///
18379 /// `DELETE /person/relationshiptypes/{id}`
18380 ///
18381 /// Deletes the relationship-type definition and every stored person-to-person relationship referencing it. Requires "edit masterdata" permission in `churchdb`. Types with the built-in `nodelete` flag cannot be deleted.
18382 ///
18383 /// Use [`Self::delete_with`] to pass query parameters.
18384 ///
18385 /// # Example
18386 ///
18387 /// ```no_run
18388 /// # use churchtools_api::*;
18389 /// # use churchtools_api::queries::*;
18390 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18391 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18392 /// client.person().relationship_types().delete(4)?;
18393 /// # Ok(())
18394 /// # }
18395 /// ```
18396 pub fn delete(&self, id: impl Display) -> Result<()> {
18397 self.delete_with(id, &Default::default())
18398 }
18399
18400 /// Delete a relationship type and its person relationships
18401 ///
18402 /// Like [`Self::delete`], with query parameters.
18403 ///
18404 /// `DELETE /person/relationshiptypes/{id}`
18405 ///
18406 /// Deletes the relationship-type definition and every stored person-to-person relationship referencing it. Requires "edit masterdata" permission in `churchdb`. Types with the built-in `nodelete` flag cannot be deleted.
18407 pub fn delete_with(&self, id: impl Display, query: &DeletePersonRelationshiptypesIdQuery) -> Result<()> {
18408 let path = format!("/person/relationshiptypes/{}", seg(id));
18409 let query: Query = query.to_query();
18410 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18411 }
18412
18413 /// Get a person relationship type
18414 ///
18415 /// `GET /person/relationshiptypes/{id}`
18416 ///
18417 /// Returns one relationship-type catalog definition, not a relationship between two persons.
18418 ///
18419 /// # Example
18420 ///
18421 /// ```
18422 /// # use churchtools_api::*;
18423 /// # use churchtools_api::queries::*;
18424 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18425 /// # let client = churchtools_api::replay::client("get-person-relationshiptypes-id");
18426 /// let relationship_type = client.person().relationship_types().get(4)?;
18427 /// println!("{:?}", relationship_type.name);
18428 /// # Ok(())
18429 /// # }
18430 /// ```
18431 pub fn get(&self, id: impl Display) -> Result<models::RelationshipType> {
18432 let path = format!("/person/relationshiptypes/{}", seg(id));
18433 let query: Query = Query::new();
18434 self.client.request_data(Method::Get, &path, &query, None)
18435 }
18436
18437 /// List person relationship types
18438 ///
18439 /// `GET /person/relationshiptypes`
18440 ///
18441 /// Lists relationship-type definitions, ordered by `sortKey` and stored name. This is a catalog, not the relationships between individual persons.
18442 ///
18443 /// # Example
18444 ///
18445 /// ```
18446 /// # use churchtools_api::*;
18447 /// # use churchtools_api::queries::*;
18448 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18449 /// # let client = churchtools_api::replay::client("get-person-relationshiptypes");
18450 /// for relationship_type in client.person().relationship_types().list()? {
18451 /// println!("{:?}", relationship_type.name);
18452 /// }
18453 /// # Ok(())
18454 /// # }
18455 /// ```
18456 pub fn list(&self) -> Result<Vec<models::RelationshipType>> {
18457 let path = "/person/relationshiptypes".to_owned();
18458 let query: Query = Query::new();
18459 self.client.request_data(Method::Get, &path, &query, None)
18460 }
18461
18462 /// Update a person relationship type
18463 ///
18464 /// `PUT /person/relationshiptypes/{id}`
18465 ///
18466 /// Replaces the editable fields of an existing relationship-type definition. Requires "edit masterdata" permission in `churchdb`. Existing person-to-person relationships retain their IDs and use the updated definition.
18467 ///
18468 /// # Example
18469 ///
18470 /// ```
18471 /// # use churchtools_api::*;
18472 /// # use churchtools_api::queries::*;
18473 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18474 /// # let client = churchtools_api::replay::client("put-person-relationshiptypes-id");
18475 /// let body = models::RelationshipTypeUpdate {
18476 /// degree_name_a: "Parent".into(),
18477 /// degree_name_b: "Child".into(),
18478 /// security_level_id: 1,
18479 /// ..Default::default()
18480 /// };
18481 /// let result = client.person().relationship_types().update(4, &body)?;
18482 /// println!("{:?}", result.name);
18483 /// # Ok(())
18484 /// # }
18485 /// ```
18486 pub fn update(&self, id: impl Display, body: &models::RelationshipTypeUpdate) -> Result<models::RelationshipType> {
18487 let path = format!("/person/relationshiptypes/{}", seg(id));
18488 let query: Query = Query::new();
18489 let body = serde_json::to_value(body).expect("request body serializes");
18490 self.client.request_data(Method::Put, &path, &query, Some(&body))
18491 }
18492
18493}
18494
18495/// `client.person().sexes()`
18496#[derive(Clone, Copy)]
18497pub struct PersonSexesResource<'a> {
18498 client: &'a Client,
18499}
18500
18501impl<'a> PersonSexesResource<'a> {
18502 /// Create sex
18503 ///
18504 /// `POST /person/sexes`
18505 ///
18506 /// Creates a sex catalog entry, not a person. Requires edit masterdata permission for Persons (churchdb). Text is trimmed; omitted salutations are null and sortKey defaults to 0. Name and salutation values may be translation keys or literal text. Creation is transactional.
18507 ///
18508 /// # Example
18509 ///
18510 /// ```
18511 /// # use churchtools_api::*;
18512 /// # use churchtools_api::queries::*;
18513 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18514 /// # let client = churchtools_api::replay::client("post-person-sexes");
18515 /// let body = models::SexCreate {
18516 /// name: "sex.other".into(),
18517 /// ..Default::default()
18518 /// };
18519 /// let result = client.person().sexes().create(&body)?;
18520 /// println!("{}", result.name);
18521 /// # Ok(())
18522 /// # }
18523 /// ```
18524 pub fn create(&self, body: &models::SexCreate) -> Result<models::Sex> {
18525 let path = "/person/sexes".to_owned();
18526 let query: Query = Query::new();
18527 let body = serde_json::to_value(body).expect("request body serializes");
18528 self.client.request_data(Method::Post, &path, &query, Some(&body))
18529 }
18530
18531 /// Delete sex
18532 ///
18533 /// `DELETE /person/sexes/{id}`
18534 ///
18535 /// Deletes an unused sex catalog entry. Requires edit masterdata permission for Persons (churchdb). IDs 1 and 2 return 403 even for dryRun. Person references block deletion with 409. dryRun=true always returns a 409 deletion report for otherwise eligible IDs, including when deletion would be allowed. A missing unused ID is a successful no-op with 204.
18536 ///
18537 /// Use [`Self::delete_with`] to pass query parameters.
18538 ///
18539 /// # Example
18540 ///
18541 /// ```no_run
18542 /// # use churchtools_api::*;
18543 /// # use churchtools_api::queries::*;
18544 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18545 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18546 /// client.person().sexes().delete(1)?;
18547 /// # Ok(())
18548 /// # }
18549 /// ```
18550 pub fn delete(&self, id: impl Display) -> Result<()> {
18551 self.delete_with(id, &Default::default())
18552 }
18553
18554 /// Delete sex
18555 ///
18556 /// Like [`Self::delete`], with query parameters.
18557 ///
18558 /// `DELETE /person/sexes/{id}`
18559 ///
18560 /// Deletes an unused sex catalog entry. Requires edit masterdata permission for Persons (churchdb). IDs 1 and 2 return 403 even for dryRun. Person references block deletion with 409. dryRun=true always returns a 409 deletion report for otherwise eligible IDs, including when deletion would be allowed. A missing unused ID is a successful no-op with 204.
18561 pub fn delete_with(&self, id: impl Display, query: &DeletePersonSexesIdQuery) -> Result<()> {
18562 let path = format!("/person/sexes/{}", seg(id));
18563 let query: Query = query.to_query();
18564 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18565 }
18566
18567 /// Get sex
18568 ///
18569 /// `GET /person/sexes/{id}`
18570 ///
18571 /// Returns one sex catalog entry with raw and localized labels and salutations. Requires view permission for Persons (churchdb).
18572 ///
18573 /// # Example
18574 ///
18575 /// ```
18576 /// # use churchtools_api::*;
18577 /// # use churchtools_api::queries::*;
18578 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18579 /// # let client = churchtools_api::replay::client("get-person-sexes-id");
18580 /// let sex = client.person().sexes().get(1)?;
18581 /// println!("{}", sex.name);
18582 /// # Ok(())
18583 /// # }
18584 /// ```
18585 pub fn get(&self, id: impl Display) -> Result<models::Sex> {
18586 let path = format!("/person/sexes/{}", seg(id));
18587 let query: Query = Query::new();
18588 self.client.request_data(Method::Get, &path, &query, None)
18589 }
18590
18591 /// Get all sexes
18592 ///
18593 /// `GET /person/sexes`
18594 ///
18595 /// Lists the configured sex catalog used by person records and salutations. Requires view permission for Persons (churchdb). Ordered by sortKey and stored name ascending; localized display text can have a different order. The complete catalog is returned without pagination.
18596 ///
18597 /// # Example
18598 ///
18599 /// ```
18600 /// # use churchtools_api::*;
18601 /// # use churchtools_api::queries::*;
18602 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18603 /// # let client = churchtools_api::replay::client("get-person-sexes");
18604 /// for sex in client.person().sexes().list()? {
18605 /// println!("{}", sex.name);
18606 /// }
18607 /// # Ok(())
18608 /// # }
18609 /// ```
18610 pub fn list(&self) -> Result<Vec<models::Sex>> {
18611 let path = "/person/sexes".to_owned();
18612 let query: Query = Query::new();
18613 self.client.request_data(Method::Get, &path, &query, None)
18614 }
18615
18616 /// Update a sex entry
18617 ///
18618 /// `PUT /person/sexes/{id}`
18619 ///
18620 /// Replaces the writable values of a sex catalog entry. Requires edit masterdata permission for Persons (churchdb). name is required; omitted sortKey is reset to 0 and omitted salutations are cleared to null. IDs 1 and 2 are protected against deletion but can be updated here. The ID is taken from the URL and is not required in the body. The update is transactional.
18621 ///
18622 /// # Example
18623 ///
18624 /// ```
18625 /// # use churchtools_api::*;
18626 /// # use churchtools_api::queries::*;
18627 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18628 /// # let client = churchtools_api::replay::client("put-person-sexes-id");
18629 /// let body = models::SexUpdate {
18630 /// name: "sex.other".into(),
18631 /// ..Default::default()
18632 /// };
18633 /// let result = client.person().sexes().update(1, &body)?;
18634 /// println!("{}", result.name);
18635 /// # Ok(())
18636 /// # }
18637 /// ```
18638 pub fn update(&self, id: impl Display, body: &models::SexUpdate) -> Result<models::Sex> {
18639 let path = format!("/person/sexes/{}", seg(id));
18640 let query: Query = Query::new();
18641 let body = serde_json::to_value(body).expect("request body serializes");
18642 self.client.request_data(Method::Put, &path, &query, Some(&body))
18643 }
18644
18645}
18646
18647/// `client.persons()`
18648#[derive(Clone, Copy)]
18649pub struct PersonsResource<'a> {
18650 client: &'a Client,
18651}
18652
18653impl<'a> PersonsResource<'a> {
18654 pub fn absences(&self) -> PersonsAbsencesResource<'a> {
18655 PersonsAbsencesResource { client: self.client }
18656 }
18657
18658 pub fn devices(&self) -> PersonsDevicesResource<'a> {
18659 PersonsDevicesResource { client: self.client }
18660 }
18661
18662 pub fn events(&self) -> PersonsEventsResource<'a> {
18663 PersonsEventsResource { client: self.client }
18664 }
18665
18666 pub fn exchange_requests(&self) -> PersonsExchangeRequestsResource<'a> {
18667 PersonsExchangeRequestsResource { client: self.client }
18668 }
18669
18670 pub fn external_logins(&self) -> PersonsExternalLoginsResource<'a> {
18671 PersonsExternalLoginsResource { client: self.client }
18672 }
18673
18674 pub fn followups(&self) -> PersonsFollowupsResource<'a> {
18675 PersonsFollowupsResource { client: self.client }
18676 }
18677
18678 pub fn merge(&self) -> PersonsMergeResource<'a> {
18679 PersonsMergeResource { client: self.client }
18680 }
18681
18682 pub fn relationships(&self) -> PersonsRelationshipsResource<'a> {
18683 PersonsRelationshipsResource { client: self.client }
18684 }
18685
18686 pub fn service_requests(&self) -> PersonsServiceRequestsResource<'a> {
18687 PersonsServiceRequestsResource { client: self.client }
18688 }
18689
18690 pub fn settings(&self) -> PersonsSettingsResource<'a> {
18691 PersonsSettingsResource { client: self.client }
18692 }
18693
18694 /// `POST /persons/{personId}/archive`
18695 ///
18696 /// archives or undos an archive of a person
18697 ///
18698 /// # Example
18699 ///
18700 /// ```no_run
18701 /// # use churchtools_api::*;
18702 /// # use churchtools_api::queries::*;
18703 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18704 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18705 /// let body = models::PostPersonsPersonIdArchiveBody {
18706 /// archived: Some(true),
18707 /// ..Default::default()
18708 /// };
18709 /// client.persons().archive(42, &body)?;
18710 /// # Ok(())
18711 /// # }
18712 /// ```
18713 pub fn archive(&self, person_id: impl Display, body: &models::PostPersonsPersonIdArchiveBody) -> Result<()> {
18714 let path = format!("/persons/{}/archive", seg(person_id));
18715 let query: Query = Query::new();
18716 let body = serde_json::to_value(body).expect("request body serializes");
18717 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
18718 }
18719
18720 /// Create new person
18721 ///
18722 /// `POST /persons`
18723 ///
18724 /// Creates a person using only fields the current user may write. Before calling this endpoint, retrieve valid `statusId`, `campusId`, and `departmentIds` values from `GET /person/masterdata`. Read `GET /config` to determine whether `privacy_policy_fields_mandatory` is enabled. If it is enabled, provide all three privacy agreement fields. `privacyPolicyAgreementTypeId` describes how the agreement was obtained, while `privacyPolicyAgreementWhoId` describes who gave it; these are independent facts and must not be inferred from each other. The `without_privacy_policy_agreement` parameter is only effective when `privacy_policy_fields_mandatory_api` is disabled and must not be used without first verifying that setting. If a duplicate person is found, repeat the request with `force` only after intentionally deciding to create the duplicate.
18725 ///
18726 /// Use [`Self::create_with`] to pass query parameters.
18727 ///
18728 /// # Example
18729 ///
18730 /// ```
18731 /// # use churchtools_api::*;
18732 /// # use churchtools_api::queries::*;
18733 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18734 /// # let client = churchtools_api::replay::client("post-persons");
18735 /// let body = models::PostPersonsBody {
18736 /// department_ids: vec![42],
18737 /// ..Default::default()
18738 /// };
18739 /// let result = client.persons().create(&body)?;
18740 /// println!("{:?}", result.title);
18741 /// # Ok(())
18742 /// # }
18743 /// ```
18744 pub fn create(&self, body: &models::PostPersonsBody) -> Result<models::Person> {
18745 self.create_with(&Default::default(), body)
18746 }
18747
18748 /// Create new person
18749 ///
18750 /// Like [`Self::create`], with query parameters.
18751 ///
18752 /// `POST /persons`
18753 ///
18754 /// Creates a person using only fields the current user may write. Before calling this endpoint, retrieve valid `statusId`, `campusId`, and `departmentIds` values from `GET /person/masterdata`. Read `GET /config` to determine whether `privacy_policy_fields_mandatory` is enabled. If it is enabled, provide all three privacy agreement fields. `privacyPolicyAgreementTypeId` describes how the agreement was obtained, while `privacyPolicyAgreementWhoId` describes who gave it; these are independent facts and must not be inferred from each other. The `without_privacy_policy_agreement` parameter is only effective when `privacy_policy_fields_mandatory_api` is disabled and must not be used without first verifying that setting. If a duplicate person is found, repeat the request with `force` only after intentionally deciding to create the duplicate.
18755 pub fn create_with(&self, query: &PostPersonsQuery, body: &models::PostPersonsBody) -> Result<models::Person> {
18756 let path = "/persons".to_owned();
18757 let query: Query = query.to_query();
18758 let body = serde_json::to_value(body).expect("request body serializes");
18759 self.client.request_data(Method::Post, &path, &query, Some(&body))
18760 }
18761
18762 /// Delete person
18763 ///
18764 /// `DELETE /persons/{personId}`
18765 ///
18766 /// Delete the Person
18767 ///
18768 /// # Example
18769 ///
18770 /// ```no_run
18771 /// # use churchtools_api::*;
18772 /// # use churchtools_api::queries::*;
18773 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18774 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18775 /// client.persons().delete(42)?;
18776 /// # Ok(())
18777 /// # }
18778 /// ```
18779 pub fn delete(&self, person_id: impl Display) -> Result<()> {
18780 let path = format!("/persons/{}", seg(person_id));
18781 let query: Query = Query::new();
18782 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18783 }
18784
18785 /// Revoke a person's confidentiality agreement
18786 ///
18787 /// `DELETE /persons/{personId}/confidentialityagreement`
18788 ///
18789 /// Clears the confidentiality acceptance date. Requires write access for Persons (churchdb); being the selected person alone is insufficient. Simulation is rejected. The policy checks module-level write access without an additional person-visibility check. Already absent acceptance is a successful no-op. This is separate from privacy-consent revocation and takes no request body.
18790 ///
18791 /// # Example
18792 ///
18793 /// ```no_run
18794 /// # use churchtools_api::*;
18795 /// # use churchtools_api::queries::*;
18796 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18797 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18798 /// client.persons().delete_confidentiality_agreement(42)?;
18799 /// # Ok(())
18800 /// # }
18801 /// ```
18802 pub fn delete_confidentiality_agreement(&self, person_id: impl Display) -> Result<()> {
18803 let path = format!("/persons/{}/confidentialityagreement", seg(person_id));
18804 let query: Query = Query::new();
18805 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18806 }
18807
18808 /// Revoke the current person’s login token
18809 ///
18810 /// `DELETE /persons/{personId}/logintoken`
18811 ///
18812 /// Deletes the current person’s persistent login token. Only the current person may revoke their own token. A missing token is treated as success. Ordinary user simulation is forbidden; support-user simulation is exempt. This does not invalidate existing sessions or separate one-time login strings. A subsequent GET creates a new token.
18813 ///
18814 /// # Example
18815 ///
18816 /// ```no_run
18817 /// # use churchtools_api::*;
18818 /// # use churchtools_api::queries::*;
18819 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18820 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18821 /// client.persons().delete_login_token(42)?;
18822 /// # Ok(())
18823 /// # }
18824 /// ```
18825 pub fn delete_login_token(&self, person_id: impl Display) -> Result<()> {
18826 let path = format!("/persons/{}/logintoken", seg(person_id));
18827 let query: Query = Query::new();
18828 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18829 }
18830
18831 /// Revoke privacy consent
18832 ///
18833 /// `DELETE /persons/{personId}/privacypolicy`
18834 ///
18835 /// Clears the person’s consent timestamp, consent type and consent-giver category, and then notifies the configured administrator by email when an address is available. Requires an enabled consent banner and either the person themselves, a super administrator, or the parent of a person not known to be at least 16 through relationship type 1. Simulation is rejected. Revocation is not idempotent: an existing person without prior consent raises an application error instead of returning 204. Notification happens after the data change, so a later failure does not imply that consent was retained.
18836 ///
18837 /// # Example
18838 ///
18839 /// ```no_run
18840 /// # use churchtools_api::*;
18841 /// # use churchtools_api::queries::*;
18842 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18843 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18844 /// client.persons().delete_privacy_policy(42)?;
18845 /// # Ok(())
18846 /// # }
18847 /// ```
18848 pub fn delete_privacy_policy(&self, person_id: impl Display) -> Result<()> {
18849 let path = format!("/persons/{}/privacypolicy", seg(person_id));
18850 let query: Query = Query::new();
18851 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
18852 }
18853
18854 /// `POST /persons/export`
18855 ///
18856 /// # Example
18857 ///
18858 /// ```no_run
18859 /// # use churchtools_api::*;
18860 /// # use churchtools_api::queries::*;
18861 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18862 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18863 /// client.persons().export()?;
18864 /// # Ok(())
18865 /// # }
18866 /// ```
18867 pub fn export(&self) -> Result<()> {
18868 let path = "/persons/export".to_owned();
18869 let query: Query = Query::new();
18870 self.client.request(Method::Post, &path, &query, None).map(|_| ())
18871 }
18872
18873 /// Filter persons with probes
18874 ///
18875 /// `POST /persons/filter`
18876 ///
18877 /// Evaluates a logical expression of probes against all persons the current user may view. Probe evaluation honors person security levels, and the matching persons are returned as a paginated collection.
18878 ///
18879 /// Use [`Self::filter_with`] to pass query parameters.
18880 ///
18881 /// # Example
18882 ///
18883 /// ```no_run
18884 /// # use churchtools_api::*;
18885 /// # use churchtools_api::queries::*;
18886 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18887 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
18888 /// let body = serde_json::json!({
18889 /// "data": {},
18890 /// "probe": "probe-person-field"
18891 /// });
18892 /// for person in client.persons().filter(&body)? {
18893 /// println!("{:?}", person.title);
18894 /// }
18895 /// # Ok(())
18896 /// # }
18897 /// ```
18898 pub fn filter(&self, body: &serde_json::Value) -> Result<Vec<models::Person>> {
18899 self.filter_with(&Default::default(), body)
18900 }
18901
18902 /// Filter persons with probes
18903 ///
18904 /// Like [`Self::filter`], with query parameters.
18905 ///
18906 /// `POST /persons/filter`
18907 ///
18908 /// Evaluates a logical expression of probes against all persons the current user may view. Probe evaluation honors person security levels, and the matching persons are returned as a paginated collection.
18909 pub fn filter_with(&self, query: &PostPersonsFilterQuery, body: &serde_json::Value) -> Result<Vec<models::Person>> {
18910 let path = "/persons/filter".to_owned();
18911 let query: Query = query.to_query();
18912 let body = serde_json::to_value(body).expect("request body serializes");
18913 self.client.request_data(Method::Post, &path, &query, Some(&body))
18914 }
18915
18916 /// Get a person by ID or GUID
18917 ///
18918 /// `GET /persons/{personId}`
18919 ///
18920 /// Each person as a unique numeric ID in ChurchTools. This ID is used all over in ChurchTools and in the API.
18921 ///
18922 /// # Example
18923 ///
18924 /// ```
18925 /// # use churchtools_api::*;
18926 /// # use churchtools_api::queries::*;
18927 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18928 /// # let client = churchtools_api::replay::client("get-persons-id");
18929 /// let person = client.persons().get(42)?;
18930 /// println!("{:?}", person.title);
18931 /// # Ok(())
18932 /// # }
18933 /// ```
18934 pub fn get(&self, person_id: impl Display) -> Result<models::Person> {
18935 let path = format!("/persons/{}", seg(person_id));
18936 let query: Query = Query::new();
18937 self.client.request_data(Method::Get, &path, &query, None)
18938 }
18939
18940 /// Generate a personal data sheet PDF
18941 ///
18942 /// `GET /persons/{personId}/information`
18943 ///
18944 /// Generates the complete configured data sheet for the person and returns a PDF download URL. Requires super-administrator access, even when exporting your own data. Despite using GET, every successful call generates and stores a file and logs the export; this is not a read-only preview. The file is associated with the datasheet domain and scheduled for deletion after one day. The API response is JSON, not PDF bytes. message is localized display text. Unknown persons return 404; generation or storage failures may return 500.
18945 ///
18946 /// # Example
18947 ///
18948 /// ```
18949 /// # use churchtools_api::*;
18950 /// # use churchtools_api::queries::*;
18951 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18952 /// # let client = churchtools_api::replay::client("get-persons-personId-information");
18953 /// let information = client.persons().get_information(42)?;
18954 /// println!("{}", information.pdf_link);
18955 /// # Ok(())
18956 /// # }
18957 /// ```
18958 pub fn get_information(&self, person_id: impl Display) -> Result<models::PersonInformationExport> {
18959 let path = format!("/persons/{}/information", seg(person_id));
18960 let query: Query = Query::new();
18961 self.client.request_data(Method::Get, &path, &query, None)
18962 }
18963
18964 /// Create a one-time login string for the current person
18965 ///
18966 /// `GET /persons/{personId}/loginstring`
18967 ///
18968 /// Creates a new one-time login credential valid for 14 days. Only the current person may request their own credential. Each GET creates and stores a fresh credential; treat the response as a secret. Use it as the loginstr parameter of a ChurchTools login link. Simulation creates a credential carrying the simulating user context. The legacy response has top-level loginString and personId fields, without a data envelope.
18969 ///
18970 /// # Example
18971 ///
18972 /// ```
18973 /// # use churchtools_api::*;
18974 /// # use churchtools_api::queries::*;
18975 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
18976 /// # let client = churchtools_api::replay::client("get-persons-id-loginstring");
18977 /// let login_string = client.persons().get_login_string("abc123")?;
18978 /// println!("{}", login_string.login_string);
18979 /// # Ok(())
18980 /// # }
18981 /// ```
18982 pub fn get_login_string(&self, person_id: impl Display) -> Result<models::GetPersonsIdLoginstringResponse> {
18983 let path = format!("/persons/{}/loginstring", seg(person_id));
18984 let query: Query = Query::new();
18985 self.client.request_json(Method::Get, &path, &query, None)
18986 }
18987
18988 /// Get or create the current person’s login token
18989 ///
18990 /// `GET /persons/{personId}/logintoken`
18991 ///
18992 /// Returns the current person’s persistent login credential, creating and storing one if absent. Only the current person may request their own token. The same token is returned on subsequent calls until revoked; treat it as a secret. It has no expiry field. Ordinary user simulation is forbidden; support-user simulation is exempt. This GET can change stored data.
18993 ///
18994 /// # Example
18995 ///
18996 /// ```
18997 /// # use churchtools_api::*;
18998 /// # use churchtools_api::queries::*;
18999 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19000 /// # let client = churchtools_api::replay::client("get-persons-id-logintoken");
19001 /// let result = client.persons().get_login_token(42)?;
19002 /// println!("{:?}", result);
19003 /// # Ok(())
19004 /// # }
19005 /// ```
19006 pub fn get_login_token(&self, person_id: impl Display) -> Result<String> {
19007 let path = format!("/persons/{}/logintoken", seg(person_id));
19008 let query: Query = Query::new();
19009 self.client.request_data(Method::Get, &path, &query, None)
19010 }
19011
19012 /// Returns the post statistics for a person
19013 ///
19014 /// `GET /persons/{personId}/poststatistics`
19015 ///
19016 /// # Example
19017 ///
19018 /// ```
19019 /// # use churchtools_api::*;
19020 /// # use churchtools_api::queries::*;
19021 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19022 /// # let client = churchtools_api::replay::client("get-persons-personId-poststatistics");
19023 /// let post_statistic = client.persons().get_post_statistics("abc123")?;
19024 /// println!("{}", post_statistic.count_banned);
19025 /// # Ok(())
19026 /// # }
19027 /// ```
19028 pub fn get_post_statistics(&self, person_id: impl Display) -> Result<models::PersonPostStatistics> {
19029 let path = format!("/persons/{}/poststatistics", seg(person_id));
19030 let query: Query = Query::new();
19031 self.client.request_data(Method::Get, &path, &query, None)
19032 }
19033
19034 /// Get privacy-consent information
19035 ///
19036 /// `GET /persons/{personId}/privacypolicy`
19037 ///
19038 /// Returns consent details and parent/child relationship information for the selected person. Simulation is rejected. Access is allowed to super administrators, the person themselves unless they are known to be younger than 16, and a parent linked through relationship type 1 for a person who is not known to be at least 16. An unknown birthday is treated differently by the self-read and acceptance checks. The response supplies suggested typeId/whoId and display flags; it does not grant permission to submit consent.
19039 ///
19040 /// # Example
19041 ///
19042 /// ```
19043 /// # use churchtools_api::*;
19044 /// # use churchtools_api::queries::*;
19045 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19046 /// # let client = churchtools_api::replay::client("get-persons-id-privacypolicy");
19047 /// let privacy_policy = client.persons().get_privacy_policy(42)?;
19048 /// println!("{}", privacy_policy.minimum_age);
19049 /// # Ok(())
19050 /// # }
19051 /// ```
19052 pub fn get_privacy_policy(&self, person_id: impl Display) -> Result<models::PersonPrivacyPolicy> {
19053 let path = format!("/persons/{}/privacypolicy", seg(person_id));
19054 let query: Query = Query::new();
19055 self.client.request_data(Method::Get, &path, &query, None)
19056 }
19057
19058 /// Invite Person to ChurchTools
19059 ///
19060 /// `POST /persons/{personId}/invite`
19061 ///
19062 /// Sends a ChurchTools invitation email to the person’s stored email address. Requires the global churchcore permission invite persons or the group-internal churchdb +invite person permission for this person. Archived people cannot be invited. The call forces sending even after an earlier invitation or acceptance. With local login enabled, the email links to setting a password; with local login disabled, it links to the login page. No request body is consumed. A 204 response indicates that invitation processing completed, not confirmed email delivery.
19063 ///
19064 /// # Example
19065 ///
19066 /// ```no_run
19067 /// # use churchtools_api::*;
19068 /// # use churchtools_api::queries::*;
19069 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19070 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19071 /// client.persons().invite(42)?;
19072 /// # Ok(())
19073 /// # }
19074 /// ```
19075 pub fn invite(&self, person_id: impl Display) -> Result<()> {
19076 let path = format!("/persons/{}/invite", seg(person_id));
19077 let query: Query = Query::new();
19078 self.client.request(Method::Post, &path, &query, None).map(|_| ())
19079 }
19080
19081 /// Get all persons
19082 ///
19083 /// `GET /persons`
19084 ///
19085 /// This endpoint gives you all the people you are allowed to see. Each person object holds only those fields you may see. You will get at least an empty array even if you cannot see any person. The results are sorted by lastname, firstname.
19086 ///
19087 /// We distinguish between `date` and `date-time` fields. `date` is a ISO representation like `YYYY-MM-DD`. On the other hand, for `date-time` we return and accept a W3C Zulu date string. Example `1994-11-05T08:15:30Z`
19088 ///
19089 /// Use [`Self::list_with`] to pass query parameters.
19090 ///
19091 /// # Example
19092 ///
19093 /// ```
19094 /// # use churchtools_api::*;
19095 /// # use churchtools_api::queries::*;
19096 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19097 /// # let client = churchtools_api::replay::client("get-persons");
19098 /// for person in client.persons().list()? {
19099 /// println!("{:?}", person.title);
19100 /// }
19101 /// # Ok(())
19102 /// # }
19103 /// ```
19104 pub fn list(&self) -> Result<Vec<models::Person>> {
19105 self.list_with(&Default::default())
19106 }
19107
19108 /// Get all persons
19109 ///
19110 /// Like [`Self::list`], with query parameters.
19111 ///
19112 /// `GET /persons`
19113 ///
19114 /// This endpoint gives you all the people you are allowed to see. Each person object holds only those fields you may see. You will get at least an empty array even if you cannot see any person. The results are sorted by lastname, firstname.
19115 ///
19116 /// We distinguish between `date` and `date-time` fields. `date` is a ISO representation like `YYYY-MM-DD`. On the other hand, for `date-time` we return and accept a W3C Zulu date string. Example `1994-11-05T08:15:30Z`
19117 pub fn list_with(&self, query: &GetPersonsQuery) -> Result<Vec<models::Person>> {
19118 let path = "/persons".to_owned();
19119 let query: Query = query.to_query();
19120 self.client.collect_pages(&path, query)
19121 }
19122
19123 /// Get all persons
19124 ///
19125 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
19126 /// Breaking off early saves the remaining requests.
19127 pub fn list_iter(&self, query: &GetPersonsQuery) -> Items<models::Person> {
19128 let path = "/persons".to_owned();
19129 self.client.items(&path, query.to_query())
19130 }
19131
19132 /// Fetch Birthdays
19133 ///
19134 /// `GET /persons/birthdays`
19135 ///
19136 /// This endpoint returns birthdays within a specific time interval. The returned objects are ordered by MONTH-DAY, where the first birthday in the list is the one next from the start date.
19137 /// The API also returns the `age` of the birthday. That age is calculated based on the date interval. That means, it is not the current age and also not the next birthday, but the age which the person had/will have at the end of the given date interval.
19138 /// There are two ways to utilize this endpoint:
19139 /// 1. With a fixed date interval (`start_date`, `end_date`). This
19140 /// interval must not be larger than one year.
19141 /// 2. With a `start_date` and a `direction` field. This combination also
19142 /// accepts a `page` and `limit` parameter (both with suitable defaults)
19143 /// to paginate through the results.
19144 ///
19145 /// Use [`Self::list_birthdays_with`] to pass query parameters.
19146 ///
19147 /// # Example
19148 ///
19149 /// ```
19150 /// # use churchtools_api::*;
19151 /// # use churchtools_api::queries::*;
19152 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19153 /// # let client = churchtools_api::replay::client("get-persons-birthdays");
19154 /// for birthday in client.persons().list_birthdays()? {
19155 /// println!("{:?}", birthday.deprecated);
19156 /// }
19157 /// # Ok(())
19158 /// # }
19159 /// ```
19160 pub fn list_birthdays(&self) -> Result<Vec<models::GetPersonsBirthdaysDataItem>> {
19161 self.list_birthdays_with(&Default::default())
19162 }
19163
19164 /// Fetch Birthdays
19165 ///
19166 /// Like [`Self::list_birthdays`], with query parameters.
19167 ///
19168 /// `GET /persons/birthdays`
19169 ///
19170 /// This endpoint returns birthdays within a specific time interval. The returned objects are ordered by MONTH-DAY, where the first birthday in the list is the one next from the start date.
19171 /// The API also returns the `age` of the birthday. That age is calculated based on the date interval. That means, it is not the current age and also not the next birthday, but the age which the person had/will have at the end of the given date interval.
19172 /// There are two ways to utilize this endpoint:
19173 /// 1. With a fixed date interval (`start_date`, `end_date`). This
19174 /// interval must not be larger than one year.
19175 /// 2. With a `start_date` and a `direction` field. This combination also
19176 /// accepts a `page` and `limit` parameter (both with suitable defaults)
19177 /// to paginate through the results.
19178 pub fn list_birthdays_with(&self, query: &GetPersonsBirthdaysQuery) -> Result<Vec<models::GetPersonsBirthdaysDataItem>> {
19179 let path = "/persons/birthdays".to_owned();
19180 let query: Query = query.to_query();
19181 self.client.collect_pages(&path, query)
19182 }
19183
19184 /// Fetch Birthdays
19185 ///
19186 /// Like [`Self::list_birthdays_with`], but lazy: each page is fetched only when the iteration reaches it.
19187 /// Breaking off early saves the remaining requests.
19188 pub fn list_birthdays_iter(&self, query: &GetPersonsBirthdaysQuery) -> Items<models::GetPersonsBirthdaysDataItem> {
19189 let path = "/persons/birthdays".to_owned();
19190 self.client.items(&path, query.to_query())
19191 }
19192
19193 /// get potential duplicates of persons
19194 ///
19195 /// `GET /persons/duplicates`
19196 ///
19197 /// **Caution:** This API is published as Beta and subject to be changed. It is published such that customers can play evaluate it with production data.
19198 ///
19199 /// Provide a list of potential duplicate person records. You can suppress some duplicates
19200 ///
19201 /// The other parameters are used to filter duplicates.
19202 ///
19203 /// Returns an array of duplicates
19204 ///
19205 /// * `p1` - properties of Person 1
19206 /// * `p2` - properties of Person 2
19207 ///
19208 /// Use [`Self::list_duplicates_with`] to pass query parameters.
19209 ///
19210 /// # Example
19211 ///
19212 /// ```
19213 /// # use churchtools_api::*;
19214 /// # use churchtools_api::queries::*;
19215 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19216 /// # let client = churchtools_api::replay::client("get-persons-duplicates");
19217 /// for duplicate in client.persons().list_duplicates()? {
19218 /// println!("{:?}", duplicate.relationship_type_id);
19219 /// }
19220 /// # Ok(())
19221 /// # }
19222 /// ```
19223 pub fn list_duplicates(&self) -> Result<Vec<models::GetPersonsDuplicatesDataItem>> {
19224 self.list_duplicates_with(&Default::default())
19225 }
19226
19227 /// get potential duplicates of persons
19228 ///
19229 /// Like [`Self::list_duplicates`], with query parameters.
19230 ///
19231 /// `GET /persons/duplicates`
19232 ///
19233 /// **Caution:** This API is published as Beta and subject to be changed. It is published such that customers can play evaluate it with production data.
19234 ///
19235 /// Provide a list of potential duplicate person records. You can suppress some duplicates
19236 ///
19237 /// The other parameters are used to filter duplicates.
19238 ///
19239 /// Returns an array of duplicates
19240 ///
19241 /// * `p1` - properties of Person 1
19242 /// * `p2` - properties of Person 2
19243 pub fn list_duplicates_with(&self, query: &GetPersonsDuplicatesQuery) -> Result<Vec<models::GetPersonsDuplicatesDataItem>> {
19244 let path = "/persons/duplicates".to_owned();
19245 let query: Query = query.to_query();
19246 self.client.request_data(Method::Get, &path, &query, None)
19247 }
19248
19249 /// Get all groups a member is in
19250 ///
19251 /// `GET /persons/{personId}/groups`
19252 ///
19253 /// This endpoint returns an array with all groups the user is in.
19254 ///
19255 /// Use [`Self::list_groups_with`] to pass query parameters.
19256 ///
19257 /// # Example
19258 ///
19259 /// ```
19260 /// # use churchtools_api::*;
19261 /// # use churchtools_api::queries::*;
19262 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19263 /// # let client = churchtools_api::replay::client("get-persons-id-groups");
19264 /// for group in client.persons().list_groups(42)? {
19265 /// println!("{}", group.id);
19266 /// }
19267 /// # Ok(())
19268 /// # }
19269 /// ```
19270 pub fn list_groups(&self, person_id: impl Display) -> Result<Vec<models::GroupMember>> {
19271 self.list_groups_with(person_id, &Default::default())
19272 }
19273
19274 /// Get all groups a member is in
19275 ///
19276 /// Like [`Self::list_groups`], with query parameters.
19277 ///
19278 /// `GET /persons/{personId}/groups`
19279 ///
19280 /// This endpoint returns an array with all groups the user is in.
19281 pub fn list_groups_with(&self, person_id: impl Display, query: &GetPersonsIdGroupsQuery) -> Result<Vec<models::GroupMember>> {
19282 let path = format!("/persons/{}/groups", seg(person_id));
19283 let query: Query = query.to_query();
19284 self.client.request_data(Method::Get, &path, &query, None)
19285 }
19286
19287 /// Get my unanswered meeting invitations
19288 ///
19289 /// `GET /persons/{personId}/openmeetingrequests`
19290 ///
19291 /// Lists meeting invitations for the authenticated person that have no response date and still have an occurrence found by recurrence calculation. personId must match the current user; querying another person returns 403, including for administrators. Tentative answers are excluded because they already have a response date. Invitations apply to the stored appointment or series, not separately to every occurrence. Results include nextStartDate and nextEndDate, are sorted by nextStartDate ascending, and are not paginated. The embedded appointment and legacy eventDate describe the stored appointment, which can start in the past for a recurring series.
19292 ///
19293 /// # Example
19294 ///
19295 /// ```
19296 /// # use churchtools_api::*;
19297 /// # use churchtools_api::queries::*;
19298 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19299 /// # let client = churchtools_api::replay::client("get-persons-personId-openmeetingrequests");
19300 /// for open_meeting_request in client.persons().list_open_meeting_requests(42)? {
19301 /// println!("{}", open_meeting_request.id);
19302 /// }
19303 /// # Ok(())
19304 /// # }
19305 /// ```
19306 pub fn list_open_meeting_requests(&self, person_id: impl Display) -> Result<Vec<models::OpenMeetingRequest>> {
19307 let path = format!("/persons/{}/openmeetingrequests", seg(person_id));
19308 let query: Query = Query::new();
19309 self.client.request_data(Method::Get, &path, &query, None)
19310 }
19311
19312 /// Returns the posts authored by a person
19313 ///
19314 /// `GET /persons/{personId}/posts`
19315 ///
19316 /// Use [`Self::list_posts_with`] to pass query parameters.
19317 ///
19318 /// # Example
19319 ///
19320 /// ```
19321 /// # use churchtools_api::*;
19322 /// # use churchtools_api::queries::*;
19323 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19324 /// # let client = churchtools_api::replay::client("get-persons-personId-posts");
19325 /// for post in client.persons().list_posts("abc123")? {
19326 /// println!("{}", post.title);
19327 /// }
19328 /// # Ok(())
19329 /// # }
19330 /// ```
19331 pub fn list_posts(&self, person_id: impl Display) -> Result<Vec<models::Post>> {
19332 self.list_posts_with(person_id, &Default::default())
19333 }
19334
19335 /// Returns the posts authored by a person
19336 ///
19337 /// Like [`Self::list_posts`], with query parameters.
19338 ///
19339 /// `GET /persons/{personId}/posts`
19340 pub fn list_posts_with(&self, person_id: impl Display, query: &GetPersonsPersonIdPostsQuery) -> Result<Vec<models::Post>> {
19341 let path = format!("/persons/{}/posts", seg(person_id));
19342 let query: Query = query.to_query();
19343 self.client.request_data(Method::Get, &path, &query, None)
19344 }
19345
19346 /// Get all relationships for all persons
19347 ///
19348 /// `GET /persons/relationships`
19349 ///
19350 /// # Example
19351 ///
19352 /// ```
19353 /// # use churchtools_api::*;
19354 /// # use churchtools_api::queries::*;
19355 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19356 /// # let client = churchtools_api::replay::client("get-persons-relationships");
19357 /// for relationship in client.persons().list_relationships()? {
19358 /// println!("{:?}", relationship.id);
19359 /// }
19360 /// # Ok(())
19361 /// # }
19362 /// ```
19363 pub fn list_relationships(&self) -> Result<Vec<models::GetPersonsRelationshipsDataItem>> {
19364 let path = "/persons/relationships".to_owned();
19365 let query: Query = Query::new();
19366 self.client.request_data(Method::Get, &path, &query, None)
19367 }
19368
19369 /// `GET /persons/search_old`
19370 ///
19371 /// # Example
19372 ///
19373 /// ```
19374 /// # use churchtools_api::*;
19375 /// # use churchtools_api::queries::*;
19376 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19377 /// # let client = churchtools_api::replay::client("get-persons-search_old");
19378 /// for search_old in client.persons().list_search_old()? {
19379 /// println!("{:?}", search_old);
19380 /// }
19381 /// # Ok(())
19382 /// # }
19383 /// ```
19384 #[deprecated = "GET /persons/search_old is deprecated in the ChurchTools API."]
19385 pub fn list_search_old(&self) -> Result<Vec<i64>> {
19386 let path = "/persons/search_old".to_owned();
19387 let query: Query = Query::new();
19388 self.client.request_data(Method::Get, &path, &query, None)
19389 }
19390
19391 /// Updates a person
19392 ///
19393 /// `PATCH /persons/{personId}`
19394 ///
19395 /// Endpoint to update a person in ChurchTools. Generally, you can provide any information to save, but be aware that you can only save information for fields you have write access to. Beware, that not all fields which are listed in the Person schema can be updated. E.g. `imageUrl` or `familyUrl`.
19396 ///
19397 /// # Example
19398 ///
19399 /// ```
19400 /// # use churchtools_api::*;
19401 /// # use churchtools_api::queries::*;
19402 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19403 /// # let client = churchtools_api::replay::client("patch-persons-id");
19404 /// let body = models::PatchPersonsIdBody {
19405 /// title: Some("Hauskreis Nord".into()),
19406 /// ..Default::default()
19407 /// };
19408 /// let result = client.persons().patch(42, &body)?;
19409 /// println!("{:?}", result.title);
19410 /// # Ok(())
19411 /// # }
19412 /// ```
19413 pub fn patch(&self, person_id: impl Display, body: &models::PatchPersonsIdBody) -> Result<models::Person> {
19414 let path = format!("/persons/{}", seg(person_id));
19415 let query: Query = Query::new();
19416 let body = serde_json::to_value(body).expect("request body serializes");
19417 self.client.request_data(Method::Patch, &path, &query, Some(&body))
19418 }
19419
19420 /// Retrieve person account properties
19421 ///
19422 /// `POST /persons/properties`
19423 ///
19424 /// Returns lightweight account and communication properties for the given person IDs. The response object is keyed by person ID. If `ids` is empty or omitted, no person properties are returned.
19425 ///
19426 /// # Example
19427 ///
19428 /// ```
19429 /// # use churchtools_api::*;
19430 /// # use churchtools_api::queries::*;
19431 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19432 /// # let client = churchtools_api::replay::client("post-persons-properties");
19433 /// let body = models::PostPersonsPropertiesBody::default();
19434 /// let result = client.persons().properties(&body)?;
19435 /// println!("{:?}", result);
19436 /// # Ok(())
19437 /// # }
19438 /// ```
19439 pub fn properties(&self, body: &models::PostPersonsPropertiesBody) -> Result<std::collections::BTreeMap<String, models::PersonProperties>> {
19440 let path = "/persons/properties".to_owned();
19441 let query: Query = Query::new();
19442 let body = serde_json::to_value(body).expect("request body serializes");
19443 self.client.request_data(Method::Post, &path, &query, Some(&body))
19444 }
19445
19446 /// Accept the current person's confidentiality agreement
19447 ///
19448 /// `PUT /persons/{personId}/confidentialityagreement`
19449 ///
19450 /// Records the current database date as the selected person’s confidentiality acceptance date. Only the current person can accept; simulation is rejected and administrators cannot accept for another person. Repeated acceptance overwrites the date. This is separate from privacy consent and takes no request body.
19451 ///
19452 /// # Example
19453 ///
19454 /// ```no_run
19455 /// # use churchtools_api::*;
19456 /// # use churchtools_api::queries::*;
19457 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19458 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19459 /// client.persons().update_confidentiality_agreement(42)?;
19460 /// # Ok(())
19461 /// # }
19462 /// ```
19463 pub fn update_confidentiality_agreement(&self, person_id: impl Display) -> Result<()> {
19464 let path = format!("/persons/{}/confidentialityagreement", seg(person_id));
19465 let query: Query = Query::new();
19466 self.client.request(Method::Put, &path, &query, None).map(|_| ())
19467 }
19468
19469 /// Change the password for the active account
19470 ///
19471 /// `PUT /persons/{personId}/password`
19472 ///
19473 /// Changes the password for the account in the password-reset session, or otherwise the currently signed-in account. The personId path value is currently ignored and does not select the target account. A reset session takes precedence over a signed-in session; in that case oldPassword must be an empty string. Without a reset session, oldPassword must match the current password (or be empty if none exists). The new password must meet the installation’s minimum_password_length (default 8), contain ASCII upper- and lowercase letters and a digit, and exclude the person’s first name, last name and nickname case-insensitively. A successful change normally invalidates all sessions and persistent login tokens and signs out the affected current user. Initial setup from no password or the default admin password retains sessions unless using a reset session. Ordinary user simulation is forbidden; support-user simulation is exempt.
19474 ///
19475 /// # Example
19476 ///
19477 /// ```no_run
19478 /// # use churchtools_api::*;
19479 /// # use churchtools_api::queries::*;
19480 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19481 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19482 /// let body = models::PersonPasswordUpdate {
19483 /// new_password: "ExamplePassword42".into(),
19484 /// new_password_confirm: "ExamplePassword42".into(),
19485 /// old_password: "PreviousPassword41".into(),
19486 /// ..Default::default()
19487 /// };
19488 /// client.persons().update_password(42, &body)?;
19489 /// # Ok(())
19490 /// # }
19491 /// ```
19492 pub fn update_password(&self, person_id: impl Display, body: &models::PersonPasswordUpdate) -> Result<()> {
19493 let path = format!("/persons/{}/password", seg(person_id));
19494 let query: Query = Query::new();
19495 let body = serde_json::to_value(body).expect("request body serializes");
19496 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
19497 }
19498
19499 /// Record privacy consent
19500 ///
19501 /// `PUT /persons/{personId}/privacypolicy`
19502 ///
19503 /// Records consent for the selected person and optionally their children. The consent banner must be enabled. The requester must be the person themselves at age 16 or above, a super administrator, or a parent authorized through relationship type 1. For own consent, a missing birthday must be supplied and the controller separately checks the age; a request can return 204 without recording own consent when that check does not pass. Children are checked against parent/child relationship type 1, missing prior consent and age below 16. If any child marked accepted is processed, 200 returns per-child outcomes, including errors or not allowed. Otherwise 204 has no body. The flow is not atomic; own consent or birthdays may already have changed when a later step fails. Unlike GET and DELETE, the acceptance policy has no explicit simulation prohibition.
19504 ///
19505 /// # Example
19506 ///
19507 /// ```no_run
19508 /// # use churchtools_api::*;
19509 /// # use churchtools_api::queries::*;
19510 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19511 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19512 /// let body = models::PersonPrivacyPolicyUpdate {
19513 /// children_accepted: false,
19514 /// own_accepted: true,
19515 /// persons: vec![models::PersonPrivacyPolicyChildUpdate {
19516 /// accepted: true,
19517 /// birthday: "2016-05-14".into(),
19518 /// edit_birthday: false,
19519 /// id: 43,
19520 /// ..Default::default()
19521 /// }],
19522 /// type_id: 2,
19523 /// who_id: 1,
19524 /// ..Default::default()
19525 /// };
19526 /// let result = client.persons().update_privacy_policy(42, &body)?;
19527 /// println!("{:?}", result);
19528 /// # Ok(())
19529 /// # }
19530 /// ```
19531 pub fn update_privacy_policy(&self, person_id: impl Display, body: &models::PersonPrivacyPolicyUpdate) -> Result<Option<Vec<models::PersonPrivacyPolicyChildResult>>> {
19532 let path = format!("/persons/{}/privacypolicy", seg(person_id));
19533 let query: Query = Query::new();
19534 let body = serde_json::to_value(body).expect("request body serializes");
19535 self.client.request_data(Method::Put, &path, &query, Some(&body))
19536 }
19537
19538}
19539
19540/// `client.persons().absences()`
19541#[derive(Clone, Copy)]
19542pub struct PersonsAbsencesResource<'a> {
19543 client: &'a Client,
19544}
19545
19546impl<'a> PersonsAbsencesResource<'a> {
19547 /// Create new absence for person
19548 ///
19549 /// `POST /persons/{personId}/absences`
19550 ///
19551 /// Creates an absence for the person. Access requires the person themselves or "manage absent" or "churchservice +view absence" permission together with access to the person.
19552 ///
19553 /// # Example
19554 ///
19555 /// ```
19556 /// # use churchtools_api::*;
19557 /// # use churchtools_api::queries::*;
19558 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19559 /// # let client = churchtools_api::replay::client("post-persons-personId-absences");
19560 /// let body = models::AbsenceCreate {
19561 /// absence_reason_id: 1,
19562 /// ..Default::default()
19563 /// };
19564 /// let result = client.persons().absences().create(42, &body)?;
19565 /// println!("{}", result.id);
19566 /// # Ok(())
19567 /// # }
19568 /// ```
19569 pub fn create(&self, person_id: impl Display, body: &models::AbsenceCreate) -> Result<models::Absence> {
19570 let path = format!("/persons/{}/absences", seg(person_id));
19571 let query: Query = Query::new();
19572 let body = serde_json::to_value(body).expect("request body serializes");
19573 self.client.request_data(Method::Post, &path, &query, Some(&body))
19574 }
19575
19576 /// Delete absence
19577 ///
19578 /// `DELETE /persons/{personId}/absences/{id}`
19579 ///
19580 /// Deletes the absence belonging to the person. Access requires the person themselves or "manage absent" or "churchservice +view absence" permission together with access to the person.
19581 ///
19582 /// Use [`Self::delete_with`] to pass query parameters.
19583 ///
19584 /// # Example
19585 ///
19586 /// ```no_run
19587 /// # use churchtools_api::*;
19588 /// # use churchtools_api::queries::*;
19589 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19590 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19591 /// client.persons().absences().delete(42, 1)?;
19592 /// # Ok(())
19593 /// # }
19594 /// ```
19595 pub fn delete(&self, person_id: impl Display, id: impl Display) -> Result<()> {
19596 self.delete_with(person_id, id, &Default::default())
19597 }
19598
19599 /// Delete absence
19600 ///
19601 /// Like [`Self::delete`], with query parameters.
19602 ///
19603 /// `DELETE /persons/{personId}/absences/{id}`
19604 ///
19605 /// Deletes the absence belonging to the person. Access requires the person themselves or "manage absent" or "churchservice +view absence" permission together with access to the person.
19606 pub fn delete_with(&self, person_id: impl Display, id: impl Display, query: &DeletePersonsPersonIdAbsencesIdQuery) -> Result<()> {
19607 let path = format!("/persons/{}/absences/{}", seg(person_id), seg(id));
19608 let query: Query = query.to_query();
19609 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
19610 }
19611
19612 /// Fetch one absence
19613 ///
19614 /// `GET /persons/{personId}/absences/{id}`
19615 ///
19616 /// Returns the absence belonging to the person. Access requires the person themselves or "manage absent" or "churchservice +view absence" permission together with access to the person.
19617 ///
19618 /// # Example
19619 ///
19620 /// ```
19621 /// # use churchtools_api::*;
19622 /// # use churchtools_api::queries::*;
19623 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19624 /// # let client = churchtools_api::replay::client("get-persons-personId-absences-id");
19625 /// let absence = client.persons().absences().get(42, 1)?;
19626 /// println!("{}", absence.id);
19627 /// # Ok(())
19628 /// # }
19629 /// ```
19630 pub fn get(&self, person_id: impl Display, id: impl Display) -> Result<models::Absence> {
19631 let path = format!("/persons/{}/absences/{}", seg(person_id), seg(id));
19632 let query: Query = Query::new();
19633 self.client.request_data(Method::Get, &path, &query, None)
19634 }
19635
19636 /// Fetch all absences for a person
19637 ///
19638 /// `GET /persons/{personId}/absences`
19639 ///
19640 /// Returns this person’s absences that overlap the requested date range, sorted by start. Access requires the person themselves or "manage absent" or "churchservice +view absence" permission together with access to the person.
19641 ///
19642 /// Use [`Self::list_with`] to pass query parameters.
19643 ///
19644 /// # Example
19645 ///
19646 /// ```
19647 /// # use churchtools_api::*;
19648 /// # use churchtools_api::queries::*;
19649 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19650 /// # let client = churchtools_api::replay::client("get-persons-personId-absences");
19651 /// for absence in client.persons().absences().list(42)? {
19652 /// println!("{}", absence.id);
19653 /// }
19654 /// # Ok(())
19655 /// # }
19656 /// ```
19657 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::Absence>> {
19658 self.list_with(person_id, &Default::default())
19659 }
19660
19661 /// Fetch all absences for a person
19662 ///
19663 /// Like [`Self::list`], with query parameters.
19664 ///
19665 /// `GET /persons/{personId}/absences`
19666 ///
19667 /// Returns this person’s absences that overlap the requested date range, sorted by start. Access requires the person themselves or "manage absent" or "churchservice +view absence" permission together with access to the person.
19668 pub fn list_with(&self, person_id: impl Display, query: &GetPersonsPersonIdAbsencesQuery) -> Result<Vec<models::Absence>> {
19669 let path = format!("/persons/{}/absences", seg(person_id));
19670 let query: Query = query.to_query();
19671 self.client.request_data(Method::Get, &path, &query, None)
19672 }
19673
19674 /// Update absence
19675 ///
19676 /// `PUT /persons/{personId}/absences/{id}`
19677 ///
19678 /// Replaces an absence belonging to the person. Access requires the person themselves or "manage absent" or "churchservice +view absence" permission together with access to the person.
19679 ///
19680 /// # Example
19681 ///
19682 /// ```
19683 /// # use churchtools_api::*;
19684 /// # use churchtools_api::queries::*;
19685 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19686 /// # let client = churchtools_api::replay::client("put-persons-personId-absences-id");
19687 /// let body = models::AbsenceUpdate {
19688 /// absence_reason_id: 1,
19689 /// ..Default::default()
19690 /// };
19691 /// let result = client.persons().absences().update(42, 1, &body)?;
19692 /// println!("{}", result.id);
19693 /// # Ok(())
19694 /// # }
19695 /// ```
19696 pub fn update(&self, person_id: impl Display, id: impl Display, body: &models::AbsenceUpdate) -> Result<models::Absence> {
19697 let path = format!("/persons/{}/absences/{}", seg(person_id), seg(id));
19698 let query: Query = Query::new();
19699 let body = serde_json::to_value(body).expect("request body serializes");
19700 self.client.request_data(Method::Put, &path, &query, Some(&body))
19701 }
19702
19703}
19704
19705/// `client.persons().devices()`
19706#[derive(Clone, Copy)]
19707pub struct PersonsDevicesResource<'a> {
19708 client: &'a Client,
19709}
19710
19711impl<'a> PersonsDevicesResource<'a> {
19712 /// Delete device for person
19713 ///
19714 /// `DELETE /persons/{personId}/devices/{deviceId}`
19715 ///
19716 /// Removes the registration identified by personId/deviceId. Requires the person themselves, a super administrator, or administer persons permission. An unknown registration is a successful no-op. Returns 204 without a response body; no other device registrations are deleted.
19717 ///
19718 /// # Example
19719 ///
19720 /// ```no_run
19721 /// # use churchtools_api::*;
19722 /// # use churchtools_api::queries::*;
19723 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19724 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19725 /// client.persons().devices().delete(42, "abc123")?;
19726 /// # Ok(())
19727 /// # }
19728 /// ```
19729 pub fn delete(&self, person_id: impl Display, device_id: impl Display) -> Result<()> {
19730 let path = format!("/persons/{}/devices/{}", seg(person_id), seg(device_id));
19731 let query: Query = Query::new();
19732 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
19733 }
19734
19735 /// Get specified device
19736 ///
19737 /// `GET /persons/{personId}/devices/{deviceId}`
19738 ///
19739 /// Returns the device identified by the personId/deviceId pair. Requires the same person-settings read access as the device list. Unknown registrations return 404. deviceId is the registration identifier; the deprecated response id is actually the push token. Reading does not refresh expiration.
19740 ///
19741 /// # Example
19742 ///
19743 /// ```
19744 /// # use churchtools_api::*;
19745 /// # use churchtools_api::queries::*;
19746 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19747 /// # let client = churchtools_api::replay::client("get-persons-personId-devices-deviceId");
19748 /// let device = client.persons().devices().get(42, "abc123")?;
19749 /// println!("{:?}", device.app_version);
19750 /// # Ok(())
19751 /// # }
19752 /// ```
19753 pub fn get(&self, person_id: impl Display, device_id: impl Display) -> Result<models::Device> {
19754 let path = format!("/persons/{}/devices/{}", seg(person_id), seg(device_id));
19755 let query: Query = Query::new();
19756 self.client.request_data(Method::Get, &path, &query, None)
19757 }
19758
19759 /// Get all registered devices for person
19760 ///
19761 /// `GET /persons/{personId}/devices`
19762 ///
19763 /// Lists all device registrations stored for the person, including registrations whose expirationDate has passed until cleanup removes them. Requires access to the person’s settings: the person themselves, a super administrator, or someone with administer persons permission. The read policy also accepts the special person ID -1. There is no pagination or guaranteed order, and this operation does not refresh expiration.
19764 ///
19765 /// # Example
19766 ///
19767 /// ```
19768 /// # use churchtools_api::*;
19769 /// # use churchtools_api::queries::*;
19770 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19771 /// # let client = churchtools_api::replay::client("get-persons-personId-devices");
19772 /// for device in client.persons().devices().list(42)? {
19773 /// println!("{:?}", device.app_version);
19774 /// }
19775 /// # Ok(())
19776 /// # }
19777 /// ```
19778 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::Device>> {
19779 let path = format!("/persons/{}/devices", seg(person_id));
19780 let query: Query = Query::new();
19781 self.client.request_data(Method::Get, &path, &query, None)
19782 }
19783
19784 /// Create or update new device for person
19785 ///
19786 /// `PUT /persons/{personId}/devices/{deviceId}`
19787 ///
19788 /// Creates or refreshes the registration identified by personId/deviceId and returns the person’s complete device list. Requires access to update the person’s settings: the person themselves, a super administrator, or someone with administer persons permission. type is required on every call. Expiration is extended by three months, or one day during simulation. Omitted pushId becomes deviceId; empty pushId preserves the previous token; null clears it. Omitted appVersion clears the previous version. Other registrations of the same person with the same non-null push token are removed. Saving is transactional. When chat is active, a supplied appVersion outside simulation also sets the person’s hasMatrixUser setting.
19789 ///
19790 /// # Example
19791 ///
19792 /// ```no_run
19793 /// # use churchtools_api::*;
19794 /// # use churchtools_api::queries::*;
19795 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19796 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19797 /// let body = models::DeviceUpdate {
19798 /// r#type: "FCM".into(),
19799 /// ..Default::default()
19800 /// };
19801 /// for device in client.persons().devices().update(42, "abc123", &body)? {
19802 /// println!("{:?}", device.app_version);
19803 /// }
19804 /// # Ok(())
19805 /// # }
19806 /// ```
19807 pub fn update(&self, person_id: impl Display, device_id: impl Display, body: &models::DeviceUpdate) -> Result<Vec<models::Device>> {
19808 let path = format!("/persons/{}/devices/{}", seg(person_id), seg(device_id));
19809 let query: Query = Query::new();
19810 let body = serde_json::to_value(body).expect("request body serializes");
19811 self.client.request_data(Method::Put, &path, &query, Some(&body))
19812 }
19813
19814}
19815
19816/// `client.persons().events()`
19817#[derive(Clone, Copy)]
19818pub struct PersonsEventsResource<'a> {
19819 client: &'a Client,
19820}
19821
19822impl<'a> PersonsEventsResource<'a> {
19823 pub fn services(&self) -> PersonsEventsServicesResource<'a> {
19824 PersonsEventsServicesResource { client: self.client }
19825 }
19826
19827 /// Get events that person is involved with
19828 ///
19829 /// `GET /persons/{personId}/events`
19830 ///
19831 /// Returns an unpaginated list of non-cancelled events where the person has a valid assignment. Requires the current user to be this person or a super administrator. from defaults to today and is compared strictly to midnight: an event exactly at midnight is excluded, later events that day are included. Results are ordered by event start ascending with no upper date bound. Visible service assignments are always included under eventServices and are not restricted to just this person. eventFiles is present but this endpoint does not load files, so it is empty. meta.count is the number returned.
19832 ///
19833 /// Use [`Self::list_with`] to pass query parameters.
19834 ///
19835 /// # Example
19836 ///
19837 /// ```
19838 /// # use churchtools_api::*;
19839 /// # use churchtools_api::queries::*;
19840 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19841 /// # let client = churchtools_api::replay::client("get-persons-id-events");
19842 /// for event in client.persons().events().list(42)? {
19843 /// println!("{}", event.name);
19844 /// }
19845 /// # Ok(())
19846 /// # }
19847 /// ```
19848 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::EventReadWithServices>> {
19849 self.list_with(person_id, &Default::default())
19850 }
19851
19852 /// Get events that person is involved with
19853 ///
19854 /// Like [`Self::list`], with query parameters.
19855 ///
19856 /// `GET /persons/{personId}/events`
19857 ///
19858 /// Returns an unpaginated list of non-cancelled events where the person has a valid assignment. Requires the current user to be this person or a super administrator. from defaults to today and is compared strictly to midnight: an event exactly at midnight is excluded, later events that day are included. Results are ordered by event start ascending with no upper date bound. Visible service assignments are always included under eventServices and are not restricted to just this person. eventFiles is present but this endpoint does not load files, so it is empty. meta.count is the number returned.
19859 pub fn list_with(&self, person_id: impl Display, query: &GetPersonsIdEventsQuery) -> Result<Vec<models::EventReadWithServices>> {
19860 let path = format!("/persons/{}/events", seg(person_id));
19861 let query: Query = query.to_query();
19862 self.client.request_data(Method::Get, &path, &query, None)
19863 }
19864
19865}
19866
19867/// `client.persons().events().services()`
19868#[derive(Clone, Copy)]
19869pub struct PersonsEventsServicesResource<'a> {
19870 client: &'a Client,
19871}
19872
19873impl<'a> PersonsEventsServicesResource<'a> {
19874 pub fn exchange_requests(&self) -> PersonsEventsServicesExchangeRequestsResource<'a> {
19875 PersonsEventsServicesExchangeRequestsResource { client: self.client }
19876 }
19877
19878 /// Get a person’s assignments in an event
19879 ///
19880 /// `GET /persons/{personId}/events/{eventId}/services`
19881 ///
19882 /// Returns the valid assignments of this person in a non-cancelled event, including both outstanding and confirmed assignments. Requires the current user to be this person or a super administrator. Unknown or cancelled events produce an empty list; related person and event objects are not enriched.
19883 ///
19884 /// # Example
19885 ///
19886 /// ```
19887 /// # use churchtools_api::*;
19888 /// # use churchtools_api::queries::*;
19889 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19890 /// # let client = churchtools_api::replay::client("get-persons-id-events-id-services");
19891 /// for service in client.persons().events().services().list(42, 42)? {
19892 /// println!("{:?}", service.name);
19893 /// }
19894 /// # Ok(())
19895 /// # }
19896 /// ```
19897 pub fn list(&self, person_id: impl Display, event_id: impl Display) -> Result<Vec<models::ServiceRequest>> {
19898 let path = format!("/persons/{}/events/{}/services", seg(person_id), seg(event_id));
19899 let query: Query = Query::new();
19900 self.client.request_data(Method::Get, &path, &query, None)
19901 }
19902
19903}
19904
19905/// `client.persons().events().services().exchange_requests()`
19906#[derive(Clone, Copy)]
19907pub struct PersonsEventsServicesExchangeRequestsResource<'a> {
19908 client: &'a Client,
19909}
19910
19911impl<'a> PersonsEventsServicesExchangeRequestsResource<'a> {
19912 /// Create a new service exchange request
19913 ///
19914 /// `POST /persons/{personId}/events/{eventId}/services/{serviceId}/exchangerequests`
19915 ///
19916 /// Creates an `UNANSWERED` exchange request and sends the request notification. Requires the current user to be assigned to the source assignment. The target requestedServiceId is an event-service assignment ID, as returned by the candidates endpoint. Creating the request does not change either assignment.
19917 ///
19918 /// # Example
19919 ///
19920 /// ```no_run
19921 /// # use churchtools_api::*;
19922 /// # use churchtools_api::queries::*;
19923 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19924 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19925 /// let body = models::ServiceExchangeRequestCreate {
19926 /// requested_service_id: 42,
19927 /// ..Default::default()
19928 /// };
19929 /// let result = client.persons().events().services().exchange_requests().create(42, 42, 42, &body)?;
19930 /// println!("{}", result.id);
19931 /// # Ok(())
19932 /// # }
19933 /// ```
19934 pub fn create(&self, person_id: impl Display, event_id: impl Display, service_id: impl Display, body: &models::ServiceExchangeRequestCreate) -> Result<models::ServiceExchangeRequest> {
19935 let path = format!("/persons/{}/events/{}/services/{}/exchangerequests", seg(person_id), seg(event_id), seg(service_id));
19936 let query: Query = Query::new();
19937 let body = serde_json::to_value(body).expect("request body serializes");
19938 self.client.request_data(Method::Post, &path, &query, Some(&body))
19939 }
19940
19941 /// Delete a service exchange request
19942 ///
19943 /// `DELETE /persons/{personId}/events/{eventId}/services/{serviceId}/exchangerequests/{requestId}`
19944 ///
19945 /// Cancels the exchange by setting status to `CANCELLED` and sending a cancellation notification. Requires the current user to be assigned to the source `serviceId`. With hardDelete=`true`, removes the request matching both `requestId` and the source assignment instead, without a cancellation notification. Neither action swaps the assigned persons. Cancellation leaves the archive flag unchanged.
19946 ///
19947 /// Use [`Self::delete_with`] to pass query parameters.
19948 ///
19949 /// # Example
19950 ///
19951 /// ```no_run
19952 /// # use churchtools_api::*;
19953 /// # use churchtools_api::queries::*;
19954 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19955 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
19956 /// client.persons().events().services().exchange_requests().delete(42, 42, 42, 42)?;
19957 /// # Ok(())
19958 /// # }
19959 /// ```
19960 pub fn delete(&self, person_id: impl Display, event_id: impl Display, service_id: impl Display, request_id: impl Display) -> Result<()> {
19961 self.delete_with(person_id, event_id, service_id, request_id, &Default::default())
19962 }
19963
19964 /// Delete a service exchange request
19965 ///
19966 /// Like [`Self::delete`], with query parameters.
19967 ///
19968 /// `DELETE /persons/{personId}/events/{eventId}/services/{serviceId}/exchangerequests/{requestId}`
19969 ///
19970 /// Cancels the exchange by setting status to `CANCELLED` and sending a cancellation notification. Requires the current user to be assigned to the source `serviceId`. With hardDelete=`true`, removes the request matching both `requestId` and the source assignment instead, without a cancellation notification. Neither action swaps the assigned persons. Cancellation leaves the archive flag unchanged.
19971 pub fn delete_with(&self, person_id: impl Display, event_id: impl Display, service_id: impl Display, request_id: impl Display, query: &DeletePersonsIdEventsIdServicesIdExchangerequestsIdQuery) -> Result<()> {
19972 let path = format!("/persons/{}/events/{}/services/{}/exchangerequests/{}", seg(person_id), seg(event_id), seg(service_id), seg(request_id));
19973 let query: Query = query.to_query();
19974 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
19975 }
19976
19977 /// Get all service exchange requests of a user for a service
19978 ///
19979 /// `GET /persons/{personId}/events/{eventId}/services/{serviceId}/exchangerequests`
19980 ///
19981 /// Returns incoming or outgoing exchange requests for the assignment identified by `serviceId`. Requires the current user to be assigned to it. The list is unpaginated and does not filter by status, archive flag or event date. Event and person details are enriched where available.
19982 ///
19983 /// Use [`Self::list_with`] to pass query parameters.
19984 ///
19985 /// # Example
19986 ///
19987 /// ```
19988 /// # use churchtools_api::*;
19989 /// # use churchtools_api::queries::*;
19990 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
19991 /// # let client = churchtools_api::replay::client("get-persons-id-events-id-services-id-exchangerequests");
19992 /// for exchange_request in client.persons().events().services().exchange_requests().list(42, 42, 42)? {
19993 /// println!("{}", exchange_request.id);
19994 /// }
19995 /// # Ok(())
19996 /// # }
19997 /// ```
19998 pub fn list(&self, person_id: impl Display, event_id: impl Display, service_id: impl Display) -> Result<Vec<models::ServiceExchangeRequest>> {
19999 self.list_with(person_id, event_id, service_id, &Default::default())
20000 }
20001
20002 /// Get all service exchange requests of a user for a service
20003 ///
20004 /// Like [`Self::list`], with query parameters.
20005 ///
20006 /// `GET /persons/{personId}/events/{eventId}/services/{serviceId}/exchangerequests`
20007 ///
20008 /// Returns incoming or outgoing exchange requests for the assignment identified by `serviceId`. Requires the current user to be assigned to it. The list is unpaginated and does not filter by status, archive flag or event date. Event and person details are enriched where available.
20009 pub fn list_with(&self, person_id: impl Display, event_id: impl Display, service_id: impl Display, query: &GetPersonsIdEventsIdServicesIdExchangerequestsQuery) -> Result<Vec<models::ServiceExchangeRequest>> {
20010 let path = format!("/persons/{}/events/{}/services/{}/exchangerequests", seg(person_id), seg(event_id), seg(service_id));
20011 let query: Query = query.to_query();
20012 self.client.request_data(Method::Get, &path, &query, None)
20013 }
20014
20015 /// Get candidates for service exchange request
20016 ///
20017 /// `GET /persons/{personId}/events/{eventId}/services/{serviceId}/exchangerequests/candidates`
20018 ///
20019 /// Returns an unpaginated list of assignments for the same reusable service as the source assignment. Requires the current user to be assigned to the source. Candidates have valid assignments with a non-`null` name, an event starting after midnight today, and a person other than `personId`. Hidden-person visibility is respected.
20020 ///
20021 /// # Example
20022 ///
20023 /// ```
20024 /// # use churchtools_api::*;
20025 /// # use churchtools_api::queries::*;
20026 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20027 /// # let client = churchtools_api::replay::client("get-persons-id-events-id-services-id-exchangerequests-candidates");
20028 /// for candidate in client.persons().events().services().exchange_requests().list_candidates(42, 42, 42)? {
20029 /// println!("{}", candidate.event_date);
20030 /// }
20031 /// # Ok(())
20032 /// # }
20033 /// ```
20034 pub fn list_candidates(&self, person_id: impl Display, event_id: impl Display, service_id: impl Display) -> Result<Vec<models::ServiceExchangeCandidate>> {
20035 let path = format!("/persons/{}/events/{}/services/{}/exchangerequests/candidates", seg(person_id), seg(event_id), seg(service_id));
20036 let query: Query = Query::new();
20037 self.client.request_data(Method::Get, &path, &query, None)
20038 }
20039
20040}
20041
20042/// `client.persons().exchange_requests()`
20043#[derive(Clone, Copy)]
20044pub struct PersonsExchangeRequestsResource<'a> {
20045 client: &'a Client,
20046}
20047
20048impl<'a> PersonsExchangeRequestsResource<'a> {
20049 /// Decline a service exchange request
20050 ///
20051 /// `DELETE /persons/{personId}/exchangerequests/{requestId}`
20052 ///
20053 /// Declines the exchange by setting its status to `DECLINED` and sending a notification. The request remains stored and its archive flag is unchanged; the assignments are not swapped. Requires `personId` to identify the current user and the person assigned to the requested assignment. Returns the updated exchange request without enriching events or persons. Already answered requests are returned unchanged.
20054 ///
20055 /// # Example
20056 ///
20057 /// ```no_run
20058 /// # use churchtools_api::*;
20059 /// # use churchtools_api::queries::*;
20060 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20061 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20062 /// let exchange_request = client.persons().exchange_requests().delete(42, 42)?;
20063 /// println!("{}", exchange_request.id);
20064 /// # Ok(())
20065 /// # }
20066 /// ```
20067 pub fn delete(&self, person_id: impl Display, request_id: impl Display) -> Result<models::ServiceExchangeRequest> {
20068 let path = format!("/persons/{}/exchangerequests/{}", seg(person_id), seg(request_id));
20069 let query: Query = Query::new();
20070 self.client.request_data(Method::Delete, &path, &query, None)
20071 }
20072
20073 /// Get all service exchange requests for a user
20074 ///
20075 /// `GET /persons/{personId}/exchangerequests`
20076 ///
20077 /// Returns an unpaginated list of incoming or outgoing exchanges for the current user; `personId` must identify that user. Both assignments must still be valid, the exchange must not be archived, and at least one event must start today or later. Status is not restricted to `UNANSWERED`. Event and person details are enriched where available.
20078 ///
20079 /// Use [`Self::list_with`] to pass query parameters.
20080 ///
20081 /// # Example
20082 ///
20083 /// ```
20084 /// # use churchtools_api::*;
20085 /// # use churchtools_api::queries::*;
20086 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20087 /// # let client = churchtools_api::replay::client("get-persons-id-exchangerequests");
20088 /// for exchange_request in client.persons().exchange_requests().list(42)? {
20089 /// println!("{}", exchange_request.id);
20090 /// }
20091 /// # Ok(())
20092 /// # }
20093 /// ```
20094 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::ServiceExchangeRequest>> {
20095 self.list_with(person_id, &Default::default())
20096 }
20097
20098 /// Get all service exchange requests for a user
20099 ///
20100 /// Like [`Self::list`], with query parameters.
20101 ///
20102 /// `GET /persons/{personId}/exchangerequests`
20103 ///
20104 /// Returns an unpaginated list of incoming or outgoing exchanges for the current user; `personId` must identify that user. Both assignments must still be valid, the exchange must not be archived, and at least one event must start today or later. Status is not restricted to `UNANSWERED`. Event and person details are enriched where available.
20105 pub fn list_with(&self, person_id: impl Display, query: &GetPersonsIdExchangerequestsQuery) -> Result<Vec<models::ServiceExchangeRequest>> {
20106 let path = format!("/persons/{}/exchangerequests", seg(person_id));
20107 let query: Query = query.to_query();
20108 self.client.request_data(Method::Get, &path, &query, None)
20109 }
20110
20111 /// Accept a service exchange request
20112 ///
20113 /// `PUT /persons/{personId}/exchangerequests/{requestId}`
20114 ///
20115 /// Accepts the exchange and swaps the persons assigned to the two event-service assignments, confirming both assignments. The workflow archives the accepted exchange and other active exchanges from the same source assignment, and sends notifications. Requires `personId` to identify the current user and the person assigned to the requested assignment. Returns the updated exchange request without enriching events or persons.
20116 ///
20117 /// # Example
20118 ///
20119 /// ```no_run
20120 /// # use churchtools_api::*;
20121 /// # use churchtools_api::queries::*;
20122 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20123 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20124 /// let result = client.persons().exchange_requests().update(42, 42)?;
20125 /// println!("{}", result.id);
20126 /// # Ok(())
20127 /// # }
20128 /// ```
20129 pub fn update(&self, person_id: impl Display, request_id: impl Display) -> Result<models::ServiceExchangeRequest> {
20130 let path = format!("/persons/{}/exchangerequests/{}", seg(person_id), seg(request_id));
20131 let query: Query = Query::new();
20132 self.client.request_data(Method::Put, &path, &query, None)
20133 }
20134
20135}
20136
20137/// `client.persons().external_logins()`
20138#[derive(Clone, Copy)]
20139pub struct PersonsExternalLoginsResource<'a> {
20140 client: &'a Client,
20141}
20142
20143impl<'a> PersonsExternalLoginsResource<'a> {
20144 /// Unlink an external login provider from a person
20145 ///
20146 /// `DELETE /persons/{personId}/external-logins/{externalLoginId}`
20147 ///
20148 /// Removes this person’s identity mapping for the selected external-login provider. Requires the person themselves, a super administrator, or administer persons permission. A missing mapping returns 404, including on repeated deletion. The provider itself is retained. The method does not end existing sessions or verify that another login method remains available. A later external login is handled by the provider’s normal matching/linking workflow.
20149 ///
20150 /// # Example
20151 ///
20152 /// ```no_run
20153 /// # use churchtools_api::*;
20154 /// # use churchtools_api::queries::*;
20155 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20156 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20157 /// client.persons().external_logins().delete(42, 7)?;
20158 /// # Ok(())
20159 /// # }
20160 /// ```
20161 pub fn delete(&self, person_id: impl Display, external_login_id: impl Display) -> Result<()> {
20162 let path = format!("/persons/{}/external-logins/{}", seg(person_id), seg(external_login_id));
20163 let query: Query = Query::new();
20164 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
20165 }
20166
20167 /// Get linked external login providers
20168 ///
20169 /// `GET /persons/{personId}/external-logins`
20170 ///
20171 /// Lists the external identity providers linked to the person. Requires access to the person’s settings: the person themselves, a super administrator, or administer persons permission; the read policy also permits personId=-1. Hidden providers are included when a mapping exists. This is a list of identity links, not a list of all configured login options. No pagination or guaranteed order applies. Person existence is not checked separately; no mappings returns an empty list.
20172 ///
20173 /// # Example
20174 ///
20175 /// ```
20176 /// # use churchtools_api::*;
20177 /// # use churchtools_api::queries::*;
20178 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20179 /// # let client = churchtools_api::replay::client("get-persons-id-external-logins");
20180 /// for external_login in client.persons().external_logins().list(42)? {
20181 /// println!("{}", external_login.external_login_id);
20182 /// }
20183 /// # Ok(())
20184 /// # }
20185 /// ```
20186 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::ExternalLoginPersonMapping>> {
20187 let path = format!("/persons/{}/external-logins", seg(person_id));
20188 let query: Query = Query::new();
20189 self.client.request_data(Method::Get, &path, &query, None)
20190 }
20191
20192}
20193
20194/// `client.persons().followups()`
20195#[derive(Clone, Copy)]
20196pub struct PersonsFollowupsResource<'a> {
20197 client: &'a Client,
20198}
20199
20200impl<'a> PersonsFollowupsResource<'a> {
20201 /// Create a follow-up concerning a person
20202 ///
20203 /// `POST /persons/{personId}/followups`
20204 ///
20205 /// Creates a task concerning this person without a group or membership context. The subject person is distinct from ownerId, which identifies who should handle the task. Requires permission to view the person; a configured success group additionally requires permission to add members there, or the corresponding group-type permission. Missing/null ownerId assigns the task to the current user. A new specification is created from the title and display/success settings. A due date is optional and may lie in the past. Configuring a success group does not itself add a membership; the completion request must explicitly select the target group.
20206 ///
20207 /// # Example
20208 ///
20209 /// ```
20210 /// # use churchtools_api::*;
20211 /// # use churchtools_api::queries::*;
20212 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20213 /// # let client = churchtools_api::replay::client("post-persons-personId-followups");
20214 /// let body = models::FollowUpCreate {
20215 /// title: "Call Peter".into(),
20216 /// ..Default::default()
20217 /// };
20218 /// let result = client.persons().followups().create(42, &body)?;
20219 /// println!("{}", result.title);
20220 /// # Ok(())
20221 /// # }
20222 /// ```
20223 pub fn create(&self, person_id: impl Display, body: &models::FollowUpCreate) -> Result<models::FollowUp2> {
20224 let path = format!("/persons/{}/followups", seg(person_id));
20225 let query: Query = Query::new();
20226 let body = serde_json::to_value(body).expect("request body serializes");
20227 self.client.request_data(Method::Post, &path, &query, Some(&body))
20228 }
20229
20230 /// Get follow-up counts for a person
20231 ///
20232 /// `GET /persons/{personId}/followups/statistics`
20233 ///
20234 /// Counts follow-ups concerning this person, including tasks linked to group memberships. Requires permission to view the person. Counts are restricted to tasks assigned to the current user and unassigned tasks in groups where that user has follow-up rights; tasks assigned to other people are omitted. Archived subject persons are excluded. Counts cover all matching tasks independently of list pagination and state filters. Due categories use the effective due date and the server’s current date. countDone includes both completed and dismissed tasks. Empty results return zero for every category.
20235 ///
20236 /// # Example
20237 ///
20238 /// ```
20239 /// # use churchtools_api::*;
20240 /// # use churchtools_api::queries::*;
20241 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20242 /// # let client = churchtools_api::replay::client("get-persons-personId-followups-statistics");
20243 /// let statistic = client.persons().followups().get_statistics(42)?;
20244 /// println!("{}", statistic.count_done);
20245 /// # Ok(())
20246 /// # }
20247 /// ```
20248 pub fn get_statistics(&self, person_id: impl Display) -> Result<models::FollowUpStatistics> {
20249 let path = format!("/persons/{}/followups/statistics", seg(person_id));
20250 let query: Query = Query::new();
20251 self.client.request_data(Method::Get, &path, &query, None)
20252 }
20253
20254 /// Get a person's follow-ups
20255 ///
20256 /// `GET /persons/{personId}/followups`
20257 ///
20258 /// Lists tasks concerning this person, including tasks linked to group memberships. The subject person is distinct from ownerId, which identifies who handles the task. Requires permission to view the person. Results are restricted to tasks assigned to the current user and unassigned tasks in groups where that user has follow-up rights; tasks assigned to others are omitted even if individually viewable. Archived subject persons are excluded. State filters are combined with OR; omission includes all states. Results are ordered by completion date descending, effective due date ascending, then ID. Pagination returns meta.count for this page only, without a total or last-page value.
20259 ///
20260 /// Use [`Self::list_with`] to pass query parameters.
20261 ///
20262 /// # Example
20263 ///
20264 /// ```
20265 /// # use churchtools_api::*;
20266 /// # use churchtools_api::queries::*;
20267 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20268 /// # let client = churchtools_api::replay::client("get-persons-personId-followups");
20269 /// for followup in client.persons().followups().list(42)? {
20270 /// println!("{}", followup.title);
20271 /// }
20272 /// # Ok(())
20273 /// # }
20274 /// ```
20275 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::FollowUp2>> {
20276 self.list_with(person_id, &Default::default())
20277 }
20278
20279 /// Get a person's follow-ups
20280 ///
20281 /// Like [`Self::list`], with query parameters.
20282 ///
20283 /// `GET /persons/{personId}/followups`
20284 ///
20285 /// Lists tasks concerning this person, including tasks linked to group memberships. The subject person is distinct from ownerId, which identifies who handles the task. Requires permission to view the person. Results are restricted to tasks assigned to the current user and unassigned tasks in groups where that user has follow-up rights; tasks assigned to others are omitted even if individually viewable. Archived subject persons are excluded. State filters are combined with OR; omission includes all states. Results are ordered by completion date descending, effective due date ascending, then ID. Pagination returns meta.count for this page only, without a total or last-page value.
20286 pub fn list_with(&self, person_id: impl Display, query: &GetPersonsPersonIdFollowupsQuery) -> Result<Vec<models::FollowUp2>> {
20287 let path = format!("/persons/{}/followups", seg(person_id));
20288 let query: Query = query.to_query();
20289 self.client.collect_pages(&path, query)
20290 }
20291
20292 /// Get a person's follow-ups
20293 ///
20294 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
20295 /// Breaking off early saves the remaining requests.
20296 pub fn list_iter(&self, person_id: impl Display, query: &GetPersonsPersonIdFollowupsQuery) -> Items<models::FollowUp2> {
20297 let path = format!("/persons/{}/followups", seg(person_id));
20298 self.client.items(&path, query.to_query())
20299 }
20300
20301}
20302
20303/// `client.persons().merge()`
20304#[derive(Clone, Copy)]
20305pub struct PersonsMergeResource<'a> {
20306 client: &'a Client,
20307}
20308
20309impl<'a> PersonsMergeResource<'a> {
20310 /// Get information to compare two person records in order to prepare a merge
20311 ///
20312 /// `GET /persons/{personId}/merge/{duplicateId}`
20313 ///
20314 /// **Caution:** This API is published as Beta and subject to be changed. It is published such that customers can play evaluate it with production data.
20315 ///
20316 /// This retrieves the basis for a merge of two person records You will receive person data, relationships, groups etc. for both persons.
20317 ///
20318 /// # Example
20319 ///
20320 /// ```
20321 /// # use churchtools_api::*;
20322 /// # use churchtools_api::queries::*;
20323 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20324 /// # let client = churchtools_api::replay::client("get-persons-personid-merge-duplicateid");
20325 /// let merge = client.persons().merge().get("abc123", "100")?;
20326 /// println!("{:?}", merge);
20327 /// # Ok(())
20328 /// # }
20329 /// ```
20330 pub fn get(&self, person_id: impl Display, duplicate_id: impl Display) -> Result<models::PersonMergeInfo> {
20331 let path = format!("/persons/{}/merge/{}", seg(person_id), seg(duplicate_id));
20332 let query: Query = Query::new();
20333 self.client.request_data(Method::Get, &path, &query, None)
20334 }
20335
20336 /// Merge two person records
20337 ///
20338 /// `PATCH /persons/{personId}/merge/{duplicateId}`
20339 ///
20340 /// **Caution:** This API is published as Beta and subject to be changed. It is published such that customers can play evaluate it with production data.
20341 ///
20342 /// Generally, you can provide any person field to save, but be aware that write access to the provided ields is required. Beware, that not all fields which are listed in the Person schema can be updated. E.g. `imageUrl` or `familyUrl`
20343 /// (see `PATCH /api/person/{id}`)
20344 ///
20345 /// * using PATCH you can perform the eventual merge, it will
20346 /// + patch the person record
20347 /// + replace the personId of the doublette with the Original in all related records.
20348 /// * Group memberships
20349 /// * Person relation
20350 /// * Bookings
20351 /// * Wiki-Entries
20352 /// * Financial transactions
20353 /// * ...
20354 /// * delete the doublette if `deleteDuplicate` is true
20355 ///
20356 /// all to be done within one transaction.
20357 ///
20358 /// # Example
20359 ///
20360 /// ```no_run
20361 /// # use churchtools_api::*;
20362 /// # use churchtools_api::queries::*;
20363 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20364 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20365 /// let body = models::PersonUpdateable {
20366 /// title: Some("Hauskreis Nord".into()),
20367 /// ..Default::default()
20368 /// };
20369 /// let result = client.persons().merge().patch("abc123", "100", &body)?;
20370 /// println!("{}", result.body);
20371 /// # Ok(())
20372 /// # }
20373 /// ```
20374 pub fn patch(&self, person_id: impl Display, duplicate_id: impl Display, body: &models::PersonUpdateable) -> Result<models::PatchPersonsPersonidMergeDuplicateidData> {
20375 let path = format!("/persons/{}/merge/{}", seg(person_id), seg(duplicate_id));
20376 let query: Query = Query::new();
20377 let body = serde_json::to_value(body).expect("request body serializes");
20378 self.client.request_data(Method::Patch, &path, &query, Some(&body))
20379 }
20380
20381}
20382
20383/// `client.persons().relationships()`
20384#[derive(Clone, Copy)]
20385pub struct PersonsRelationshipsResource<'a> {
20386 client: &'a Client,
20387}
20388
20389impl<'a> PersonsRelationshipsResource<'a> {
20390 /// Create new relationship for person
20391 ///
20392 /// `POST /persons/{personId}/relationships`
20393 ///
20394 /// Create a new relationship between the specified person and another person.
20395 ///
20396 /// # Example
20397 ///
20398 /// ```
20399 /// # use churchtools_api::*;
20400 /// # use churchtools_api::queries::*;
20401 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20402 /// # let client = churchtools_api::replay::client("post-persons-personId-relationships");
20403 /// let body = models::PostPersonsPersonIdRelationshipsBody {
20404 /// other_person_id: 42,
20405 /// relationship_type_id: 42,
20406 /// ..Default::default()
20407 /// };
20408 /// let result = client.persons().relationships().create(42, &body)?;
20409 /// println!("{:?}", result.id);
20410 /// # Ok(())
20411 /// # }
20412 /// ```
20413 pub fn create(&self, person_id: impl Display, body: &models::PostPersonsPersonIdRelationshipsBody) -> Result<models::GetPersonsRelationshipsDataItem> {
20414 let path = format!("/persons/{}/relationships", seg(person_id));
20415 let query: Query = Query::new();
20416 let body = serde_json::to_value(body).expect("request body serializes");
20417 self.client.request_data(Method::Post, &path, &query, Some(&body))
20418 }
20419
20420 /// Delete specified relationship
20421 ///
20422 /// `DELETE /persons/{personId}/relationships/{relationshipId}`
20423 ///
20424 /// Delete the specified relationship.
20425 ///
20426 /// # Example
20427 ///
20428 /// ```no_run
20429 /// # use churchtools_api::*;
20430 /// # use churchtools_api::queries::*;
20431 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20432 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20433 /// client.persons().relationships().delete(42, 18)?;
20434 /// # Ok(())
20435 /// # }
20436 /// ```
20437 pub fn delete(&self, person_id: impl Display, relationship_id: impl Display) -> Result<()> {
20438 let path = format!("/persons/{}/relationships/{}", seg(person_id), seg(relationship_id));
20439 let query: Query = Query::new();
20440 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
20441 }
20442
20443 /// Get all relationships linked to this person
20444 ///
20445 /// `GET /persons/{personId}/relationships`
20446 ///
20447 /// Returns all relationships of the specified person. The result is sorted by 1. the `sortkey` of the relationship type, 2. last name, and 3. first name of a person.
20448 ///
20449 /// # Example
20450 ///
20451 /// ```
20452 /// # use churchtools_api::*;
20453 /// # use churchtools_api::queries::*;
20454 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20455 /// # let client = churchtools_api::replay::client("get-persons-personId-relationships");
20456 /// for relationship in client.persons().relationships().list(42)? {
20457 /// println!("{}", relationship.id);
20458 /// }
20459 /// # Ok(())
20460 /// # }
20461 /// ```
20462 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::PersonRelationship>> {
20463 let path = format!("/persons/{}/relationships", seg(person_id));
20464 let query: Query = Query::new();
20465 self.client.request_data(Method::Get, &path, &query, None)
20466 }
20467
20468}
20469
20470/// `client.persons().service_requests()`
20471#[derive(Clone, Copy)]
20472pub struct PersonsServiceRequestsResource<'a> {
20473 client: &'a Client,
20474}
20475
20476impl<'a> PersonsServiceRequestsResource<'a> {
20477 /// Decline a service request for a person
20478 ///
20479 /// `DELETE /persons/{personId}/servicerequests/{requestId}`
20480 ///
20481 /// Declines the current assignment and returns HTTP 200 with a new unassigned record: person and name are null, isValid=true and isAccepted=false. The original requestId becomes invalid. Related exchange requests are deleted and the workflow sends notifications. Requires permission to decline; assigned persons additionally need allowDecline on the service unless another permission grants access. Invalid records return 404 and unassigned slots return 422.
20482 ///
20483 /// Use [`Self::delete_with`] to pass query parameters.
20484 ///
20485 /// # Example
20486 ///
20487 /// ```no_run
20488 /// # use churchtools_api::*;
20489 /// # use churchtools_api::queries::*;
20490 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20491 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20492 /// let service_request = client.persons().service_requests().delete(42, 42)?;
20493 /// println!("{:?}", service_request.name);
20494 /// # Ok(())
20495 /// # }
20496 /// ```
20497 pub fn delete(&self, person_id: impl Display, request_id: impl Display) -> Result<models::ServiceRequest> {
20498 self.delete_with(person_id, request_id, &Default::default())
20499 }
20500
20501 /// Decline a service request for a person
20502 ///
20503 /// Like [`Self::delete`], with query parameters.
20504 ///
20505 /// `DELETE /persons/{personId}/servicerequests/{requestId}`
20506 ///
20507 /// Declines the current assignment and returns HTTP 200 with a new unassigned record: person and name are null, isValid=true and isAccepted=false. The original requestId becomes invalid. Related exchange requests are deleted and the workflow sends notifications. Requires permission to decline; assigned persons additionally need allowDecline on the service unless another permission grants access. Invalid records return 404 and unassigned slots return 422.
20508 pub fn delete_with(&self, person_id: impl Display, request_id: impl Display, query: &DeletePersonsIdServicerequestsIdQuery) -> Result<models::ServiceRequest> {
20509 let path = format!("/persons/{}/servicerequests/{}", seg(person_id), seg(request_id));
20510 let query: Query = query.to_query();
20511 self.client.request_data(Method::Delete, &path, &query, None)
20512 }
20513
20514 /// Get a specific service request for a person
20515 ///
20516 /// `GET /persons/{personId}/servicerequests/{requestId}`
20517 ///
20518 /// Returns the assignment identified by requestId and personId when the viewer has access. Unlike the list endpoint, this lookup can return invalid historical records. Comments are null if the viewer cannot see the reason.
20519 ///
20520 /// # Example
20521 ///
20522 /// ```
20523 /// # use churchtools_api::*;
20524 /// # use churchtools_api::queries::*;
20525 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20526 /// # let client = churchtools_api::replay::client("get-persons-id-servicerequests-id");
20527 /// let service_request = client.persons().service_requests().get(42, 42)?;
20528 /// println!("{:?}", service_request.name);
20529 /// # Ok(())
20530 /// # }
20531 /// ```
20532 pub fn get(&self, person_id: impl Display, request_id: impl Display) -> Result<models::ServiceRequest> {
20533 let path = format!("/persons/{}/servicerequests/{}", seg(person_id), seg(request_id));
20534 let query: Query = Query::new();
20535 self.client.request_data(Method::Get, &path, &query, None)
20536 }
20537
20538 /// Get all service requests for a person
20539 ///
20540 /// `GET /persons/{personId}/servicerequests`
20541 ///
20542 /// Returns an unpaginated list of visible, valid assignments for this person, including both outstanding and confirmed requests. Declined and superseded records are excluded. Sorted by event start ascending. only_future=true starts at midnight today, so events earlier today are included. meta.count is the number returned after permission filtering.
20543 ///
20544 /// Use [`Self::list_with`] to pass query parameters.
20545 ///
20546 /// # Example
20547 ///
20548 /// ```
20549 /// # use churchtools_api::*;
20550 /// # use churchtools_api::queries::*;
20551 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20552 /// # let client = churchtools_api::replay::client("get-persons-id-servicerequests");
20553 /// for service_request in client.persons().service_requests().list(42)? {
20554 /// println!("{:?}", service_request.name);
20555 /// }
20556 /// # Ok(())
20557 /// # }
20558 /// ```
20559 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::ServiceRequest>> {
20560 self.list_with(person_id, &Default::default())
20561 }
20562
20563 /// Get all service requests for a person
20564 ///
20565 /// Like [`Self::list`], with query parameters.
20566 ///
20567 /// `GET /persons/{personId}/servicerequests`
20568 ///
20569 /// Returns an unpaginated list of visible, valid assignments for this person, including both outstanding and confirmed requests. Declined and superseded records are excluded. Sorted by event start ascending. only_future=true starts at midnight today, so events earlier today are included. meta.count is the number returned after permission filtering.
20570 pub fn list_with(&self, person_id: impl Display, query: &GetPersonsIdServicerequestsQuery) -> Result<Vec<models::ServiceRequest>> {
20571 let path = format!("/persons/{}/servicerequests", seg(person_id));
20572 let query: Query = query.to_query();
20573 self.client.request_data(Method::Get, &path, &query, None)
20574 }
20575
20576 /// Undo last service request action
20577 ///
20578 /// `POST /persons/{personId}/servicerequests/{requestId}/undo`
20579 ///
20580 /// Reverts the last acceptance or decline to an outstanding request. Only the assigned person may do this. The legacy history must identify this as the last action and its timestamp must be within the 10-minute undo window; otherwise 400 is returned. For a decline, use the original declined request ID, not the new unassigned record returned by the decline operation. The automatically created empty record is removed when undoing a decline. Returns the legacy response shape ServiceRequestUndoResult.
20581 ///
20582 /// # Example
20583 ///
20584 /// ```no_run
20585 /// # use churchtools_api::*;
20586 /// # use churchtools_api::queries::*;
20587 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20588 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20589 /// let service_request = client.persons().service_requests().undo(42, 42)?;
20590 /// println!("{:?}", service_request.name);
20591 /// # Ok(())
20592 /// # }
20593 /// ```
20594 pub fn undo(&self, person_id: impl Display, request_id: impl Display) -> Result<models::ServiceRequestUndoResult> {
20595 let path = format!("/persons/{}/servicerequests/{}/undo", seg(person_id), seg(request_id));
20596 let query: Query = Query::new();
20597 self.client.request_data(Method::Post, &path, &query, None)
20598 }
20599
20600 /// Update a service assignment
20601 ///
20602 /// `PUT /persons/{personId}/servicerequests/{requestId}`
20603 ///
20604 /// Creates a replacement assignment and invalidates the previous active record for the same event, service and slot index. Always use the returned ID for subsequent actions. isAccepted=true confirms it; false leaves it awaiting confirmation and does not decline it. Notifications follow the assignment workflow. Updating an occupied slot requires permission to update that assignment; free slots use the self-assignment policy, and target-person restrictions apply. The legacy agreed input is accepted as an alias for isAccepted.
20605 ///
20606 /// # Example
20607 ///
20608 /// ```no_run
20609 /// # use churchtools_api::*;
20610 /// # use churchtools_api::queries::*;
20611 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20612 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20613 /// let body = models::PersonServiceRequestUpdate {
20614 /// comment: Some(Some("Hallo zusammen".into())),
20615 /// ..Default::default()
20616 /// };
20617 /// let result = client.persons().service_requests().update(42, 42, &body)?;
20618 /// println!("{:?}", result.name);
20619 /// # Ok(())
20620 /// # }
20621 /// ```
20622 pub fn update(&self, person_id: impl Display, request_id: impl Display, body: &models::PersonServiceRequestUpdate) -> Result<models::ServiceRequest> {
20623 let path = format!("/persons/{}/servicerequests/{}", seg(person_id), seg(request_id));
20624 let query: Query = Query::new();
20625 let body = serde_json::to_value(body).expect("request body serializes");
20626 self.client.request_data(Method::Put, &path, &query, Some(&body))
20627 }
20628
20629}
20630
20631/// `client.persons().settings()`
20632#[derive(Clone, Copy)]
20633pub struct PersonsSettingsResource<'a> {
20634 client: &'a Client,
20635}
20636
20637impl<'a> PersonsSettingsResource<'a> {
20638 pub fn two_factor(&self) -> PersonsSettingsTwoFactorResource<'a> {
20639 PersonsSettingsTwoFactorResource { client: self.client }
20640 }
20641
20642 /// Delete a person setting
20643 ///
20644 /// `DELETE /persons/{personId}/settings/{module}/{attribute}`
20645 ///
20646 /// Deletes the exact stored setting and returns 204, including if it did not exist. Requires the person themselves, a super administrator, or administer persons permission. The administer global views (churchgroup) exception also applies to churchdb/group-custom-views without restricting the target person. Unlike PUT, DELETE does not enforce the setting write allowlist. No setting-specific update hook is run.
20647 ///
20648 /// # Example
20649 ///
20650 /// ```no_run
20651 /// # use churchtools_api::*;
20652 /// # use churchtools_api::queries::*;
20653 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20654 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20655 /// client.persons().settings().delete(42, "beispiel", "beispiel")?;
20656 /// # Ok(())
20657 /// # }
20658 /// ```
20659 pub fn delete(&self, person_id: impl Display, module: impl Display, attribute: impl Display) -> Result<()> {
20660 let path = format!("/persons/{}/settings/{}/{}", seg(person_id), seg(module), seg(attribute));
20661 let query: Query = Query::new();
20662 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
20663 }
20664
20665 /// Get person setting
20666 ///
20667 /// `GET /persons/{personId}/settings/{module}/{attribute}`
20668 ///
20669 /// Requires access to the person’s settings: the person themselves, a super administrator, or administer persons permission. The special person ID -1 is also readable by authenticated users. Returns the exact stored module/attribute pair. A missing setting returns 404 rather than a default value. Readability does not mean the setting can be changed through the PUT endpoint.
20670 ///
20671 /// # Example
20672 ///
20673 /// ```
20674 /// # use churchtools_api::*;
20675 /// # use churchtools_api::queries::*;
20676 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20677 /// # let client = churchtools_api::replay::client("get-persons-id-settings-module-attribute");
20678 /// let setting = client.persons().settings().get(42, "beispiel", "beispiel")?;
20679 /// println!("{}", setting.attribute);
20680 /// # Ok(())
20681 /// # }
20682 /// ```
20683 pub fn get(&self, person_id: impl Display, module: impl Display, attribute: impl Display) -> Result<models::PersonSetting> {
20684 let path = format!("/persons/{}/settings/{}/{}", seg(person_id), seg(module), seg(attribute));
20685 let query: Query = Query::new();
20686 self.client.request_data(Method::Get, &path, &query, None)
20687 }
20688
20689 /// Get all person settings of a module
20690 ///
20691 /// `GET /persons/{personId}/settings/{module}`
20692 ///
20693 /// Requires access to the person’s settings: the person themselves, a super administrator, or administer persons permission. The special person ID -1 is also readable by authenticated users. Returns stored settings in the exact module namespace as a flat list. Unknown or empty namespaces return an empty list. No pagination or guaranteed order is applied; the read endpoint is not restricted to the write allowlist.
20694 ///
20695 /// # Example
20696 ///
20697 /// ```
20698 /// # use churchtools_api::*;
20699 /// # use churchtools_api::queries::*;
20700 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20701 /// # let client = churchtools_api::replay::client("get-persons-id-settings-module");
20702 /// for module in client.persons().settings().get_module(42, "beispiel")? {
20703 /// println!("{}", module.attribute);
20704 /// }
20705 /// # Ok(())
20706 /// # }
20707 /// ```
20708 pub fn get_module(&self, person_id: impl Display, module: impl Display) -> Result<Vec<models::PersonSetting>> {
20709 let path = format!("/persons/{}/settings/{}", seg(person_id), seg(module));
20710 let query: Query = Query::new();
20711 self.client.request_data(Method::Get, &path, &query, None)
20712 }
20713
20714 /// Get all person settings
20715 ///
20716 /// `GET /persons/{personId}/settings`
20717 ///
20718 /// Requires access to the person’s settings: the person themselves, a super administrator, or administer persons permission. The special person ID -1 is also readable by authenticated users. Returns all stored preferences as a flat list of module/attribute/value records. No pagination, guaranteed order, or write-allowlist filtering is applied. An empty list means no stored settings were found; person existence is not checked separately.
20719 ///
20720 /// # Example
20721 ///
20722 /// ```
20723 /// # use churchtools_api::*;
20724 /// # use churchtools_api::queries::*;
20725 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20726 /// # let client = churchtools_api::replay::client("get-persons-id-settings");
20727 /// for setting in client.persons().settings().list(42)? {
20728 /// println!("{}", setting.attribute);
20729 /// }
20730 /// # Ok(())
20731 /// # }
20732 /// ```
20733 pub fn list(&self, person_id: impl Display) -> Result<Vec<models::PersonSetting>> {
20734 let path = format!("/persons/{}/settings", seg(person_id));
20735 let query: Query = Query::new();
20736 self.client.request_data(Method::Get, &path, &query, None)
20737 }
20738
20739 /// Create/Update person setting
20740 ///
20741 /// `PUT /persons/{personId}/settings/{module}/{attribute}`
20742 ///
20743 /// Creates or replaces one allowlisted setting; arbitrary module/attribute pairs return 400. Requires the person themselves, a super administrator, or administer persons permission. Additionally, administer global views (churchgroup) permits writes to churchdb/group-custom-views; the current policy does not restrict that exception to personId=-1. The response contains the value returned by the service, which can have a different JSON numeric type from a later GET. The three churchcal calendar-filter settings require JSON-array text and normalize referenced calendar IDs. See PersonSettingUpdate for supported pairs and value types.
20744 ///
20745 /// # Example
20746 ///
20747 /// ```
20748 /// # use churchtools_api::*;
20749 /// # use churchtools_api::queries::*;
20750 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20751 /// # let client = churchtools_api::replay::client("put-persons-id-settings-module-attribute");
20752 /// let body = models::PersonSettingUpdate {
20753 /// value: serde_json::json!("beispiel"),
20754 /// ..Default::default()
20755 /// };
20756 /// let result = client.persons().settings().update(42, "push", "disableGroupSignUpNotifications", &body)?;
20757 /// println!("{}", result.attribute);
20758 /// # Ok(())
20759 /// # }
20760 /// ```
20761 pub fn update(&self, person_id: impl Display, module: impl Display, attribute: impl Display, body: &models::PersonSettingUpdate) -> Result<models::PersonSetting> {
20762 let path = format!("/persons/{}/settings/{}/{}", seg(person_id), seg(module), seg(attribute));
20763 let query: Query = Query::new();
20764 let body = serde_json::to_value(body).expect("request body serializes");
20765 self.client.request_data(Method::Put, &path, &query, Some(&body))
20766 }
20767
20768}
20769
20770/// `client.persons().settings().two_factor()`
20771#[derive(Clone, Copy)]
20772pub struct PersonsSettingsTwoFactorResource<'a> {
20773 client: &'a Client,
20774}
20775
20776impl<'a> PersonsSettingsTwoFactorResource<'a> {
20777 /// Initialize an authenticator for the current person
20778 ///
20779 /// `POST /persons/{personId}/settings/twofactor`
20780 ///
20781 /// Verifies the current person’s username/email and password, then stores a new TOTP secret and sets twoFactorEnabled to false. Only the current person can initialize their own authenticator. Repeating this call replaces the previous secret and disables an already active authenticator. Keep the returned secret or QR code for enrollment, verify a generated code through POST /twofactor/totp, then call PUT on this path to activate. This step does not complete activation.
20782 ///
20783 /// # Example
20784 ///
20785 /// ```no_run
20786 /// # use churchtools_api::*;
20787 /// # use churchtools_api::queries::*;
20788 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20789 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20790 /// let body = models::LoginCredentials {
20791 /// password: "example-password".into(),
20792 /// username: "alex@example.org".into(),
20793 /// ..Default::default()
20794 /// };
20795 /// let result = client.persons().settings().two_factor().create(42, &body)?;
20796 /// println!("{}", result.qrcode);
20797 /// # Ok(())
20798 /// # }
20799 /// ```
20800 pub fn create(&self, person_id: impl Display, body: &models::LoginCredentials) -> Result<models::TwoFactorSetupSecret> {
20801 let path = format!("/persons/{}/settings/twofactor", seg(person_id));
20802 let query: Query = Query::new();
20803 let body = serde_json::to_value(body).expect("request body serializes");
20804 self.client.request_data(Method::Post, &path, &query, Some(&body))
20805 }
20806
20807 /// Deactivate the current person’s authenticator
20808 ///
20809 /// `DELETE /persons/{personId}/settings/twofactor`
20810 ///
20811 /// Sets twoFactorEnabled to false and deletes the stored TOTP secret. Only the current person may deactivate their own authenticator. No password or authenticator code is consumed. Repeating the call is allowed. This does not clear an administrator’s twoFactorForce setting or group-role requirements, so a later login can require setup again.
20812 ///
20813 /// # Example
20814 ///
20815 /// ```no_run
20816 /// # use churchtools_api::*;
20817 /// # use churchtools_api::queries::*;
20818 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20819 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20820 /// client.persons().settings().two_factor().delete(42)?;
20821 /// # Ok(())
20822 /// # }
20823 /// ```
20824 pub fn delete(&self, person_id: impl Display) -> Result<()> {
20825 let path = format!("/persons/{}/settings/twofactor", seg(person_id));
20826 let query: Query = Query::new();
20827 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
20828 }
20829
20830 /// Get the person’s two-factor activation setting
20831 ///
20832 /// `GET /persons/{personId}/settings/twofactor`
20833 ///
20834 /// Returns the stored twoFactorEnabled setting, defaulting to false without storing it when absent. Requires access to the person’s settings (self, super administrator or administer persons; the global defaults person -1 is also allowed). This reports activation only, not whether two-factor authentication is required by an administrator or group role.
20835 ///
20836 /// # Example
20837 ///
20838 /// ```
20839 /// # use churchtools_api::*;
20840 /// # use churchtools_api::queries::*;
20841 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20842 /// # let client = churchtools_api::replay::client("get-persons-id-settings-twofactor");
20843 /// let two_factor = client.persons().settings().two_factor().get(42)?;
20844 /// println!("{}", two_factor.attribute);
20845 /// # Ok(())
20846 /// # }
20847 /// ```
20848 pub fn get(&self, person_id: impl Display) -> Result<models::PersonTwoFactorEnabled> {
20849 let path = format!("/persons/{}/settings/twofactor", seg(person_id));
20850 let query: Query = Query::new();
20851 self.client.request_data(Method::Get, &path, &query, None)
20852 }
20853
20854 /// Get the person’s explicit two-factor requirement
20855 ///
20856 /// `GET /persons/{personId}/settings/twofactor/force`
20857 ///
20858 /// Returns the stored twoFactorForce setting, defaulting to false when absent. Requires churchcore administer persons or simulate persons. This is only the explicit person-level flag; an applicable group role may still require two-factor authentication when this value is false.
20859 ///
20860 /// # Example
20861 ///
20862 /// ```
20863 /// # use churchtools_api::*;
20864 /// # use churchtools_api::queries::*;
20865 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20866 /// # let client = churchtools_api::replay::client("get-persons-id-settings-twofactor-force");
20867 /// let force = client.persons().settings().two_factor().get_force(42)?;
20868 /// println!("{}", force.attribute);
20869 /// # Ok(())
20870 /// # }
20871 /// ```
20872 pub fn get_force(&self, person_id: impl Display) -> Result<models::PersonTwoFactorForce> {
20873 let path = format!("/persons/{}/settings/twofactor/force", seg(person_id));
20874 let query: Query = Query::new();
20875 self.client.request_data(Method::Get, &path, &query, None)
20876 }
20877
20878 /// Activate the current person’s initialized authenticator
20879 ///
20880 /// `PUT /persons/{personId}/settings/twofactor`
20881 ///
20882 /// Sets twoFactorEnabled to true and refreshes person session data. Only the current person may activate their own authenticator. A stored secret from initialization is required; otherwise 400 is returned. No request body is consumed. Clients should first verify an authenticator code with POST /twofactor/totp; this activation handler itself checks only that a secret exists, not that a code was previously verified. Existing login tokens and other sessions are not revoked.
20883 ///
20884 /// # Example
20885 ///
20886 /// ```no_run
20887 /// # use churchtools_api::*;
20888 /// # use churchtools_api::queries::*;
20889 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20890 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20891 /// let result = client.persons().settings().two_factor().update(42)?;
20892 /// println!("{}", result.attribute);
20893 /// # Ok(())
20894 /// # }
20895 /// ```
20896 pub fn update(&self, person_id: impl Display) -> Result<models::PersonTwoFactorEnabled> {
20897 let path = format!("/persons/{}/settings/twofactor", seg(person_id));
20898 let query: Query = Query::new();
20899 self.client.request_data(Method::Put, &path, &query, None)
20900 }
20901
20902 /// Set the person’s explicit two-factor requirement
20903 ///
20904 /// `PUT /persons/{personId}/settings/twofactor/force`
20905 ///
20906 /// Stores the explicit person-level two-factor requirement. Requires churchcore administer persons or simulate persons; only a super administrator may change this flag for another super administrator. Setting false does not remove a requirement inherited from a group role. This neither enrolls an authenticator nor changes twoFactorEnabled.
20907 ///
20908 /// # Example
20909 ///
20910 /// ```no_run
20911 /// # use churchtools_api::*;
20912 /// # use churchtools_api::queries::*;
20913 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20914 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
20915 /// let body = models::PersonTwoFactorForceUpdate {
20916 /// value: true,
20917 /// ..Default::default()
20918 /// };
20919 /// let result = client.persons().settings().two_factor().update_force(42, &body)?;
20920 /// println!("{}", result.attribute);
20921 /// # Ok(())
20922 /// # }
20923 /// ```
20924 pub fn update_force(&self, person_id: impl Display, body: &models::PersonTwoFactorForceUpdate) -> Result<models::PersonTwoFactorForce> {
20925 let path = format!("/persons/{}/settings/twofactor/force", seg(person_id));
20926 let query: Query = Query::new();
20927 let body = serde_json::to_value(body).expect("request body serializes");
20928 self.client.request_data(Method::Put, &path, &query, Some(&body))
20929 }
20930
20931}
20932
20933/// `client.placeholders()`
20934#[derive(Clone, Copy)]
20935pub struct PlaceholdersResource<'a> {
20936 client: &'a Client,
20937}
20938
20939impl<'a> PlaceholdersResource<'a> {
20940 pub fn group(&self) -> PlaceholdersGroupResource<'a> {
20941 PlaceholdersGroupResource { client: self.client }
20942 }
20943
20944 /// Get email placeholders
20945 ///
20946 /// `GET /placeholders/email`
20947 ///
20948 /// Returns the editor’s available email-template placeholders using an empty person context. No recipient values are rendered. The response data is a recursive menu: groups have name and items, selectable leaves have placeholder and label, optionally menuLabel. Labels are translated. Insert the supplied expression verbatim; ordinary values use triple braces, while block helpers use double braces. The set of fields depends on configuration, so names are not a fixed enum. This object-backed tree has no meta.count envelope.
20949 ///
20950 /// # Example
20951 ///
20952 /// ```
20953 /// # use churchtools_api::*;
20954 /// # use churchtools_api::queries::*;
20955 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20956 /// # let client = churchtools_api::replay::client("get-placeholders-email");
20957 /// for email in client.placeholders().list_email()? {
20958 /// println!("{}", email.name);
20959 /// }
20960 /// # Ok(())
20961 /// # }
20962 /// ```
20963 pub fn list_email(&self) -> Result<Vec<models::PlaceholderMenuGroup>> {
20964 let path = "/placeholders/email".to_owned();
20965 let query: Query = Query::new();
20966 self.client.request_data(Method::Get, &path, &query, None)
20967 }
20968
20969}
20970
20971/// `client.placeholders().group()`
20972#[derive(Clone, Copy)]
20973pub struct PlaceholdersGroupResource<'a> {
20974 client: &'a Client,
20975}
20976
20977impl<'a> PlaceholdersGroupResource<'a> {
20978 /// Get group placeholders
20979 ///
20980 /// `GET /placeholders/group/{id}`
20981 ///
20982 /// Returns the editor’s available group and group-membership placeholders, including this group’s custom membership fields. id must be numeric; GUIDs are not accepted by this controller. No group/member values are rendered. The handler loads the group without a separate group-visibility check. The response data is a recursive menu: groups have name and items, selectable leaves have placeholder and label, optionally menuLabel. Labels are translated. Insert the supplied expression verbatim; ordinary values use triple braces, while block helpers use double braces. The set of fields depends on configuration, so names are not a fixed enum. This object-backed tree has no meta.count envelope.
20983 ///
20984 /// # Example
20985 ///
20986 /// ```
20987 /// # use churchtools_api::*;
20988 /// # use churchtools_api::queries::*;
20989 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
20990 /// # let client = churchtools_api::replay::client("get-placeholders-group-id");
20991 /// for group in client.placeholders().group().get(11)? {
20992 /// println!("{}", group.name);
20993 /// }
20994 /// # Ok(())
20995 /// # }
20996 /// ```
20997 pub fn get(&self, id: impl Display) -> Result<Vec<models::PlaceholderMenuGroup>> {
20998 let path = format!("/placeholders/group/{}", seg(id));
20999 let query: Query = Query::new();
21000 self.client.request_data(Method::Get, &path, &query, None)
21001 }
21002
21003}
21004
21005/// `client.poll_for_news()`
21006#[derive(Clone, Copy)]
21007pub struct PollForNewsResource<'a> {
21008 client: &'a Client,
21009}
21010
21011impl<'a> PollForNewsResource<'a> {
21012 /// `GET /pollfornews`
21013 ///
21014 /// This endpoint returns the identifiers of changed entities since the last call.
21015 ///
21016 /// # Example
21017 ///
21018 /// ```
21019 /// # use churchtools_api::*;
21020 /// # use churchtools_api::queries::*;
21021 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21022 /// # let client = churchtools_api::replay::client("get-pollfornews");
21023 /// let query = GetPollfornewsQuery {
21024 /// domain_types: Some(vec!["beispiel".into()]),
21025 /// since: Some("2022-10-19T12:00:00Z".parse()?),
21026 /// ..Default::default()
21027 /// };
21028 /// for poll_for_new in client.poll_for_news().list(&query)? {
21029 /// println!("{}", poll_for_new.domain_id);
21030 /// }
21031 /// # Ok(())
21032 /// # }
21033 /// ```
21034 pub fn list(&self, query: &GetPollfornewsQuery) -> Result<Vec<models::PollForNewsResult>> {
21035 let path = "/pollfornews".to_owned();
21036 let query: Query = query.to_query();
21037 self.client.request_data(Method::Get, &path, &query, None)
21038 }
21039
21040}
21041
21042/// `client.post()`
21043#[derive(Clone, Copy)]
21044pub struct PostResource<'a> {
21045 client: &'a Client,
21046}
21047
21048impl<'a> PostResource<'a> {
21049 pub fn hidden(&self) -> PostHiddenResource<'a> {
21050 PostHiddenResource { client: self.client }
21051 }
21052
21053 pub fn reports(&self) -> PostReportsResource<'a> {
21054 PostReportsResource { client: self.client }
21055 }
21056
21057 /// `GET /post/linkings`
21058 ///
21059 /// Use [`Self::get_linkings_with`] to pass query parameters.
21060 ///
21061 /// # Example
21062 ///
21063 /// ```
21064 /// # use churchtools_api::*;
21065 /// # use churchtools_api::queries::*;
21066 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21067 /// # let client = churchtools_api::replay::client("get-post-linkings");
21068 /// let result = client.post().get_linkings()?;
21069 /// println!("{:?}", result);
21070 /// # Ok(())
21071 /// # }
21072 /// ```
21073 pub fn get_linkings(&self) -> Result<serde_json::Value> {
21074 self.get_linkings_with(&Default::default())
21075 }
21076
21077 /// `GET /post/linkings`
21078 ///
21079 /// Like [`Self::get_linkings`], with query parameters.
21080 pub fn get_linkings_with(&self, query: &GetPostLinkingsQuery) -> Result<serde_json::Value> {
21081 let path = "/post/linkings".to_owned();
21082 let query: Query = query.to_query();
21083 self.client.request_data(Method::Get, &path, &query, None)
21084 }
21085
21086 /// `GET /post/groups`
21087 ///
21088 /// # Example
21089 ///
21090 /// ```
21091 /// # use churchtools_api::*;
21092 /// # use churchtools_api::queries::*;
21093 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21094 /// # let client = churchtools_api::replay::client("get-post-groups");
21095 /// for group in client.post().list_groups()? {
21096 /// println!("{}", group.favorite_group);
21097 /// }
21098 /// # Ok(())
21099 /// # }
21100 /// ```
21101 pub fn list_groups(&self) -> Result<Vec<models::PossiblePostGroup>> {
21102 let path = "/post/groups".to_owned();
21103 let query: Query = Query::new();
21104 self.client.request_data(Method::Get, &path, &query, None)
21105 }
21106
21107 /// `GET /post/search`
21108 ///
21109 /// Search posts
21110 ///
21111 /// Use [`Self::list_search_with`] to pass query parameters.
21112 ///
21113 /// # Example
21114 ///
21115 /// ```
21116 /// # use churchtools_api::*;
21117 /// # use churchtools_api::queries::*;
21118 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21119 /// # let client = churchtools_api::replay::client("get-post-search");
21120 /// for search in client.post().list_search()? {
21121 /// println!("{}", search.title);
21122 /// }
21123 /// # Ok(())
21124 /// # }
21125 /// ```
21126 pub fn list_search(&self) -> Result<Vec<models::Post>> {
21127 self.list_search_with(&Default::default())
21128 }
21129
21130 /// `GET /post/search`
21131 ///
21132 /// Like [`Self::list_search`], with query parameters.
21133 ///
21134 /// Search posts
21135 pub fn list_search_with(&self, query: &GetPostSearchQuery) -> Result<Vec<models::Post>> {
21136 let path = "/post/search".to_owned();
21137 let query: Query = query.to_query();
21138 self.client.request_data(Method::Get, &path, &query, None)
21139 }
21140
21141}
21142
21143/// `client.post().hidden()`
21144#[derive(Clone, Copy)]
21145pub struct PostHiddenResource<'a> {
21146 client: &'a Client,
21147}
21148
21149impl<'a> PostHiddenResource<'a> {
21150 /// `DELETE /post/hidden/{domainType}/{domainId}`
21151 ///
21152 /// # Example
21153 ///
21154 /// ```no_run
21155 /// # use churchtools_api::*;
21156 /// # use churchtools_api::queries::*;
21157 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21158 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21159 /// client.post().hidden().delete("actor", 42)?;
21160 /// # Ok(())
21161 /// # }
21162 /// ```
21163 pub fn delete(&self, domain_type: impl Display, domain_id: impl Display) -> Result<()> {
21164 let path = format!("/post/hidden/{}/{}", seg(domain_type), seg(domain_id));
21165 let query: Query = Query::new();
21166 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
21167 }
21168
21169 /// `GET /post/hidden`
21170 ///
21171 /// # Example
21172 ///
21173 /// ```
21174 /// # use churchtools_api::*;
21175 /// # use churchtools_api::queries::*;
21176 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21177 /// # let client = churchtools_api::replay::client("get-post-hidden");
21178 /// for hidden in client.post().hidden().list()? {
21179 /// println!("{:?}", hidden);
21180 /// }
21181 /// # Ok(())
21182 /// # }
21183 /// ```
21184 pub fn list(&self) -> Result<Vec<serde_json::Value>> {
21185 let path = "/post/hidden".to_owned();
21186 let query: Query = Query::new();
21187 self.client.request_data(Method::Get, &path, &query, None)
21188 }
21189
21190}
21191
21192/// `client.post().reports()`
21193#[derive(Clone, Copy)]
21194pub struct PostReportsResource<'a> {
21195 client: &'a Client,
21196}
21197
21198impl<'a> PostReportsResource<'a> {
21199 /// `POST /post/reports`
21200 ///
21201 /// # Example
21202 ///
21203 /// ```no_run
21204 /// # use churchtools_api::*;
21205 /// # use churchtools_api::queries::*;
21206 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21207 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21208 /// let body = models::ReportCreate {
21209 /// domain_id: 42,
21210 /// domain_type: "post".into(),
21211 /// ..Default::default()
21212 /// };
21213 /// let result = client.post().reports().create(&body)?;
21214 /// println!("{:?}", result.comment);
21215 /// # Ok(())
21216 /// # }
21217 /// ```
21218 pub fn create(&self, body: &models::ReportCreate) -> Result<models::Report> {
21219 let path = "/post/reports".to_owned();
21220 let query: Query = Query::new();
21221 let body = serde_json::to_value(body).expect("request body serializes");
21222 self.client.request_data(Method::Post, &path, &query, Some(&body))
21223 }
21224
21225 /// `GET /post/reports`
21226 ///
21227 /// Use [`Self::list_with`] to pass query parameters.
21228 ///
21229 /// # Example
21230 ///
21231 /// ```
21232 /// # use churchtools_api::*;
21233 /// # use churchtools_api::queries::*;
21234 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21235 /// # let client = churchtools_api::replay::client("get-post-reports");
21236 /// for report in client.post().reports().list()? {
21237 /// println!("{:?}", report);
21238 /// }
21239 /// # Ok(())
21240 /// # }
21241 /// ```
21242 pub fn list(&self) -> Result<Vec<serde_json::Value>> {
21243 self.list_with(&Default::default())
21244 }
21245
21246 /// `GET /post/reports`
21247 ///
21248 /// Like [`Self::list`], with query parameters.
21249 pub fn list_with(&self, query: &GetPostReportsQuery) -> Result<Vec<serde_json::Value>> {
21250 let path = "/post/reports".to_owned();
21251 let query: Query = query.to_query();
21252 self.client.request_data(Method::Get, &path, &query, None)
21253 }
21254
21255 /// `PUT /post/reports/answer`
21256 ///
21257 /// # Example
21258 ///
21259 /// ```no_run
21260 /// # use churchtools_api::*;
21261 /// # use churchtools_api::queries::*;
21262 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21263 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21264 /// let body = models::ReportAnswer {
21265 /// domain_id: 42,
21266 /// domain_type: "post".into(),
21267 /// response: "accept".into(),
21268 /// ..Default::default()
21269 /// };
21270 /// client.post().reports().update_answer(&body)?;
21271 /// # Ok(())
21272 /// # }
21273 /// ```
21274 pub fn update_answer(&self, body: &models::ReportAnswer) -> Result<()> {
21275 let path = "/post/reports/answer".to_owned();
21276 let query: Query = Query::new();
21277 let body = serde_json::to_value(body).expect("request body serializes");
21278 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
21279 }
21280
21281}
21282
21283/// `client.posts()`
21284#[derive(Clone, Copy)]
21285pub struct PostsResource<'a> {
21286 client: &'a Client,
21287}
21288
21289impl<'a> PostsResource<'a> {
21290 pub fn comments(&self) -> PostsCommentsResource<'a> {
21291 PostsCommentsResource { client: self.client }
21292 }
21293
21294 pub fn hidden(&self) -> PostsHiddenResource<'a> {
21295 PostsHiddenResource { client: self.client }
21296 }
21297
21298 pub fn reactions(&self) -> PostsReactionsResource<'a> {
21299 PostsReactionsResource { client: self.client }
21300 }
21301
21302 /// `POST /posts`
21303 ///
21304 /// Create a new post. Images must be uploaded previously in a separate request.
21305 ///
21306 /// # Example
21307 ///
21308 /// ```
21309 /// # use churchtools_api::*;
21310 /// # use churchtools_api::queries::*;
21311 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21312 /// # let client = churchtools_api::replay::client("post-posts");
21313 /// let body = models::PostCreate {
21314 /// content: Some("Hallo zusammen".into()),
21315 /// title: "Hauskreis Nord".into(),
21316 /// visibility: "group_intern".into(),
21317 /// group_id: 42,
21318 /// ..Default::default()
21319 /// };
21320 /// let result = client.posts().create(&body)?;
21321 /// println!("{}", result.title);
21322 /// # Ok(())
21323 /// # }
21324 /// ```
21325 pub fn create(&self, body: &models::PostCreate) -> Result<models::Post> {
21326 let path = "/posts".to_owned();
21327 let query: Query = Query::new();
21328 let body = serde_json::to_value(body).expect("request body serializes");
21329 self.client.request_data(Method::Post, &path, &query, Some(&body))
21330 }
21331
21332 /// `DELETE /posts/{postId}`
21333 ///
21334 /// Delete a post.
21335 ///
21336 /// # Example
21337 ///
21338 /// ```no_run
21339 /// # use churchtools_api::*;
21340 /// # use churchtools_api::queries::*;
21341 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21342 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21343 /// let query = DeletePostsPostIdQuery {
21344 /// dry_run: Some(true),
21345 /// ..Default::default()
21346 /// };
21347 /// client.posts().delete(42, &query)?;
21348 /// # Ok(())
21349 /// # }
21350 /// ```
21351 pub fn delete(&self, post_id: impl Display, query: &DeletePostsPostIdQuery) -> Result<()> {
21352 let path = format!("/posts/{}", seg(post_id));
21353 let query: Query = query.to_query();
21354 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
21355 }
21356
21357 /// `GET /posts/{postId}`
21358 ///
21359 /// Get a post.
21360 ///
21361 /// Use [`Self::get_with`] to pass query parameters.
21362 ///
21363 /// # Example
21364 ///
21365 /// ```
21366 /// # use churchtools_api::*;
21367 /// # use churchtools_api::queries::*;
21368 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21369 /// # let client = churchtools_api::replay::client("get-posts-postId");
21370 /// let post = client.posts().get(42)?;
21371 /// println!("{}", post.title);
21372 /// # Ok(())
21373 /// # }
21374 /// ```
21375 pub fn get(&self, post_id: impl Display) -> Result<models::Post> {
21376 self.get_with(post_id, &Default::default())
21377 }
21378
21379 /// `GET /posts/{postId}`
21380 ///
21381 /// Like [`Self::get`], with query parameters.
21382 ///
21383 /// Get a post.
21384 pub fn get_with(&self, post_id: impl Display, query: &GetPostsPostIdQuery) -> Result<models::Post> {
21385 let path = format!("/posts/{}", seg(post_id));
21386 let query: Query = query.to_query();
21387 self.client.request_data(Method::Get, &path, &query, None)
21388 }
21389
21390 /// `GET /posts`
21391 ///
21392 /// Get a list of posts sorted by `publishedDate` descending. This endpoint uses cursor-based pagination because the result can contain posts from external ChurchTools instances. To load another batch, use `before` together with `last_post_identifier`; page-based pagination is not supported.
21393 ///
21394 /// Use [`Self::list_with`] to pass query parameters.
21395 ///
21396 /// # Example
21397 ///
21398 /// ```
21399 /// # use churchtools_api::*;
21400 /// # use churchtools_api::queries::*;
21401 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21402 /// # let client = churchtools_api::replay::client("get-posts");
21403 /// for post in client.posts().list()? {
21404 /// println!("{}", post.title);
21405 /// }
21406 /// # Ok(())
21407 /// # }
21408 /// ```
21409 pub fn list(&self) -> Result<Vec<models::Post>> {
21410 self.list_with(&Default::default())
21411 }
21412
21413 /// `GET /posts`
21414 ///
21415 /// Like [`Self::list`], with query parameters.
21416 ///
21417 /// Get a list of posts sorted by `publishedDate` descending. This endpoint uses cursor-based pagination because the result can contain posts from external ChurchTools instances. To load another batch, use `before` together with `last_post_identifier`; page-based pagination is not supported.
21418 pub fn list_with(&self, query: &GetPostsQuery) -> Result<Vec<models::Post>> {
21419 let path = "/posts".to_owned();
21420 let query: Query = query.to_query();
21421 self.client.request_data(Method::Get, &path, &query, None)
21422 }
21423
21424 /// `PATCH /posts/{postId}`
21425 ///
21426 /// Update a post.
21427 ///
21428 /// # Example
21429 ///
21430 /// ```
21431 /// # use churchtools_api::*;
21432 /// # use churchtools_api::queries::*;
21433 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21434 /// # let client = churchtools_api::replay::client("patch-posts-postId");
21435 /// let body = models::PostUpdate {
21436 /// title: Some("Hauskreis Nord".into()),
21437 /// ..Default::default()
21438 /// };
21439 /// let result = client.posts().patch(42, &body)?;
21440 /// println!("{}", result.title);
21441 /// # Ok(())
21442 /// # }
21443 /// ```
21444 pub fn patch(&self, post_id: impl Display, body: &models::PostUpdate) -> Result<models::Post> {
21445 let path = format!("/posts/{}", seg(post_id));
21446 let query: Query = Query::new();
21447 let body = serde_json::to_value(body).expect("request body serializes");
21448 self.client.request_data(Method::Patch, &path, &query, Some(&body))
21449 }
21450
21451 /// `PUT /posts/{postId}/expire`
21452 ///
21453 /// Expire the referenced post immediately.
21454 ///
21455 /// # Example
21456 ///
21457 /// ```no_run
21458 /// # use churchtools_api::*;
21459 /// # use churchtools_api::queries::*;
21460 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21461 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21462 /// client.posts().update_expire(42)?;
21463 /// # Ok(())
21464 /// # }
21465 /// ```
21466 pub fn update_expire(&self, post_id: impl Display) -> Result<()> {
21467 let path = format!("/posts/{}/expire", seg(post_id));
21468 let query: Query = Query::new();
21469 self.client.request(Method::Put, &path, &query, None).map(|_| ())
21470 }
21471
21472}
21473
21474/// `client.posts().comments()`
21475#[derive(Clone, Copy)]
21476pub struct PostsCommentsResource<'a> {
21477 client: &'a Client,
21478}
21479
21480impl<'a> PostsCommentsResource<'a> {
21481 pub fn reactions(&self) -> PostsCommentsReactionsResource<'a> {
21482 PostsCommentsReactionsResource { client: self.client }
21483 }
21484
21485 /// `POST /posts/{postId}/comments`
21486 ///
21487 /// Create a new comment for a post.
21488 ///
21489 /// # Example
21490 ///
21491 /// ```
21492 /// # use churchtools_api::*;
21493 /// # use churchtools_api::queries::*;
21494 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21495 /// # let client = churchtools_api::replay::client("post-posts-postId-comments");
21496 /// let body = models::PostCommentCreate {
21497 /// content: "Hallo zusammen".into(),
21498 /// post_id: 42,
21499 /// ..Default::default()
21500 /// };
21501 /// let result = client.posts().comments().create(42, &body)?;
21502 /// println!("{}", result.id);
21503 /// # Ok(())
21504 /// # }
21505 /// ```
21506 pub fn create(&self, post_id: impl Display, body: &models::PostCommentCreate) -> Result<models::PostComment> {
21507 let path = format!("/posts/{}/comments", seg(post_id));
21508 let query: Query = Query::new();
21509 let body = serde_json::to_value(body).expect("request body serializes");
21510 self.client.request_data(Method::Post, &path, &query, Some(&body))
21511 }
21512
21513 /// `DELETE /posts/{postId}/comments/{commentId}`
21514 ///
21515 /// Delete a comment of a post.
21516 ///
21517 /// # Example
21518 ///
21519 /// ```no_run
21520 /// # use churchtools_api::*;
21521 /// # use churchtools_api::queries::*;
21522 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21523 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21524 /// client.posts().comments().delete(42, 42)?;
21525 /// # Ok(())
21526 /// # }
21527 /// ```
21528 pub fn delete(&self, post_id: impl Display, comment_id: impl Display) -> Result<()> {
21529 let path = format!("/posts/{}/comments/{}", seg(post_id), seg(comment_id));
21530 let query: Query = Query::new();
21531 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
21532 }
21533
21534 /// `GET /posts/{postId}/comments`
21535 ///
21536 /// Get a list of comments for a post.
21537 ///
21538 /// # Example
21539 ///
21540 /// ```
21541 /// # use churchtools_api::*;
21542 /// # use churchtools_api::queries::*;
21543 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21544 /// # let client = churchtools_api::replay::client("get-posts-postId-comments");
21545 /// for comment in client.posts().comments().list(42)? {
21546 /// println!("{}", comment.id);
21547 /// }
21548 /// # Ok(())
21549 /// # }
21550 /// ```
21551 pub fn list(&self, post_id: impl Display) -> Result<Vec<models::PostComment>> {
21552 let path = format!("/posts/{}/comments", seg(post_id));
21553 let query: Query = Query::new();
21554 self.client.request_data(Method::Get, &path, &query, None)
21555 }
21556
21557}
21558
21559/// `client.posts().comments().reactions()`
21560#[derive(Clone, Copy)]
21561pub struct PostsCommentsReactionsResource<'a> {
21562 client: &'a Client,
21563}
21564
21565impl<'a> PostsCommentsReactionsResource<'a> {
21566 /// `DELETE /posts/{postId}/comments/{commentId}/reactions/{emoji}`
21567 ///
21568 /// Delete a reaction of the current person for a post comment.
21569 ///
21570 /// # Example
21571 ///
21572 /// ```no_run
21573 /// # use churchtools_api::*;
21574 /// # use churchtools_api::queries::*;
21575 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21576 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21577 /// client.posts().comments().reactions().delete(42, 42, "👍")?;
21578 /// # Ok(())
21579 /// # }
21580 /// ```
21581 pub fn delete(&self, post_id: impl Display, comment_id: impl Display, emoji: impl Display) -> Result<()> {
21582 let path = format!("/posts/{}/comments/{}/reactions/{}", seg(post_id), seg(comment_id), seg(emoji));
21583 let query: Query = Query::new();
21584 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
21585 }
21586
21587 /// `GET /posts/{postId}/comments/{commentId}/reactions`
21588 ///
21589 /// Get a list of reactions for a post comment.
21590 ///
21591 /// # Example
21592 ///
21593 /// ```
21594 /// # use churchtools_api::*;
21595 /// # use churchtools_api::queries::*;
21596 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21597 /// # let client = churchtools_api::replay::client("get-posts-postId-comments-commentId-reactions");
21598 /// for reaction in client.posts().comments().reactions().list(42, 42)? {
21599 /// println!("{}", reaction.comment_id);
21600 /// }
21601 /// # Ok(())
21602 /// # }
21603 /// ```
21604 pub fn list(&self, post_id: impl Display, comment_id: impl Display) -> Result<Vec<models::PostCommentReaction>> {
21605 let path = format!("/posts/{}/comments/{}/reactions", seg(post_id), seg(comment_id));
21606 let query: Query = Query::new();
21607 self.client.request_data(Method::Get, &path, &query, None)
21608 }
21609
21610 /// `PUT /posts/{postId}/comments/{commentId}/reactions`
21611 ///
21612 /// Create a new reaction of the current person for a post comment.
21613 ///
21614 /// # Example
21615 ///
21616 /// ```
21617 /// # use churchtools_api::*;
21618 /// # use churchtools_api::queries::*;
21619 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21620 /// # let client = churchtools_api::replay::client("put-posts-postId-comments-commentId-reactions");
21621 /// let body = models::PostCommentReactionCreate {
21622 /// emoji: "👍".into(),
21623 /// ..Default::default()
21624 /// };
21625 /// let result = client.posts().comments().reactions().update(42, 42, &body)?;
21626 /// println!("{}", result.comment_id);
21627 /// # Ok(())
21628 /// # }
21629 /// ```
21630 pub fn update(&self, post_id: impl Display, comment_id: impl Display, body: &models::PostCommentReactionCreate) -> Result<models::PostCommentReaction> {
21631 let path = format!("/posts/{}/comments/{}/reactions", seg(post_id), seg(comment_id));
21632 let query: Query = Query::new();
21633 let body = serde_json::to_value(body).expect("request body serializes");
21634 self.client.request_data(Method::Put, &path, &query, Some(&body))
21635 }
21636
21637}
21638
21639/// `client.posts().hidden()`
21640#[derive(Clone, Copy)]
21641pub struct PostsHiddenResource<'a> {
21642 client: &'a Client,
21643}
21644
21645impl<'a> PostsHiddenResource<'a> {
21646 /// `PUT /posts/{postId}/hidden/{domainType}`
21647 ///
21648 /// Hide a post. This endpoint is used to hide a post from the timeline of the user. The post is not deleted, but the user will not see it anymore. NB: If the supplied domain type is `group`, this will also deactivate post-related subscriptions for that group.
21649 ///
21650 /// # Example
21651 ///
21652 /// ```no_run
21653 /// # use churchtools_api::*;
21654 /// # use churchtools_api::queries::*;
21655 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21656 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21657 /// client.posts().hidden().update(42, "actor")?;
21658 /// # Ok(())
21659 /// # }
21660 /// ```
21661 pub fn update(&self, post_id: impl Display, domain_type: impl Display) -> Result<()> {
21662 let path = format!("/posts/{}/hidden/{}", seg(post_id), seg(domain_type));
21663 let query: Query = Query::new();
21664 self.client.request(Method::Put, &path, &query, None).map(|_| ())
21665 }
21666
21667}
21668
21669/// `client.posts().reactions()`
21670#[derive(Clone, Copy)]
21671pub struct PostsReactionsResource<'a> {
21672 client: &'a Client,
21673}
21674
21675impl<'a> PostsReactionsResource<'a> {
21676 pub fn persons(&self) -> PostsReactionsPersonsResource<'a> {
21677 PostsReactionsPersonsResource { client: self.client }
21678 }
21679
21680 /// `GET /posts/{postId}/reactions`
21681 ///
21682 /// Get a list of reactions for a post.
21683 ///
21684 /// # Example
21685 ///
21686 /// ```
21687 /// # use churchtools_api::*;
21688 /// # use churchtools_api::queries::*;
21689 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21690 /// # let client = churchtools_api::replay::client("get-posts-postId-reactions");
21691 /// for reaction in client.posts().reactions().list(42)? {
21692 /// println!("{}", reaction.emoji);
21693 /// }
21694 /// # Ok(())
21695 /// # }
21696 /// ```
21697 pub fn list(&self, post_id: impl Display) -> Result<Vec<models::PostReaction>> {
21698 let path = format!("/posts/{}/reactions", seg(post_id));
21699 let query: Query = Query::new();
21700 self.client.request_data(Method::Get, &path, &query, None)
21701 }
21702
21703}
21704
21705/// `client.posts().reactions().persons()`
21706#[derive(Clone, Copy)]
21707pub struct PostsReactionsPersonsResource<'a> {
21708 client: &'a Client,
21709}
21710
21711impl<'a> PostsReactionsPersonsResource<'a> {
21712 /// `DELETE /posts/{postId}/reactions/{emoji}/persons/{personId}`
21713 ///
21714 /// Delete a reaction of a person for a post.
21715 ///
21716 /// # Example
21717 ///
21718 /// ```no_run
21719 /// # use churchtools_api::*;
21720 /// # use churchtools_api::queries::*;
21721 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21722 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21723 /// client.posts().reactions().persons().delete(42, "👍", "abc123")?;
21724 /// # Ok(())
21725 /// # }
21726 /// ```
21727 pub fn delete(&self, post_id: impl Display, emoji: impl Display, person_id: impl Display) -> Result<()> {
21728 let path = format!("/posts/{}/reactions/{}/persons/{}", seg(post_id), seg(emoji), seg(person_id));
21729 let query: Query = Query::new();
21730 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
21731 }
21732
21733 /// `PUT /posts/{postId}/reactions/{emoji}/persons/{personId}`
21734 ///
21735 /// Create a new reaction of a person for a post.
21736 ///
21737 /// # Example
21738 ///
21739 /// ```
21740 /// # use churchtools_api::*;
21741 /// # use churchtools_api::queries::*;
21742 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21743 /// # let client = churchtools_api::replay::client("put-posts-postId-reactions-emoji-persons-personId");
21744 /// let result = client.posts().reactions().persons().update(42, "👍", "abc123")?;
21745 /// println!("{}", result.emoji);
21746 /// # Ok(())
21747 /// # }
21748 /// ```
21749 pub fn update(&self, post_id: impl Display, emoji: impl Display, person_id: impl Display) -> Result<models::PostReaction> {
21750 let path = format!("/posts/{}/reactions/{}/persons/{}", seg(post_id), seg(emoji), seg(person_id));
21751 let query: Query = Query::new();
21752 self.client.request_data(Method::Put, &path, &query, None)
21753 }
21754
21755}
21756
21757/// `client.pr()`
21758#[derive(Clone, Copy)]
21759pub struct PrResource<'a> {
21760 client: &'a Client,
21761}
21762
21763impl<'a> PrResource<'a> {
21764 /// Get public relations master data
21765 ///
21766 /// `GET /pr/masterdata`
21767 ///
21768 /// Returns the master data used by the public relations module and public profiles. The response groups each master data collection under `data` and returns the item count for each collection under `meta`.
21769 ///
21770 /// # Example
21771 ///
21772 /// ```
21773 /// # use churchtools_api::*;
21774 /// # use churchtools_api::queries::*;
21775 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21776 /// # let client = churchtools_api::replay::client("get-pr-masterdata");
21777 /// let master_data = client.pr().get_master_data()?;
21778 /// println!("{:?}", master_data);
21779 /// # Ok(())
21780 /// # }
21781 /// ```
21782 pub fn get_master_data(&self) -> Result<models::PublicRelationsMasterData> {
21783 let path = "/pr/masterdata".to_owned();
21784 let query: Query = Query::new();
21785 self.client.request_data(Method::Get, &path, &query, None)
21786 }
21787
21788}
21789
21790/// `client.printers()`
21791#[derive(Clone, Copy)]
21792pub struct PrintersResource<'a> {
21793 client: &'a Client,
21794}
21795
21796impl<'a> PrintersResource<'a> {
21797 /// Get printers
21798 ///
21799 /// `GET /printers`
21800 ///
21801 /// Lists all configured check-in code printers, including inactive printers. active indicates whether a printer is enabled; the endpoint does not check online status or submit a print job. Requires authentication but no additional printer/check-in permission in this handler. Results have no pagination or guaranteed order, and meta.count is the number of returned printers.
21802 ///
21803 /// # Example
21804 ///
21805 /// ```
21806 /// # use churchtools_api::*;
21807 /// # use churchtools_api::queries::*;
21808 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21809 /// # let client = churchtools_api::replay::client("get-printers");
21810 /// for printer in client.printers().list()? {
21811 /// println!("{}", printer.title);
21812 /// }
21813 /// # Ok(())
21814 /// # }
21815 /// ```
21816 pub fn list(&self) -> Result<Vec<models::Printer>> {
21817 let path = "/printers".to_owned();
21818 let query: Query = Query::new();
21819 self.client.request_data(Method::Get, &path, &query, None)
21820 }
21821
21822}
21823
21824/// `client.probes()`
21825#[derive(Clone, Copy)]
21826pub struct ProbesResource<'a> {
21827 client: &'a Client,
21828}
21829
21830impl<'a> ProbesResource<'a> {
21831 /// Get filtered probes
21832 ///
21833 /// `POST /probes`
21834 ///
21835 /// Returns probe definitions filtered by one or more domain types.
21836 ///
21837 /// # Example
21838 ///
21839 /// ```no_run
21840 /// # use churchtools_api::*;
21841 /// # use churchtools_api::queries::*;
21842 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21843 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21844 /// let body = models::PostProbesBody {
21845 /// domain_type: vec!["person".into()],
21846 /// ..Default::default()
21847 /// };
21848 /// for probe in client.probes().filter(&body)? {
21849 /// println!("{}", probe.domain_type);
21850 /// }
21851 /// # Ok(())
21852 /// # }
21853 /// ```
21854 pub fn filter(&self, body: &models::PostProbesBody) -> Result<Vec<models::Probe>> {
21855 let path = "/probes".to_owned();
21856 let query: Query = Query::new();
21857 let body = serde_json::to_value(body).expect("request body serializes");
21858 self.client.request_data(Method::Post, &path, &query, Some(&body))
21859 }
21860
21861}
21862
21863/// `client.profiles()`
21864#[derive(Clone, Copy)]
21865pub struct ProfilesResource<'a> {
21866 client: &'a Client,
21867}
21868
21869impl<'a> ProfilesResource<'a> {
21870 pub fn campuses(&self) -> ProfilesCampusesResource<'a> {
21871 ProfilesCampusesResource { client: self.client }
21872 }
21873
21874 pub fn slug_check(&self) -> ProfilesSlugCheckResource<'a> {
21875 ProfilesSlugCheckResource { client: self.client }
21876 }
21877
21878 /// Get a profile
21879 ///
21880 /// `GET /profiles/church`
21881 ///
21882 /// Get church profile information.
21883 ///
21884 /// # Example
21885 ///
21886 /// ```
21887 /// # use churchtools_api::*;
21888 /// # use churchtools_api::queries::*;
21889 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21890 /// # let client = churchtools_api::replay::client("get-profiles-church");
21891 /// let church = client.profiles().get_church()?;
21892 /// println!("{}", church.name);
21893 /// # Ok(())
21894 /// # }
21895 /// ```
21896 pub fn get_church(&self) -> Result<models::Profile> {
21897 let path = "/profiles/church".to_owned();
21898 let query: Query = Query::new();
21899 self.client.request_data(Method::Get, &path, &query, None)
21900 }
21901
21902 /// Get all profiles
21903 ///
21904 /// `GET /profiles`
21905 ///
21906 /// This endpoint returns all profiles for logged in users with permissions. All others (incl. public access) will only get published profiles.
21907 ///
21908 /// # Example
21909 ///
21910 /// ```
21911 /// # use churchtools_api::*;
21912 /// # use churchtools_api::queries::*;
21913 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21914 /// # let client = churchtools_api::replay::client("get-profiles");
21915 /// for profile in client.profiles().list()? {
21916 /// println!("{}", profile.name);
21917 /// }
21918 /// # Ok(())
21919 /// # }
21920 /// ```
21921 pub fn list(&self) -> Result<Vec<models::Profile>> {
21922 let path = "/profiles".to_owned();
21923 let query: Query = Query::new();
21924 self.client.request_data(Method::Get, &path, &query, None)
21925 }
21926
21927 /// Update the church profile
21928 ///
21929 /// `PUT /profiles/church`
21930 ///
21931 /// Update church information
21932 ///
21933 /// # Example
21934 ///
21935 /// ```no_run
21936 /// # use churchtools_api::*;
21937 /// # use churchtools_api::queries::*;
21938 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21939 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21940 /// let body = models::ProfileUpdate {
21941 /// name: "Hauskreis Nord".into(),
21942 /// ..Default::default()
21943 /// };
21944 /// let result = client.profiles().update_church(&body)?;
21945 /// println!("{}", result.name);
21946 /// # Ok(())
21947 /// # }
21948 /// ```
21949 pub fn update_church(&self, body: &models::ProfileUpdate) -> Result<models::Profile> {
21950 let path = "/profiles/church".to_owned();
21951 let query: Query = Query::new();
21952 let body = serde_json::to_value(body).expect("request body serializes");
21953 self.client.request_data(Method::Put, &path, &query, Some(&body))
21954 }
21955
21956}
21957
21958/// `client.profiles().campuses()`
21959#[derive(Clone, Copy)]
21960pub struct ProfilesCampusesResource<'a> {
21961 client: &'a Client,
21962}
21963
21964impl<'a> ProfilesCampusesResource<'a> {
21965 /// Update a campus profile
21966 ///
21967 /// `PUT /profiles/campuses/{id}`
21968 ///
21969 /// Update campus profile information
21970 ///
21971 /// # Example
21972 ///
21973 /// ```no_run
21974 /// # use churchtools_api::*;
21975 /// # use churchtools_api::queries::*;
21976 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
21977 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
21978 /// let body = models::ProfileUpdate {
21979 /// name: "Hauskreis Nord".into(),
21980 /// ..Default::default()
21981 /// };
21982 /// let result = client.profiles().campuses().update(42, &body)?;
21983 /// println!("{}", result.name);
21984 /// # Ok(())
21985 /// # }
21986 /// ```
21987 pub fn update(&self, id: impl Display, body: &models::ProfileUpdate) -> Result<models::Profile> {
21988 let path = format!("/profiles/campuses/{}", seg(id));
21989 let query: Query = Query::new();
21990 let body = serde_json::to_value(body).expect("request body serializes");
21991 self.client.request_data(Method::Put, &path, &query, Some(&body))
21992 }
21993
21994}
21995
21996/// `client.profiles().slug_check()`
21997#[derive(Clone, Copy)]
21998pub struct ProfilesSlugCheckResource<'a> {
21999 client: &'a Client,
22000}
22001
22002impl<'a> ProfilesSlugCheckResource<'a> {
22003 /// Check if a finder slug is free
22004 ///
22005 /// `GET /profiles/slugcheck/{slug}`
22006 ///
22007 /// Published profiles are visibale in ChurchTools Finder. Each profile has an unique slug (URI). This endpoint can be used to check if a slug is free.
22008 ///
22009 /// Use [`Self::get_with`] to pass query parameters.
22010 ///
22011 /// # Example
22012 ///
22013 /// ```no_run
22014 /// # use churchtools_api::*;
22015 /// # use churchtools_api::queries::*;
22016 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22017 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22018 /// client.profiles().slug_check().get("my-church")?;
22019 /// # Ok(())
22020 /// # }
22021 /// ```
22022 pub fn get(&self, slug: impl Display) -> Result<()> {
22023 self.get_with(slug, &Default::default())
22024 }
22025
22026 /// Check if a finder slug is free
22027 ///
22028 /// Like [`Self::get`], with query parameters.
22029 ///
22030 /// `GET /profiles/slugcheck/{slug}`
22031 ///
22032 /// Published profiles are visibale in ChurchTools Finder. Each profile has an unique slug (URI). This endpoint can be used to check if a slug is free.
22033 pub fn get_with(&self, slug: impl Display, query: &GetProfilesSlugcheckSlugQuery) -> Result<()> {
22034 let path = format!("/profiles/slugcheck/{}", seg(slug));
22035 let query: Query = query.to_query();
22036 self.client.request(Method::Get, &path, &query, None).map(|_| ())
22037 }
22038
22039}
22040
22041/// `client.public_groups()`
22042#[derive(Clone, Copy)]
22043pub struct PublicGroupsResource<'a> {
22044 client: &'a Client,
22045}
22046
22047impl<'a> PublicGroupsResource<'a> {
22048 pub fn signup(&self) -> PublicGroupsSignupResource<'a> {
22049 PublicGroupsSignupResource { client: self.client }
22050 }
22051
22052 /// Get public group details
22053 ///
22054 /// `GET /publicgroups/{groupId}`
22055 ///
22056 /// Returns group details, signup conditions and eligible signUpPersons for the current user. Public access is supported, but normal group-view permission still applies. Optional hash restricts the lookup to an enabled group homepage. Without it, the group is loaded directly. Seat counts include membership/role rules and need not equal the number of persons. Image and leader fields depend on the homepage display settings; signUpConditions explains why a signup is currently available or unavailable.
22057 ///
22058 /// Use [`Self::get_with`] to pass query parameters.
22059 ///
22060 /// # Example
22061 ///
22062 /// ```
22063 /// # use churchtools_api::*;
22064 /// # use churchtools_api::queries::*;
22065 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22066 /// # let client = churchtools_api::replay::client("get-publicgroups-id");
22067 /// let public_group = client.public_groups().get(42)?;
22068 /// println!("{}", public_group.name);
22069 /// # Ok(())
22070 /// # }
22071 /// ```
22072 pub fn get(&self, group_id: impl Display) -> Result<models::PublicGroupDetail> {
22073 self.get_with(group_id, &Default::default())
22074 }
22075
22076 /// Get public group details
22077 ///
22078 /// Like [`Self::get`], with query parameters.
22079 ///
22080 /// `GET /publicgroups/{groupId}`
22081 ///
22082 /// Returns group details, signup conditions and eligible signUpPersons for the current user. Public access is supported, but normal group-view permission still applies. Optional hash restricts the lookup to an enabled group homepage. Without it, the group is loaded directly. Seat counts include membership/role rules and need not equal the number of persons. Image and leader fields depend on the homepage display settings; signUpConditions explains why a signup is currently available or unavailable.
22083 pub fn get_with(&self, group_id: impl Display, query: &GetPublicgroupsIdQuery) -> Result<models::PublicGroupDetail> {
22084 let path = format!("/publicgroups/{}", seg(group_id));
22085 let query: Query = query.to_query();
22086 self.client.request_data(Method::Get, &path, &query, None)
22087 }
22088
22089 /// Get group signup form
22090 ///
22091 /// `GET /publicgroups/{groupId}/form`
22092 ///
22093 /// Loads the dynamic signup form for a token belonging to this group. Requires access to group signup. The response is wrapped in data. Each field is identified by type plus id; required fields and allowed options depend on group configuration and on the requester. Additional spouse/child/other forms are null when unavailable. Optional personId selects the requester and persists that choice on the token (this GET changes state). Use a person returned by possiblerequesters. Prefilled person values and privacy state are returned in signUpPersons.
22094 ///
22095 /// # Example
22096 ///
22097 /// ```
22098 /// # use churchtools_api::*;
22099 /// # use churchtools_api::queries::*;
22100 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22101 /// # let client = churchtools_api::replay::client("get-publicgroups-groupId-form");
22102 /// let query = GetPublicgroupsGroupIdFormQuery {
22103 /// token: Some("abc123".into()),
22104 /// ..Default::default()
22105 /// };
22106 /// let form = client.public_groups().get_form(42, &query)?;
22107 /// println!("{:?}", form.email);
22108 /// # Ok(())
22109 /// # }
22110 /// ```
22111 pub fn get_form(&self, group_id: impl Display, query: &GetPublicgroupsGroupIdFormQuery) -> Result<models::PublicGroupFormResult> {
22112 let path = format!("/publicgroups/{}/form", seg(group_id));
22113 let query: Query = query.to_query();
22114 self.client.request_data(Method::Get, &path, &query, None)
22115 }
22116
22117 /// List possible signup requesters
22118 ///
22119 /// `GET /publicgroups/{groupId}/possiblerequesters`
22120 ///
22121 /// Returns a requester-selection object for a token belonging to this group. Requires access to group signup. An email token lists persons sharing that address, because email addresses are not unique in ChurchTools; a token without email uses its requesterId. Status distinguishes existing members, pending/waiting requests and persons not yet requested. Results are not paginated and the DTO has no meta.count.
22122 ///
22123 /// # Example
22124 ///
22125 /// ```
22126 /// # use churchtools_api::*;
22127 /// # use churchtools_api::queries::*;
22128 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22129 /// # let client = churchtools_api::replay::client("get-publicgroups-groupId-possiblerequesters");
22130 /// let query = GetPublicgroupsGroupIdPossiblerequestersQuery {
22131 /// token: Some("abc123".into()),
22132 /// ..Default::default()
22133 /// };
22134 /// let possible_requester = client.public_groups().get_possible_requesters(42, &query)?;
22135 /// println!("{:?}", possible_requester.email);
22136 /// # Ok(())
22137 /// # }
22138 /// ```
22139 pub fn get_possible_requesters(&self, group_id: impl Display, query: &GetPublicgroupsGroupIdPossiblerequestersQuery) -> Result<models::PublicGroupPossibleRequesters> {
22140 let path = format!("/publicgroups/{}/possiblerequesters", seg(group_id));
22141 let query: Query = query.to_query();
22142 self.client.request_data(Method::Get, &path, &query, None)
22143 }
22144
22145 /// Get group withdrawal options
22146 ///
22147 /// `GET /publicgroups/{groupId}/signoutdata`
22148 ///
22149 /// Returns requester information and the persons whose group participation may be withdrawn directly or requires contacting leaders. A supplied signup token must belong to this group; without token the current user is used and signup access is required. For requesterId=-1 (no person created), requester and both person lists are null and noUserCreated=true is included. For a normal requester that flag is omitted. This GET does not withdraw anyone.
22150 ///
22151 /// Use [`Self::get_signout_data_with`] to pass query parameters.
22152 ///
22153 /// # Example
22154 ///
22155 /// ```
22156 /// # use churchtools_api::*;
22157 /// # use churchtools_api::queries::*;
22158 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22159 /// # let client = churchtools_api::replay::client("get-publicgroups-id-signoutdata");
22160 /// let signout_data = client.public_groups().get_signout_data(42)?;
22161 /// println!("{}", signout_data.group_has_auto_accept);
22162 /// # Ok(())
22163 /// # }
22164 /// ```
22165 pub fn get_signout_data(&self, group_id: impl Display) -> Result<models::PublicGroupSignoutData> {
22166 self.get_signout_data_with(group_id, &Default::default())
22167 }
22168
22169 /// Get group withdrawal options
22170 ///
22171 /// Like [`Self::get_signout_data`], with query parameters.
22172 ///
22173 /// `GET /publicgroups/{groupId}/signoutdata`
22174 ///
22175 /// Returns requester information and the persons whose group participation may be withdrawn directly or requires contacting leaders. A supplied signup token must belong to this group; without token the current user is used and signup access is required. For requesterId=-1 (no person created), requester and both person lists are null and noUserCreated=true is included. For a normal requester that flag is omitted. This GET does not withdraw anyone.
22176 pub fn get_signout_data_with(&self, group_id: impl Display, query: &GetPublicgroupsIdSignoutdataQuery) -> Result<models::PublicGroupSignoutData> {
22177 let path = format!("/publicgroups/{}/signoutdata", seg(group_id));
22178 let query: Query = query.to_query();
22179 self.client.request_data(Method::Get, &path, &query, None)
22180 }
22181
22182 /// Get public group details
22183 ///
22184 /// `GET /publicgroups/{groupId}/{hash}`
22185 ///
22186 /// Returns group details, signup conditions and eligible signUpPersons for the current user. Public access is supported, but normal group-view permission still applies. The hash identifies an enabled group homepage; the group must be included in that homepage. This endpoint returns one group, not the whole homepage. Seat counts include membership/role rules and need not equal the number of persons. Image and leader fields depend on the homepage display settings; signUpConditions explains why a signup is currently available or unavailable.
22187 ///
22188 /// # Example
22189 ///
22190 /// ```
22191 /// # use churchtools_api::*;
22192 /// # use churchtools_api::queries::*;
22193 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22194 /// # let client = churchtools_api::replay::client("get-publicgroups-id-hash");
22195 /// let with_hash = client.public_groups().get_with_hash(42, "abc123")?;
22196 /// println!("{}", with_hash.name);
22197 /// # Ok(())
22198 /// # }
22199 /// ```
22200 pub fn get_with_hash(&self, group_id: impl Display, hash: impl Display) -> Result<models::PublicGroupDetail> {
22201 let path = format!("/publicgroups/{}/{}", seg(group_id), seg(hash));
22202 let query: Query = Query::new();
22203 self.client.request_data(Method::Get, &path, &query, None)
22204 }
22205
22206 /// Contact public group leaders
22207 ///
22208 /// `POST /publicgroups/{groupId}/mailToLeaders`
22209 ///
22210 /// Sends the supplied message to group leaders with a default email address. Requires group signup access or a valid signup token for this group. The sender name/email are supplied by the caller. hideContactLeader is a display setting and is not checked here. No reachable leaders causes a server error; successful processing returns a message and does not create a membership.
22211 ///
22212 /// # Example
22213 ///
22214 /// ```no_run
22215 /// # use churchtools_api::*;
22216 /// # use churchtools_api::queries::*;
22217 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22218 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22219 /// let body = models::PublicGroupLeaderMailCreate {
22220 /// email: "mara@example.org".into(),
22221 /// message: "Hallo zusammen".into(),
22222 /// name: "Hauskreis Nord".into(),
22223 /// ..Default::default()
22224 /// };
22225 /// let public_group = client.public_groups().mail_to_leaders(42, &body)?;
22226 /// println!("{}", public_group.success);
22227 /// # Ok(())
22228 /// # }
22229 /// ```
22230 pub fn mail_to_leaders(&self, group_id: impl Display, body: &models::PublicGroupLeaderMailCreate) -> Result<models::PostPublicgroupsGroupIdMailToLeadersData> {
22231 let path = format!("/publicgroups/{}/mailToLeaders", seg(group_id));
22232 let query: Query = Query::new();
22233 let body = serde_json::to_value(body).expect("request body serializes");
22234 self.client.request_data(Method::Post, &path, &query, Some(&body))
22235 }
22236
22237 /// Withdraw group registrations
22238 ///
22239 /// `POST /publicgroups/{groupId}/signout`
22240 ///
22241 /// Withdraws selected memberships for the requester or people registered by that requester. A group sign-up token identifies the requester without requiring a login; without a token the current user and group sign-up access are used. When registration is open, active, requested and waiting memberships are eligible. Otherwise the requester needs the group exit permission and only active memberships qualify. All person IDs are checked before changes begin. With automatic acceptance enabled, memberships are deleted; otherwise they are marked to_delete for approval and their role is cleared. The changes run in a transaction. An empty personIds list is a successful no-op. This signs people out of a group, not out of their ChurchTools session.
22242 ///
22243 /// # Example
22244 ///
22245 /// ```no_run
22246 /// # use churchtools_api::*;
22247 /// # use churchtools_api::queries::*;
22248 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22249 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22250 /// let body = models::PublicGroupSignOutRequest {
22251 /// person_ids: vec![42, 43],
22252 /// ..Default::default()
22253 /// };
22254 /// client.public_groups().signout(42, &body)?;
22255 /// # Ok(())
22256 /// # }
22257 /// ```
22258 pub fn signout(&self, group_id: impl Display, body: &models::PublicGroupSignOutRequest) -> Result<()> {
22259 let path = format!("/publicgroups/{}/signout", seg(group_id));
22260 let query: Query = Query::new();
22261 let body = serde_json::to_value(body).expect("request body serializes");
22262 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
22263 }
22264
22265 /// Submit group signup forms
22266 ///
22267 /// `POST /publicgroups/{groupId}/signup`
22268 ///
22269 /// Submits one form per person using a signup token for this group. Copy field type/id from the dynamic form and use its mandatory/options rules. Existing person IDs must be eligible for this requester; new spouse/child/other forms are available only when allowed by group settings. Adding related/other persons requires hasAcceptedPrivacyForOther=true. A child must be younger than 16. Membership may be accepted immediately, requested from leaders or placed on a waiting list; capacity is checked for the entire submitted set. Depending on group configuration, a new applicant may produce a request email instead of a new person. The operation is transactional for database changes. Success returns a top-level nullable groupHomepageHash, without a data wrapper.
22270 ///
22271 /// # Example
22272 ///
22273 /// ```no_run
22274 /// # use churchtools_api::*;
22275 /// # use churchtools_api::queries::*;
22276 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22277 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22278 /// let body = models::PublicGroupSignupCreate {
22279 /// forms: vec![models::PublicGroupSignupCreateFormsItem {
22280 /// form: vec![models::PublicGroupSignupCreateFormsItemFormItem::default()],
22281 /// ..Default::default()
22282 /// }],
22283 /// token: "abc123".into(),
22284 /// ..Default::default()
22285 /// };
22286 /// let public_group = client.public_groups().submit_signup(42, &body)?;
22287 /// println!("{:?}", public_group.group_homepage_hash);
22288 /// # Ok(())
22289 /// # }
22290 /// ```
22291 pub fn submit_signup(&self, group_id: impl Display, body: &models::PublicGroupSignupCreate) -> Result<models::PostPublicgroupsGroupIdSignupResponse> {
22292 let path = format!("/publicgroups/{}/signup", seg(group_id));
22293 let query: Query = Query::new();
22294 let body = serde_json::to_value(body).expect("request body serializes");
22295 self.client.request_json(Method::Post, &path, &query, Some(&body))
22296 }
22297
22298 /// Create group signup token
22299 ///
22300 /// `POST /publicgroups/{groupId}/token`
22301 ///
22302 /// Starts a group-membership signup, distinct from account self-registration. Requires access to this group’s signup and an open signup feature. In verification mode `all`, supply either the current logged-in personId for a token returned directly or an email address for a verification link. Another personId is forbidden, and personId and email are mutually exclusive. In modes `existing` and `none`, both may be omitted and a new-person token is returned directly; in mode `existing`, matching uses the email supplied later in the signup form. Email flow returns only a success message. Tokens can be used to load forms, select a requester and submit memberships; they have no stored expiry in the current implementation.
22303 ///
22304 /// # Example
22305 ///
22306 /// ```no_run
22307 /// # use churchtools_api::*;
22308 /// # use churchtools_api::queries::*;
22309 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22310 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22311 /// let body = models::PublicGroupTokenCreate {
22312 /// email: Some("mara@example.org".into()),
22313 /// ..Default::default()
22314 /// };
22315 /// let result = client.public_groups().token(42, &body)?;
22316 /// println!("{:?}", result);
22317 /// # Ok(())
22318 /// # }
22319 /// ```
22320 pub fn token(&self, group_id: impl Display, body: &models::PublicGroupTokenCreate) -> Result<serde_json::Value> {
22321 let path = format!("/publicgroups/{}/token", seg(group_id));
22322 let query: Query = Query::new();
22323 let body = serde_json::to_value(body).expect("request body serializes");
22324 self.client.request_data(Method::Post, &path, &query, Some(&body))
22325 }
22326
22327}
22328
22329/// `client.public_groups().signup()`
22330#[derive(Clone, Copy)]
22331pub struct PublicGroupsSignupResource<'a> {
22332 client: &'a Client,
22333}
22334
22335impl<'a> PublicGroupsSignupResource<'a> {
22336 pub fn confirm(&self) -> PublicGroupsSignupConfirmResource<'a> {
22337 PublicGroupsSignupConfirmResource { client: self.client }
22338 }
22339
22340}
22341
22342/// `client.public_groups().signup().confirm()`
22343#[derive(Clone, Copy)]
22344pub struct PublicGroupsSignupConfirmResource<'a> {
22345 client: &'a Client,
22346}
22347
22348impl<'a> PublicGroupsSignupConfirmResource<'a> {
22349 /// Confirm a deferred public group signup
22350 ///
22351 /// `POST /publicgroups/signup/confirm/{confirmationToken}`
22352 ///
22353 /// Confirms a deferred group signup using the secret emailed to the requester. The link expires after 72 hours. Places are assigned using the group's current signup and waiting-list rules. Repeated confirmation is safe.
22354 ///
22355 /// # Example
22356 ///
22357 /// ```no_run
22358 /// # use churchtools_api::*;
22359 /// # use churchtools_api::queries::*;
22360 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22361 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22362 /// let body: std::collections::BTreeMap<String, serde_json::Value> = Default::default();
22363 /// let result = client.public_groups().signup().confirm().create("abc123", &body)?;
22364 /// println!("{:?}", result.group_homepage_hash);
22365 /// # Ok(())
22366 /// # }
22367 /// ```
22368 pub fn create(&self, confirmation_token: impl Display, body: &std::collections::BTreeMap<String, serde_json::Value>) -> Result<models::PostPublicgroupsSignupConfirmConfirmationTokenData> {
22369 let path = format!("/publicgroups/signup/confirm/{}", seg(confirmation_token));
22370 let query: Query = Query::new();
22371 let body = serde_json::to_value(body).expect("request body serializes");
22372 self.client.request_data(Method::Post, &path, &query, Some(&body))
22373 }
22374
22375 /// Show the deferred public group signup confirmation page
22376 ///
22377 /// `GET /publicgroups/signup/confirm/{confirmationToken}`
22378 ///
22379 /// Renders the deferred signup confirmation page without changing signup data. The page starts confirmation through the POST endpoint after JavaScript has loaded, preventing email link scanners from confirming the signup.
22380 ///
22381 /// # Example
22382 ///
22383 /// ```no_run
22384 /// # use churchtools_api::*;
22385 /// # use churchtools_api::queries::*;
22386 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22387 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22388 /// let data = client.public_groups().signup().confirm().get("abc123")?;
22389 /// std::fs::write("ergebnis.bin", &data)?;
22390 /// # Ok(())
22391 /// # }
22392 /// ```
22393 pub fn get(&self, confirmation_token: impl Display) -> Result<Vec<u8>> {
22394 let path = format!("/publicgroups/signup/confirm/{}", seg(confirmation_token));
22395 let query: Query = Query::new();
22396 self.client.request(Method::Get, &path, &query, None)
22397 }
22398
22399}
22400
22401/// `client.queues()`
22402#[derive(Clone, Copy)]
22403pub struct QueuesResource<'a> {
22404 client: &'a Client,
22405}
22406
22407impl<'a> QueuesResource<'a> {
22408 pub fn job_groups(&self) -> QueuesJobGroupsResource<'a> {
22409 QueuesJobGroupsResource { client: self.client }
22410 }
22411
22412 /// Start Worker For Queue
22413 ///
22414 /// `POST /queues/{queue}`
22415 ///
22416 /// ChurchTools utilizes a queueing system to offload time-intensive or processing-intensive work. Calling this endpoint will start a worker, which grabs pending jobs and processing them. If the queue has still jobs pending the worker starts a new worker to continue the work.
22417 ///
22418 /// # Example
22419 ///
22420 /// ```no_run
22421 /// # use churchtools_api::*;
22422 /// # use churchtools_api::queries::*;
22423 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22424 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22425 /// let result = client.queues().create("default")?;
22426 /// println!("{:?}", result.queue);
22427 /// # Ok(())
22428 /// # }
22429 /// ```
22430 pub fn create(&self, queue: impl Display) -> Result<models::PostQueuesQueueData> {
22431 let path = format!("/queues/{}", seg(queue));
22432 let query: Query = Query::new();
22433 self.client.request_data(Method::Post, &path, &query, None)
22434 }
22435
22436}
22437
22438/// `client.queues().job_groups()`
22439#[derive(Clone, Copy)]
22440pub struct QueuesJobGroupsResource<'a> {
22441 client: &'a Client,
22442}
22443
22444impl<'a> QueuesJobGroupsResource<'a> {
22445 /// Status Information About Job Groups in Queue
22446 ///
22447 /// `GET /queues/{queue}/jobgroups/{jobGroup}`
22448 ///
22449 /// Job in a queue can belong to a job group to categorize a job. This endpoint counts jobs in queue and groups them by they status.
22450 ///
22451 /// Use this endpoint to check if all jobs are processed or if still jobs are pending and wait to be processed.
22452 ///
22453 /// # Example
22454 ///
22455 /// ```
22456 /// # use churchtools_api::*;
22457 /// # use churchtools_api::queries::*;
22458 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22459 /// # let client = churchtools_api::replay::client("get-queues-queue-jobgroups-jobGroup");
22460 /// for job_group in client.queues().job_groups().get("beispiel", "beispiel")? {
22461 /// println!("{}", job_group.name);
22462 /// }
22463 /// # Ok(())
22464 /// # }
22465 /// ```
22466 pub fn get(&self, queue: impl Display, job_group: impl Display) -> Result<Vec<models::JobGroupStatus>> {
22467 let path = format!("/queues/{}/jobgroups/{}", seg(queue), seg(job_group));
22468 let query: Query = Query::new();
22469 self.client.request_data(Method::Get, &path, &query, None)
22470 }
22471
22472}
22473
22474/// `client.registration_config()`
22475#[derive(Clone, Copy)]
22476pub struct RegistrationConfigResource<'a> {
22477 client: &'a Client,
22478}
22479
22480impl<'a> RegistrationConfigResource<'a> {
22481 /// Get self-registration configuration
22482 ///
22483 /// `GET /registrationconfig/{id}`
22484 ///
22485 /// Loads the form and campus choices for self-registration. Callers with "churchcore administer persons" permission also receive administrative settings and audit metadata. `fields` contains active configured fields, or the default phone, address, sex and birthday fields when no selection is stored.
22486 ///
22487 /// # Example
22488 ///
22489 /// ```
22490 /// # use churchtools_api::*;
22491 /// # use churchtools_api::queries::*;
22492 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22493 /// # let client = churchtools_api::replay::client("get-registrationconfig-id");
22494 /// let registration_config = client.registration_config().get(serde_json::json!(42))?;
22495 /// println!("{}", registration_config.id);
22496 /// # Ok(())
22497 /// # }
22498 /// ```
22499 pub fn get(&self, id: impl Display) -> Result<models::RegistrationConfig> {
22500 let path = format!("/registrationconfig/{}", seg(id));
22501 let query: Query = Query::new();
22502 self.client.request_data(Method::Get, &path, &query, None)
22503 }
22504
22505 /// Update self-registration configuration
22506 ///
22507 /// `PATCH /registrationconfig/{id}`
22508 ///
22509 /// Partially updates the numeric configuration ID. Requires "churchcore administer persons" permission. Supplied arrays replace their complete lists. Changing the configuration does not alter existing persons or memberships. Returns the complete administrative configuration.
22510 ///
22511 /// # Example
22512 ///
22513 /// ```no_run
22514 /// # use churchtools_api::*;
22515 /// # use churchtools_api::queries::*;
22516 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22517 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22518 /// let body = models::RegistrationConfigUpdate {
22519 /// is_active: Some(true),
22520 /// ..Default::default()
22521 /// };
22522 /// let result = client.registration_config().patch(1, &body)?;
22523 /// println!("{}", result.id);
22524 /// # Ok(())
22525 /// # }
22526 /// ```
22527 pub fn patch(&self, id: impl Display, body: &models::RegistrationConfigUpdate) -> Result<models::RegistrationConfigAdmin> {
22528 let path = format!("/registrationconfig/{}", seg(id));
22529 let query: Query = Query::new();
22530 let body = serde_json::to_value(body).expect("request body serializes");
22531 self.client.request_data(Method::Patch, &path, &query, Some(&body))
22532 }
22533
22534}
22535
22536/// `client.registrations()`
22537#[derive(Clone, Copy)]
22538pub struct RegistrationsResource<'a> {
22539 client: &'a Client,
22540}
22541
22542impl<'a> RegistrationsResource<'a> {
22543 /// Confirm self-registration email
22544 ///
22545 /// `POST /registrations/{registrationGuid}/confirm`
22546 ///
22547 /// Verifies the emailed token for an unconverted registration and records the confirmation time. Returns active persons with the same default email as `possibleMatches`, including configured form fields and `hasPassword`. Repeated confirmation is accepted while the registration is unconverted.
22548 ///
22549 /// # Example
22550 ///
22551 /// ```no_run
22552 /// # use churchtools_api::*;
22553 /// # use churchtools_api::queries::*;
22554 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22555 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22556 /// let body = models::RegistrationConfirm {
22557 /// token: "abc123".into(),
22558 /// ..Default::default()
22559 /// };
22560 /// let registration = client.registrations().confirm("8c3bf5f0-305d-4e24-8e06-7c1d217fd3f1", &body)?;
22561 /// println!("{}", registration.first_name);
22562 /// # Ok(())
22563 /// # }
22564 /// ```
22565 pub fn confirm(&self, registration_guid: impl Display, body: &models::RegistrationConfirm) -> Result<models::Registration> {
22566 let path = format!("/registrations/{}/confirm", seg(registration_guid));
22567 let query: Query = Query::new();
22568 let body = serde_json::to_value(body).expect("request body serializes");
22569 self.client.request_data(Method::Post, &path, &query, Some(&body))
22570 }
22571
22572 /// Complete self-registration
22573 ///
22574 /// `POST /registrations/{registrationGuid}/convert`
22575 ///
22576 /// Completes an email-confirmed, unconverted registration using its token. Creates a new person or links `personId` to an active person with the same default email. Requires an active/complete configuration and enabled default login. `formData` supplies consent and configured fields by field ID or modern person field name (ID takes precedence); unknown/unconfigured fields are discarded. Required configured fields and person data are validated. A new person receives configured status, departments, tags and campus group memberships; a sole campus is selected automatically, otherwise `formData.campusId` must match a configured campus. Existing persons receive supplied fields, configured existing-person tags and the registration password. Success marks conversion complete and logs in that person in the current session.
22577 ///
22578 /// # Example
22579 ///
22580 /// ```no_run
22581 /// # use churchtools_api::*;
22582 /// # use churchtools_api::queries::*;
22583 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22584 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22585 /// let body = models::RegistrationConvert {
22586 /// form_data: models::RegistrationConvertFormData {
22587 /// accept_data_privacy: true,
22588 /// ..Default::default()
22589 /// },
22590 /// token: "abc123".into(),
22591 /// ..Default::default()
22592 /// };
22593 /// client.registrations().convert("8c3bf5f0-305d-4e24-8e06-7c1d217fd3f1", &body)?;
22594 /// # Ok(())
22595 /// # }
22596 /// ```
22597 pub fn convert(&self, registration_guid: impl Display, body: &models::RegistrationConvert) -> Result<()> {
22598 let path = format!("/registrations/{}/convert", seg(registration_guid));
22599 let query: Query = Query::new();
22600 let body = serde_json::to_value(body).expect("request body serializes");
22601 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
22602 }
22603
22604 /// Start self-registration
22605 ///
22606 /// `POST /registrations`
22607 ///
22608 /// Starts account self-registration for the configuration GUID and emails a confirmation link. Requires an active, complete configuration and an enabled default login. Blacklisted email addresses, blocked accounts and recognized existing login accounts receive an informational email and return `204` without creating a registration.
22609 ///
22610 /// # Example
22611 ///
22612 /// ```no_run
22613 /// # use churchtools_api::*;
22614 /// # use churchtools_api::queries::*;
22615 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22616 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22617 /// let body = models::RegistrationCreate {
22618 /// config_id: "8c3bf5f0-305d-4e24-8e06-7c1d217fd3f1".into(),
22619 /// email: "mara@example.org".into(),
22620 /// first_name: "Mara".into(),
22621 /// last_name: "Becker".into(),
22622 /// password: "geheim".into(),
22623 /// ..Default::default()
22624 /// };
22625 /// let result = client.registrations().create(&body)?;
22626 /// println!("{:?}", result);
22627 /// # Ok(())
22628 /// # }
22629 /// ```
22630 pub fn create(&self, body: &models::RegistrationCreate) -> Result<Option<models::Registration>> {
22631 let path = "/registrations".to_owned();
22632 let query: Query = Query::new();
22633 let body = serde_json::to_value(body).expect("request body serializes");
22634 self.client.request_data(Method::Post, &path, &query, Some(&body))
22635 }
22636
22637 /// Delete self-registration
22638 ///
22639 /// `DELETE /registrations/{registrationGuid}`
22640 ///
22641 /// Deletes the registration record by GUID. This does not delete a person created by an earlier conversion.
22642 ///
22643 /// # Example
22644 ///
22645 /// ```no_run
22646 /// # use churchtools_api::*;
22647 /// # use churchtools_api::queries::*;
22648 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22649 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22650 /// client.registrations().delete("8c3bf5f0-305d-4e24-8e06-7c1d217fd3f1")?;
22651 /// # Ok(())
22652 /// # }
22653 /// ```
22654 pub fn delete(&self, registration_guid: impl Display) -> Result<()> {
22655 let path = format!("/registrations/{}", seg(registration_guid));
22656 let query: Query = Query::new();
22657 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
22658 }
22659
22660 /// Resend self-registration confirmation
22661 ///
22662 /// `POST /registrations/{registrationGuid}/resend`
22663 ///
22664 /// Resends the confirmation email for this registration.
22665 ///
22666 /// # Example
22667 ///
22668 /// ```no_run
22669 /// # use churchtools_api::*;
22670 /// # use churchtools_api::queries::*;
22671 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22672 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22673 /// client.registrations().resend("8c3bf5f0-305d-4e24-8e06-7c1d217fd3f1")?;
22674 /// # Ok(())
22675 /// # }
22676 /// ```
22677 pub fn resend(&self, registration_guid: impl Display) -> Result<()> {
22678 let path = format!("/registrations/{}/resend", seg(registration_guid));
22679 let query: Query = Query::new();
22680 self.client.request(Method::Post, &path, &query, None).map(|_| ())
22681 }
22682
22683}
22684
22685/// `client.repeat_calculation()`
22686#[derive(Clone, Copy)]
22687pub struct RepeatCalculationResource<'a> {
22688 client: &'a Client,
22689}
22690
22691impl<'a> RepeatCalculationResource<'a> {
22692 /// Calculate occurrence dates without saving an appointment
22693 ///
22694 /// `POST /repeatcalculation`
22695 ///
22696 /// Calculates occurrence dates without storing an appointment.
22697 ///
22698 /// # Example
22699 ///
22700 /// ```
22701 /// # use churchtools_api::*;
22702 /// # use churchtools_api::queries::*;
22703 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22704 /// # let client = churchtools_api::replay::client("post-repeatcalculation");
22705 /// let body = models::RepeatCalculationCreate {
22706 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
22707 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
22708 /// ..Default::default()
22709 /// };
22710 /// for repeat_calculation in client.repeat_calculation().calculate(&body)? {
22711 /// println!("{:?}", repeat_calculation);
22712 /// }
22713 /// # Ok(())
22714 /// # }
22715 /// ```
22716 pub fn calculate(&self, body: &models::RepeatCalculationCreate) -> Result<Vec<models::RepeatCalculationOccurrence>> {
22717 let path = "/repeatcalculation".to_owned();
22718 let query: Query = Query::new();
22719 let body = serde_json::to_value(body).expect("request body serializes");
22720 self.client.request_json(Method::Post, &path, &query, Some(&body))
22721 }
22722
22723 /// Calculate occurrence dates without saving an appointment
22724 ///
22725 /// `DELETE /repeatcalculation`
22726 ///
22727 /// Calculates occurrence dates without storing an appointment. This is an alias of POST; use POST for new integrations.
22728 ///
22729 /// # Example
22730 ///
22731 /// ```no_run
22732 /// # use churchtools_api::*;
22733 /// # use churchtools_api::queries::*;
22734 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22735 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22736 /// let body = models::RepeatCalculationCreate {
22737 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
22738 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
22739 /// ..Default::default()
22740 /// };
22741 /// for repeat_calculation in client.repeat_calculation().delete(&body)? {
22742 /// println!("{:?}", repeat_calculation);
22743 /// }
22744 /// # Ok(())
22745 /// # }
22746 /// ```
22747 pub fn delete(&self, body: &models::RepeatCalculationCreate) -> Result<Vec<models::RepeatCalculationOccurrence>> {
22748 let path = "/repeatcalculation".to_owned();
22749 let query: Query = Query::new();
22750 let body = serde_json::to_value(body).expect("request body serializes");
22751 self.client.request_json(Method::Delete, &path, &query, Some(&body))
22752 }
22753
22754 /// Calculate occurrence dates without saving an appointment
22755 ///
22756 /// `GET /repeatcalculation`
22757 ///
22758 /// Calculates occurrence dates without storing an appointment. This is an alias of POST; use POST for new integrations.
22759 ///
22760 /// # Example
22761 ///
22762 /// ```
22763 /// # use churchtools_api::*;
22764 /// # use churchtools_api::queries::*;
22765 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22766 /// # let client = churchtools_api::replay::client("get-repeatcalculation");
22767 /// let query = GetRepeatcalculationQuery {
22768 /// end_date: Some(serde_json::json!("2026-09-20T09:30:00Z")),
22769 /// start_date: Some(serde_json::json!("2026-09-20T08:00:00Z")),
22770 /// ..Default::default()
22771 /// };
22772 /// for repeat_calculation in client.repeat_calculation().list(&query)? {
22773 /// println!("{:?}", repeat_calculation);
22774 /// }
22775 /// # Ok(())
22776 /// # }
22777 /// ```
22778 pub fn list(&self, query: &GetRepeatcalculationQuery) -> Result<Vec<models::RepeatCalculationOccurrence>> {
22779 let path = "/repeatcalculation".to_owned();
22780 let query: Query = query.to_query();
22781 self.client.request_json(Method::Get, &path, &query, None)
22782 }
22783
22784 /// Calculate occurrence dates without saving an appointment
22785 ///
22786 /// `PATCH /repeatcalculation`
22787 ///
22788 /// Calculates occurrence dates without storing an appointment. This is an alias of POST; use POST for new integrations.
22789 ///
22790 /// # Example
22791 ///
22792 /// ```no_run
22793 /// # use churchtools_api::*;
22794 /// # use churchtools_api::queries::*;
22795 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22796 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22797 /// let body = models::RepeatCalculationCreate {
22798 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
22799 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
22800 /// ..Default::default()
22801 /// };
22802 /// for repeat_calculation in client.repeat_calculation().patch(&body)? {
22803 /// println!("{:?}", repeat_calculation);
22804 /// }
22805 /// # Ok(())
22806 /// # }
22807 /// ```
22808 pub fn patch(&self, body: &models::RepeatCalculationCreate) -> Result<Vec<models::RepeatCalculationOccurrence>> {
22809 let path = "/repeatcalculation".to_owned();
22810 let query: Query = Query::new();
22811 let body = serde_json::to_value(body).expect("request body serializes");
22812 self.client.request_json(Method::Patch, &path, &query, Some(&body))
22813 }
22814
22815 /// Calculate occurrence dates without saving an appointment
22816 ///
22817 /// `PUT /repeatcalculation`
22818 ///
22819 /// Calculates occurrence dates without storing an appointment. This is an alias of POST; use POST for new integrations.
22820 ///
22821 /// # Example
22822 ///
22823 /// ```no_run
22824 /// # use churchtools_api::*;
22825 /// # use churchtools_api::queries::*;
22826 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22827 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22828 /// let body = models::RepeatCalculationCreate {
22829 /// end_date: DateOrDateTime::DateTime("2026-09-20T09:30:00Z".parse()?),
22830 /// start_date: DateOrDateTime::DateTime("2026-09-20T08:00:00Z".parse()?),
22831 /// ..Default::default()
22832 /// };
22833 /// for repeat_calculation in client.repeat_calculation().update(&body)? {
22834 /// println!("{:?}", repeat_calculation);
22835 /// }
22836 /// # Ok(())
22837 /// # }
22838 /// ```
22839 pub fn update(&self, body: &models::RepeatCalculationCreate) -> Result<Vec<models::RepeatCalculationOccurrence>> {
22840 let path = "/repeatcalculation".to_owned();
22841 let query: Query = Query::new();
22842 let body = serde_json::to_value(body).expect("request body serializes");
22843 self.client.request_json(Method::Put, &path, &query, Some(&body))
22844 }
22845
22846}
22847
22848/// `client.reset_password()`
22849#[derive(Clone, Copy)]
22850pub struct ResetPasswordResource<'a> {
22851 client: &'a Client,
22852}
22853
22854impl<'a> ResetPasswordResource<'a> {
22855 /// Request password reset
22856 ///
22857 /// `POST /reset-password`
22858 ///
22859 /// Requests password-reset emails for active, non-archived accounts matching the stored email address or login name. More than one account can match. The account must already have a password, a previous login or a stored invitation login token. Eligible accounts receive a reset link valid for two weeks. The response always contains a generic translated information message, including when no account matches; it does not reveal which accounts exist or confirm delivery. This public endpoint is rate-limited (normally 20 requests per 60 seconds; configurable through ratelimit.login). Opening a valid reset link creates a password-reset session; submit the new password through PUT /persons/{personId}/password.
22860 ///
22861 /// # Example
22862 ///
22863 /// ```no_run
22864 /// # use churchtools_api::*;
22865 /// # use churchtools_api::queries::*;
22866 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22867 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22868 /// let body = models::PasswordResetCreate {
22869 /// email_or_username: "alex@example.org".into(),
22870 /// ..Default::default()
22871 /// };
22872 /// let result = client.reset_password().create(&body)?;
22873 /// println!("{:?}", result);
22874 /// # Ok(())
22875 /// # }
22876 /// ```
22877 pub fn create(&self, body: &models::PasswordResetCreate) -> Result<models::PostResetPasswordData> {
22878 let path = "/reset-password".to_owned();
22879 let query: Query = Query::new();
22880 let body = serde_json::to_value(body).expect("request body serializes");
22881 self.client.request_data(Method::Post, &path, &query, Some(&body))
22882 }
22883
22884}
22885
22886/// `client.resource()`
22887#[derive(Clone, Copy)]
22888pub struct ResourceResource<'a> {
22889 client: &'a Client,
22890}
22891
22892impl<'a> ResourceResource<'a> {
22893 /// Get resource planning master data
22894 ///
22895 /// `GET /resource/masterdata`
22896 ///
22897 /// Returns all resource types ordered by `sortKey` and all resources visible to the current user. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its `adminIds`. Resource types are not filtered, so some may have no visible resources. Use `include[]` to resolve resource administrators.
22898 ///
22899 /// Use [`Self::get_master_data_with`] to pass query parameters.
22900 ///
22901 /// # Example
22902 ///
22903 /// ```
22904 /// # use churchtools_api::*;
22905 /// # use churchtools_api::queries::*;
22906 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22907 /// # let client = churchtools_api::replay::client("get-resource-masterdata");
22908 /// let master_data = client.resource().get_master_data()?;
22909 /// println!("{:?}", master_data);
22910 /// # Ok(())
22911 /// # }
22912 /// ```
22913 pub fn get_master_data(&self) -> Result<models::ResourceMasterData> {
22914 self.get_master_data_with(&Default::default())
22915 }
22916
22917 /// Get resource planning master data
22918 ///
22919 /// Like [`Self::get_master_data`], with query parameters.
22920 ///
22921 /// `GET /resource/masterdata`
22922 ///
22923 /// Returns all resource types ordered by `sortKey` and all resources visible to the current user. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its `adminIds`. Resource types are not filtered, so some may have no visible resources. Use `include[]` to resolve resource administrators.
22924 pub fn get_master_data_with(&self, query: &GetResourceMasterdataQuery) -> Result<models::ResourceMasterData> {
22925 let path = "/resource/masterdata".to_owned();
22926 let query: Query = query.to_query();
22927 self.client.request_data(Method::Get, &path, &query, None)
22928 }
22929
22930}
22931
22932/// `client.resource_types()`
22933#[derive(Clone, Copy)]
22934pub struct ResourceTypesResource<'a> {
22935 client: &'a Client,
22936}
22937
22938impl<'a> ResourceTypesResource<'a> {
22939 /// Create a resource type
22940 ///
22941 /// `POST /resourcetypes`
22942 ///
22943 /// Creates a category used to group resources. `campusId` optionally associates the type with an organizational campus.
22944 ///
22945 /// # Example
22946 ///
22947 /// ```
22948 /// # use churchtools_api::*;
22949 /// # use churchtools_api::queries::*;
22950 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22951 /// # let client = churchtools_api::replay::client("post-resourcetypes");
22952 /// let body = models::ResourceTypeCreate {
22953 /// name: "Room".into(),
22954 /// name_plural: "Rooms".into(),
22955 /// sort_key: 1,
22956 /// ..Default::default()
22957 /// };
22958 /// let result = client.resource_types().create(&body)?;
22959 /// println!("{}", result.name);
22960 /// # Ok(())
22961 /// # }
22962 /// ```
22963 pub fn create(&self, body: &models::ResourceTypeCreate) -> Result<models::ResourceType> {
22964 let path = "/resourcetypes".to_owned();
22965 let query: Query = Query::new();
22966 let body = serde_json::to_value(body).expect("request body serializes");
22967 self.client.request_data(Method::Post, &path, &query, Some(&body))
22968 }
22969
22970 /// Delete a resource type
22971 ///
22972 /// `DELETE /resourcetypes/{resourceTypeId}`
22973 ///
22974 /// Deletes a resource category.
22975 ///
22976 /// # Example
22977 ///
22978 /// ```no_run
22979 /// # use churchtools_api::*;
22980 /// # use churchtools_api::queries::*;
22981 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
22982 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
22983 /// client.resource_types().delete(2)?;
22984 /// # Ok(())
22985 /// # }
22986 /// ```
22987 pub fn delete(&self, resource_type_id: impl Display) -> Result<()> {
22988 let path = format!("/resourcetypes/{}", seg(resource_type_id));
22989 let query: Query = Query::new();
22990 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
22991 }
22992
22993 /// Get a resource type
22994 ///
22995 /// `GET /resourcetypes/{resourceTypeId}`
22996 ///
22997 /// Returns the resource category, its labels and optional campus assignment. It does not include the resources belonging to the type.
22998 ///
22999 /// # Example
23000 ///
23001 /// ```
23002 /// # use churchtools_api::*;
23003 /// # use churchtools_api::queries::*;
23004 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23005 /// # let client = churchtools_api::replay::client("get-resourcetypes-resourceTypeId");
23006 /// let resource_type = client.resource_types().get(2)?;
23007 /// println!("{}", resource_type.name);
23008 /// # Ok(())
23009 /// # }
23010 /// ```
23011 pub fn get(&self, resource_type_id: impl Display) -> Result<models::ResourceType> {
23012 let path = format!("/resourcetypes/{}", seg(resource_type_id));
23013 let query: Query = Query::new();
23014 self.client.request_data(Method::Get, &path, &query, None)
23015 }
23016
23017 /// List resource types
23018 ///
23019 /// `GET /resourcetypes`
23020 ///
23021 /// Returns all resource categories, such as rooms or vehicles, without filtering by resource visibility. A type may have no resources visible to the reader.
23022 ///
23023 /// # Example
23024 ///
23025 /// ```
23026 /// # use churchtools_api::*;
23027 /// # use churchtools_api::queries::*;
23028 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23029 /// # let client = churchtools_api::replay::client("get-resourcetypes");
23030 /// for resource_type in client.resource_types().list()? {
23031 /// println!("{}", resource_type.name);
23032 /// }
23033 /// # Ok(())
23034 /// # }
23035 /// ```
23036 pub fn list(&self) -> Result<Vec<models::ResourceType>> {
23037 let path = "/resourcetypes".to_owned();
23038 let query: Query = Query::new();
23039 self.client.request_data(Method::Get, &path, &query, None)
23040 }
23041
23042 /// Update a resource type
23043 ///
23044 /// `PUT /resourcetypes/{resourceTypeId}`
23045 ///
23046 /// Replaces the resource category’s labels, sort value and campus assignment.
23047 ///
23048 /// # Example
23049 ///
23050 /// ```
23051 /// # use churchtools_api::*;
23052 /// # use churchtools_api::queries::*;
23053 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23054 /// # let client = churchtools_api::replay::client("put-resourcetypes-resourceTypeId");
23055 /// let body = models::ResourceTypeUpdate {
23056 /// name: "Room".into(),
23057 /// name_plural: "Rooms".into(),
23058 /// sort_key: 1,
23059 /// ..Default::default()
23060 /// };
23061 /// let result = client.resource_types().update(2, &body)?;
23062 /// println!("{}", result.name);
23063 /// # Ok(())
23064 /// # }
23065 /// ```
23066 pub fn update(&self, resource_type_id: impl Display, body: &models::ResourceTypeUpdate) -> Result<models::ResourceType> {
23067 let path = format!("/resourcetypes/{}", seg(resource_type_id));
23068 let query: Query = Query::new();
23069 let body = serde_json::to_value(body).expect("request body serializes");
23070 self.client.request_data(Method::Put, &path, &query, Some(&body))
23071 }
23072
23073}
23074
23075/// `client.resources()`
23076#[derive(Clone, Copy)]
23077pub struct ResourcesResource<'a> {
23078 client: &'a Client,
23079}
23080
23081impl<'a> ResourcesResource<'a> {
23082 /// Create a resource
23083 ///
23084 /// `POST /resources`
23085 ///
23086 /// Creates an individual bookable resource. Returns 402 when the licensed resource limit is reached.
23087 ///
23088 /// # Example
23089 ///
23090 /// ```
23091 /// # use churchtools_api::*;
23092 /// # use churchtools_api::queries::*;
23093 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23094 /// # let client = churchtools_api::replay::client("post-resources");
23095 /// let body = models::ResourceCreate {
23096 /// name: "Main Hall".into(),
23097 /// resource_type_id: 2,
23098 /// sort_key: 1,
23099 /// ..Default::default()
23100 /// };
23101 /// let result = client.resources().create(&body)?;
23102 /// println!("{}", result.name);
23103 /// # Ok(())
23104 /// # }
23105 /// ```
23106 pub fn create(&self, body: &models::ResourceCreate) -> Result<models::Resource> {
23107 let path = "/resources".to_owned();
23108 let query: Query = Query::new();
23109 let body = serde_json::to_value(body).expect("request body serializes");
23110 self.client.request_data(Method::Post, &path, &query, Some(&body))
23111 }
23112
23113 /// Delete a resource
23114 ///
23115 /// `DELETE /resources/{resourceId}`
23116 ///
23117 /// Deletes the resource.
23118 ///
23119 /// # Example
23120 ///
23121 /// ```no_run
23122 /// # use churchtools_api::*;
23123 /// # use churchtools_api::queries::*;
23124 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23125 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23126 /// client.resources().delete(7)?;
23127 /// # Ok(())
23128 /// # }
23129 /// ```
23130 pub fn delete(&self, resource_id: impl Display) -> Result<()> {
23131 let path = format!("/resources/{}", seg(resource_id));
23132 let query: Query = Query::new();
23133 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
23134 }
23135
23136 /// Get a resource
23137 ///
23138 /// `GET /resources/{resourceId}`
23139 ///
23140 /// Returns one resource and its booking settings. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its `adminIds`. Use `include[]` to resolve administrators.
23141 ///
23142 /// Use [`Self::get_with`] to pass query parameters.
23143 ///
23144 /// # Example
23145 ///
23146 /// ```
23147 /// # use churchtools_api::*;
23148 /// # use churchtools_api::queries::*;
23149 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23150 /// # let client = churchtools_api::replay::client("get-resources-resourceId");
23151 /// let resource = client.resources().get(7)?;
23152 /// println!("{}", resource.name);
23153 /// # Ok(())
23154 /// # }
23155 /// ```
23156 pub fn get(&self, resource_id: impl Display) -> Result<models::Resource> {
23157 self.get_with(resource_id, &Default::default())
23158 }
23159
23160 /// Get a resource
23161 ///
23162 /// Like [`Self::get`], with query parameters.
23163 ///
23164 /// `GET /resources/{resourceId}`
23165 ///
23166 /// Returns one resource and its booking settings. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its `adminIds`. Use `include[]` to resolve administrators.
23167 pub fn get_with(&self, resource_id: impl Display, query: &GetResourcesResourceIdQuery) -> Result<models::Resource> {
23168 let path = format!("/resources/{}", seg(resource_id));
23169 let query: Query = query.to_query();
23170 self.client.request_data(Method::Get, &path, &query, None)
23171 }
23172
23173 /// Count pending booking occurrences
23174 ///
23175 /// `GET /resources/{resourceId}/statistics`
23176 ///
23177 /// Returns the number of pending booking occurrences from now onward for this resource. Recurring bookings can contribute more than one occurrence. Candidate series are selected using a ten-year lookahead window, then expanded from now without an upper date limit. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its `adminIds`.
23178 ///
23179 /// # Example
23180 ///
23181 /// ```
23182 /// # use churchtools_api::*;
23183 /// # use churchtools_api::queries::*;
23184 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23185 /// # let client = churchtools_api::replay::client("get-resources-resourceId-statistics");
23186 /// let statistic = client.resources().get_statistics(7)?;
23187 /// println!("{}", statistic.num_requested_bookings_in_future);
23188 /// # Ok(())
23189 /// # }
23190 /// ```
23191 pub fn get_statistics(&self, resource_id: impl Display) -> Result<models::ResourceStatistics> {
23192 let path = format!("/resources/{}/statistics", seg(resource_id));
23193 let query: Query = Query::new();
23194 self.client.request_data(Method::Get, &path, &query, None)
23195 }
23196
23197 /// List visible resources
23198 ///
23199 /// `GET /resources`
23200 ///
23201 /// Returns all resources visible to the current user. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its `adminIds`. Use `include[]` to resolve administrators.
23202 ///
23203 /// Use [`Self::list_with`] to pass query parameters.
23204 ///
23205 /// # Example
23206 ///
23207 /// ```
23208 /// # use churchtools_api::*;
23209 /// # use churchtools_api::queries::*;
23210 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23211 /// # let client = churchtools_api::replay::client("get-resources");
23212 /// for resource in client.resources().list()? {
23213 /// println!("{}", resource.name);
23214 /// }
23215 /// # Ok(())
23216 /// # }
23217 /// ```
23218 pub fn list(&self) -> Result<Vec<models::Resource>> {
23219 self.list_with(&Default::default())
23220 }
23221
23222 /// List visible resources
23223 ///
23224 /// Like [`Self::list`], with query parameters.
23225 ///
23226 /// `GET /resources`
23227 ///
23228 /// Returns all resources visible to the current user. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its `adminIds`. Use `include[]` to resolve administrators.
23229 pub fn list_with(&self, query: &GetResourcesQuery) -> Result<Vec<models::Resource>> {
23230 let path = "/resources".to_owned();
23231 let query: Query = query.to_query();
23232 self.client.request_data(Method::Get, &path, &query, None)
23233 }
23234
23235 /// Update a resource
23236 ///
23237 /// `PUT /resources/{resourceId}`
23238 ///
23239 /// Replaces the resource configuration.
23240 ///
23241 /// # Example
23242 ///
23243 /// ```
23244 /// # use churchtools_api::*;
23245 /// # use churchtools_api::queries::*;
23246 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23247 /// # let client = churchtools_api::replay::client("put-resources-resourceId");
23248 /// let body = models::ResourceUpdate {
23249 /// name: "Main Hall".into(),
23250 /// resource_type_id: 2,
23251 /// sort_key: 1,
23252 /// ..Default::default()
23253 /// };
23254 /// let result = client.resources().update(7, &body)?;
23255 /// println!("{}", result.name);
23256 /// # Ok(())
23257 /// # }
23258 /// ```
23259 pub fn update(&self, resource_id: impl Display, body: &models::ResourceUpdate) -> Result<models::Resource> {
23260 let path = format!("/resources/{}", seg(resource_id));
23261 let query: Query = Query::new();
23262 let body = serde_json::to_value(body).expect("request body serializes");
23263 self.client.request_data(Method::Put, &path, &query, Some(&body))
23264 }
23265
23266}
23267
23268/// `client.routines()`
23269#[derive(Clone, Copy)]
23270pub struct RoutinesResource<'a> {
23271 client: &'a Client,
23272}
23273
23274impl<'a> RoutinesResource<'a> {
23275 pub fn runs(&self) -> RoutinesRunsResource<'a> {
23276 RoutinesRunsResource { client: self.client }
23277 }
23278
23279 pub fn steps(&self) -> RoutinesStepsResource<'a> {
23280 RoutinesStepsResource { client: self.client }
23281 }
23282
23283 /// Create group-membership automation
23284 ///
23285 /// `POST /routines`
23286 ///
23287 /// Creates a routine and attaches it to a group, role and optional membership status. Currently domainType must be group_membership. Requires routine administration for the context group. The new definition has no steps; use PATCH to add the complete step tree. isEnabled defaults to false and priority to 0. Creation alone does not explicitly start the worker.
23288 ///
23289 /// # Example
23290 ///
23291 /// ```no_run
23292 /// # use churchtools_api::*;
23293 /// # use churchtools_api::queries::*;
23294 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23295 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23296 /// let body = models::RoutineCreate {
23297 /// domain_context: models::RoutineCreateDomainContext {
23298 /// group_id: 42,
23299 /// group_type_role_id: 42,
23300 /// ..Default::default()
23301 /// },
23302 /// domain_type: "group_membership".into(),
23303 /// name: "Welcome new members".into(),
23304 /// ..Default::default()
23305 /// };
23306 /// let result = client.routines().create(&body)?;
23307 /// println!("{}", result.name);
23308 /// # Ok(())
23309 /// # }
23310 /// ```
23311 pub fn create(&self, body: &models::RoutineCreate) -> Result<models::Routine> {
23312 let path = "/routines".to_owned();
23313 let query: Query = Query::new();
23314 let body = serde_json::to_value(body).expect("request body serializes");
23315 self.client.request_data(Method::Post, &path, &query, Some(&body))
23316 }
23317
23318 /// Delete automation definition
23319 ///
23320 /// `DELETE /routines/{routineId}`
23321 ///
23322 /// Requires routine administration for every associated group. Deletes the routine, its steps and associated action definitions through action cleanup handlers. A missing routine returns 404. This endpoint has no dry-run. Effects already produced by previous runs, such as sent mail or person changes, are not reversed.
23323 ///
23324 /// # Example
23325 ///
23326 /// ```no_run
23327 /// # use churchtools_api::*;
23328 /// # use churchtools_api::queries::*;
23329 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23330 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23331 /// client.routines().delete(9)?;
23332 /// # Ok(())
23333 /// # }
23334 /// ```
23335 pub fn delete(&self, routine_id: impl Display) -> Result<()> {
23336 let path = format!("/routines/{}", seg(routine_id));
23337 let query: Query = Query::new();
23338 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
23339 }
23340
23341 /// Process pending automation runs
23342 ///
23343 /// `POST /routines/execute`
23344 ///
23345 /// Triggers the shared routine worker for pending ready runs of enabled routines. Requires authentication; this controller has no additional routine/group authorization check. Processes batches of up to 25 runs and schedules another worker when a batch is full. A recent worker marker or ongoing bulk processing can skip execution while still returning 204. This is a global processing trigger, not a request to execute one selected routine or a completion report.
23346 ///
23347 /// # Example
23348 ///
23349 /// ```no_run
23350 /// # use churchtools_api::*;
23351 /// # use churchtools_api::queries::*;
23352 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23353 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23354 /// client.routines().execute()?;
23355 /// # Ok(())
23356 /// # }
23357 /// ```
23358 pub fn execute(&self) -> Result<()> {
23359 let path = "/routines/execute".to_owned();
23360 let query: Query = Query::new();
23361 self.client.request(Method::Post, &path, &query, None).map(|_| ())
23362 }
23363
23364 /// Get automation definition
23365 ///
23366 /// `GET /routines/{routineId}`
23367 ///
23368 /// Requires routine administration for every associated group. Returns the definition and nested step tree, including disabled steps. A routine with no associated domain context is not visible through this endpoint. Action data is expanded for clients, including stored email/follow-up definitions. Run progress is available separately from /runs.
23369 ///
23370 /// # Example
23371 ///
23372 /// ```
23373 /// # use churchtools_api::*;
23374 /// # use churchtools_api::queries::*;
23375 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23376 /// # let client = churchtools_api::replay::client("get-routines-routineId");
23377 /// let routine = client.routines().get(9)?;
23378 /// println!("{}", routine.name);
23379 /// # Ok(())
23380 /// # }
23381 /// ```
23382 pub fn get(&self, routine_id: impl Display) -> Result<models::Routine> {
23383 let path = format!("/routines/{}", seg(routine_id));
23384 let query: Query = Query::new();
23385 self.client.request_data(Method::Get, &path, &query, None)
23386 }
23387
23388 /// List visible automation definitions
23389 ///
23390 /// `GET /routines`
23391 ///
23392 /// A routine is an automation definition attached to a domain context (currently a group membership role/status). Each matching membership can have its own run and progress. Lists only routines with at least one domain attachment for which the caller can administer routines in every associated group. Includes enabled and disabled definitions with nested step trees; no pagination or explicit sort order. meta.count counts the returned routines.
23393 ///
23394 /// Use [`Self::list_with`] to pass query parameters.
23395 ///
23396 /// # Example
23397 ///
23398 /// ```
23399 /// # use churchtools_api::*;
23400 /// # use churchtools_api::queries::*;
23401 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23402 /// # let client = churchtools_api::replay::client("get-routines");
23403 /// for routine in client.routines().list()? {
23404 /// println!("{}", routine.name);
23405 /// }
23406 /// # Ok(())
23407 /// # }
23408 /// ```
23409 pub fn list(&self) -> Result<Vec<models::Routine>> {
23410 self.list_with(&Default::default())
23411 }
23412
23413 /// List visible automation definitions
23414 ///
23415 /// Like [`Self::list`], with query parameters.
23416 ///
23417 /// `GET /routines`
23418 ///
23419 /// A routine is an automation definition attached to a domain context (currently a group membership role/status). Each matching membership can have its own run and progress. Lists only routines with at least one domain attachment for which the caller can administer routines in every associated group. Includes enabled and disabled definitions with nested step trees; no pagination or explicit sort order. meta.count counts the returned routines.
23420 pub fn list_with(&self, query: &GetRoutinesQuery) -> Result<Vec<models::Routine>> {
23421 let path = "/routines".to_owned();
23422 let query: Query = query.to_query();
23423 self.client.request_data(Method::Get, &path, &query, None)
23424 }
23425
23426 /// Update automation and reposition runs
23427 ///
23428 /// `PATCH /routines/{routineId}`
23429 ///
23430 /// Requires routine administration for every associated group. Partially updates definition fields. Supplied steps replaces the entire step tree: keep id to update an existing step, omit id to create one; an existing step’s actionKey cannot change. Omitted steps are deleted, but affected runs must be repositioned or the operation returns 422. restart/finish and per-step reposition accept source step IDs or not-started/started/finished run buckets. Repeat loops may occur only at root level, must contain a waiting action, and an unbounded loop must be last. Destructive membership actions must be last. dry_run=true validates input and permissions, returns 204 and skips persistence; persistence-only consistency checks can still fail on the real update. Enabling, changing steps or repositioning runs can immediately trigger pending execution beyond this routine.
23431 ///
23432 /// Use [`Self::patch_with`] to pass query parameters.
23433 ///
23434 /// # Example
23435 ///
23436 /// ```no_run
23437 /// # use churchtools_api::*;
23438 /// # use churchtools_api::queries::*;
23439 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23440 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23441 /// let body = models::RoutineUpdate {
23442 /// name: Some("Welcome new members".into()),
23443 /// ..Default::default()
23444 /// };
23445 /// let result = client.routines().patch(9, &body)?;
23446 /// println!("{:?}", result);
23447 /// # Ok(())
23448 /// # }
23449 /// ```
23450 pub fn patch(&self, routine_id: impl Display, body: &models::RoutineUpdate) -> Result<Option<models::Routine>> {
23451 self.patch_with(routine_id, &Default::default(), body)
23452 }
23453
23454 /// Update automation and reposition runs
23455 ///
23456 /// Like [`Self::patch`], with query parameters.
23457 ///
23458 /// `PATCH /routines/{routineId}`
23459 ///
23460 /// Requires routine administration for every associated group. Partially updates definition fields. Supplied steps replaces the entire step tree: keep id to update an existing step, omit id to create one; an existing step’s actionKey cannot change. Omitted steps are deleted, but affected runs must be repositioned or the operation returns 422. restart/finish and per-step reposition accept source step IDs or not-started/started/finished run buckets. Repeat loops may occur only at root level, must contain a waiting action, and an unbounded loop must be last. Destructive membership actions must be last. dry_run=true validates input and permissions, returns 204 and skips persistence; persistence-only consistency checks can still fail on the real update. Enabling, changing steps or repositioning runs can immediately trigger pending execution beyond this routine.
23461 pub fn patch_with(&self, routine_id: impl Display, query: &PatchRoutinesRoutineIdQuery, body: &models::RoutineUpdate) -> Result<Option<models::Routine>> {
23462 let path = format!("/routines/{}", seg(routine_id));
23463 let query: Query = query.to_query();
23464 let body = serde_json::to_value(body).expect("request body serializes");
23465 self.client.request_data(Method::Patch, &path, &query, Some(&body))
23466 }
23467
23468}
23469
23470/// `client.routines().runs()`
23471#[derive(Clone, Copy)]
23472pub struct RoutinesRunsResource<'a> {
23473 client: &'a Client,
23474}
23475
23476impl<'a> RoutinesRunsResource<'a> {
23477 pub fn bulk(&self) -> RoutinesRunsBulkResource<'a> {
23478 RoutinesRunsBulkResource { client: self.client }
23479 }
23480
23481 /// Apply action to an automation run
23482 ///
23483 /// `POST /routines/{routineId}/runs/{runId}/{runAction}`
23484 ///
23485 /// Requires routine administration for every associated group. Actions pause, resume, restart-routine, restart-step, skip-step and update change run state and then invoke the worker, so the returned status may already reflect further execution. For update, supply at most one of currentIteration and waitingSince. currentIteration=0 is ignored by the current implementation; other integers have no minimum constraint. waitingSince is stored as a calendar date. A state change incompatible with the current step can return 422. Use run IDs belonging to the route routine; the current backend authorizes routineId separately from the run lookup.
23486 ///
23487 /// # Example
23488 ///
23489 /// ```no_run
23490 /// # use churchtools_api::*;
23491 /// # use churchtools_api::queries::*;
23492 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23493 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23494 /// let body = models::RoutineRunUpdate {
23495 /// current_iteration: Some(42),
23496 /// ..Default::default()
23497 /// };
23498 /// let result = client.routines().runs().create(9, 16, "pause", &body)?;
23499 /// println!("{:?}", result.id);
23500 /// # Ok(())
23501 /// # }
23502 /// ```
23503 pub fn create(&self, routine_id: impl Display, run_id: impl Display, run_action: impl Display, body: &models::RoutineRunUpdate) -> Result<models::RoutineRun> {
23504 let path = format!("/routines/{}/runs/{}/{}", seg(routine_id), seg(run_id), seg(run_action));
23505 let query: Query = Query::new();
23506 let body = serde_json::to_value(body).expect("request body serializes");
23507 self.client.request_data(Method::Post, &path, &query, Some(&body))
23508 }
23509
23510 /// List automation runs and potential runs
23511 ///
23512 /// `GET /routines/{routineId}/runs`
23513 ///
23514 /// Requires routine administration for every associated group. Lists persisted runs with isReady=true for this routine. with_potential_domain_objects=true appends eligible memberships without a run as not-started entries with id=null and meta=null; these are previews, not newly persisted runs. No pagination or explicit ordering. include\[\]=domainObject adds the resolved membership domain object or null if it cannot be resolved. Loop iteration and wait-start date are included only when available; terminal runs omit them.
23515 ///
23516 /// Use [`Self::list_with`] to pass query parameters.
23517 ///
23518 /// # Example
23519 ///
23520 /// ```
23521 /// # use churchtools_api::*;
23522 /// # use churchtools_api::queries::*;
23523 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23524 /// # let client = churchtools_api::replay::client("get-routines-routineId-runs");
23525 /// for run in client.routines().runs().list(9)? {
23526 /// println!("{:?}", run.id);
23527 /// }
23528 /// # Ok(())
23529 /// # }
23530 /// ```
23531 pub fn list(&self, routine_id: impl Display) -> Result<Vec<models::RoutineRun>> {
23532 self.list_with(routine_id, &Default::default())
23533 }
23534
23535 /// List automation runs and potential runs
23536 ///
23537 /// Like [`Self::list`], with query parameters.
23538 ///
23539 /// `GET /routines/{routineId}/runs`
23540 ///
23541 /// Requires routine administration for every associated group. Lists persisted runs with isReady=true for this routine. with_potential_domain_objects=true appends eligible memberships without a run as not-started entries with id=null and meta=null; these are previews, not newly persisted runs. No pagination or explicit ordering. include\[\]=domainObject adds the resolved membership domain object or null if it cannot be resolved. Loop iteration and wait-start date are included only when available; terminal runs omit them.
23542 pub fn list_with(&self, routine_id: impl Display, query: &GetRoutinesRoutineIdRunsQuery) -> Result<Vec<models::RoutineRun>> {
23543 let path = format!("/routines/{}/runs", seg(routine_id));
23544 let query: Query = query.to_query();
23545 self.client.request_data(Method::Get, &path, &query, None)
23546 }
23547
23548}
23549
23550/// `client.routines().runs().bulk()`
23551#[derive(Clone, Copy)]
23552pub struct RoutinesRunsBulkResource<'a> {
23553 client: &'a Client,
23554}
23555
23556impl<'a> RoutinesRunsBulkResource<'a> {
23557 /// Apply action to multiple automation runs
23558 ///
23559 /// `POST /routines/{routineId}/runs/bulk/{runAction}`
23560 ///
23561 /// Requires routine administration for every associated group. Actions pause, resume, restart-routine, restart-step, skip-step and update change run state and then invoke the worker, so the returned status may already reflect further execution. runIds is a nonempty list. Each run is processed in a separate transaction; earlier runs may remain changed when a later one fails. The bulk endpoint validates no currentIteration/waitingSince fields, so update cannot change those values here. Use run IDs belonging to the route routine; the current backend authorizes routineId separately from the run lookup.
23562 ///
23563 /// # Example
23564 ///
23565 /// ```no_run
23566 /// # use churchtools_api::*;
23567 /// # use churchtools_api::queries::*;
23568 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23569 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23570 /// let body = models::RoutineRunBulkUpdate {
23571 /// run_ids: vec![42],
23572 /// ..Default::default()
23573 /// };
23574 /// for bulk in client.routines().runs().bulk().create(9, "pause", &body)? {
23575 /// println!("{:?}", bulk.id);
23576 /// }
23577 /// # Ok(())
23578 /// # }
23579 /// ```
23580 pub fn create(&self, routine_id: impl Display, run_action: impl Display, body: &models::RoutineRunBulkUpdate) -> Result<Vec<models::RoutineRun>> {
23581 let path = format!("/routines/{}/runs/bulk/{}", seg(routine_id), seg(run_action));
23582 let query: Query = Query::new();
23583 let body = serde_json::to_value(body).expect("request body serializes");
23584 self.client.request_data(Method::Post, &path, &query, Some(&body))
23585 }
23586
23587}
23588
23589/// `client.routines().steps()`
23590#[derive(Clone, Copy)]
23591pub struct RoutinesStepsResource<'a> {
23592 client: &'a Client,
23593}
23594
23595impl<'a> RoutinesStepsResource<'a> {
23596 /// Validate one automation action
23597 ///
23598 /// `POST /routines/{routineId}/steps/validate`
23599 ///
23600 /// Requires routine administration for every associated group. Validates actionKey/actionData and checks action execution permission in the routine context without creating or executing a step. For special:repeat, count is optional (unbounded) and otherwise at least 1. special:wait requires exactly one of untilDate or duration, with at least one positive numDays/numMonths/numYears. This endpoint does not validate a complete step tree, nesting, ordering or whether a repeat loop includes a delay; PATCH applies those checks separately. Unknown action keys currently produce a server error.
23601 ///
23602 /// # Example
23603 ///
23604 /// ```no_run
23605 /// # use churchtools_api::*;
23606 /// # use churchtools_api::queries::*;
23607 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23608 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23609 /// let body = models::RoutineActionValidation {
23610 /// action_key: "special:wait".into(),
23611 /// ..Default::default()
23612 /// };
23613 /// client.routines().steps().validate(42, &body)?;
23614 /// # Ok(())
23615 /// # }
23616 /// ```
23617 pub fn validate(&self, routine_id: impl Display, body: &models::RoutineActionValidation) -> Result<()> {
23618 let path = format!("/routines/{}/steps/validate", seg(routine_id));
23619 let query: Query = Query::new();
23620 let body = serde_json::to_value(body).expect("request body serializes");
23621 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
23622 }
23623
23624}
23625
23626/// `client.saml()`
23627#[derive(Clone, Copy)]
23628pub struct SamlResource<'a> {
23629 client: &'a Client,
23630}
23631
23632impl<'a> SamlResource<'a> {
23633 /// Consume a SAML authentication response
23634 ///
23635 /// `POST /saml/acs`
23636 ///
23637 /// Legacy SAML URL. Resolves the single configured SAML provider; with zero or multiple SAML providers it cannot resolve a provider. Prefer the provider-specific /externallogins/{externalLoginId}/saml/acs URL. Public assertion-consumer callback for the identity provider’s form POST. Validates the SAML response and maps the external identity to a ChurchTools person. Successful login redirects to the stored destination or the installation landing page; identities needing account linking are redirected into that flow instead. Normal login requires a visible provider. Administrator test flows can use hidden providers and return a small HTML page that closes the popup, without logging the tested identity in. Test failures can also return that 200 HTML page: read the separate test-result endpoint for the outcome. A pending administrator test with missing RelayState also returns the popup page. Normal failures return 401 as localized text or an HTML error page, never the usual JSON error envelope.
23638 ///
23639 /// # Example
23640 ///
23641 /// ```no_run
23642 /// # use churchtools_api::*;
23643 /// # use churchtools_api::queries::*;
23644 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23645 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23646 /// let data = client.saml().acs()?;
23647 /// std::fs::write("ergebnis.bin", &data)?;
23648 /// # Ok(())
23649 /// # }
23650 /// ```
23651 pub fn acs(&self) -> Result<Vec<u8>> {
23652 let path = "/saml/acs".to_owned();
23653 let query: Query = Query::new();
23654 self.client.request(Method::Post, &path, &query, None)
23655 }
23656
23657 /// Start a SAML browser login
23658 ///
23659 /// `GET /saml/login`
23660 ///
23661 /// Legacy SAML URL. Resolves the single configured SAML provider; with zero or multiple SAML providers it cannot resolve a provider. Prefer the provider-specific /externallogins/{externalLoginId}/saml/login URL. Starts the browser-based SAML login for a visible SAML external-login provider. Redirects to the configured identity provider with a SAML authentication request and an opaque RelayState. An optional post-login redirect is saved in the browser session, so the callback must retain that session. Only absolute URLs on this installation’s origin and within its base path are accepted; invalid redirect values are ignored. Missing, hidden or invalid providers and other setup failures produce a localized 404 response. No login or JSON access token is returned by this endpoint itself.
23662 ///
23663 /// Use [`Self::get_login_with`] to pass query parameters.
23664 ///
23665 /// # Example
23666 ///
23667 /// ```no_run
23668 /// # use churchtools_api::*;
23669 /// # use churchtools_api::queries::*;
23670 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23671 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23672 /// client.saml().get_login()?;
23673 /// # Ok(())
23674 /// # }
23675 /// ```
23676 pub fn get_login(&self) -> Result<()> {
23677 self.get_login_with(&Default::default())
23678 }
23679
23680 /// Start a SAML browser login
23681 ///
23682 /// Like [`Self::get_login`], with query parameters.
23683 ///
23684 /// `GET /saml/login`
23685 ///
23686 /// Legacy SAML URL. Resolves the single configured SAML provider; with zero or multiple SAML providers it cannot resolve a provider. Prefer the provider-specific /externallogins/{externalLoginId}/saml/login URL. Starts the browser-based SAML login for a visible SAML external-login provider. Redirects to the configured identity provider with a SAML authentication request and an opaque RelayState. An optional post-login redirect is saved in the browser session, so the callback must retain that session. Only absolute URLs on this installation’s origin and within its base path are accepted; invalid redirect values are ignored. Missing, hidden or invalid providers and other setup failures produce a localized 404 response. No login or JSON access token is returned by this endpoint itself.
23687 pub fn get_login_with(&self, query: &GetSamlLoginQuery) -> Result<()> {
23688 let path = "/saml/login".to_owned();
23689 let query: Query = query.to_query();
23690 self.client.request(Method::Get, &path, &query, None).map(|_| ())
23691 }
23692
23693 /// Get SAML service-provider metadata
23694 ///
23695 /// `GET /saml/metadata`
23696 ///
23697 /// Legacy SAML URL. Resolves the single configured SAML provider; with zero or multiple SAML providers it cannot resolve a provider. Prefer the provider-specific /externallogins/{externalLoginId}/saml/metadata URL. Returns the XML metadata that an identity-provider administrator uses to configure ChurchTools as a SAML service provider. The entity ID, assertion-consumer URL and logout URL refer to this external-login provider. This endpoint is public and also works for a hidden provider, allowing setup before enabling login. Any provider/configuration/metadata-generation failure is returned as 404 with localized text, not a JSON error envelope.
23698 ///
23699 /// # Example
23700 ///
23701 /// ```no_run
23702 /// # use churchtools_api::*;
23703 /// # use churchtools_api::queries::*;
23704 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23705 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23706 /// let data = client.saml().get_metadata()?;
23707 /// std::fs::write("ergebnis.bin", &data)?;
23708 /// # Ok(())
23709 /// # }
23710 /// ```
23711 pub fn get_metadata(&self) -> Result<Vec<u8>> {
23712 let path = "/saml/metadata".to_owned();
23713 let query: Query = Query::new();
23714 self.client.request(Method::Get, &path, &query, None)
23715 }
23716
23717}
23718
23719/// `client.search()`
23720#[derive(Clone, Copy)]
23721pub struct SearchResource<'a> {
23722 client: &'a Client,
23723}
23724
23725impl<'a> SearchResource<'a> {
23726 /// Global Search
23727 ///
23728 /// `GET /search`
23729 ///
23730 /// Search globally for different or all domain types.
23731 ///
23732 /// # Example
23733 ///
23734 /// ```
23735 /// # use churchtools_api::*;
23736 /// # use churchtools_api::queries::*;
23737 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23738 /// # let client = churchtools_api::replay::client("get-search");
23739 /// let query = GetSearchQuery {
23740 /// query: Some("max".into()),
23741 /// ..Default::default()
23742 /// };
23743 /// for search in client.search().list(&query)? {
23744 /// println!("{}", search.r#type);
23745 /// }
23746 /// # Ok(())
23747 /// # }
23748 /// ```
23749 pub fn list(&self, query: &GetSearchQuery) -> Result<Vec<models::GetSearchDataItem>> {
23750 let path = "/search".to_owned();
23751 let query: Query = query.to_query();
23752 self.client.request_data(Method::Get, &path, &query, None)
23753 }
23754
23755}
23756
23757/// `client.security_levels()`
23758#[derive(Clone, Copy)]
23759pub struct SecurityLevelsResource<'a> {
23760 client: &'a Client,
23761}
23762
23763impl<'a> SecurityLevelsResource<'a> {
23764 /// Create a new security Level
23765 ///
23766 /// `POST /securitylevels/{id}`
23767 ///
23768 /// Create a new Security level
23769 ///
23770 /// # Example
23771 ///
23772 /// ```no_run
23773 /// # use churchtools_api::*;
23774 /// # use churchtools_api::queries::*;
23775 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23776 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23777 /// let body = models::PostSecuritylevelsIdBody {
23778 /// name: Some("Hauskreis Nord".into()),
23779 /// ..Default::default()
23780 /// };
23781 /// let result = client.security_levels().create(1, &body)?;
23782 /// println!("{}", result.name);
23783 /// # Ok(())
23784 /// # }
23785 /// ```
23786 pub fn create(&self, id: impl Display, body: &models::PostSecuritylevelsIdBody) -> Result<models::PostSecuritylevelsIdResponse> {
23787 let path = format!("/securitylevels/{}", seg(id));
23788 let query: Query = Query::new();
23789 let body = serde_json::to_value(body).expect("request body serializes");
23790 self.client.request_json(Method::Post, &path, &query, Some(&body))
23791 }
23792
23793 /// Delete the Security Level
23794 ///
23795 /// `DELETE /securitylevels/{id}`
23796 ///
23797 /// Delete a security level
23798 ///
23799 /// Use [`Self::delete_with`] to pass query parameters.
23800 ///
23801 /// # Example
23802 ///
23803 /// ```no_run
23804 /// # use churchtools_api::*;
23805 /// # use churchtools_api::queries::*;
23806 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23807 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23808 /// client.security_levels().delete(1)?;
23809 /// # Ok(())
23810 /// # }
23811 /// ```
23812 pub fn delete(&self, id: impl Display) -> Result<()> {
23813 self.delete_with(id, &Default::default())
23814 }
23815
23816 /// Delete the Security Level
23817 ///
23818 /// Like [`Self::delete`], with query parameters.
23819 ///
23820 /// `DELETE /securitylevels/{id}`
23821 ///
23822 /// Delete a security level
23823 pub fn delete_with(&self, id: impl Display, query: &DeleteSecuritylevelsIdQuery) -> Result<()> {
23824 let path = format!("/securitylevels/{}", seg(id));
23825 let query: Query = query.to_query();
23826 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
23827 }
23828
23829 /// Get a particular security level
23830 ///
23831 /// `GET /securitylevels/{id}`
23832 ///
23833 /// Get a particular Security Level
23834 ///
23835 /// # Example
23836 ///
23837 /// ```
23838 /// # use churchtools_api::*;
23839 /// # use churchtools_api::queries::*;
23840 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23841 /// # let client = churchtools_api::replay::client("get-securitylevels-id");
23842 /// let security_level = client.security_levels().get(1)?;
23843 /// println!("{}", security_level.name);
23844 /// # Ok(())
23845 /// # }
23846 /// ```
23847 pub fn get(&self, id: impl Display) -> Result<models::SecurityLevel> {
23848 let path = format!("/securitylevels/{}", seg(id));
23849 let query: Query = Query::new();
23850 self.client.request_json(Method::Get, &path, &query, None)
23851 }
23852
23853 /// get all securitylevels
23854 ///
23855 /// `GET /securitylevels`
23856 ///
23857 /// # Example
23858 ///
23859 /// ```
23860 /// # use churchtools_api::*;
23861 /// # use churchtools_api::queries::*;
23862 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23863 /// # let client = churchtools_api::replay::client("get-securitylevels");
23864 /// for security_level in client.security_levels().list()? {
23865 /// println!("{}", security_level.name);
23866 /// }
23867 /// # Ok(())
23868 /// # }
23869 /// ```
23870 pub fn list(&self) -> Result<Vec<models::SecurityLevel>> {
23871 let path = "/securitylevels".to_owned();
23872 let query: Query = Query::new();
23873 self.client.request_data(Method::Get, &path, &query, None)
23874 }
23875
23876 /// Update the security level
23877 ///
23878 /// `PATCH /securitylevels/{id}`
23879 ///
23880 /// Change the Security Level
23881 ///
23882 /// Use [`Self::patch_with`] to pass query parameters.
23883 ///
23884 /// # Example
23885 ///
23886 /// ```no_run
23887 /// # use churchtools_api::*;
23888 /// # use churchtools_api::queries::*;
23889 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23890 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23891 /// let body = models::PatchSecuritylevelsIdBody {
23892 /// name: Some("Hauskreis Nord".into()),
23893 /// ..Default::default()
23894 /// };
23895 /// let result = client.security_levels().patch(1, &body)?;
23896 /// println!("{}", result.name);
23897 /// # Ok(())
23898 /// # }
23899 /// ```
23900 pub fn patch(&self, id: impl Display, body: &models::PatchSecuritylevelsIdBody) -> Result<models::PatchSecuritylevelsIdResponse> {
23901 self.patch_with(id, &Default::default(), body)
23902 }
23903
23904 /// Update the security level
23905 ///
23906 /// Like [`Self::patch`], with query parameters.
23907 ///
23908 /// `PATCH /securitylevels/{id}`
23909 ///
23910 /// Change the Security Level
23911 pub fn patch_with(&self, id: impl Display, query: &PatchSecuritylevelsIdQuery, body: &models::PatchSecuritylevelsIdBody) -> Result<models::PatchSecuritylevelsIdResponse> {
23912 let path = format!("/securitylevels/{}", seg(id));
23913 let query: Query = query.to_query();
23914 let body = serde_json::to_value(body).expect("request body serializes");
23915 self.client.request_json(Method::Patch, &path, &query, Some(&body))
23916 }
23917
23918}
23919
23920/// `client.service_groups()`
23921#[derive(Clone, Copy)]
23922pub struct ServiceGroupsResource<'a> {
23923 client: &'a Client,
23924}
23925
23926impl<'a> ServiceGroupsResource<'a> {
23927 /// Create a service group
23928 ///
23929 /// `POST /servicegroups`
23930 ///
23931 /// Creates a reusable service group master-data record. Requires the "edit masterdata" permission for the service planning domain.
23932 ///
23933 /// # Example
23934 ///
23935 /// ```
23936 /// # use churchtools_api::*;
23937 /// # use churchtools_api::queries::*;
23938 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23939 /// # let client = churchtools_api::replay::client("post-servicegroups");
23940 /// let body = models::ServiceGroupCreate {
23941 /// name: "Hauskreis Nord".into(),
23942 /// ..Default::default()
23943 /// };
23944 /// let result = client.service_groups().create(&body)?;
23945 /// println!("{}", result.name);
23946 /// # Ok(())
23947 /// # }
23948 /// ```
23949 pub fn create(&self, body: &models::ServiceGroupCreate) -> Result<models::ServiceGroup> {
23950 let path = "/servicegroups".to_owned();
23951 let query: Query = Query::new();
23952 let body = serde_json::to_value(body).expect("request body serializes");
23953 self.client.request_data(Method::Post, &path, &query, Some(&body))
23954 }
23955
23956 /// Delete a service group
23957 ///
23958 /// `DELETE /servicegroups/{serviceGroupId}`
23959 ///
23960 /// Deletes the service group master-data record through the dependency-aware deletion service. A dependency conflict returns `409`. Requires the "edit masterdata" permission for the service planning domain.
23961 ///
23962 /// # Example
23963 ///
23964 /// ```no_run
23965 /// # use churchtools_api::*;
23966 /// # use churchtools_api::queries::*;
23967 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23968 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
23969 /// client.service_groups().delete(13)?;
23970 /// # Ok(())
23971 /// # }
23972 /// ```
23973 pub fn delete(&self, service_group_id: impl Display) -> Result<()> {
23974 let path = format!("/servicegroups/{}", seg(service_group_id));
23975 let query: Query = Query::new();
23976 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
23977 }
23978
23979 /// Get a service group
23980 ///
23981 /// `GET /servicegroups/{serviceGroupId}`
23982 ///
23983 /// Returns the reusable service group master-data record with the specified ID.
23984 ///
23985 /// # Example
23986 ///
23987 /// ```
23988 /// # use churchtools_api::*;
23989 /// # use churchtools_api::queries::*;
23990 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
23991 /// # let client = churchtools_api::replay::client("get-servicegroups-id");
23992 /// let service_group = client.service_groups().get(13)?;
23993 /// println!("{}", service_group.name);
23994 /// # Ok(())
23995 /// # }
23996 /// ```
23997 pub fn get(&self, service_group_id: impl Display) -> Result<models::ServiceGroup> {
23998 let path = format!("/servicegroups/{}", seg(service_group_id));
23999 let query: Query = Query::new();
24000 self.client.request_data(Method::Get, &path, &query, None)
24001 }
24002
24003 /// Get all service groups
24004 ///
24005 /// `GET /servicegroups`
24006 ///
24007 /// Returns all service groups as an unpaginated list, sorted by `sortKey` and then name, both ascending.
24008 ///
24009 /// # Example
24010 ///
24011 /// ```
24012 /// # use churchtools_api::*;
24013 /// # use churchtools_api::queries::*;
24014 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24015 /// # let client = churchtools_api::replay::client("get-servicegroups");
24016 /// for service_group in client.service_groups().list()? {
24017 /// println!("{}", service_group.name);
24018 /// }
24019 /// # Ok(())
24020 /// # }
24021 /// ```
24022 pub fn list(&self) -> Result<Vec<models::ServiceGroup>> {
24023 let path = "/servicegroups".to_owned();
24024 let query: Query = Query::new();
24025 self.client.request_data(Method::Get, &path, &query, None)
24026 }
24027
24028 /// Update a service group
24029 ///
24030 /// `PUT /servicegroups/{serviceGroupId}`
24031 ///
24032 /// Requires the "edit masterdata" permission for the service planning domain.
24033 ///
24034 /// # Example
24035 ///
24036 /// ```
24037 /// # use churchtools_api::*;
24038 /// # use churchtools_api::queries::*;
24039 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24040 /// # let client = churchtools_api::replay::client("put-servicegroups-id");
24041 /// let body = models::ServiceGroupUpdate {
24042 /// name: "Hauskreis Nord".into(),
24043 /// ..Default::default()
24044 /// };
24045 /// let result = client.service_groups().update(13, &body)?;
24046 /// println!("{}", result.name);
24047 /// # Ok(())
24048 /// # }
24049 /// ```
24050 pub fn update(&self, service_group_id: impl Display, body: &models::ServiceGroupUpdate) -> Result<models::ServiceGroup> {
24051 let path = format!("/servicegroups/{}", seg(service_group_id));
24052 let query: Query = Query::new();
24053 let body = serde_json::to_value(body).expect("request body serializes");
24054 self.client.request_data(Method::Put, &path, &query, Some(&body))
24055 }
24056
24057}
24058
24059/// `client.services()`
24060#[derive(Clone, Copy)]
24061pub struct ServicesResource<'a> {
24062 client: &'a Client,
24063}
24064
24065impl<'a> ServicesResource<'a> {
24066 /// Create a service
24067 ///
24068 /// `POST /services`
24069 ///
24070 /// Creates a reusable service master-data record. Requires the "edit masterdata" permission for the service planning domain.
24071 ///
24072 /// # Example
24073 ///
24074 /// ```
24075 /// # use churchtools_api::*;
24076 /// # use churchtools_api::queries::*;
24077 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24078 /// # let client = churchtools_api::replay::client("post-services");
24079 /// let body = models::ServiceCreate {
24080 /// name: "Hauskreis Nord".into(),
24081 /// service_group_id: 42,
24082 /// ..Default::default()
24083 /// };
24084 /// let result = client.services().create(&body)?;
24085 /// println!("{}", result.name);
24086 /// # Ok(())
24087 /// # }
24088 /// ```
24089 pub fn create(&self, body: &models::ServiceCreate) -> Result<models::Service> {
24090 let path = "/services".to_owned();
24091 let query: Query = Query::new();
24092 let body = serde_json::to_value(body).expect("request body serializes");
24093 self.client.request_data(Method::Post, &path, &query, Some(&body))
24094 }
24095
24096 /// Delete a service
24097 ///
24098 /// `DELETE /services/{serviceId}`
24099 ///
24100 /// Deletes the service master-data record through the dependency-aware deletion service. A dependency conflict returns `409`. Requires the "edit masterdata" permission for the service planning domain.
24101 ///
24102 /// # Example
24103 ///
24104 /// ```no_run
24105 /// # use churchtools_api::*;
24106 /// # use churchtools_api::queries::*;
24107 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24108 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24109 /// client.services().delete(2)?;
24110 /// # Ok(())
24111 /// # }
24112 /// ```
24113 pub fn delete(&self, service_id: impl Display) -> Result<()> {
24114 let path = format!("/services/{}", seg(service_id));
24115 let query: Query = Query::new();
24116 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
24117 }
24118
24119 /// Get a service
24120 ///
24121 /// `GET /services/{serviceId}`
24122 ///
24123 /// Returns the reusable service master-data record with the specified ID.
24124 ///
24125 /// # Example
24126 ///
24127 /// ```
24128 /// # use churchtools_api::*;
24129 /// # use churchtools_api::queries::*;
24130 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24131 /// # let client = churchtools_api::replay::client("get-services-id");
24132 /// let service = client.services().get(2)?;
24133 /// println!("{}", service.name);
24134 /// # Ok(())
24135 /// # }
24136 /// ```
24137 pub fn get(&self, service_id: impl Display) -> Result<models::Service> {
24138 let path = format!("/services/{}", seg(service_id));
24139 let query: Query = Query::new();
24140 self.client.request_data(Method::Get, &path, &query, None)
24141 }
24142
24143 /// Get all services
24144 ///
24145 /// `GET /services`
24146 ///
24147 /// Returns all services as an unpaginated list, sorted by `sortKey` and then name, both ascending.
24148 ///
24149 /// # Example
24150 ///
24151 /// ```
24152 /// # use churchtools_api::*;
24153 /// # use churchtools_api::queries::*;
24154 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24155 /// # let client = churchtools_api::replay::client("get-services");
24156 /// for service in client.services().list()? {
24157 /// println!("{}", service.name);
24158 /// }
24159 /// # Ok(())
24160 /// # }
24161 /// ```
24162 pub fn list(&self) -> Result<Vec<models::Service>> {
24163 let path = "/services".to_owned();
24164 let query: Query = Query::new();
24165 self.client.request_data(Method::Get, &path, &query, None)
24166 }
24167
24168 /// Update a service
24169 ///
24170 /// `PUT /services/{serviceId}`
24171 ///
24172 /// Update a service role. Requires the "edit masterdata" permission for the service planning domain.
24173 ///
24174 /// # Example
24175 ///
24176 /// ```
24177 /// # use churchtools_api::*;
24178 /// # use churchtools_api::queries::*;
24179 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24180 /// # let client = churchtools_api::replay::client("put-services-id");
24181 /// let body = models::ServiceUpdate {
24182 /// name: "Hauskreis Nord".into(),
24183 /// service_group_id: 42,
24184 /// ..Default::default()
24185 /// };
24186 /// let result = client.services().update(2, &body)?;
24187 /// println!("{}", result.name);
24188 /// # Ok(())
24189 /// # }
24190 /// ```
24191 pub fn update(&self, service_id: impl Display, body: &models::ServiceUpdate) -> Result<models::Service> {
24192 let path = format!("/services/{}", seg(service_id));
24193 let query: Query = Query::new();
24194 let body = serde_json::to_value(body).expect("request body serializes");
24195 self.client.request_data(Method::Put, &path, &query, Some(&body))
24196 }
24197
24198}
24199
24200/// `client.simulate()`
24201#[derive(Clone, Copy)]
24202pub struct SimulateResource<'a> {
24203 client: &'a Client,
24204}
24205
24206impl<'a> SimulateResource<'a> {
24207 /// Start person simulation
24208 ///
24209 /// `POST /simulate`
24210 ///
24211 /// Starts simulating another person. The current user's session will act as the specified person until the simulation is stopped.
24212 ///
24213 /// # Example
24214 ///
24215 /// ```no_run
24216 /// # use churchtools_api::*;
24217 /// # use churchtools_api::queries::*;
24218 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24219 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24220 /// let body = models::PostSimulateBody {
24221 /// person_id: 42,
24222 /// ..Default::default()
24223 /// };
24224 /// client.simulate().create(&body)?;
24225 /// # Ok(())
24226 /// # }
24227 /// ```
24228 pub fn create(&self, body: &models::PostSimulateBody) -> Result<()> {
24229 let path = "/simulate".to_owned();
24230 let query: Query = Query::new();
24231 let body = serde_json::to_value(body).expect("request body serializes");
24232 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
24233 }
24234
24235 /// Stop person simulation
24236 ///
24237 /// `DELETE /simulate`
24238 ///
24239 /// Stops the current person simulation and returns a redirect path to navigate back.
24240 ///
24241 /// # Example
24242 ///
24243 /// ```no_run
24244 /// # use churchtools_api::*;
24245 /// # use churchtools_api::queries::*;
24246 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24247 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24248 /// let simulate = client.simulate().delete()?;
24249 /// println!("{}", simulate.redirect);
24250 /// # Ok(())
24251 /// # }
24252 /// ```
24253 pub fn delete(&self) -> Result<models::DeleteSimulateData> {
24254 let path = "/simulate".to_owned();
24255 let query: Query = Query::new();
24256 self.client.request_data(Method::Delete, &path, &query, None)
24257 }
24258
24259}
24260
24261/// `client.song()`
24262#[derive(Clone, Copy)]
24263pub struct SongResource<'a> {
24264 client: &'a Client,
24265}
24266
24267impl<'a> SongResource<'a> {
24268 pub fn categories(&self) -> SongCategoriesResource<'a> {
24269 SongCategoriesResource { client: self.client }
24270 }
24271
24272 pub fn sources(&self) -> SongSourcesResource<'a> {
24273 SongSourcesResource { client: self.client }
24274 }
24275
24276}
24277
24278/// `client.song().categories()`
24279#[derive(Clone, Copy)]
24280pub struct SongCategoriesResource<'a> {
24281 client: &'a Client,
24282}
24283
24284impl<'a> SongCategoriesResource<'a> {
24285 /// Create a song category
24286 ///
24287 /// `POST /song/categories`
24288 ///
24289 /// Creates a song category. Requires `edit masterdata` in churchservice. A supplied campus ID must exist.
24290 ///
24291 /// # Example
24292 ///
24293 /// ```
24294 /// # use churchtools_api::*;
24295 /// # use churchtools_api::queries::*;
24296 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24297 /// # let client = churchtools_api::replay::client("post-song-categories");
24298 /// let body = models::SongCategoryCreate {
24299 /// name: "Worship".into(),
24300 /// ..Default::default()
24301 /// };
24302 /// let result = client.song().categories().create(&body)?;
24303 /// println!("{}", result.name);
24304 /// # Ok(())
24305 /// # }
24306 /// ```
24307 pub fn create(&self, body: &models::SongCategoryCreate) -> Result<models::SongCategory> {
24308 let path = "/song/categories".to_owned();
24309 let query: Query = Query::new();
24310 let body = serde_json::to_value(body).expect("request body serializes");
24311 self.client.request_data(Method::Post, &path, &query, Some(&body))
24312 }
24313
24314 /// Delete song category
24315 ///
24316 /// `DELETE /song/categories/{songCategoryId}`
24317 ///
24318 /// Deletes the song category. Requires `edit masterdata` in churchservice. Songs referencing this category prevent deletion.
24319 ///
24320 /// # Example
24321 ///
24322 /// ```no_run
24323 /// # use churchtools_api::*;
24324 /// # use churchtools_api::queries::*;
24325 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24326 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24327 /// client.song().categories().delete(1)?;
24328 /// # Ok(())
24329 /// # }
24330 /// ```
24331 pub fn delete(&self, song_category_id: impl Display) -> Result<()> {
24332 let path = format!("/song/categories/{}", seg(song_category_id));
24333 let query: Query = Query::new();
24334 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
24335 }
24336
24337 /// Get a song category by ID
24338 ///
24339 /// `GET /song/categories/{songCategoryId}`
24340 ///
24341 /// Returns one song category without an additional record-level visibility check.
24342 ///
24343 /// # Example
24344 ///
24345 /// ```
24346 /// # use churchtools_api::*;
24347 /// # use churchtools_api::queries::*;
24348 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24349 /// # let client = churchtools_api::replay::client("get-song-categories-id");
24350 /// let category = client.song().categories().get(1)?;
24351 /// println!("{}", category.name);
24352 /// # Ok(())
24353 /// # }
24354 /// ```
24355 pub fn get(&self, song_category_id: impl Display) -> Result<models::SongCategory> {
24356 let path = format!("/song/categories/{}", seg(song_category_id));
24357 let query: Query = Query::new();
24358 self.client.request_data(Method::Get, &path, &query, None)
24359 }
24360
24361 /// Get all song categories
24362 ///
24363 /// `GET /song/categories`
24364 ///
24365 /// Returns all song categories ordered by sortKey ascending and then name ascending. The list is unpaginated and has no visibility or campus filter.
24366 ///
24367 /// # Example
24368 ///
24369 /// ```
24370 /// # use churchtools_api::*;
24371 /// # use churchtools_api::queries::*;
24372 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24373 /// # let client = churchtools_api::replay::client("get-song-categories");
24374 /// for category in client.song().categories().list()? {
24375 /// println!("{}", category.name);
24376 /// }
24377 /// # Ok(())
24378 /// # }
24379 /// ```
24380 pub fn list(&self) -> Result<Vec<models::SongCategory>> {
24381 let path = "/song/categories".to_owned();
24382 let query: Query = Query::new();
24383 self.client.request_data(Method::Get, &path, &query, None)
24384 }
24385
24386 /// Update song category
24387 ///
24388 /// `PUT /song/categories/{songCategoryId}`
24389 ///
24390 /// Replaces the song category. Requires `edit masterdata` in churchservice. A supplied campus ID must exist.
24391 ///
24392 /// # Example
24393 ///
24394 /// ```
24395 /// # use churchtools_api::*;
24396 /// # use churchtools_api::queries::*;
24397 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24398 /// # let client = churchtools_api::replay::client("put-song-categories-id");
24399 /// let body = models::SongCategoryUpdate {
24400 /// name: "Worship".into(),
24401 /// ..Default::default()
24402 /// };
24403 /// let result = client.song().categories().update(1, &body)?;
24404 /// println!("{}", result.name);
24405 /// # Ok(())
24406 /// # }
24407 /// ```
24408 pub fn update(&self, song_category_id: impl Display, body: &models::SongCategoryUpdate) -> Result<models::SongCategory> {
24409 let path = format!("/song/categories/{}", seg(song_category_id));
24410 let query: Query = Query::new();
24411 let body = serde_json::to_value(body).expect("request body serializes");
24412 self.client.request_data(Method::Put, &path, &query, Some(&body))
24413 }
24414
24415}
24416
24417/// `client.song().sources()`
24418#[derive(Clone, Copy)]
24419pub struct SongSourcesResource<'a> {
24420 client: &'a Client,
24421}
24422
24423impl<'a> SongSourcesResource<'a> {
24424 /// Create a song source
24425 ///
24426 /// `POST /song/sources`
24427 ///
24428 /// Creates a song source. Requires `edit masterdata` in churchservice.
24429 ///
24430 /// # Example
24431 ///
24432 /// ```
24433 /// # use churchtools_api::*;
24434 /// # use churchtools_api::queries::*;
24435 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24436 /// # let client = churchtools_api::replay::client("post-song-sources");
24437 /// let body = models::SongSourceCreate {
24438 /// name: "Community hymnal".into(),
24439 /// ..Default::default()
24440 /// };
24441 /// let result = client.song().sources().create(&body)?;
24442 /// println!("{}", result.name);
24443 /// # Ok(())
24444 /// # }
24445 /// ```
24446 pub fn create(&self, body: &models::SongSourceCreate) -> Result<models::SongSource> {
24447 let path = "/song/sources".to_owned();
24448 let query: Query = Query::new();
24449 let body = serde_json::to_value(body).expect("request body serializes");
24450 self.client.request_data(Method::Post, &path, &query, Some(&body))
24451 }
24452
24453 /// Delete song source
24454 ///
24455 /// `DELETE /song/sources/{songSourceId}`
24456 ///
24457 /// Deletes the song source. Requires `edit masterdata` in churchservice. Arrangements referencing this source prevent deletion.
24458 ///
24459 /// # Example
24460 ///
24461 /// ```no_run
24462 /// # use churchtools_api::*;
24463 /// # use churchtools_api::queries::*;
24464 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24465 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24466 /// client.song().sources().delete(1)?;
24467 /// # Ok(())
24468 /// # }
24469 /// ```
24470 pub fn delete(&self, song_source_id: impl Display) -> Result<()> {
24471 let path = format!("/song/sources/{}", seg(song_source_id));
24472 let query: Query = Query::new();
24473 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
24474 }
24475
24476 /// Get song source by ID
24477 ///
24478 /// `GET /song/sources/{songSourceId}`
24479 ///
24480 /// Returns one song source without an additional record-level visibility check.
24481 ///
24482 /// # Example
24483 ///
24484 /// ```
24485 /// # use churchtools_api::*;
24486 /// # use churchtools_api::queries::*;
24487 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24488 /// # let client = churchtools_api::replay::client("get-song-sources-id");
24489 /// let source = client.song().sources().get(1)?;
24490 /// println!("{}", source.name);
24491 /// # Ok(())
24492 /// # }
24493 /// ```
24494 pub fn get(&self, song_source_id: impl Display) -> Result<models::SongSource> {
24495 let path = format!("/song/sources/{}", seg(song_source_id));
24496 let query: Query = Query::new();
24497 self.client.request_data(Method::Get, &path, &query, None)
24498 }
24499
24500 /// Get all song sources
24501 ///
24502 /// `GET /song/sources`
24503 ///
24504 /// Returns all song sources ordered by sortKey ascending and then name ascending. The list is unpaginated and has no visibility or campus filter.
24505 ///
24506 /// # Example
24507 ///
24508 /// ```
24509 /// # use churchtools_api::*;
24510 /// # use churchtools_api::queries::*;
24511 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24512 /// # let client = churchtools_api::replay::client("get-song-sources");
24513 /// for source in client.song().sources().list()? {
24514 /// println!("{}", source.name);
24515 /// }
24516 /// # Ok(())
24517 /// # }
24518 /// ```
24519 pub fn list(&self) -> Result<Vec<models::SongSource>> {
24520 let path = "/song/sources".to_owned();
24521 let query: Query = Query::new();
24522 self.client.request_data(Method::Get, &path, &query, None)
24523 }
24524
24525 /// Update song source
24526 ///
24527 /// `PUT /song/sources/{songSourceId}`
24528 ///
24529 /// Replaces the song source. Requires `edit masterdata` in churchservice.
24530 ///
24531 /// # Example
24532 ///
24533 /// ```
24534 /// # use churchtools_api::*;
24535 /// # use churchtools_api::queries::*;
24536 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24537 /// # let client = churchtools_api::replay::client("put-song-sources-id");
24538 /// let body = models::SongSourceUpdate {
24539 /// name: "Community hymnal".into(),
24540 /// ..Default::default()
24541 /// };
24542 /// let result = client.song().sources().update(1, &body)?;
24543 /// println!("{}", result.name);
24544 /// # Ok(())
24545 /// # }
24546 /// ```
24547 pub fn update(&self, song_source_id: impl Display, body: &models::SongSourceUpdate) -> Result<models::SongSource> {
24548 let path = format!("/song/sources/{}", seg(song_source_id));
24549 let query: Query = Query::new();
24550 let body = serde_json::to_value(body).expect("request body serializes");
24551 self.client.request_data(Method::Put, &path, &query, Some(&body))
24552 }
24553
24554}
24555
24556/// `client.songs()`
24557#[derive(Clone, Copy)]
24558pub struct SongsResource<'a> {
24559 client: &'a Client,
24560}
24561
24562impl<'a> SongsResource<'a> {
24563 pub fn arrangements(&self) -> SongsArrangementsResource<'a> {
24564 SongsArrangementsResource { client: self.client }
24565 }
24566
24567 /// Create a new song
24568 ///
24569 /// `POST /songs`
24570 ///
24571 /// Creates a song in an existing category. Requires edit songcategory permission for that category. Inline arrangements use the same contract as the arrangement creation endpoint, including source and file assignments. The first arrangement becomes the default unless a later item requests that role. The response does not enrich tags.
24572 ///
24573 /// # Example
24574 ///
24575 /// ```
24576 /// # use churchtools_api::*;
24577 /// # use churchtools_api::queries::*;
24578 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24579 /// # let client = churchtools_api::replay::client("post-songs");
24580 /// let body = models::SongCreate {
24581 /// category_id: 1,
24582 /// name: "Hallelujah".into(),
24583 /// ..Default::default()
24584 /// };
24585 /// let result = client.songs().create(&body)?;
24586 /// println!("{}", result.name);
24587 /// # Ok(())
24588 /// # }
24589 /// ```
24590 pub fn create(&self, body: &models::SongCreate) -> Result<models::Song> {
24591 let path = "/songs".to_owned();
24592 let query: Query = Query::new();
24593 let body = serde_json::to_value(body).expect("request body serializes");
24594 self.client.request_data(Method::Post, &path, &query, Some(&body))
24595 }
24596
24597 /// Delete song
24598 ///
24599 /// `DELETE /songs/{songId}`
24600 ///
24601 /// Deletes the song, its tag associations, arrangements and arrangement files. The tags themselves remain available. Requires edit songcategory permission for the song's category. Agenda items referring to deleted arrangements keep their item records but lose the arrangement reference.
24602 ///
24603 /// # Example
24604 ///
24605 /// ```no_run
24606 /// # use churchtools_api::*;
24607 /// # use churchtools_api::queries::*;
24608 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24609 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24610 /// client.songs().delete(42)?;
24611 /// # Ok(())
24612 /// # }
24613 /// ```
24614 pub fn delete(&self, song_id: impl Display) -> Result<()> {
24615 let path = format!("/songs/{}", seg(song_id));
24616 let query: Query = Query::new();
24617 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
24618 }
24619
24620 /// Get song
24621 ///
24622 /// `GET /songs/{songId}`
24623 ///
24624 /// Returns a song with its category, musical details and all arrangements. Requires view songcategory or edit songcategory permission for its category. Use include=tags to additionally retrieve its tags. Arrangement selection for a particular event belongs to that event's agenda item.
24625 ///
24626 /// Use [`Self::get_with`] to pass query parameters.
24627 ///
24628 /// # Example
24629 ///
24630 /// ```
24631 /// # use churchtools_api::*;
24632 /// # use churchtools_api::queries::*;
24633 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24634 /// # let client = churchtools_api::replay::client("get-songs-songId");
24635 /// let song = client.songs().get(42)?;
24636 /// println!("{}", song.name);
24637 /// # Ok(())
24638 /// # }
24639 /// ```
24640 pub fn get(&self, song_id: impl Display) -> Result<models::Song> {
24641 self.get_with(song_id, &Default::default())
24642 }
24643
24644 /// Get song
24645 ///
24646 /// Like [`Self::get`], with query parameters.
24647 ///
24648 /// `GET /songs/{songId}`
24649 ///
24650 /// Returns a song with its category, musical details and all arrangements. Requires view songcategory or edit songcategory permission for its category. Use include=tags to additionally retrieve its tags. Arrangement selection for a particular event belongs to that event's agenda item.
24651 pub fn get_with(&self, song_id: impl Display, query: &GetSongsSongIdQuery) -> Result<models::Song> {
24652 let path = format!("/songs/{}", seg(song_id));
24653 let query: Query = query.to_query();
24654 self.client.request_data(Method::Get, &path, &query, None)
24655 }
24656
24657 /// Get all songs
24658 ///
24659 /// `GET /songs`
24660 ///
24661 /// Returns songs in categories for which the caller has view songcategory or edit songcategory permission. Songs are sorted by name, then ID, both ascending. Filters are combined with AND; query matches either title or author. Category filters are intersected with permitted categories. No permitted or matching songs returns an empty list. Each song includes all arrangements, including those that do not match key_of_arrangement. Results are paginated.
24662 ///
24663 /// Use [`Self::list_with`] to pass query parameters.
24664 ///
24665 /// # Example
24666 ///
24667 /// ```
24668 /// # use churchtools_api::*;
24669 /// # use churchtools_api::queries::*;
24670 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24671 /// # let client = churchtools_api::replay::client("get-songs");
24672 /// for song in client.songs().list()? {
24673 /// println!("{}", song.name);
24674 /// }
24675 /// # Ok(())
24676 /// # }
24677 /// ```
24678 pub fn list(&self) -> Result<Vec<models::Song>> {
24679 self.list_with(&Default::default())
24680 }
24681
24682 /// Get all songs
24683 ///
24684 /// Like [`Self::list`], with query parameters.
24685 ///
24686 /// `GET /songs`
24687 ///
24688 /// Returns songs in categories for which the caller has view songcategory or edit songcategory permission. Songs are sorted by name, then ID, both ascending. Filters are combined with AND; query matches either title or author. Category filters are intersected with permitted categories. No permitted or matching songs returns an empty list. Each song includes all arrangements, including those that do not match key_of_arrangement. Results are paginated.
24689 pub fn list_with(&self, query: &GetSongsQuery) -> Result<Vec<models::Song>> {
24690 let path = "/songs".to_owned();
24691 let query: Query = query.to_query();
24692 self.client.collect_pages(&path, query)
24693 }
24694
24695 /// Get all songs
24696 ///
24697 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
24698 /// Breaking off early saves the remaining requests.
24699 pub fn list_iter(&self, query: &GetSongsQuery) -> Items<models::Song> {
24700 let path = "/songs".to_owned();
24701 self.client.items(&path, query.to_query())
24702 }
24703
24704 /// Update song
24705 ///
24706 /// `PUT /songs/{songId}`
24707 ///
24708 /// Replaces the song's main details. Requires "edit songcategory" permission for both the current and requested category. When supplied, tags replace all current tag associations. Arrangements are not processed. The response is not enriched with tags.
24709 ///
24710 /// # Example
24711 ///
24712 /// ```
24713 /// # use churchtools_api::*;
24714 /// # use churchtools_api::queries::*;
24715 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24716 /// # let client = churchtools_api::replay::client("put-songs-songId");
24717 /// let body = models::SongUpdate {
24718 /// category_id: 1,
24719 /// name: "Hallelujah".into(),
24720 /// ..Default::default()
24721 /// };
24722 /// let result = client.songs().update(42, &body)?;
24723 /// println!("{}", result.name);
24724 /// # Ok(())
24725 /// # }
24726 /// ```
24727 pub fn update(&self, song_id: impl Display, body: &models::SongUpdate) -> Result<models::Song> {
24728 let path = format!("/songs/{}", seg(song_id));
24729 let query: Query = Query::new();
24730 let body = serde_json::to_value(body).expect("request body serializes");
24731 self.client.request_data(Method::Put, &path, &query, Some(&body))
24732 }
24733
24734}
24735
24736/// `client.songs().arrangements()`
24737#[derive(Clone, Copy)]
24738pub struct SongsArrangementsResource<'a> {
24739 client: &'a Client,
24740}
24741
24742impl<'a> SongsArrangementsResource<'a> {
24743 pub fn files(&self) -> SongsArrangementsFilesResource<'a> {
24744 SongsArrangementsFilesResource { client: self.client }
24745 }
24746
24747 /// Create new arrangement for song
24748 ///
24749 /// `POST /songs/{songId}/arrangements`
24750 ///
24751 /// Creates a musical version of an existing song. Requires edit songcategory permission for the song's category. Existing files can be assigned with fileIds. The first arrangement becomes the default; otherwise `isDefault: true` replaces the current default.
24752 ///
24753 /// # Example
24754 ///
24755 /// ```
24756 /// # use churchtools_api::*;
24757 /// # use churchtools_api::queries::*;
24758 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24759 /// # let client = churchtools_api::replay::client("post-songs-songId-arrangements");
24760 /// let body = models::ArrangementCreate {
24761 /// name: "Men Voicing".into(),
24762 /// ..Default::default()
24763 /// };
24764 /// let result = client.songs().arrangements().create(42, &body)?;
24765 /// println!("{}", result.name);
24766 /// # Ok(())
24767 /// # }
24768 /// ```
24769 pub fn create(&self, song_id: impl Display, body: &models::ArrangementCreate) -> Result<models::Arrangement> {
24770 let path = format!("/songs/{}/arrangements", seg(song_id));
24771 let query: Query = Query::new();
24772 let body = serde_json::to_value(body).expect("request body serializes");
24773 self.client.request_data(Method::Post, &path, &query, Some(&body))
24774 }
24775
24776 /// Delete arrangement
24777 ///
24778 /// `DELETE /songs/{songId}/arrangements/{arrangementId}`
24779 ///
24780 /// Deletes an arrangement belonging to this song and its attached files and links. Requires edit songcategory permission for the song's category. When arrangements remain, one is selected as the default and agenda items referring to the deleted arrangement are reassigned to it.
24781 ///
24782 /// # Example
24783 ///
24784 /// ```no_run
24785 /// # use churchtools_api::*;
24786 /// # use churchtools_api::queries::*;
24787 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24788 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24789 /// client.songs().arrangements().delete(42, 42)?;
24790 /// # Ok(())
24791 /// # }
24792 /// ```
24793 pub fn delete(&self, song_id: impl Display, arrangement_id: impl Display) -> Result<()> {
24794 let path = format!("/songs/{}/arrangements/{}", seg(song_id), seg(arrangement_id));
24795 let query: Query = Query::new();
24796 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
24797 }
24798
24799 /// Get arrangement of song
24800 ///
24801 /// `GET /songs/{songId}/arrangements/{arrangementId}`
24802 ///
24803 /// Returns one arrangement with its musical details, source, files and links. Requires view songcategory or edit songcategory permission for the song's category. The arrangement must belong to the song in the path.
24804 ///
24805 /// # Example
24806 ///
24807 /// ```
24808 /// # use churchtools_api::*;
24809 /// # use churchtools_api::queries::*;
24810 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24811 /// # let client = churchtools_api::replay::client("get-songs-songId-arrangements-arrangementId");
24812 /// let arrangement = client.songs().arrangements().get(42, 42)?;
24813 /// println!("{}", arrangement.name);
24814 /// # Ok(())
24815 /// # }
24816 /// ```
24817 pub fn get(&self, song_id: impl Display, arrangement_id: impl Display) -> Result<models::Arrangement> {
24818 let path = format!("/songs/{}/arrangements/{}", seg(song_id), seg(arrangement_id));
24819 let query: Query = Query::new();
24820 self.client.request_data(Method::Get, &path, &query, None)
24821 }
24822
24823 /// Get arrangements of song
24824 ///
24825 /// `GET /songs/{songId}/arrangements`
24826 ///
24827 /// Returns every arrangement belonging to the song, including each arrangement's files and links. An arrangement is a musical version with its own key, tempo and source. The list is unpaginated, has no guaranteed order and includes meta.count. Requires view songcategory or edit songcategory permission for the song's category.
24828 ///
24829 /// # Example
24830 ///
24831 /// ```
24832 /// # use churchtools_api::*;
24833 /// # use churchtools_api::queries::*;
24834 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24835 /// # let client = churchtools_api::replay::client("get-songs-songId-arrangements");
24836 /// for arrangement in client.songs().arrangements().list(42)? {
24837 /// println!("{}", arrangement.name);
24838 /// }
24839 /// # Ok(())
24840 /// # }
24841 /// ```
24842 pub fn list(&self, song_id: impl Display) -> Result<Vec<models::Arrangement>> {
24843 let path = format!("/songs/{}/arrangements", seg(song_id));
24844 let query: Query = Query::new();
24845 self.client.request_data(Method::Get, &path, &query, None)
24846 }
24847
24848 /// Make arrangement the default
24849 ///
24850 /// `PATCH /songs/{songId}/arrangements/{arrangementId}/default`
24851 ///
24852 /// Makes this arrangement the only default for the song by clearing the default flag on all of the song's other arrangements. Requires edit songcategory permission for the song's category. The arrangement must belong to this song. No request body is needed. Selecting an arrangement that is already the default also returns 204.
24853 ///
24854 /// # Example
24855 ///
24856 /// ```no_run
24857 /// # use churchtools_api::*;
24858 /// # use churchtools_api::queries::*;
24859 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24860 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24861 /// client.songs().arrangements().patch_default(42, 42)?;
24862 /// # Ok(())
24863 /// # }
24864 /// ```
24865 pub fn patch_default(&self, song_id: impl Display, arrangement_id: impl Display) -> Result<()> {
24866 let path = format!("/songs/{}/arrangements/{}/default", seg(song_id), seg(arrangement_id));
24867 let query: Query = Query::new();
24868 self.client.request(Method::Patch, &path, &query, None).map(|_| ())
24869 }
24870
24871 /// Update arrangement of song
24872 ///
24873 /// `PUT /songs/{songId}/arrangements/{arrangementId}`
24874 ///
24875 /// Replaces the musical details of an arrangement belonging to this song. Requires edit songcategory permission for the song's category. Files and links are unchanged. To change the default arrangement, use the dedicated default endpoint; isDefault is not processed here.
24876 ///
24877 /// # Example
24878 ///
24879 /// ```
24880 /// # use churchtools_api::*;
24881 /// # use churchtools_api::queries::*;
24882 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24883 /// # let client = churchtools_api::replay::client("put-songs-songId-arrangements-arrangementId");
24884 /// let body = models::ArrangementUpdate {
24885 /// name: "Men Voicing".into(),
24886 /// ..Default::default()
24887 /// };
24888 /// let result = client.songs().arrangements().update(42, 42, &body)?;
24889 /// println!("{}", result.name);
24890 /// # Ok(())
24891 /// # }
24892 /// ```
24893 pub fn update(&self, song_id: impl Display, arrangement_id: impl Display, body: &models::ArrangementUpdate) -> Result<models::Arrangement> {
24894 let path = format!("/songs/{}/arrangements/{}", seg(song_id), seg(arrangement_id));
24895 let query: Query = Query::new();
24896 let body = serde_json::to_value(body).expect("request body serializes");
24897 self.client.request_data(Method::Put, &path, &query, Some(&body))
24898 }
24899
24900}
24901
24902/// `client.songs().arrangements().files()`
24903#[derive(Clone, Copy)]
24904pub struct SongsArrangementsFilesResource<'a> {
24905 client: &'a Client,
24906}
24907
24908impl<'a> SongsArrangementsFilesResource<'a> {
24909 /// Create a transposed arrangement audio file
24910 ///
24911 /// `POST /songs/{songId}/arrangements/{arrangementId}/files/{fileId}/transpose`
24912 ///
24913 /// Transposes an existing audio file by one to six semitones and saves a new file on the arrangement identified by arrangementId. The original file is retained. Processing is synchronous, so the response is sent after conversion and saving finish. Pitch is changed with tempo compensation to preserve the playback duration. The output retains the source filename extension and contains audio only. Supported formats depend on the server's FFmpeg installation; an unsupported or unreadable input causes an error. Each successful call creates a new file record. This does not update the arrangement's key or tempo metadata. Requires view permission for churchservice and edit permission for the source file; for song arrangement files, this is edit songcategory permission for the source song's category.
24914 ///
24915 /// # Example
24916 ///
24917 /// ```no_run
24918 /// # use churchtools_api::*;
24919 /// # use churchtools_api::queries::*;
24920 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24921 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
24922 /// let body = models::ArrangementFileTransposeCreate {
24923 /// transpose_interval: "up2".into(),
24924 /// ..Default::default()
24925 /// };
24926 /// let file = client.songs().arrangements().files().transpose(42, 42, 42, &body)?;
24927 /// println!("{}", file.id);
24928 /// # Ok(())
24929 /// # }
24930 /// ```
24931 pub fn transpose(&self, song_id: impl Display, arrangement_id: impl Display, file_id: impl Display, body: &models::ArrangementFileTransposeCreate) -> Result<models::ArrangementFileTranspose> {
24932 let path = format!("/songs/{}/arrangements/{}/files/{}/transpose", seg(song_id), seg(arrangement_id), seg(file_id));
24933 let query: Query = Query::new();
24934 let body = serde_json::to_value(body).expect("request body serializes");
24935 self.client.request_json(Method::Post, &path, &query, Some(&body))
24936 }
24937
24938}
24939
24940/// `client.sso_logins()`
24941#[derive(Clone, Copy)]
24942pub struct SsoLoginsResource<'a> {
24943 client: &'a Client,
24944}
24945
24946impl<'a> SsoLoginsResource<'a> {
24947 /// List visible single sign-on providers
24948 ///
24949 /// `GET /sso-logins`
24950 ///
24951 /// Returns visible external login providers that have a registered handler and login link. This public list is intended for the login screen and does not expose provider credentials or configuration. Providers are returned without pagination or a guaranteed order. Hidden providers are omitted. primaryLogin and hasRegistration are presentation/configuration flags, not a guarantee that an external login or account creation will succeed.
24952 ///
24953 /// # Example
24954 ///
24955 /// ```
24956 /// # use churchtools_api::*;
24957 /// # use churchtools_api::queries::*;
24958 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24959 /// # let client = churchtools_api::replay::client("get-sso-logins");
24960 /// for sso_login in client.sso_logins().list()? {
24961 /// println!("{}", sso_login.name);
24962 /// }
24963 /// # Ok(())
24964 /// # }
24965 /// ```
24966 pub fn list(&self) -> Result<Vec<models::SsoLogin>> {
24967 let path = "/sso-logins".to_owned();
24968 let query: Query = Query::new();
24969 self.client.request_data(Method::Get, &path, &query, None)
24970 }
24971
24972}
24973
24974/// `client.start_page()`
24975#[derive(Clone, Copy)]
24976pub struct StartPageResource<'a> {
24977 client: &'a Client,
24978}
24979
24980impl<'a> StartPageResource<'a> {
24981 /// Widgets and data for startpage
24982 ///
24983 /// `GET /startpage`
24984 ///
24985 /// Here you get data like birthdays in the next seven days, open meeting requests, next appointments and songs to lern
24986 ///
24987 /// # Example
24988 ///
24989 /// ```
24990 /// # use churchtools_api::*;
24991 /// # use churchtools_api::queries::*;
24992 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24993 /// # let client = churchtools_api::replay::client("get-startpage");
24994 /// for start_page in client.start_page().list()? {
24995 /// println!("{:?}", start_page);
24996 /// }
24997 /// # Ok(())
24998 /// # }
24999 /// ```
25000 pub fn list(&self) -> Result<Vec<serde_json::Value>> {
25001 let path = "/startpage".to_owned();
25002 let query: Query = Query::new();
25003 self.client.request_data(Method::Get, &path, &query, None)
25004 }
25005
25006}
25007
25008/// `client.statuses()`
25009#[derive(Clone, Copy)]
25010pub struct StatusesResource<'a> {
25011 client: &'a Client,
25012}
25013
25014impl<'a> StatusesResource<'a> {
25015 /// Save new status
25016 ///
25017 /// `POST /statuses`
25018 ///
25019 /// Creates a person-status definition. Requires "edit masterdata" permission in `churchdb`.
25020 ///
25021 /// # Example
25022 ///
25023 /// ```
25024 /// # use churchtools_api::*;
25025 /// # use churchtools_api::queries::*;
25026 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25027 /// # let client = churchtools_api::replay::client("post-statuses");
25028 /// let body = models::StatusCreate {
25029 /// name: "Member".into(),
25030 /// security_level_id: 2,
25031 /// ..Default::default()
25032 /// };
25033 /// let result = client.statuses().create(&body)?;
25034 /// println!("{}", result.name);
25035 /// # Ok(())
25036 /// # }
25037 /// ```
25038 pub fn create(&self, body: &models::StatusCreate) -> Result<models::Status> {
25039 let path = "/statuses".to_owned();
25040 let query: Query = Query::new();
25041 let body = serde_json::to_value(body).expect("request body serializes");
25042 self.client.request_data(Method::Post, &path, &query, Some(&body))
25043 }
25044
25045 /// Delete a status
25046 ///
25047 /// `DELETE /statuses/{id}`
25048 ///
25049 /// Deletes the status definition after checking dependent references. Requires "edit masterdata" permission in `churchdb`. Person assignments and other configuration can block deletion.
25050 ///
25051 /// # Example
25052 ///
25053 /// ```no_run
25054 /// # use churchtools_api::*;
25055 /// # use churchtools_api::queries::*;
25056 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25057 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25058 /// client.statuses().delete(1)?;
25059 /// # Ok(())
25060 /// # }
25061 /// ```
25062 pub fn delete(&self, id: impl Display) -> Result<()> {
25063 let path = format!("/statuses/{}", seg(id));
25064 let query: Query = Query::new();
25065 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
25066 }
25067
25068 /// Get a specific status
25069 ///
25070 /// `GET /statuses/{id}`
25071 ///
25072 /// Returns one person-status definition, including its translated name and abbreviation.
25073 ///
25074 /// # Example
25075 ///
25076 /// ```
25077 /// # use churchtools_api::*;
25078 /// # use churchtools_api::queries::*;
25079 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25080 /// # let client = churchtools_api::replay::client("get-statuses-id");
25081 /// let status = client.statuses().get(1)?;
25082 /// println!("{}", status.name);
25083 /// # Ok(())
25084 /// # }
25085 /// ```
25086 pub fn get(&self, id: impl Display) -> Result<models::Status> {
25087 let path = format!("/statuses/{}", seg(id));
25088 let query: Query = Query::new();
25089 self.client.request_data(Method::Get, &path, &query, None)
25090 }
25091
25092 /// Get all statuses
25093 ///
25094 /// `GET /statuses`
25095 ///
25096 /// Returns all person-status definitions, ordered by `sortKey` and then name.
25097 ///
25098 /// # Example
25099 ///
25100 /// ```
25101 /// # use churchtools_api::*;
25102 /// # use churchtools_api::queries::*;
25103 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25104 /// # let client = churchtools_api::replay::client("get-statuses");
25105 /// for status in client.statuses().list()? {
25106 /// println!("{}", status.name);
25107 /// }
25108 /// # Ok(())
25109 /// # }
25110 /// ```
25111 pub fn list(&self) -> Result<Vec<models::Status>> {
25112 let path = "/statuses".to_owned();
25113 let query: Query = Query::new();
25114 self.client.request_data(Method::Get, &path, &query, None)
25115 }
25116
25117 /// Update status
25118 ///
25119 /// `PATCH /statuses/{id}`
25120 ///
25121 /// Updates the supplied fields of the specified person-status definition. Requires "edit masterdata" permission in `churchdb`. Omitted fields remain unchanged.
25122 ///
25123 /// # Example
25124 ///
25125 /// ```
25126 /// # use churchtools_api::*;
25127 /// # use churchtools_api::queries::*;
25128 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25129 /// # let client = churchtools_api::replay::client("patch-statuses-id");
25130 /// let body = models::StatusUpdate {
25131 /// name: Some("Member".into()),
25132 /// ..Default::default()
25133 /// };
25134 /// let result = client.statuses().patch(1, &body)?;
25135 /// println!("{}", result.name);
25136 /// # Ok(())
25137 /// # }
25138 /// ```
25139 pub fn patch(&self, id: impl Display, body: &models::StatusUpdate) -> Result<models::Status> {
25140 let path = format!("/statuses/{}", seg(id));
25141 let query: Query = Query::new();
25142 let body = serde_json::to_value(body).expect("request body serializes");
25143 self.client.request_data(Method::Patch, &path, &query, Some(&body))
25144 }
25145
25146 /// Update status
25147 ///
25148 /// `PUT /statuses/{id}`
25149 ///
25150 /// Replaces a person-status definition. Requires "edit masterdata" permission in `churchdb`. Existing persons retain the status ID. Use `PATCH /statuses/{id}` instead.
25151 ///
25152 /// # Example
25153 ///
25154 /// ```
25155 /// # use churchtools_api::*;
25156 /// # use churchtools_api::queries::*;
25157 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25158 /// # let client = churchtools_api::replay::client("put-statuses-id");
25159 /// let body = models::StatusCreate {
25160 /// name: "Member".into(),
25161 /// security_level_id: 2,
25162 /// ..Default::default()
25163 /// };
25164 /// let result = client.statuses().update(1, &body)?;
25165 /// println!("{}", result.name);
25166 /// # Ok(())
25167 /// # }
25168 /// ```
25169 #[deprecated = "PUT /statuses/{id} is deprecated in the ChurchTools API. Use `PATCH /statuses/{id}` instead."]
25170 pub fn update(&self, id: impl Display, body: &models::StatusCreate) -> Result<models::Status> {
25171 let path = format!("/statuses/{}", seg(id));
25172 let query: Query = Query::new();
25173 let body = serde_json::to_value(body).expect("request body serializes");
25174 self.client.request_data(Method::Put, &path, &query, Some(&body))
25175 }
25176
25177}
25178
25179/// `client.subscriptions()`
25180#[derive(Clone, Copy)]
25181pub struct SubscriptionsResource<'a> {
25182 client: &'a Client,
25183}
25184
25185impl<'a> SubscriptionsResource<'a> {
25186 /// Delete an explicit subscription override
25187 ///
25188 /// `DELETE /subscriptions/{personId}/{subject}/{subjectIdentifier}`
25189 ///
25190 /// Subscriptions control notifications for a subject (for example a group, post or resource). Explicit settings override implicit defaults for the same person, subject and identifier. Only the current person may access their own subscriptions. Removes the stored override, not the implicit default. If no explicit row exists, returns 404 even when GET returns an implicit subscription. Removing an inactive override can enable notifications again through the default; use PUT with isActive=false to opt out. Legacy subjects meetingrequests and servicerequests are normalized to meetingrequest and servicerequest; identifier 0 is normalized to root for both. List responses additionally include a legacy alias for each canonical root result. These aliases are compatibility copies, not separate subscriptions.
25191 ///
25192 /// # Example
25193 ///
25194 /// ```no_run
25195 /// # use churchtools_api::*;
25196 /// # use churchtools_api::queries::*;
25197 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25198 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25199 /// client.subscriptions().delete(42, "group", "root")?;
25200 /// # Ok(())
25201 /// # }
25202 /// ```
25203 pub fn delete(&self, person_id: impl Display, subject: impl Display, subject_identifier: impl Display) -> Result<()> {
25204 let path = format!("/subscriptions/{}/{}/{}", seg(person_id), seg(subject), seg(subject_identifier));
25205 let query: Query = Query::new();
25206 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
25207 }
25208
25209 /// Get one effective subscription
25210 ///
25211 /// `GET /subscriptions/{personId}/{subject}/{subjectIdentifier}`
25212 ///
25213 /// Subscriptions control notifications for a subject (for example a group, post or resource). Explicit settings override implicit defaults for the same person, subject and identifier. Only the current person may access their own subscriptions. Read results include active and inactive subscriptions, after subject-specific eligibility filtering: meeting/service requests require a registered push-capable device, email summaries require an eligible recipient, and resources require administration or booking-administration rights. A stored override can therefore be absent from a read response. Legacy subjects meetingrequests and servicerequests are normalized to meetingrequest and servicerequest; identifier 0 is normalized to root for both. List responses additionally include a legacy alias for each canonical root result. These aliases are compatibility copies, not separate subscriptions. This endpoint returns one object using the canonical subject and identifier, without a compatibility copy. It returns 404 when no eligible effective subscription exists and 422 if more than one result remains.
25214 ///
25215 /// # Example
25216 ///
25217 /// ```
25218 /// # use churchtools_api::*;
25219 /// # use churchtools_api::queries::*;
25220 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25221 /// # let client = churchtools_api::replay::client("get-subscriptions-personId-subject-subjectIdentifier");
25222 /// let result = client.subscriptions().get(42, "group", "root")?;
25223 /// println!("{:?}", result);
25224 /// # Ok(())
25225 /// # }
25226 /// ```
25227 pub fn get(&self, person_id: impl Display, subject: impl Display, subject_identifier: impl Display) -> Result<serde_json::Value> {
25228 let path = format!("/subscriptions/{}/{}/{}", seg(person_id), seg(subject), seg(subject_identifier));
25229 let query: Query = Query::new();
25230 self.client.request_data(Method::Get, &path, &query, None)
25231 }
25232
25233 /// List the current person’s effective subscriptions
25234 ///
25235 /// `GET /subscriptions/{personId}`
25236 ///
25237 /// Subscriptions control notifications for a subject (for example a group, post or resource). Explicit settings override implicit defaults for the same person, subject and identifier. Only the current person may access their own subscriptions. Read results include active and inactive subscriptions, after subject-specific eligibility filtering: meeting/service requests require a registered push-capable device, email summaries require an eligible recipient, and resources require administration or booking-administration rights. A stored override can therefore be absent from a read response. Results are not paginated; meta.count includes compatibility aliases. Legacy subjects meetingrequests and servicerequests are normalized to meetingrequest and servicerequest; identifier 0 is normalized to root for both. List responses additionally include a legacy alias for each canonical root result. These aliases are compatibility copies, not separate subscriptions.
25238 ///
25239 /// # Example
25240 ///
25241 /// ```
25242 /// # use churchtools_api::*;
25243 /// # use churchtools_api::queries::*;
25244 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25245 /// # let client = churchtools_api::replay::client("get-subscriptions-personId");
25246 /// for subscription in client.subscriptions().list(42)? {
25247 /// println!("{:?}", subscription);
25248 /// }
25249 /// # Ok(())
25250 /// # }
25251 /// ```
25252 pub fn list(&self, person_id: impl Display) -> Result<Vec<serde_json::Value>> {
25253 let path = format!("/subscriptions/{}", seg(person_id));
25254 let query: Query = Query::new();
25255 self.client.request_data(Method::Get, &path, &query, None)
25256 }
25257
25258 /// List effective subscriptions for one subject
25259 ///
25260 /// `GET /subscriptions/{personId}/{subject}`
25261 ///
25262 /// Subscriptions control notifications for a subject (for example a group, post or resource). Explicit settings override implicit defaults for the same person, subject and identifier. Only the current person may access their own subscriptions. Read results include active and inactive subscriptions, after subject-specific eligibility filtering: meeting/service requests require a registered push-capable device, email summaries require an eligible recipient, and resources require administration or booking-administration rights. A stored override can therefore be absent from a read response. Results are not paginated; meta.count includes compatibility aliases. Legacy subjects meetingrequests and servicerequests are normalized to meetingrequest and servicerequest; identifier 0 is normalized to root for both. List responses additionally include a legacy alias for each canonical root result. These aliases are compatibility copies, not separate subscriptions.
25263 ///
25264 /// # Example
25265 ///
25266 /// ```
25267 /// # use churchtools_api::*;
25268 /// # use churchtools_api::queries::*;
25269 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25270 /// # let client = churchtools_api::replay::client("get-subscriptions-personId-subject");
25271 /// for for_subject in client.subscriptions().list_for_subject(42, "group")? {
25272 /// println!("{:?}", for_subject);
25273 /// }
25274 /// # Ok(())
25275 /// # }
25276 /// ```
25277 pub fn list_for_subject(&self, person_id: impl Display, subject: impl Display) -> Result<Vec<serde_json::Value>> {
25278 let path = format!("/subscriptions/{}/{}", seg(person_id), seg(subject));
25279 let query: Query = Query::new();
25280 self.client.request_data(Method::Get, &path, &query, None)
25281 }
25282
25283 /// Create or replace an explicit subscription override
25284 ///
25285 /// `PUT /subscriptions/{personId}/{subject}/{subjectIdentifier}`
25286 ///
25287 /// Subscriptions control notifications for a subject (for example a group, post or resource). Explicit settings override implicit defaults for the same person, subject and identifier. Only the current person may access their own subscriptions. Creates or updates a stored override and returns that single object before read-side eligibility filtering. Omitted isActive becomes true and omitted options clears existing options to null. For post_summary, options.filter and 1–7 distinct options.weekdays are required, and the current person needs a receiving email address. Use identifier 0 for post_summary. Legacy subjects meetingrequests and servicerequests are normalized to meetingrequest and servicerequest; identifier 0 is normalized to root for both. List responses additionally include a legacy alias for each canonical root result. These aliases are compatibility copies, not separate subscriptions.
25288 ///
25289 /// # Example
25290 ///
25291 /// ```no_run
25292 /// # use churchtools_api::*;
25293 /// # use churchtools_api::queries::*;
25294 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25295 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25296 /// let body = models::SubscriptionUpdate {
25297 /// is_active: Some(true),
25298 /// ..Default::default()
25299 /// };
25300 /// let result = client.subscriptions().update(42, "group", "root", &body)?;
25301 /// println!("{:?}", result);
25302 /// # Ok(())
25303 /// # }
25304 /// ```
25305 pub fn update(&self, person_id: impl Display, subject: impl Display, subject_identifier: impl Display, body: &models::SubscriptionUpdate) -> Result<serde_json::Value> {
25306 let path = format!("/subscriptions/{}/{}/{}", seg(person_id), seg(subject), seg(subject_identifier));
25307 let query: Query = Query::new();
25308 let body = serde_json::to_value(body).expect("request body serializes");
25309 self.client.request_data(Method::Put, &path, &query, Some(&body))
25310 }
25311
25312}
25313
25314/// `client.sync()`
25315#[derive(Clone, Copy)]
25316pub struct SyncResource<'a> {
25317 client: &'a Client,
25318}
25319
25320impl<'a> SyncResource<'a> {
25321 pub fn adapters(&self) -> SyncAdaptersResource<'a> {
25322 SyncAdaptersResource { client: self.client }
25323 }
25324
25325 pub fn conflicts(&self) -> SyncConflictsResource<'a> {
25326 SyncConflictsResource { client: self.client }
25327 }
25328
25329 pub fn entity_mappings(&self) -> SyncEntityMappingsResource<'a> {
25330 SyncEntityMappingsResource { client: self.client }
25331 }
25332
25333 pub fn externalsystems(&self) -> SyncExternalsystemsResource<'a> {
25334 SyncExternalsystemsResource { client: self.client }
25335 }
25336
25337 /// Store sync log entries
25338 ///
25339 /// `POST /sync/logs`
25340 ///
25341 /// Stores log entries. `messageKey`, translation arguments and changes are rendered into a stored message.
25342 ///
25343 /// # Example
25344 ///
25345 /// ```no_run
25346 /// # use churchtools_api::*;
25347 /// # use churchtools_api::queries::*;
25348 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25349 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25350 /// let body = models::SyncLogsCreate {
25351 /// logs: vec![models::SyncLogCreate {
25352 /// date: "2022-10-19T12:00:00Z".parse()?,
25353 /// execution_id: "abc123".into(),
25354 /// job_id: 42,
25355 /// level: "debug".into(),
25356 /// message_key: "Hallo zusammen".into(),
25357 /// r#type: "create".into(),
25358 /// ..Default::default()
25359 /// }],
25360 /// ..Default::default()
25361 /// };
25362 /// let result = client.sync().create_logs(&body)?;
25363 /// println!("{}", result.persisted);
25364 /// # Ok(())
25365 /// # }
25366 /// ```
25367 pub fn create_logs(&self, body: &models::SyncLogsCreate) -> Result<models::SyncLogsPersisted> {
25368 let path = "/sync/logs".to_owned();
25369 let query: Query = Query::new();
25370 let body = serde_json::to_value(body).expect("request body serializes");
25371 self.client.request_data(Method::Post, &path, &query, Some(&body))
25372 }
25373
25374 /// List sync execution summaries
25375 ///
25376 /// `GET /sync/executions`
25377 ///
25378 /// Returns background executions ordered by creation date descending and job ID ascending. Counts are derived from operation logs.
25379 ///
25380 /// Use [`Self::list_executions_with`] to pass query parameters.
25381 ///
25382 /// # Example
25383 ///
25384 /// ```
25385 /// # use churchtools_api::*;
25386 /// # use churchtools_api::queries::*;
25387 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25388 /// # let client = churchtools_api::replay::client("get-sync-executions");
25389 /// for execution in client.sync().list_executions()? {
25390 /// println!("{:?}", execution.created_date);
25391 /// }
25392 /// # Ok(())
25393 /// # }
25394 /// ```
25395 pub fn list_executions(&self) -> Result<Vec<models::SyncExecutionSummary>> {
25396 self.list_executions_with(&Default::default())
25397 }
25398
25399 /// List sync execution summaries
25400 ///
25401 /// Like [`Self::list_executions`], with query parameters.
25402 ///
25403 /// `GET /sync/executions`
25404 ///
25405 /// Returns background executions ordered by creation date descending and job ID ascending. Counts are derived from operation logs.
25406 pub fn list_executions_with(&self, query: &GetSyncExecutionsQuery) -> Result<Vec<models::SyncExecutionSummary>> {
25407 let path = "/sync/executions".to_owned();
25408 let query: Query = query.to_query();
25409 self.client.collect_pages(&path, query)
25410 }
25411
25412 /// List sync execution summaries
25413 ///
25414 /// Like [`Self::list_executions_with`], but lazy: each page is fetched only when the iteration reaches it.
25415 /// Breaking off early saves the remaining requests.
25416 pub fn list_executions_iter(&self, query: &GetSyncExecutionsQuery) -> Items<models::SyncExecutionSummary> {
25417 let path = "/sync/executions".to_owned();
25418 self.client.items(&path, query.to_query())
25419 }
25420
25421 /// List sync job configurations
25422 ///
25423 /// `GET /sync/jobconfigs`
25424 ///
25425 /// Lists job configurations ordered by name.
25426 ///
25427 /// Use [`Self::list_job_configs_with`] to pass query parameters.
25428 ///
25429 /// # Example
25430 ///
25431 /// ```
25432 /// # use churchtools_api::*;
25433 /// # use churchtools_api::queries::*;
25434 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25435 /// # let client = churchtools_api::replay::client("get-sync-jobconfigs");
25436 /// for job_config in client.sync().list_job_configs()? {
25437 /// println!("{}", job_config.name);
25438 /// }
25439 /// # Ok(())
25440 /// # }
25441 /// ```
25442 pub fn list_job_configs(&self) -> Result<Vec<models::JobConfigurationReturn>> {
25443 self.list_job_configs_with(&Default::default())
25444 }
25445
25446 /// List sync job configurations
25447 ///
25448 /// Like [`Self::list_job_configs`], with query parameters.
25449 ///
25450 /// `GET /sync/jobconfigs`
25451 ///
25452 /// Lists job configurations ordered by name.
25453 pub fn list_job_configs_with(&self, query: &GetSyncJobconfigsQuery) -> Result<Vec<models::JobConfigurationReturn>> {
25454 let path = "/sync/jobconfigs".to_owned();
25455 let query: Query = query.to_query();
25456 self.client.request_data(Method::Get, &path, &query, None)
25457 }
25458
25459 /// List sync log entries
25460 ///
25461 /// `GET /sync/logs`
25462 ///
25463 /// Returns rendered log messages ordered by log ID descending.
25464 ///
25465 /// Use [`Self::list_logs_with`] to pass query parameters.
25466 ///
25467 /// # Example
25468 ///
25469 /// ```
25470 /// # use churchtools_api::*;
25471 /// # use churchtools_api::queries::*;
25472 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25473 /// # let client = churchtools_api::replay::client("get-sync-logs");
25474 /// for log in client.sync().list_logs()? {
25475 /// println!("{}", log.id);
25476 /// }
25477 /// # Ok(())
25478 /// # }
25479 /// ```
25480 pub fn list_logs(&self) -> Result<Vec<models::SyncLog>> {
25481 self.list_logs_with(&Default::default())
25482 }
25483
25484 /// List sync log entries
25485 ///
25486 /// Like [`Self::list_logs`], with query parameters.
25487 ///
25488 /// `GET /sync/logs`
25489 ///
25490 /// Returns rendered log messages ordered by log ID descending.
25491 pub fn list_logs_with(&self, query: &GetSyncLogsQuery) -> Result<Vec<models::SyncLog>> {
25492 let path = "/sync/logs".to_owned();
25493 let query: Query = query.to_query();
25494 self.client.collect_pages(&path, query)
25495 }
25496
25497 /// List sync log entries
25498 ///
25499 /// Like [`Self::list_logs_with`], but lazy: each page is fetched only when the iteration reaches it.
25500 /// Breaking off early saves the remaining requests.
25501 pub fn list_logs_iter(&self, query: &GetSyncLogsQuery) -> Items<models::SyncLog> {
25502 let path = "/sync/logs".to_owned();
25503 self.client.items(&path, query.to_query())
25504 }
25505
25506}
25507
25508/// `client.sync().adapters()`
25509#[derive(Clone, Copy)]
25510pub struct SyncAdaptersResource<'a> {
25511 client: &'a Client,
25512}
25513
25514impl<'a> SyncAdaptersResource<'a> {
25515 pub fn proxy(&self) -> SyncAdaptersProxyResource<'a> {
25516 SyncAdaptersProxyResource { client: self.client }
25517 }
25518
25519 /// Register a sync adapter
25520 ///
25521 /// `POST /sync/adapters`
25522 ///
25523 /// Registers the service URL and authentication token of an adapter. Registration does not configure an external connection.
25524 ///
25525 /// # Example
25526 ///
25527 /// ```no_run
25528 /// # use churchtools_api::*;
25529 /// # use churchtools_api::queries::*;
25530 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25531 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25532 /// let body = models::SyncAdapterCreate {
25533 /// name: "churchtools".into(),
25534 /// token: "kfghsjdlkfigblszurglizeifuz4".into(),
25535 /// url: "http://localhost:8090".into(),
25536 /// ..Default::default()
25537 /// };
25538 /// let result = client.sync().adapters().create(&body)?;
25539 /// println!("{}", result.name);
25540 /// # Ok(())
25541 /// # }
25542 /// ```
25543 pub fn create(&self, body: &models::SyncAdapterCreate) -> Result<models::SyncAdapter> {
25544 let path = "/sync/adapters".to_owned();
25545 let query: Query = Query::new();
25546 let body = serde_json::to_value(body).expect("request body serializes");
25547 self.client.request_data(Method::Post, &path, &query, Some(&body))
25548 }
25549
25550 /// Delete a sync adapter
25551 ///
25552 /// `DELETE /sync/adapters/{id}`
25553 ///
25554 /// Deletes the adapter registration. External connections referencing it block deletion.
25555 ///
25556 /// Use [`Self::delete_with`] to pass query parameters.
25557 ///
25558 /// # Example
25559 ///
25560 /// ```no_run
25561 /// # use churchtools_api::*;
25562 /// # use churchtools_api::queries::*;
25563 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25564 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25565 /// client.sync().adapters().delete(1)?;
25566 /// # Ok(())
25567 /// # }
25568 /// ```
25569 pub fn delete(&self, id: impl Display) -> Result<()> {
25570 self.delete_with(id, &Default::default())
25571 }
25572
25573 /// Delete a sync adapter
25574 ///
25575 /// Like [`Self::delete`], with query parameters.
25576 ///
25577 /// `DELETE /sync/adapters/{id}`
25578 ///
25579 /// Deletes the adapter registration. External connections referencing it block deletion.
25580 pub fn delete_with(&self, id: impl Display, query: &DeleteSyncAdaptersIdQuery) -> Result<()> {
25581 let path = format!("/sync/adapters/{}", seg(id));
25582 let query: Query = query.to_query();
25583 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
25584 }
25585
25586 /// Get a sync adapter
25587 ///
25588 /// `GET /sync/adapters/{id}`
25589 ///
25590 /// Returns adapter settings with a masked token.
25591 ///
25592 /// # Example
25593 ///
25594 /// ```
25595 /// # use churchtools_api::*;
25596 /// # use churchtools_api::queries::*;
25597 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25598 /// # let client = churchtools_api::replay::client("get-sync-adapters-id");
25599 /// let adapter = client.sync().adapters().get(1)?;
25600 /// println!("{}", adapter.name);
25601 /// # Ok(())
25602 /// # }
25603 /// ```
25604 pub fn get(&self, id: impl Display) -> Result<models::SyncAdapter> {
25605 let path = format!("/sync/adapters/{}", seg(id));
25606 let query: Query = Query::new();
25607 self.client.request_data(Method::Get, &path, &query, None)
25608 }
25609
25610 /// List sync adapters
25611 ///
25612 /// `GET /sync/adapters`
25613 ///
25614 /// Lists registered adapter services. An adapter translates between the Sync worker and a system-specific API.
25615 ///
25616 /// # Example
25617 ///
25618 /// ```
25619 /// # use churchtools_api::*;
25620 /// # use churchtools_api::queries::*;
25621 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25622 /// # let client = churchtools_api::replay::client("get-sync-adapters");
25623 /// for adapter in client.sync().adapters().list()? {
25624 /// println!("{}", adapter.name);
25625 /// }
25626 /// # Ok(())
25627 /// # }
25628 /// ```
25629 pub fn list(&self) -> Result<Vec<models::SyncAdapter>> {
25630 let path = "/sync/adapters".to_owned();
25631 let query: Query = Query::new();
25632 self.client.request_data(Method::Get, &path, &query, None)
25633 }
25634
25635 /// Replace sync adapter settings
25636 ///
25637 /// `PUT /sync/adapters/{id}`
25638 ///
25639 /// Replaces the adapter name, URL and authentication token.
25640 ///
25641 /// # Example
25642 ///
25643 /// ```no_run
25644 /// # use churchtools_api::*;
25645 /// # use churchtools_api::queries::*;
25646 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25647 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25648 /// let body = models::SyncAdapterUpdate {
25649 /// name: "churchtools".into(),
25650 /// token: "kfghsjdlkfigblszurglizeifuz4".into(),
25651 /// url: "http://localhost:8090".into(),
25652 /// ..Default::default()
25653 /// };
25654 /// let result = client.sync().adapters().update(1, &body)?;
25655 /// println!("{}", result.name);
25656 /// # Ok(())
25657 /// # }
25658 /// ```
25659 pub fn update(&self, id: impl Display, body: &models::SyncAdapterUpdate) -> Result<models::SyncAdapter> {
25660 let path = format!("/sync/adapters/{}", seg(id));
25661 let query: Query = Query::new();
25662 let body = serde_json::to_value(body).expect("request body serializes");
25663 self.client.request_data(Method::Put, &path, &query, Some(&body))
25664 }
25665
25666}
25667
25668/// `client.sync().adapters().proxy()`
25669#[derive(Clone, Copy)]
25670pub struct SyncAdaptersProxyResource<'a> {
25671 client: &'a Client,
25672}
25673
25674impl<'a> SyncAdaptersProxyResource<'a> {
25675 /// Proxy POST to a sync adapter
25676 ///
25677 /// `POST /sync/adapters/{adapterName}/proxy/{uri}`
25678 ///
25679 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. Uses the registered adapter token.
25680 ///
25681 /// # Example
25682 ///
25683 /// ```no_run
25684 /// # use churchtools_api::*;
25685 /// # use churchtools_api::queries::*;
25686 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25687 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25688 /// client.sync().adapters().proxy().create("churchtools", "adapter/info")?;
25689 /// # Ok(())
25690 /// # }
25691 /// ```
25692 pub fn create(&self, adapter_name: impl Display, uri: impl Display) -> Result<()> {
25693 let path = format!("/sync/adapters/{}/proxy/{}", seg(adapter_name), seg(uri));
25694 let query: Query = Query::new();
25695 self.client.request(Method::Post, &path, &query, None).map(|_| ())
25696 }
25697
25698 /// Proxy DELETE to a sync adapter
25699 ///
25700 /// `DELETE /sync/adapters/{adapterName}/proxy/{uri}`
25701 ///
25702 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. Uses the registered adapter token.
25703 ///
25704 /// # Example
25705 ///
25706 /// ```no_run
25707 /// # use churchtools_api::*;
25708 /// # use churchtools_api::queries::*;
25709 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25710 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25711 /// client.sync().adapters().proxy().delete("churchtools", "adapter/info")?;
25712 /// # Ok(())
25713 /// # }
25714 /// ```
25715 pub fn delete(&self, adapter_name: impl Display, uri: impl Display) -> Result<()> {
25716 let path = format!("/sync/adapters/{}/proxy/{}", seg(adapter_name), seg(uri));
25717 let query: Query = Query::new();
25718 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
25719 }
25720
25721 /// Proxy GET to a sync adapter
25722 ///
25723 /// `GET /sync/adapters/{adapterName}/proxy/{uri}`
25724 ///
25725 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. Uses the registered adapter token.
25726 ///
25727 /// # Example
25728 ///
25729 /// ```no_run
25730 /// # use churchtools_api::*;
25731 /// # use churchtools_api::queries::*;
25732 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25733 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25734 /// client.sync().adapters().proxy().get("churchtools", "adapter/info")?;
25735 /// # Ok(())
25736 /// # }
25737 /// ```
25738 pub fn get(&self, adapter_name: impl Display, uri: impl Display) -> Result<()> {
25739 let path = format!("/sync/adapters/{}/proxy/{}", seg(adapter_name), seg(uri));
25740 let query: Query = Query::new();
25741 self.client.request(Method::Get, &path, &query, None).map(|_| ())
25742 }
25743
25744 /// Proxy PATCH to a sync adapter
25745 ///
25746 /// `PATCH /sync/adapters/{adapterName}/proxy/{uri}`
25747 ///
25748 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. Uses the registered adapter token.
25749 ///
25750 /// # Example
25751 ///
25752 /// ```no_run
25753 /// # use churchtools_api::*;
25754 /// # use churchtools_api::queries::*;
25755 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25756 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25757 /// client.sync().adapters().proxy().patch("churchtools", "adapter/info")?;
25758 /// # Ok(())
25759 /// # }
25760 /// ```
25761 pub fn patch(&self, adapter_name: impl Display, uri: impl Display) -> Result<()> {
25762 let path = format!("/sync/adapters/{}/proxy/{}", seg(adapter_name), seg(uri));
25763 let query: Query = Query::new();
25764 self.client.request(Method::Patch, &path, &query, None).map(|_| ())
25765 }
25766
25767 /// Proxy PUT to a sync adapter
25768 ///
25769 /// `PUT /sync/adapters/{adapterName}/proxy/{uri}`
25770 ///
25771 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. Uses the registered adapter token.
25772 ///
25773 /// # Example
25774 ///
25775 /// ```no_run
25776 /// # use churchtools_api::*;
25777 /// # use churchtools_api::queries::*;
25778 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25779 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25780 /// client.sync().adapters().proxy().update("churchtools", "adapter/info")?;
25781 /// # Ok(())
25782 /// # }
25783 /// ```
25784 pub fn update(&self, adapter_name: impl Display, uri: impl Display) -> Result<()> {
25785 let path = format!("/sync/adapters/{}/proxy/{}", seg(adapter_name), seg(uri));
25786 let query: Query = Query::new();
25787 self.client.request(Method::Put, &path, &query, None).map(|_| ())
25788 }
25789
25790}
25791
25792/// `client.sync().conflicts()`
25793#[derive(Clone, Copy)]
25794pub struct SyncConflictsResource<'a> {
25795 client: &'a Client,
25796}
25797
25798impl<'a> SyncConflictsResource<'a> {
25799 /// Record a sync conflict
25800 ///
25801 /// `POST /sync/conflicts`
25802 ///
25803 /// Creates a conflict record. Requires "churchcore: administer persons" permission.
25804 ///
25805 /// # Example
25806 ///
25807 /// ```no_run
25808 /// # use churchtools_api::*;
25809 /// # use churchtools_api::queries::*;
25810 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25811 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25812 /// let body = models::SyncConflictCreate {
25813 /// data: vec![models::SyncConflictDataCreate {
25814 /// key: "abc123".into(),
25815 /// value: "beispiel".into(),
25816 /// ..Default::default()
25817 /// }],
25818 /// entity_mapping_id: 1,
25819 /// job_id: "7e31c399-91b1-4148-bfdd-6c05b557a25c".into(),
25820 /// r#type: "create".into(),
25821 /// ..Default::default()
25822 /// };
25823 /// let result = client.sync().conflicts().create(&body)?;
25824 /// println!("{}", result.id);
25825 /// # Ok(())
25826 /// # }
25827 /// ```
25828 pub fn create(&self, body: &models::SyncConflictCreate) -> Result<models::SyncConflicts> {
25829 let path = "/sync/conflicts".to_owned();
25830 let query: Query = Query::new();
25831 let body = serde_json::to_value(body).expect("request body serializes");
25832 self.client.request_data(Method::Post, &path, &query, Some(&body))
25833 }
25834
25835 /// Delete a sync conflict
25836 ///
25837 /// `DELETE /sync/conflicts/{id}`
25838 ///
25839 /// Removes the conflict record without resolving or modifying the underlying records. Missing conflicts also return `204`. Requires "churchcore: administer persons" permission.
25840 ///
25841 /// # Example
25842 ///
25843 /// ```no_run
25844 /// # use churchtools_api::*;
25845 /// # use churchtools_api::queries::*;
25846 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25847 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25848 /// client.sync().conflicts().delete(1)?;
25849 /// # Ok(())
25850 /// # }
25851 /// ```
25852 pub fn delete(&self, id: impl Display) -> Result<()> {
25853 let path = format!("/sync/conflicts/{}", seg(id));
25854 let query: Query = Query::new();
25855 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
25856 }
25857
25858 /// Get a sync conflict
25859 ///
25860 /// `GET /sync/conflicts/{id}`
25861 ///
25862 /// Returns one conflict and its supporting key/value data. Requires "churchcore: administer persons" permission.
25863 ///
25864 /// # Example
25865 ///
25866 /// ```no_run
25867 /// # use churchtools_api::*;
25868 /// # use churchtools_api::queries::*;
25869 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25870 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25871 /// let conflict = client.sync().conflicts().get(1)?;
25872 /// println!("{}", conflict.id);
25873 /// # Ok(())
25874 /// # }
25875 /// ```
25876 pub fn get(&self, id: impl Display) -> Result<models::SyncConflicts> {
25877 let path = format!("/sync/conflicts/{}", seg(id));
25878 let query: Query = Query::new();
25879 self.client.request_data(Method::Get, &path, &query, None)
25880 }
25881
25882 /// List sync conflicts
25883 ///
25884 /// `GET /sync/conflicts`
25885 ///
25886 /// Filters on source and domain refer to the linked entity mapping. Conflict `jobId` identifies the producing sync run, not a job configuration. Requires "churchcore: administer persons" permission.
25887 ///
25888 /// Use [`Self::list_with`] to pass query parameters.
25889 ///
25890 /// # Example
25891 ///
25892 /// ```
25893 /// # use churchtools_api::*;
25894 /// # use churchtools_api::queries::*;
25895 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25896 /// # let client = churchtools_api::replay::client("get-sync-conflicts");
25897 /// for conflict in client.sync().conflicts().list()? {
25898 /// println!("{}", conflict.id);
25899 /// }
25900 /// # Ok(())
25901 /// # }
25902 /// ```
25903 pub fn list(&self) -> Result<Vec<models::SyncConflicts>> {
25904 self.list_with(&Default::default())
25905 }
25906
25907 /// List sync conflicts
25908 ///
25909 /// Like [`Self::list`], with query parameters.
25910 ///
25911 /// `GET /sync/conflicts`
25912 ///
25913 /// Filters on source and domain refer to the linked entity mapping. Conflict `jobId` identifies the producing sync run, not a job configuration. Requires "churchcore: administer persons" permission.
25914 pub fn list_with(&self, query: &GetSyncConflictsQuery) -> Result<Vec<models::SyncConflicts>> {
25915 let path = "/sync/conflicts".to_owned();
25916 let query: Query = query.to_query();
25917 self.client.collect_pages(&path, query)
25918 }
25919
25920 /// List sync conflicts
25921 ///
25922 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
25923 /// Breaking off early saves the remaining requests.
25924 pub fn list_iter(&self, query: &GetSyncConflictsQuery) -> Items<models::SyncConflicts> {
25925 let path = "/sync/conflicts".to_owned();
25926 self.client.items(&path, query.to_query())
25927 }
25928
25929 /// Replace a sync conflict
25930 ///
25931 /// `PUT /sync/conflicts/{id}`
25932 ///
25933 /// Replaces job, relationship, type and all conflict data. This does not modify either synchronized record. Requires "churchcore: administer persons" permission.
25934 ///
25935 /// # Example
25936 ///
25937 /// ```no_run
25938 /// # use churchtools_api::*;
25939 /// # use churchtools_api::queries::*;
25940 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25941 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25942 /// let body = models::SyncConflictUpdate {
25943 /// data: vec![models::SyncConflictDataCreate {
25944 /// key: "abc123".into(),
25945 /// value: "beispiel".into(),
25946 /// ..Default::default()
25947 /// }],
25948 /// entity_mapping_id: 1,
25949 /// job_id: "7e31c399-91b1-4148-bfdd-6c05b557a25c".into(),
25950 /// r#type: "create".into(),
25951 /// ..Default::default()
25952 /// };
25953 /// let result = client.sync().conflicts().update(1, &body)?;
25954 /// println!("{}", result.id);
25955 /// # Ok(())
25956 /// # }
25957 /// ```
25958 pub fn update(&self, id: impl Display, body: &models::SyncConflictUpdate) -> Result<models::SyncConflicts> {
25959 let path = format!("/sync/conflicts/{}", seg(id));
25960 let query: Query = Query::new();
25961 let body = serde_json::to_value(body).expect("request body serializes");
25962 self.client.request_data(Method::Put, &path, &query, Some(&body))
25963 }
25964
25965}
25966
25967/// `client.sync().entity_mappings()`
25968#[derive(Clone, Copy)]
25969pub struct SyncEntityMappingsResource<'a> {
25970 client: &'a Client,
25971}
25972
25973impl<'a> SyncEntityMappingsResource<'a> {
25974 /// Create an entity mapping
25975 ///
25976 /// `POST /sync/entitymappings`
25977 ///
25978 /// Registers a relationship without creating either underlying record. Provided ChurchTools or external IDs must not be linked for the same domain and source. Requires "churchcore: administer persons" permission.
25979 ///
25980 /// # Example
25981 ///
25982 /// ```no_run
25983 /// # use churchtools_api::*;
25984 /// # use churchtools_api::queries::*;
25985 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
25986 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
25987 /// let body = models::SyncEntityMappingCreate {
25988 /// domain_id: Some("42".into()),
25989 /// domain_type: "status".into(),
25990 /// source_entity_id: Some("p-42".into()),
25991 /// source_id: 1,
25992 /// status: "synced".into(),
25993 /// ..Default::default()
25994 /// };
25995 /// let result = client.sync().entity_mappings().create(&body)?;
25996 /// println!("{}", result.id);
25997 /// # Ok(())
25998 /// # }
25999 /// ```
26000 pub fn create(&self, body: &models::SyncEntityMappingCreate) -> Result<models::SyncEntityMapping> {
26001 let path = "/sync/entitymappings".to_owned();
26002 let query: Query = Query::new();
26003 let body = serde_json::to_value(body).expect("request body serializes");
26004 self.client.request_data(Method::Post, &path, &query, Some(&body))
26005 }
26006
26007 /// Delete an entity mapping
26008 ///
26009 /// `DELETE /sync/entitymappings/{id}`
26010 ///
26011 /// Removes only the stored relationship; neither the ChurchTools record nor the external record is deleted. A missing mapping also returns `204`. Requires "churchcore: administer persons" permission.
26012 ///
26013 /// # Example
26014 ///
26015 /// ```no_run
26016 /// # use churchtools_api::*;
26017 /// # use churchtools_api::queries::*;
26018 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26019 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26020 /// client.sync().entity_mappings().delete(1)?;
26021 /// # Ok(())
26022 /// # }
26023 /// ```
26024 pub fn delete(&self, id: impl Display) -> Result<()> {
26025 let path = format!("/sync/entitymappings/{}", seg(id));
26026 let query: Query = Query::new();
26027 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26028 }
26029
26030 /// Get an entity mapping
26031 ///
26032 /// `GET /sync/entitymappings/{id}`
26033 ///
26034 /// Returns a stored relationship. Requires "churchcore: administer persons" permission.
26035 ///
26036 /// # Example
26037 ///
26038 /// ```
26039 /// # use churchtools_api::*;
26040 /// # use churchtools_api::queries::*;
26041 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26042 /// # let client = churchtools_api::replay::client("get-sync-entitymappings-id");
26043 /// let entity_mapping = client.sync().entity_mappings().get(1)?;
26044 /// println!("{}", entity_mapping.id);
26045 /// # Ok(())
26046 /// # }
26047 /// ```
26048 pub fn get(&self, id: impl Display) -> Result<models::SyncEntityMapping> {
26049 let path = format!("/sync/entitymappings/{}", seg(id));
26050 let query: Query = Query::new();
26051 self.client.request_data(Method::Get, &path, &query, None)
26052 }
26053
26054 /// List entity mappings
26055 ///
26056 /// `GET /sync/entitymappings`
26057 ///
26058 /// Lists relationships between ChurchTools records and external records, newest mapping ID first. `domainId` and `sourceEntityId` are record identifiers; `sourceId` identifies the external connection. Requires "churchcore: administer persons" permission.
26059 ///
26060 /// Use [`Self::list_with`] to pass query parameters.
26061 ///
26062 /// # Example
26063 ///
26064 /// ```
26065 /// # use churchtools_api::*;
26066 /// # use churchtools_api::queries::*;
26067 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26068 /// # let client = churchtools_api::replay::client("get-sync-entitymappings");
26069 /// for entity_mapping in client.sync().entity_mappings().list()? {
26070 /// println!("{}", entity_mapping.id);
26071 /// }
26072 /// # Ok(())
26073 /// # }
26074 /// ```
26075 pub fn list(&self) -> Result<Vec<models::SyncEntityMapping>> {
26076 self.list_with(&Default::default())
26077 }
26078
26079 /// List entity mappings
26080 ///
26081 /// Like [`Self::list`], with query parameters.
26082 ///
26083 /// `GET /sync/entitymappings`
26084 ///
26085 /// Lists relationships between ChurchTools records and external records, newest mapping ID first. `domainId` and `sourceEntityId` are record identifiers; `sourceId` identifies the external connection. Requires "churchcore: administer persons" permission.
26086 pub fn list_with(&self, query: &GetSyncEntitymappingsQuery) -> Result<Vec<models::SyncEntityMapping>> {
26087 let path = "/sync/entitymappings".to_owned();
26088 let query: Query = query.to_query();
26089 self.client.collect_pages(&path, query)
26090 }
26091
26092 /// List entity mappings
26093 ///
26094 /// Like [`Self::list_with`], but lazy: each page is fetched only when the iteration reaches it.
26095 /// Breaking off early saves the remaining requests.
26096 pub fn list_iter(&self, query: &GetSyncEntitymappingsQuery) -> Items<models::SyncEntityMapping> {
26097 let path = "/sync/entitymappings".to_owned();
26098 self.client.items(&path, query.to_query())
26099 }
26100
26101 /// Update or create an entity mapping
26102 ///
26103 /// `PUT /sync/entitymappings/{id}`
26104 ///
26105 /// Updates the relationship. Requires "churchcore: administer persons" permission.
26106 ///
26107 /// # Example
26108 ///
26109 /// ```no_run
26110 /// # use churchtools_api::*;
26111 /// # use churchtools_api::queries::*;
26112 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26113 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26114 /// let body = models::SyncEntityMappingUpdate {
26115 /// domain_id: Some("42".into()),
26116 /// domain_type: "status".into(),
26117 /// source_entity_id: Some("p-42".into()),
26118 /// source_id: 1,
26119 /// status: "synced".into(),
26120 /// ..Default::default()
26121 /// };
26122 /// let result = client.sync().entity_mappings().update(1, &body)?;
26123 /// println!("{}", result.id);
26124 /// # Ok(())
26125 /// # }
26126 /// ```
26127 pub fn update(&self, id: impl Display, body: &models::SyncEntityMappingUpdate) -> Result<models::SyncEntityMapping> {
26128 let path = format!("/sync/entitymappings/{}", seg(id));
26129 let query: Query = Query::new();
26130 let body = serde_json::to_value(body).expect("request body serializes");
26131 self.client.request_data(Method::Put, &path, &query, Some(&body))
26132 }
26133
26134}
26135
26136/// `client.sync().externalsystems()`
26137#[derive(Clone, Copy)]
26138pub struct SyncExternalsystemsResource<'a> {
26139 client: &'a Client,
26140}
26141
26142impl<'a> SyncExternalsystemsResource<'a> {
26143 pub fn adapter_proxy(&self) -> SyncExternalsystemsAdapterProxyResource<'a> {
26144 SyncExternalsystemsAdapterProxyResource { client: self.client }
26145 }
26146
26147 pub fn field_mappings(&self) -> SyncExternalsystemsFieldMappingsResource<'a> {
26148 SyncExternalsystemsFieldMappingsResource { client: self.client }
26149 }
26150
26151 pub fn job_configs(&self) -> SyncExternalsystemsJobConfigsResource<'a> {
26152 SyncExternalsystemsJobConfigsResource { client: self.client }
26153 }
26154
26155 /// Create an external connection
26156 ///
26157 /// `POST /sync/externalsystems`
26158 ///
26159 /// Creates a connection using an existing adapter name and copies available field-mapping presets. Outside the trial period, the licensed connection limit is checked.
26160 ///
26161 /// # Example
26162 ///
26163 /// ```no_run
26164 /// # use churchtools_api::*;
26165 /// # use churchtools_api::queries::*;
26166 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26167 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26168 /// let body = models::ExternalSystemCreate {
26169 /// access_header_values: serde_json::json!({}),
26170 /// adapter: "churchtools".into(),
26171 /// name: "Accounting system".into(),
26172 /// ..Default::default()
26173 /// };
26174 /// let result = client.sync().externalsystems().create(&body)?;
26175 /// println!("{}", result.name);
26176 /// # Ok(())
26177 /// # }
26178 /// ```
26179 pub fn create(&self, body: &models::ExternalSystemCreate) -> Result<models::ExternalSystem> {
26180 let path = "/sync/externalsystems".to_owned();
26181 let query: Query = Query::new();
26182 let body = serde_json::to_value(body).expect("request body serializes");
26183 self.client.request_data(Method::Post, &path, &query, Some(&body))
26184 }
26185
26186 /// Delete an external connection
26187 ///
26188 /// `DELETE /sync/externalsystems/{externalSystemId}`
26189 ///
26190 /// Deletes the connection, its job configurations, related job logs and executions, field mappings and entity mappings. Synchronized records themselves are not deleted. Returns `204` if the connection is missing.
26191 ///
26192 /// # Example
26193 ///
26194 /// ```no_run
26195 /// # use churchtools_api::*;
26196 /// # use churchtools_api::queries::*;
26197 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26198 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26199 /// client.sync().externalsystems().delete(1)?;
26200 /// # Ok(())
26201 /// # }
26202 /// ```
26203 pub fn delete(&self, external_system_id: impl Display) -> Result<()> {
26204 let path = format!("/sync/externalsystems/{}", seg(external_system_id));
26205 let query: Query = Query::new();
26206 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26207 }
26208
26209 /// Delete all mappings for an external connection
26210 ///
26211 /// `DELETE /sync/externalsystems/{externalSystemId}/entitymappings`
26212 ///
26213 /// Removes all relationships belonging to the external connection. Underlying records remain. Returns `204` when no mapping exists. Requires "churchcore: administer persons" permission.
26214 ///
26215 /// # Example
26216 ///
26217 /// ```no_run
26218 /// # use churchtools_api::*;
26219 /// # use churchtools_api::queries::*;
26220 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26221 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26222 /// client.sync().externalsystems().delete_entity_mappings(1)?;
26223 /// # Ok(())
26224 /// # }
26225 /// ```
26226 pub fn delete_entity_mappings(&self, external_system_id: impl Display) -> Result<()> {
26227 let path = format!("/sync/externalsystems/{}/entitymappings", seg(external_system_id));
26228 let query: Query = Query::new();
26229 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26230 }
26231
26232 /// Get an external connection
26233 ///
26234 /// `GET /sync/externalsystems/{externalSystemId}`
26235 ///
26236 /// Returns connection settings with masked access credentials.
26237 ///
26238 /// # Example
26239 ///
26240 /// ```
26241 /// # use churchtools_api::*;
26242 /// # use churchtools_api::queries::*;
26243 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26244 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-externalSystemId");
26245 /// let externalsystem = client.sync().externalsystems().get(1)?;
26246 /// println!("{}", externalsystem.name);
26247 /// # Ok(())
26248 /// # }
26249 /// ```
26250 pub fn get(&self, external_system_id: impl Display) -> Result<models::ExternalSystem> {
26251 let path = format!("/sync/externalsystems/{}", seg(external_system_id));
26252 let query: Query = Query::new();
26253 self.client.request_data(Method::Get, &path, &query, None)
26254 }
26255
26256 /// List external connections
26257 ///
26258 /// `GET /sync/externalsystems`
26259 ///
26260 /// Lists configured connections, including their adapter names and job counts. A connection identifies one external installation or account; several can use the same adapter.
26261 ///
26262 /// # Example
26263 ///
26264 /// ```
26265 /// # use churchtools_api::*;
26266 /// # use churchtools_api::queries::*;
26267 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26268 /// # let client = churchtools_api::replay::client("get-sync-externalsystems");
26269 /// for externalsystem in client.sync().externalsystems().list()? {
26270 /// println!("{}", externalsystem.name);
26271 /// }
26272 /// # Ok(())
26273 /// # }
26274 /// ```
26275 pub fn list(&self) -> Result<Vec<models::ExternalSystem>> {
26276 let path = "/sync/externalsystems".to_owned();
26277 let query: Query = Query::new();
26278 self.client.request_data(Method::Get, &path, &query, None)
26279 }
26280
26281 /// Test a saved external connection
26282 ///
26283 /// `POST /sync/externalsystems/{externalSystemId}/test`
26284 ///
26285 /// Calls the adapter’s connection test using the saved settings. This is a connection check, not a synchronization run.
26286 ///
26287 /// # Example
26288 ///
26289 /// ```no_run
26290 /// # use churchtools_api::*;
26291 /// # use churchtools_api::queries::*;
26292 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26293 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26294 /// client.sync().externalsystems().test(1)?;
26295 /// # Ok(())
26296 /// # }
26297 /// ```
26298 pub fn test(&self, external_system_id: impl Display) -> Result<()> {
26299 let path = format!("/sync/externalsystems/{}/test", seg(external_system_id));
26300 let query: Query = Query::new();
26301 self.client.request(Method::Post, &path, &query, None).map(|_| ())
26302 }
26303
26304 /// Test proposed external connection settings
26305 ///
26306 /// `POST /sync/externalsystems/test`
26307 ///
26308 /// Runs the adapter's connection test without saving the supplied settings.
26309 ///
26310 /// # Example
26311 ///
26312 /// ```no_run
26313 /// # use churchtools_api::*;
26314 /// # use churchtools_api::queries::*;
26315 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26316 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26317 /// let body = models::SyncExternalSystemTestCreate {
26318 /// access_header_values: serde_json::json!({}),
26319 /// adapter: "churchtools".into(),
26320 /// name: "Accounting system".into(),
26321 /// ..Default::default()
26322 /// };
26323 /// let result = client.sync().externalsystems().test_settings(&body)?;
26324 /// println!("{:?}", result);
26325 /// # Ok(())
26326 /// # }
26327 /// ```
26328 pub fn test_settings(&self, body: &models::SyncExternalSystemTestCreate) -> Result<serde_json::Value> {
26329 let path = "/sync/externalsystems/test".to_owned();
26330 let query: Query = Query::new();
26331 let body = serde_json::to_value(body).expect("request body serializes");
26332 self.client.request_data(Method::Post, &path, &query, Some(&body))
26333 }
26334
26335 /// Update an external connection
26336 ///
26337 /// `PUT /sync/externalsystems/{externalSystemId}`
26338 ///
26339 /// Changes the name and adapter and merges supplied access headers.
26340 ///
26341 /// # Example
26342 ///
26343 /// ```no_run
26344 /// # use churchtools_api::*;
26345 /// # use churchtools_api::queries::*;
26346 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26347 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26348 /// let body = models::ExternalSystemUpdate {
26349 /// access_header_values: serde_json::json!({}),
26350 /// adapter: "churchtools".into(),
26351 /// name: "Accounting system".into(),
26352 /// id: 1,
26353 /// ..Default::default()
26354 /// };
26355 /// let result = client.sync().externalsystems().update(1, &body)?;
26356 /// println!("{}", result.name);
26357 /// # Ok(())
26358 /// # }
26359 /// ```
26360 pub fn update(&self, external_system_id: impl Display, body: &models::ExternalSystemUpdate) -> Result<models::ExternalSystem> {
26361 let path = format!("/sync/externalsystems/{}", seg(external_system_id));
26362 let query: Query = Query::new();
26363 let body = serde_json::to_value(body).expect("request body serializes");
26364 self.client.request_data(Method::Put, &path, &query, Some(&body))
26365 }
26366
26367}
26368
26369/// `client.sync().externalsystems().adapter_proxy()`
26370#[derive(Clone, Copy)]
26371pub struct SyncExternalsystemsAdapterProxyResource<'a> {
26372 client: &'a Client,
26373}
26374
26375impl<'a> SyncExternalsystemsAdapterProxyResource<'a> {
26376 /// Proxy POST to a sync adapter
26377 ///
26378 /// `POST /sync/externalsystems/{externalSystemId}/adapterproxy/{uri}`
26379 ///
26380 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. `externalSystemId` set to `0` selects the local ChurchTools system.
26381 ///
26382 /// # Example
26383 ///
26384 /// ```no_run
26385 /// # use churchtools_api::*;
26386 /// # use churchtools_api::queries::*;
26387 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26388 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26389 /// client.sync().externalsystems().adapter_proxy().create(1, "adapter/info")?;
26390 /// # Ok(())
26391 /// # }
26392 /// ```
26393 pub fn create(&self, external_system_id: impl Display, uri: impl Display) -> Result<()> {
26394 let path = format!("/sync/externalsystems/{}/adapterproxy/{}", seg(external_system_id), seg(uri));
26395 let query: Query = Query::new();
26396 self.client.request(Method::Post, &path, &query, None).map(|_| ())
26397 }
26398
26399 /// Proxy DELETE to a sync adapter
26400 ///
26401 /// `DELETE /sync/externalsystems/{externalSystemId}/adapterproxy/{uri}`
26402 ///
26403 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. `externalSystemId` set to `0` selects the local ChurchTools system.
26404 ///
26405 /// # Example
26406 ///
26407 /// ```no_run
26408 /// # use churchtools_api::*;
26409 /// # use churchtools_api::queries::*;
26410 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26411 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26412 /// client.sync().externalsystems().adapter_proxy().delete(1, "adapter/info")?;
26413 /// # Ok(())
26414 /// # }
26415 /// ```
26416 pub fn delete(&self, external_system_id: impl Display, uri: impl Display) -> Result<()> {
26417 let path = format!("/sync/externalsystems/{}/adapterproxy/{}", seg(external_system_id), seg(uri));
26418 let query: Query = Query::new();
26419 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26420 }
26421
26422 /// Proxy GET to a sync adapter
26423 ///
26424 /// `GET /sync/externalsystems/{externalSystemId}/adapterproxy/{uri}`
26425 ///
26426 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. `externalSystemId` set to `0` selects the local ChurchTools system.
26427 ///
26428 /// # Example
26429 ///
26430 /// ```no_run
26431 /// # use churchtools_api::*;
26432 /// # use churchtools_api::queries::*;
26433 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26434 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26435 /// client.sync().externalsystems().adapter_proxy().get(1, "adapter/info")?;
26436 /// # Ok(())
26437 /// # }
26438 /// ```
26439 pub fn get(&self, external_system_id: impl Display, uri: impl Display) -> Result<()> {
26440 let path = format!("/sync/externalsystems/{}/adapterproxy/{}", seg(external_system_id), seg(uri));
26441 let query: Query = Query::new();
26442 self.client.request(Method::Get, &path, &query, None).map(|_| ())
26443 }
26444
26445 /// Proxy PATCH to a sync adapter
26446 ///
26447 /// `PATCH /sync/externalsystems/{externalSystemId}/adapterproxy/{uri}`
26448 ///
26449 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. `externalSystemId` set to `0` selects the local ChurchTools system.
26450 ///
26451 /// # Example
26452 ///
26453 /// ```no_run
26454 /// # use churchtools_api::*;
26455 /// # use churchtools_api::queries::*;
26456 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26457 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26458 /// client.sync().externalsystems().adapter_proxy().patch(1, "adapter/info")?;
26459 /// # Ok(())
26460 /// # }
26461 /// ```
26462 pub fn patch(&self, external_system_id: impl Display, uri: impl Display) -> Result<()> {
26463 let path = format!("/sync/externalsystems/{}/adapterproxy/{}", seg(external_system_id), seg(uri));
26464 let query: Query = Query::new();
26465 self.client.request(Method::Patch, &path, &query, None).map(|_| ())
26466 }
26467
26468 /// Proxy PUT to a sync adapter
26469 ///
26470 /// `PUT /sync/externalsystems/{externalSystemId}/adapterproxy/{uri}`
26471 ///
26472 /// Forwards the HTTP method and query parameters to the adapter’s `/api/{uri}` route. Response status, body and `Content-Type` come from the adapter without a `data` wrapper. `externalSystemId` set to `0` selects the local ChurchTools system.
26473 ///
26474 /// # Example
26475 ///
26476 /// ```no_run
26477 /// # use churchtools_api::*;
26478 /// # use churchtools_api::queries::*;
26479 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26480 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26481 /// client.sync().externalsystems().adapter_proxy().update(1, "adapter/info")?;
26482 /// # Ok(())
26483 /// # }
26484 /// ```
26485 pub fn update(&self, external_system_id: impl Display, uri: impl Display) -> Result<()> {
26486 let path = format!("/sync/externalsystems/{}/adapterproxy/{}", seg(external_system_id), seg(uri));
26487 let query: Query = Query::new();
26488 self.client.request(Method::Put, &path, &query, None).map(|_| ())
26489 }
26490
26491}
26492
26493/// `client.sync().externalsystems().field_mappings()`
26494#[derive(Clone, Copy)]
26495pub struct SyncExternalsystemsFieldMappingsResource<'a> {
26496 client: &'a Client,
26497}
26498
26499impl<'a> SyncExternalsystemsFieldMappingsResource<'a> {
26500 /// Delete field mappings for a domain
26501 ///
26502 /// `DELETE /sync/externalsystems/{externalSystemId}/fieldmappings/{domainType}`
26503 ///
26504 /// Removes the stored field mapping and its entries for this connection and domain. A missing mapping also returns `204`.
26505 ///
26506 /// # Example
26507 ///
26508 /// ```no_run
26509 /// # use churchtools_api::*;
26510 /// # use churchtools_api::queries::*;
26511 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26512 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26513 /// client.sync().externalsystems().field_mappings().delete(1, "status")?;
26514 /// # Ok(())
26515 /// # }
26516 /// ```
26517 pub fn delete(&self, external_system_id: impl Display, domain_type: impl Display) -> Result<()> {
26518 let path = format!("/sync/externalsystems/{}/fieldmappings/{}", seg(external_system_id), seg(domain_type));
26519 let query: Query = Query::new();
26520 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26521 }
26522
26523 /// Get field mappings for a domain
26524 ///
26525 /// `GET /sync/externalsystems/{externalSystemId}/fieldmappings/{domainType}`
26526 ///
26527 /// Returns mappings in both directions. If the connection exists but no mapping is stored for the domain, returns an unsaved mapping.
26528 ///
26529 /// # Example
26530 ///
26531 /// ```
26532 /// # use churchtools_api::*;
26533 /// # use churchtools_api::queries::*;
26534 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26535 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-id-fieldmappings-domaintype");
26536 /// let field_mapping = client.sync().externalsystems().field_mappings().get(1, "status")?;
26537 /// println!("{:?}", field_mapping.id);
26538 /// # Ok(())
26539 /// # }
26540 /// ```
26541 pub fn get(&self, external_system_id: impl Display, domain_type: impl Display) -> Result<models::FieldMapping> {
26542 let path = format!("/sync/externalsystems/{}/fieldmappings/{}", seg(external_system_id), seg(domain_type));
26543 let query: Query = Query::new();
26544 self.client.request_data(Method::Get, &path, &query, None)
26545 }
26546
26547 /// List fields without mapping suggestions
26548 ///
26549 /// `GET /sync/externalsystems/{externalSystemId}/fieldmappings/{domainType}/nosuggestions`
26550 ///
26551 /// Returns source fields whose adapter preset has no target suggestion, grouped by system. This reports preset coverage, not all unselected job fields.
26552 ///
26553 /// # Example
26554 ///
26555 /// ```
26556 /// # use churchtools_api::*;
26557 /// # use churchtools_api::queries::*;
26558 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26559 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-id-fieldmappings-domaintype-nosuggestions");
26560 /// let result = client.sync().externalsystems().field_mappings().get_nosuggestions(1, "status")?;
26561 /// println!("{:?}", result);
26562 /// # Ok(())
26563 /// # }
26564 /// ```
26565 pub fn get_nosuggestions(&self, external_system_id: impl Display, domain_type: impl Display) -> Result<serde_json::Value> {
26566 let path = format!("/sync/externalsystems/{}/fieldmappings/{}/nosuggestions", seg(external_system_id), seg(domain_type));
26567 let query: Query = Query::new();
26568 self.client.request_data(Method::Get, &path, &query, None)
26569 }
26570
26571 /// List field mappings for a connection
26572 ///
26573 /// `GET /sync/externalsystems/{externalSystemId}/fieldmappings`
26574 ///
26575 /// Lists stored domain-level field mappings. These define available translations between fields; a job separately selects which mappings to use.
26576 ///
26577 /// # Example
26578 ///
26579 /// ```
26580 /// # use churchtools_api::*;
26581 /// # use churchtools_api::queries::*;
26582 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26583 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-externalSystemId-fieldmappings");
26584 /// for field_mapping in client.sync().externalsystems().field_mappings().list(1)? {
26585 /// println!("{:?}", field_mapping.id);
26586 /// }
26587 /// # Ok(())
26588 /// # }
26589 /// ```
26590 pub fn list(&self, external_system_id: impl Display) -> Result<Vec<models::FieldMapping>> {
26591 let path = format!("/sync/externalsystems/{}/fieldmappings", seg(external_system_id));
26592 let query: Query = Query::new();
26593 self.client.request_data(Method::Get, &path, &query, None)
26594 }
26595
26596 /// Replace field mappings for a domain
26597 ///
26598 /// `PUT /sync/externalsystems/{externalSystemId}/fieldmappings/{domainType}`
26599 ///
26600 /// Replaces both direction lists. Direction is inferred from the enclosing list.
26601 ///
26602 /// # Example
26603 ///
26604 /// ```no_run
26605 /// # use churchtools_api::*;
26606 /// # use churchtools_api::queries::*;
26607 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26608 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26609 /// let body = models::SyncFieldMappingUpdate {
26610 /// property_mappings_es_to_master: vec![models::SyncFieldMappingEntryCreate {
26611 /// from: "firstName".into(),
26612 /// from_filter: "".into(),
26613 /// others: serde_json::json!({}),
26614 /// to: "firstName".into(),
26615 /// to_filter: "".into(),
26616 /// value_mapping: serde_json::json!({}),
26617 /// ..Default::default()
26618 /// }],
26619 /// property_mappings_master_to_es: vec![models::SyncFieldMappingEntryCreate {
26620 /// from: "firstName".into(),
26621 /// from_filter: "".into(),
26622 /// others: serde_json::json!({}),
26623 /// to: "firstName".into(),
26624 /// to_filter: "".into(),
26625 /// value_mapping: serde_json::json!({}),
26626 /// ..Default::default()
26627 /// }],
26628 /// ..Default::default()
26629 /// };
26630 /// let result = client.sync().externalsystems().field_mappings().update(1, "status", &body)?;
26631 /// println!("{:?}", result.id);
26632 /// # Ok(())
26633 /// # }
26634 /// ```
26635 pub fn update(&self, external_system_id: impl Display, domain_type: impl Display, body: &models::SyncFieldMappingUpdate) -> Result<models::FieldMapping> {
26636 let path = format!("/sync/externalsystems/{}/fieldmappings/{}", seg(external_system_id), seg(domain_type));
26637 let query: Query = Query::new();
26638 let body = serde_json::to_value(body).expect("request body serializes");
26639 self.client.request_data(Method::Put, &path, &query, Some(&body))
26640 }
26641
26642}
26643
26644/// `client.sync().externalsystems().job_configs()`
26645#[derive(Clone, Copy)]
26646pub struct SyncExternalsystemsJobConfigsResource<'a> {
26647 client: &'a Client,
26648}
26649
26650impl<'a> SyncExternalsystemsJobConfigsResource<'a> {
26651 pub fn executions(&self) -> SyncExternalsystemsJobConfigsExecutionsResource<'a> {
26652 SyncExternalsystemsJobConfigsExecutionsResource { client: self.client }
26653 }
26654
26655 /// Create a sync job configuration
26656 ///
26657 /// `POST /sync/externalsystems/{externalSystemId}/jobconfigs`
26658 ///
26659 /// Selected fields and record filters are managed through the properties and filter endpoints.
26660 ///
26661 /// # Example
26662 ///
26663 /// ```no_run
26664 /// # use churchtools_api::*;
26665 /// # use churchtools_api::queries::*;
26666 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26667 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26668 /// let body = models::SyncJobConfigurationCreate {
26669 /// auto_schedule_enabled: false,
26670 /// domain_type: "person".into(),
26671 /// name: "Synchronize people".into(),
26672 /// ..Default::default()
26673 /// };
26674 /// let result = client.sync().externalsystems().job_configs().create(1, &body)?;
26675 /// println!("{}", result.name);
26676 /// # Ok(())
26677 /// # }
26678 /// ```
26679 pub fn create(&self, external_system_id: impl Display, body: &models::SyncJobConfigurationCreate) -> Result<models::JobConfigurationReturn> {
26680 let path = format!("/sync/externalsystems/{}/jobconfigs", seg(external_system_id));
26681 let query: Query = Query::new();
26682 let body = serde_json::to_value(body).expect("request body serializes");
26683 self.client.request_data(Method::Post, &path, &query, Some(&body))
26684 }
26685
26686 /// Delete a sync job configuration
26687 ///
26688 /// `DELETE /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}`
26689 ///
26690 /// Deletes the configuration together with selected properties, filters, logs and associated background executions. Missing jobs also return `204`.
26691 ///
26692 /// # Example
26693 ///
26694 /// ```no_run
26695 /// # use churchtools_api::*;
26696 /// # use churchtools_api::queries::*;
26697 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26698 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26699 /// client.sync().externalsystems().job_configs().delete(1, 1)?;
26700 /// # Ok(())
26701 /// # }
26702 /// ```
26703 pub fn delete(&self, external_system_id: impl Display, job_id: impl Display) -> Result<()> {
26704 let path = format!("/sync/externalsystems/{}/jobconfigs/{}", seg(external_system_id), seg(job_id));
26705 let query: Query = Query::new();
26706 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26707 }
26708
26709 /// Clear sync job record filters
26710 ///
26711 /// `DELETE /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/filter`
26712 ///
26713 /// Deletes all record filters; the job configuration remains.
26714 ///
26715 /// # Example
26716 ///
26717 /// ```no_run
26718 /// # use churchtools_api::*;
26719 /// # use churchtools_api::queries::*;
26720 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26721 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26722 /// client.sync().externalsystems().job_configs().delete_filter(1, 1)?;
26723 /// # Ok(())
26724 /// # }
26725 /// ```
26726 pub fn delete_filter(&self, external_system_id: impl Display, job_id: impl Display) -> Result<()> {
26727 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/filter", seg(external_system_id), seg(job_id));
26728 let query: Query = Query::new();
26729 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26730 }
26731
26732 /// Clear sync job selected fields
26733 ///
26734 /// `DELETE /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/properties`
26735 ///
26736 /// Deletes all selected fields; the job configuration remains.
26737 ///
26738 /// # Example
26739 ///
26740 /// ```no_run
26741 /// # use churchtools_api::*;
26742 /// # use churchtools_api::queries::*;
26743 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26744 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26745 /// client.sync().externalsystems().job_configs().delete_properties(1, 1)?;
26746 /// # Ok(())
26747 /// # }
26748 /// ```
26749 pub fn delete_properties(&self, external_system_id: impl Display, job_id: impl Display) -> Result<()> {
26750 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/properties", seg(external_system_id), seg(job_id));
26751 let query: Query = Query::new();
26752 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
26753 }
26754
26755 /// Find a sync job configuration
26756 ///
26757 /// `GET /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}`
26758 ///
26759 /// Returns configurations matching the job and external connection IDs.
26760 ///
26761 /// # Example
26762 ///
26763 /// ```
26764 /// # use churchtools_api::*;
26765 /// # use churchtools_api::queries::*;
26766 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26767 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-externalSystemId-jobconfigs-jobId");
26768 /// for job_config in client.sync().externalsystems().job_configs().get(1, 1)? {
26769 /// println!("{}", job_config.name);
26770 /// }
26771 /// # Ok(())
26772 /// # }
26773 /// ```
26774 pub fn get(&self, external_system_id: impl Display, job_id: impl Display) -> Result<Vec<models::JobConfigurationReturn>> {
26775 let path = format!("/sync/externalsystems/{}/jobconfigs/{}", seg(external_system_id), seg(job_id));
26776 let query: Query = Query::new();
26777 self.client.request_data(Method::Get, &path, &query, None)
26778 }
26779
26780 /// Get sync job record filters
26781 ///
26782 /// `GET /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/filter`
26783 ///
26784 /// Returns record filters grouped by direction.
26785 ///
26786 /// # Example
26787 ///
26788 /// ```
26789 /// # use churchtools_api::*;
26790 /// # use churchtools_api::queries::*;
26791 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26792 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-externalSystemId-jobconfigs-jobId-filter");
26793 /// let filter = client.sync().externalsystems().job_configs().get_filter(1, 1)?;
26794 /// println!("{:?}", filter);
26795 /// # Ok(())
26796 /// # }
26797 /// ```
26798 pub fn get_filter(&self, external_system_id: impl Display, job_id: impl Display) -> Result<models::SyncJobFilters> {
26799 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/filter", seg(external_system_id), seg(job_id));
26800 let query: Query = Query::new();
26801 self.client.request_data(Method::Get, &path, &query, None)
26802 }
26803
26804 /// Get sync job selected fields
26805 ///
26806 /// `GET /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/properties`
26807 ///
26808 /// Returns selected fields grouped by direction.
26809 ///
26810 /// # Example
26811 ///
26812 /// ```
26813 /// # use churchtools_api::*;
26814 /// # use churchtools_api::queries::*;
26815 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26816 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-externalSystemId-jobconfigs-jobId-properties");
26817 /// let property = client.sync().externalsystems().job_configs().get_properties(1, 1)?;
26818 /// println!("{}", property.domain_type);
26819 /// # Ok(())
26820 /// # }
26821 /// ```
26822 pub fn get_properties(&self, external_system_id: impl Display, job_id: impl Display) -> Result<models::SyncJobProperties> {
26823 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/properties", seg(external_system_id), seg(job_id));
26824 let query: Query = Query::new();
26825 self.client.request_data(Method::Get, &path, &query, None)
26826 }
26827
26828 /// List jobs for an external connection
26829 ///
26830 /// `GET /sync/externalsystems/{externalSystemId}/jobconfigs`
26831 ///
26832 /// Lists job configurations belonging to the external connection.
26833 ///
26834 /// # Example
26835 ///
26836 /// ```
26837 /// # use churchtools_api::*;
26838 /// # use churchtools_api::queries::*;
26839 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26840 /// # let client = churchtools_api::replay::client("get-sync-externalsystems-id-jobconfigs");
26841 /// for job_config in client.sync().externalsystems().job_configs().list(1)? {
26842 /// println!("{}", job_config.name);
26843 /// }
26844 /// # Ok(())
26845 /// # }
26846 /// ```
26847 pub fn list(&self, external_system_id: impl Display) -> Result<Vec<models::JobConfigurationReturn>> {
26848 let path = format!("/sync/externalsystems/{}/jobconfigs", seg(external_system_id));
26849 let query: Query = Query::new();
26850 self.client.request_data(Method::Get, &path, &query, None)
26851 }
26852
26853 /// Schedule a sync execution
26854 ///
26855 /// `POST /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/start`
26856 ///
26857 /// Schedules the configuration as a background job. A `204` response confirms scheduling, not successful synchronization. Inspect `/sync/executions` and `/sync/logs` for progress. Requires an enabled license or active trial.
26858 ///
26859 /// # Example
26860 ///
26861 /// ```no_run
26862 /// # use churchtools_api::*;
26863 /// # use churchtools_api::queries::*;
26864 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26865 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26866 /// let body = models::SyncExecutionCreate {
26867 /// is_dry_run: Some(true),
26868 /// ..Default::default()
26869 /// };
26870 /// client.sync().externalsystems().job_configs().start(1, 1, &body)?;
26871 /// # Ok(())
26872 /// # }
26873 /// ```
26874 pub fn start(&self, external_system_id: impl Display, job_id: impl Display, body: &models::SyncExecutionCreate) -> Result<()> {
26875 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/start", seg(external_system_id), seg(job_id));
26876 let query: Query = Query::new();
26877 let body = serde_json::to_value(body).expect("request body serializes");
26878 self.client.request(Method::Post, &path, &query, Some(&body)).map(|_| ())
26879 }
26880
26881 /// Update a sync job configuration
26882 ///
26883 /// `PUT /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}`
26884 ///
26885 /// Updates the job configuration for the external connection.
26886 ///
26887 /// # Example
26888 ///
26889 /// ```no_run
26890 /// # use churchtools_api::*;
26891 /// # use churchtools_api::queries::*;
26892 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26893 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26894 /// let body = models::SyncJobConfigurationUpdate {
26895 /// auto_schedule_enabled: false,
26896 /// domain_type: "person".into(),
26897 /// name: "Synchronize people".into(),
26898 /// id: 1,
26899 /// ..Default::default()
26900 /// };
26901 /// let result = client.sync().externalsystems().job_configs().update(1, 1, &body)?;
26902 /// println!("{}", result.name);
26903 /// # Ok(())
26904 /// # }
26905 /// ```
26906 pub fn update(&self, external_system_id: impl Display, job_id: impl Display, body: &models::SyncJobConfigurationUpdate) -> Result<models::JobConfigurationReturn> {
26907 let path = format!("/sync/externalsystems/{}/jobconfigs/{}", seg(external_system_id), seg(job_id));
26908 let query: Query = Query::new();
26909 let body = serde_json::to_value(body).expect("request body serializes");
26910 self.client.request_data(Method::Put, &path, &query, Some(&body))
26911 }
26912
26913 /// Replace sync job record filters
26914 ///
26915 /// `PUT /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/filter`
26916 ///
26917 /// Filter operators and values are interpreted by the adapter.
26918 ///
26919 /// # Example
26920 ///
26921 /// ```no_run
26922 /// # use churchtools_api::*;
26923 /// # use churchtools_api::queries::*;
26924 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26925 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26926 /// let body = models::SyncJobFiltersUpdate {
26927 /// es: vec![models::SyncJobFilterCreate {
26928 /// field: "statusId".into(),
26929 /// system: "master".into(),
26930 /// values: serde_json::json!({}),
26931 /// ..Default::default()
26932 /// }],
26933 /// master: vec![models::SyncJobFilterCreate {
26934 /// field: "statusId".into(),
26935 /// system: "master".into(),
26936 /// values: serde_json::json!({}),
26937 /// ..Default::default()
26938 /// }],
26939 /// ..Default::default()
26940 /// };
26941 /// let result = client.sync().externalsystems().job_configs().update_filter(1, 1, &body)?;
26942 /// println!("{:?}", result);
26943 /// # Ok(())
26944 /// # }
26945 /// ```
26946 pub fn update_filter(&self, external_system_id: impl Display, job_id: impl Display, body: &models::SyncJobFiltersUpdate) -> Result<models::SyncJobFilters> {
26947 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/filter", seg(external_system_id), seg(job_id));
26948 let query: Query = Query::new();
26949 let body = serde_json::to_value(body).expect("request body serializes");
26950 self.client.request_data(Method::Put, &path, &query, Some(&body))
26951 }
26952
26953 /// Replace sync job selected fields
26954 ///
26955 /// `PUT /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/properties`
26956 ///
26957 /// Value mappings and adapter options are inherited from the referenced mapping.
26958 ///
26959 /// # Example
26960 ///
26961 /// ```no_run
26962 /// # use churchtools_api::*;
26963 /// # use churchtools_api::queries::*;
26964 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
26965 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
26966 /// let body = models::SyncJobPropertiesUpdate {
26967 /// property_mappings_es_to_master: vec![models::SyncJobPropertyCreate {
26968 /// field_mapping_id: 1,
26969 /// from: "firstName".into(),
26970 /// from_filter: "".into(),
26971 /// system: "master".into(),
26972 /// to: "firstName".into(),
26973 /// to_filter: "".into(),
26974 /// ..Default::default()
26975 /// }],
26976 /// property_mappings_master_to_es: vec![models::SyncJobPropertyCreate {
26977 /// field_mapping_id: 1,
26978 /// from: "firstName".into(),
26979 /// from_filter: "".into(),
26980 /// system: "master".into(),
26981 /// to: "firstName".into(),
26982 /// to_filter: "".into(),
26983 /// ..Default::default()
26984 /// }],
26985 /// ..Default::default()
26986 /// };
26987 /// let result = client.sync().externalsystems().job_configs().update_properties(1, 1, &body)?;
26988 /// println!("{}", result.domain_type);
26989 /// # Ok(())
26990 /// # }
26991 /// ```
26992 pub fn update_properties(&self, external_system_id: impl Display, job_id: impl Display, body: &models::SyncJobPropertiesUpdate) -> Result<models::SyncJobProperties> {
26993 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/properties", seg(external_system_id), seg(job_id));
26994 let query: Query = Query::new();
26995 let body = serde_json::to_value(body).expect("request body serializes");
26996 self.client.request_data(Method::Put, &path, &query, Some(&body))
26997 }
26998
26999}
27000
27001/// `client.sync().externalsystems().job_configs().executions()`
27002#[derive(Clone, Copy)]
27003pub struct SyncExternalsystemsJobConfigsExecutionsResource<'a> {
27004 client: &'a Client,
27005}
27006
27007impl<'a> SyncExternalsystemsJobConfigsExecutionsResource<'a> {
27008 /// Get a sync execution configuration snapshot
27009 ///
27010 /// `GET /sync/externalsystems/{externalSystemId}/jobconfigs/{jobId}/executions/{executionId}`
27011 ///
27012 /// Returns the arguments saved for a background execution. Adapter credentials and the external connection headers are removed. Mapping system values are normalized to `master` and `es`.
27013 ///
27014 /// # Example
27015 ///
27016 /// ```no_run
27017 /// # use churchtools_api::*;
27018 /// # use churchtools_api::queries::*;
27019 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27020 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27021 /// let execution = client.sync().externalsystems().job_configs().executions().get(1, 1, "run-123")?;
27022 /// println!("{}", execution.domain_type);
27023 /// # Ok(())
27024 /// # }
27025 /// ```
27026 pub fn get(&self, external_system_id: impl Display, job_id: impl Display, execution_id: impl Display) -> Result<models::SyncExecutionDetails> {
27027 let path = format!("/sync/externalsystems/{}/jobconfigs/{}/executions/{}", seg(external_system_id), seg(job_id), seg(execution_id));
27028 let query: Query = Query::new();
27029 self.client.request_data(Method::Get, &path, &query, None)
27030 }
27031
27032}
27033
27034/// `client.tags()`
27035#[derive(Clone, Copy)]
27036pub struct TagsResource<'a> {
27037 client: &'a Client,
27038}
27039
27040impl<'a> TagsResource<'a> {
27041 /// Attach an existing tag to an object
27042 ///
27043 /// `PUT /tags/{domainType}/{domainId}/{tagId}`
27044 ///
27045 /// Attaches the tag to the target without a request body. Requires domain-specific assignment rights for the target. An existing assignment is reused. A new assignment requires the tag to exist in the specified domain. The response contains the tag with `count` normally set to `1`, not the tag link.
27046 ///
27047 /// # Example
27048 ///
27049 /// ```
27050 /// # use churchtools_api::*;
27051 /// # use churchtools_api::queries::*;
27052 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27053 /// # let client = churchtools_api::replay::client("put-tags-domainType-domainId-tagId");
27054 /// let tag = client.tags().attach("person", 35, 42)?;
27055 /// println!("{}", tag.name);
27056 /// # Ok(())
27057 /// # }
27058 /// ```
27059 pub fn attach(&self, domain_type: impl Display, domain_id: impl Display, tag_id: impl Display) -> Result<models::TagWithCount> {
27060 let path = format!("/tags/{}/{}/{}", seg(domain_type), seg(domain_id), seg(tag_id));
27061 let query: Query = Query::new();
27062 self.client.request_data(Method::Put, &path, &query, None)
27063 }
27064
27065 /// Find or create a tag and attach it to an object
27066 ///
27067 /// `POST /tags/{domainType}/{domainId}`
27068 ///
27069 /// Finds or creates the named tag and attaches it to the target. Requires domain-specific assignment rights: person-tag visibility and person write or group-internal edit rights, group visibility and applicable group-edit rights, song-category edit rights, or appointment edit rights. Separate tag administration rights are not required. An existing assignment is reused. The response contains the tag with `count` normally set to `1`, not the tag link.
27070 ///
27071 /// # Example
27072 ///
27073 /// ```
27074 /// # use churchtools_api::*;
27075 /// # use churchtools_api::queries::*;
27076 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27077 /// # let client = churchtools_api::replay::client("post-tags-domainType-domainId");
27078 /// let body = models::TagAssignmentCreate {
27079 /// name: "Mission".into(),
27080 /// ..Default::default()
27081 /// };
27082 /// let tag = client.tags().attach_new("person", 35, &body)?;
27083 /// println!("{}", tag.name);
27084 /// # Ok(())
27085 /// # }
27086 /// ```
27087 pub fn attach_new(&self, domain_type: impl Display, domain_id: impl Display, body: &models::TagAssignmentCreate) -> Result<models::TagWithCount> {
27088 let path = format!("/tags/{}/{}", seg(domain_type), seg(domain_id));
27089 let query: Query = Query::new();
27090 let body = serde_json::to_value(body).expect("request body serializes");
27091 self.client.request_data(Method::Post, &path, &query, Some(&body))
27092 }
27093
27094 /// Create new tag
27095 ///
27096 /// `POST /tags/{domainType}`
27097 ///
27098 /// Creates an unused tag with `count` set to `0`. Requires "edit masterdata" permission in `churchdb`, `churchgroup`, or `churchservice`, or "admin appointment tags" permission in `churchcal`, depending on the domain. The scheduled purge may remove unused song tags and, when person settings are disabled, unused person tags not referenced by services. It retains group and appointment tags.
27099 ///
27100 /// # Example
27101 ///
27102 /// ```
27103 /// # use churchtools_api::*;
27104 /// # use churchtools_api::queries::*;
27105 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27106 /// # let client = churchtools_api::replay::client("post-tags-domainType");
27107 /// let body = models::TagCreate {
27108 /// name: "Mission".into(),
27109 /// ..Default::default()
27110 /// };
27111 /// let result = client.tags().create("person", &body)?;
27112 /// println!("{}", result.name);
27113 /// # Ok(())
27114 /// # }
27115 /// ```
27116 pub fn create(&self, domain_type: impl Display, body: &models::TagCreate) -> Result<models::TagWithCount> {
27117 let path = format!("/tags/{}", seg(domain_type));
27118 let query: Query = Query::new();
27119 let body = serde_json::to_value(body).expect("request body serializes");
27120 self.client.request_data(Method::Post, &path, &query, Some(&body))
27121 }
27122
27123 /// Delete tag
27124 ///
27125 /// `DELETE /tags/{tagId}`
27126 ///
27127 /// Deletes the tag and all its object assignments through the database cascade. Requires "edit masterdata" permission in `churchdb`, `churchgroup`, or `churchservice`, or "admin appointment tags" permission in `churchcal`, depending on the domain. No dry-run or delete-conflict workflow is available.
27128 ///
27129 /// # Example
27130 ///
27131 /// ```no_run
27132 /// # use churchtools_api::*;
27133 /// # use churchtools_api::queries::*;
27134 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27135 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27136 /// client.tags().delete(42)?;
27137 /// # Ok(())
27138 /// # }
27139 /// ```
27140 pub fn delete(&self, tag_id: impl Display) -> Result<()> {
27141 let path = format!("/tags/{}", seg(tag_id));
27142 let query: Query = Query::new();
27143 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
27144 }
27145
27146 /// Remove tag from domain object
27147 ///
27148 /// `DELETE /tags/{domainType}/{domainId}/{tagId}`
27149 ///
27150 /// Removes the matching assignment while retaining the tag itself. Requires the same domain-specific assignment rights as adding a tag. A missing assignment succeeds, including when the tag is missing or belongs to another domain. A missing target may still produce `404`, depending on its domain policy.
27151 ///
27152 /// # Example
27153 ///
27154 /// ```no_run
27155 /// # use churchtools_api::*;
27156 /// # use churchtools_api::queries::*;
27157 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27158 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27159 /// client.tags().detach("person", 35, 42)?;
27160 /// # Ok(())
27161 /// # }
27162 /// ```
27163 pub fn detach(&self, domain_type: impl Display, domain_id: impl Display, tag_id: impl Display) -> Result<()> {
27164 let path = format!("/tags/{}/{}/{}", seg(domain_type), seg(domain_id), seg(tag_id));
27165 let query: Query = Query::new();
27166 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
27167 }
27168
27169 /// Get tag
27170 ///
27171 /// `GET /tags/{tagId}`
27172 ///
27173 /// Returns one tag. Requires "edit masterdata" permission in `churchdb`, `churchgroup`, or `churchservice`, or "admin appointment tags" permission in `churchcal`, depending on the domain. Unlike object-specific reads, this endpoint requires administration rights. The tag’s `count` is normally `1`, not a calculated usage count.
27174 ///
27175 /// # Example
27176 ///
27177 /// ```
27178 /// # use churchtools_api::*;
27179 /// # use churchtools_api::queries::*;
27180 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27181 /// # let client = churchtools_api::replay::client("get-tags-tagId");
27182 /// let tag = client.tags().get(42)?;
27183 /// println!("{}", tag.name);
27184 /// # Ok(())
27185 /// # }
27186 /// ```
27187 pub fn get(&self, tag_id: impl Display) -> Result<models::TagWithCount> {
27188 let path = format!("/tags/{}", seg(tag_id));
27189 let query: Query = Query::new();
27190 self.client.request_data(Method::Get, &path, &query, None)
27191 }
27192
27193 /// Get tags for domain type
27194 ///
27195 /// `GET /tags/{domainType}`
27196 ///
27197 /// Lists all tags in the domain, including currently unused tags, sorted by name and without per-object visibility checks. Each tag’s `count` includes links to objects the caller may not be able to view, while `meta.count` is the number of returned tags.
27198 ///
27199 /// # Example
27200 ///
27201 /// ```
27202 /// # use churchtools_api::*;
27203 /// # use churchtools_api::queries::*;
27204 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27205 /// # let client = churchtools_api::replay::client("get-tags-domainType");
27206 /// for tag in client.tags().list("person")? {
27207 /// println!("{}", tag.name);
27208 /// }
27209 /// # Ok(())
27210 /// # }
27211 /// ```
27212 pub fn list(&self, domain_type: impl Display) -> Result<Vec<models::TagWithCount>> {
27213 let path = format!("/tags/{}", seg(domain_type));
27214 let query: Query = Query::new();
27215 self.client.request_data(Method::Get, &path, &query, None)
27216 }
27217
27218 /// Get tags for domain object
27219 ///
27220 /// `GET /tags/{domainType}/{domainId}`
27221 ///
27222 /// Lists tags attached to this domain object, sorted by name and without pagination. Requires the domain’s tag-view permission for the target. Each tag’s `count` is normally `1`, not its overall usage count, while `meta.count` is the number of returned tags.
27223 ///
27224 /// # Example
27225 ///
27226 /// ```
27227 /// # use churchtools_api::*;
27228 /// # use churchtools_api::queries::*;
27229 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27230 /// # let client = churchtools_api::replay::client("get-tags-domainType-domainId");
27231 /// for for_object in client.tags().list_for_object("person", 35)? {
27232 /// println!("{}", for_object.name);
27233 /// }
27234 /// # Ok(())
27235 /// # }
27236 /// ```
27237 pub fn list_for_object(&self, domain_type: impl Display, domain_id: impl Display) -> Result<Vec<models::TagWithCount>> {
27238 let path = format!("/tags/{}/{}", seg(domain_type), seg(domain_id));
27239 let query: Query = Query::new();
27240 self.client.request_data(Method::Get, &path, &query, None)
27241 }
27242
27243 /// Replace tag properties
27244 ///
27245 /// `PUT /tags/{tagId}`
27246 ///
27247 /// Replaces name, description and color while keeping the domain unchanged. Requires "edit masterdata" permission in `churchdb`, `churchgroup`, or `churchservice`, or "admin appointment tags" permission in `churchcal`, depending on the domain. The uniqueness check reads `id` instead of the route’s `tagId`, so retaining the same name may be rejected as a duplicate.
27248 ///
27249 /// # Example
27250 ///
27251 /// ```
27252 /// # use churchtools_api::*;
27253 /// # use churchtools_api::queries::*;
27254 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27255 /// # let client = churchtools_api::replay::client("put-tags-tagId");
27256 /// let body = models::TagUpdate {
27257 /// name: "Mission".into(),
27258 /// ..Default::default()
27259 /// };
27260 /// let result = client.tags().update(42, &body)?;
27261 /// println!("{}", result.name);
27262 /// # Ok(())
27263 /// # }
27264 /// ```
27265 pub fn update(&self, tag_id: impl Display, body: &models::TagUpdate) -> Result<models::TagWithCount> {
27266 let path = format!("/tags/{}", seg(tag_id));
27267 let query: Query = Query::new();
27268 let body = serde_json::to_value(body).expect("request body serializes");
27269 self.client.request_data(Method::Put, &path, &query, Some(&body))
27270 }
27271
27272}
27273
27274/// `client.translations()`
27275#[derive(Clone, Copy)]
27276pub struct TranslationsResource<'a> {
27277 client: &'a Client,
27278}
27279
27280impl<'a> TranslationsResource<'a> {
27281 pub fn languages(&self) -> TranslationsLanguagesResource<'a> {
27282 TranslationsLanguagesResource { client: self.client }
27283 }
27284
27285 /// Delete translation key
27286 ///
27287 /// `DELETE /translations/{keyId}`
27288 ///
27289 /// Marks a locally created translation key as deleted and clears generated message files. It no longer appears in translation queries. Product-supplied keys are rejected with 400. This is a soft deletion; language entries are not individually deleted by this operation. There is no dry-run mode.
27290 ///
27291 /// # Example
27292 ///
27293 /// ```no_run
27294 /// # use churchtools_api::*;
27295 /// # use churchtools_api::queries::*;
27296 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27297 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27298 /// client.translations().delete(1)?;
27299 /// # Ok(())
27300 /// # }
27301 /// ```
27302 pub fn delete(&self, key_id: impl Display) -> Result<()> {
27303 let path = format!("/translations/{}", seg(key_id));
27304 let query: Query = Query::new();
27305 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
27306 }
27307
27308 /// Get all translations
27309 ///
27310 /// `GET /translations`
27311 ///
27312 /// Returns non-deleted translation keys with matching non-deleted language entries. updated_by_church and needs_check filter language entries; omit either to include both boolean states. The returned translations map contains the matching entries, and keys without any match are omitted. The list is unpaginated, has no guaranteed order and returns meta.count, not page metadata.
27313 ///
27314 /// Use [`Self::list_with`] to pass query parameters.
27315 ///
27316 /// # Example
27317 ///
27318 /// ```
27319 /// # use churchtools_api::*;
27320 /// # use churchtools_api::queries::*;
27321 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27322 /// # let client = churchtools_api::replay::client("get-translations");
27323 /// for translation in client.translations().list()? {
27324 /// println!("{}", translation.id);
27325 /// }
27326 /// # Ok(())
27327 /// # }
27328 /// ```
27329 pub fn list(&self) -> Result<Vec<models::TranslationKey>> {
27330 self.list_with(&Default::default())
27331 }
27332
27333 /// Get all translations
27334 ///
27335 /// Like [`Self::list`], with query parameters.
27336 ///
27337 /// `GET /translations`
27338 ///
27339 /// Returns non-deleted translation keys with matching non-deleted language entries. updated_by_church and needs_check filter language entries; omit either to include both boolean states. The returned translations map contains the matching entries, and keys without any match are omitted. The list is unpaginated, has no guaranteed order and returns meta.count, not page metadata.
27340 pub fn list_with(&self, query: &GetTranslationsQuery) -> Result<Vec<models::TranslationKey>> {
27341 let path = "/translations".to_owned();
27342 let query: Query = query.to_query();
27343 self.client.request_data(Method::Get, &path, &query, None)
27344 }
27345
27346 /// Get all translation keys, which match a translation
27347 ///
27348 /// `GET /translations/keysbytext`
27349 ///
27350 /// Finds keys whose non-deleted translation text exactly matches the trimmed query in any language. This is not a substring search. Keys are returned in a nested array: data always contains one array, which is empty when nothing matches; meta.count is therefore always 1. A key can appear more than once if multiple languages match. No global ordering or pagination is applied.
27351 ///
27352 /// # Example
27353 ///
27354 /// ```
27355 /// # use churchtools_api::*;
27356 /// # use churchtools_api::queries::*;
27357 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27358 /// # let client = churchtools_api::replay::client("get-translations-keysbytext");
27359 /// let query = GetTranslationsKeysbytextQuery {
27360 /// query: Some("Welcome".into()),
27361 /// ..Default::default()
27362 /// };
27363 /// for keys_by_text in client.translations().list_keys_by_text(&query)? {
27364 /// println!("{:?}", keys_by_text);
27365 /// }
27366 /// # Ok(())
27367 /// # }
27368 /// ```
27369 pub fn list_keys_by_text(&self, query: &GetTranslationsKeysbytextQuery) -> Result<Vec<Vec<String>>> {
27370 let path = "/translations/keysbytext".to_owned();
27371 let query: Query = query.to_query();
27372 self.client.request_data(Method::Get, &path, &query, None)
27373 }
27374
27375 /// Update a local translation key
27376 ///
27377 /// `PUT /translations/{keyId}`
27378 ///
27379 /// Changes the key string and module of an installation-created translation key. Both fields are required; individual translated texts are unchanged. Product-supplied keys are rejected with 400. The response is empty.
27380 ///
27381 /// # Example
27382 ///
27383 /// ```no_run
27384 /// # use churchtools_api::*;
27385 /// # use churchtools_api::queries::*;
27386 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27387 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27388 /// let body = models::TranslationKeyUpdate {
27389 /// key: "mychurch.welcome".into(),
27390 /// module: "churchcore".into(),
27391 /// ..Default::default()
27392 /// };
27393 /// client.translations().update(1, &body)?;
27394 /// # Ok(())
27395 /// # }
27396 /// ```
27397 pub fn update(&self, key_id: impl Display, body: &models::TranslationKeyUpdate) -> Result<()> {
27398 let path = format!("/translations/{}", seg(key_id));
27399 let query: Query = Query::new();
27400 let body = serde_json::to_value(body).expect("request body serializes");
27401 self.client.request(Method::Put, &path, &query, Some(&body)).map(|_| ())
27402 }
27403
27404}
27405
27406/// `client.translations().languages()`
27407#[derive(Clone, Copy)]
27408pub struct TranslationsLanguagesResource<'a> {
27409 client: &'a Client,
27410}
27411
27412impl<'a> TranslationsLanguagesResource<'a> {
27413 /// Delete translation language for key
27414 ///
27415 /// `DELETE /translations/{keyId}/languages/{languageId}`
27416 ///
27417 /// Marks one language translation as deleted, updates its modification timestamp and clears generated message files. The key and other language entries remain. An unknown key/language pair returns 404. Repeating the operation on an existing already-deleted entry also succeeds with 204. There is no dry-run mode.
27418 ///
27419 /// # Example
27420 ///
27421 /// ```no_run
27422 /// # use churchtools_api::*;
27423 /// # use churchtools_api::queries::*;
27424 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27425 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27426 /// client.translations().languages().delete(1, 1)?;
27427 /// # Ok(())
27428 /// # }
27429 /// ```
27430 pub fn delete(&self, key_id: impl Display, language_id: impl Display) -> Result<()> {
27431 let path = format!("/translations/{}/languages/{}", seg(key_id), seg(language_id));
27432 let query: Query = Query::new();
27433 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
27434 }
27435
27436}
27437
27438/// `client.two_factor()`
27439#[derive(Clone, Copy)]
27440pub struct TwoFactorResource<'a> {
27441 client: &'a Client,
27442}
27443
27444impl<'a> TwoFactorResource<'a> {
27445 /// Verify an authenticator code during enrollment
27446 ///
27447 /// `POST /twofactor/totp`
27448 ///
27449 /// Checks a code against the stored authenticator secret for the current person. Only the current person may verify their own secret. Initialization must have completed first. A successful call returns status=success and records the code as used; it does not enable two-factor authentication. Call PUT /persons/{personId}/settings/twofactor separately to activate. Missing secrets, invalid codes and codes already recorded as used produce 400. Keep the code as a string to preserve leading zeroes.
27450 ///
27451 /// # Example
27452 ///
27453 /// ```no_run
27454 /// # use churchtools_api::*;
27455 /// # use churchtools_api::queries::*;
27456 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27457 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27458 /// let body = models::PersonTwoFactorVerify {
27459 /// code: "012345".into(),
27460 /// person_id: 42,
27461 /// ..Default::default()
27462 /// };
27463 /// let two_factor = client.two_factor().totp(&body)?;
27464 /// println!("{}", two_factor.status);
27465 /// # Ok(())
27466 /// # }
27467 /// ```
27468 pub fn totp(&self, body: &models::PersonTwoFactorVerify) -> Result<models::PostTwofactorTotpData> {
27469 let path = "/twofactor/totp".to_owned();
27470 let query: Query = Query::new();
27471 let body = serde_json::to_value(body).expect("request body serializes");
27472 self.client.request_data(Method::Post, &path, &query, Some(&body))
27473 }
27474
27475}
27476
27477/// `client.website()`
27478#[derive(Clone, Copy)]
27479pub struct WebsiteResource<'a> {
27480 client: &'a Client,
27481}
27482
27483impl<'a> WebsiteResource<'a> {
27484 pub fn data(&self) -> WebsiteDataResource<'a> {
27485 WebsiteDataResource { client: self.client }
27486 }
27487
27488 /// `GET /website/starttest`
27489 ///
27490 /// # Example
27491 ///
27492 /// ```
27493 /// # use churchtools_api::*;
27494 /// # use churchtools_api::queries::*;
27495 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27496 /// # let client = churchtools_api::replay::client("get-website-starttest");
27497 /// client.website().get_start_test()?;
27498 /// # Ok(())
27499 /// # }
27500 /// ```
27501 pub fn get_start_test(&self) -> Result<()> {
27502 let path = "/website/starttest".to_owned();
27503 let query: Query = Query::new();
27504 self.client.request(Method::Get, &path, &query, None).map(|_| ())
27505 }
27506
27507}
27508
27509/// `client.website().data()`
27510#[derive(Clone, Copy)]
27511pub struct WebsiteDataResource<'a> {
27512 client: &'a Client,
27513}
27514
27515impl<'a> WebsiteDataResource<'a> {
27516 /// `POST /website/data`
27517 ///
27518 /// # Example
27519 ///
27520 /// ```no_run
27521 /// # use churchtools_api::*;
27522 /// # use churchtools_api::queries::*;
27523 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27524 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27525 /// let body = models::WebsiteDataCreate {
27526 /// domain_id: 42,
27527 /// domain_type: "calendar".into(),
27528 /// ..Default::default()
27529 /// };
27530 /// let result = client.website().data().create(&body)?;
27531 /// println!("{}", result.id);
27532 /// # Ok(())
27533 /// # }
27534 /// ```
27535 pub fn create(&self, body: &models::WebsiteDataCreate) -> Result<models::WebsiteDataWithoutInclude> {
27536 let path = "/website/data".to_owned();
27537 let query: Query = Query::new();
27538 let body = serde_json::to_value(body).expect("request body serializes");
27539 self.client.request_data(Method::Post, &path, &query, Some(&body))
27540 }
27541
27542 /// `DELETE /website/data/{id}`
27543 ///
27544 /// # Example
27545 ///
27546 /// ```no_run
27547 /// # use churchtools_api::*;
27548 /// # use churchtools_api::queries::*;
27549 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27550 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27551 /// client.website().data().delete(4)?;
27552 /// # Ok(())
27553 /// # }
27554 /// ```
27555 pub fn delete(&self, id: impl Display) -> Result<()> {
27556 let path = format!("/website/data/{}", seg(id));
27557 let query: Query = Query::new();
27558 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
27559 }
27560
27561 /// `GET /website/data`
27562 ///
27563 /// Get the data that is shared with the CT website
27564 ///
27565 /// Use [`Self::list_with`] to pass query parameters.
27566 ///
27567 /// # Example
27568 ///
27569 /// ```
27570 /// # use churchtools_api::*;
27571 /// # use churchtools_api::queries::*;
27572 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27573 /// # let client = churchtools_api::replay::client("get-website-data");
27574 /// for item in client.website().data().list()? {
27575 /// println!("{:?}", item);
27576 /// }
27577 /// # Ok(())
27578 /// # }
27579 /// ```
27580 pub fn list(&self) -> Result<Vec<serde_json::Value>> {
27581 self.list_with(&Default::default())
27582 }
27583
27584 /// `GET /website/data`
27585 ///
27586 /// Like [`Self::list`], with query parameters.
27587 ///
27588 /// Get the data that is shared with the CT website
27589 pub fn list_with(&self, query: &GetWebsiteDataQuery) -> Result<Vec<serde_json::Value>> {
27590 let path = "/website/data".to_owned();
27591 let query: Query = query.to_query();
27592 self.client.request_data(Method::Get, &path, &query, None)
27593 }
27594
27595}
27596
27597/// `client.whoami()`
27598#[derive(Clone, Copy)]
27599pub struct WhoamiResource<'a> {
27600 client: &'a Client,
27601}
27602
27603impl<'a> WhoamiResource<'a> {
27604 /// Currently logged in user.
27605 ///
27606 /// `GET /whoami`
27607 ///
27608 /// This endpoint returns the current user. If the request is unauthorized, the anonymous user (aka public user) is returned.
27609 ///
27610 /// Use [`Self::get_with`] to pass query parameters.
27611 ///
27612 /// # Example
27613 ///
27614 /// ```
27615 /// # use churchtools_api::*;
27616 /// # use churchtools_api::queries::*;
27617 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27618 /// # let client = churchtools_api::replay::client("get-whoami");
27619 /// let whoami = client.whoami().get()?;
27620 /// println!("{:?}", whoami.title);
27621 /// # Ok(())
27622 /// # }
27623 /// ```
27624 pub fn get(&self) -> Result<models::Person> {
27625 self.get_with(&Default::default())
27626 }
27627
27628 /// Currently logged in user.
27629 ///
27630 /// Like [`Self::get`], with query parameters.
27631 ///
27632 /// `GET /whoami`
27633 ///
27634 /// This endpoint returns the current user. If the request is unauthorized, the anonymous user (aka public user) is returned.
27635 pub fn get_with(&self, query: &GetWhoamiQuery) -> Result<models::Person> {
27636 let path = "/whoami".to_owned();
27637 let query: Query = query.to_query();
27638 self.client.request_data(Method::Get, &path, &query, None)
27639 }
27640
27641}
27642
27643/// `client.widgets()`
27644#[derive(Clone, Copy)]
27645pub struct WidgetsResource<'a> {
27646 client: &'a Client,
27647}
27648
27649impl<'a> WidgetsResource<'a> {
27650 /// `GET /widgets/blog`
27651 ///
27652 /// # Example
27653 ///
27654 /// ```
27655 /// # use churchtools_api::*;
27656 /// # use churchtools_api::queries::*;
27657 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27658 /// # let client = churchtools_api::replay::client("get-widgets-blog");
27659 /// let blog = client.widgets().get_blog()?;
27660 /// println!("{:?}", blog.title);
27661 /// # Ok(())
27662 /// # }
27663 /// ```
27664 pub fn get_blog(&self) -> Result<models::GetWidgetsBlogData> {
27665 let path = "/widgets/blog".to_owned();
27666 let query: Query = Query::new();
27667 self.client.request_data(Method::Get, &path, &query, None)
27668 }
27669
27670 /// `GET /widgets/rss`
27671 ///
27672 /// # Example
27673 ///
27674 /// ```
27675 /// # use churchtools_api::*;
27676 /// # use churchtools_api::queries::*;
27677 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27678 /// # let client = churchtools_api::replay::client("get-widgets-rss");
27679 /// let rss = client.widgets().get_rss()?;
27680 /// println!("{}", rss.title);
27681 /// # Ok(())
27682 /// # }
27683 /// ```
27684 pub fn get_rss(&self) -> Result<models::RssFeed> {
27685 let path = "/widgets/rss".to_owned();
27686 let query: Query = Query::new();
27687 self.client.request_data(Method::Get, &path, &query, None)
27688 }
27689
27690}
27691
27692/// `client.wiki()`
27693#[derive(Clone, Copy)]
27694pub struct WikiResource<'a> {
27695 client: &'a Client,
27696}
27697
27698impl<'a> WikiResource<'a> {
27699 pub fn categories(&self) -> WikiCategoriesResource<'a> {
27700 WikiCategoriesResource { client: self.client }
27701 }
27702
27703 /// List wiki pages
27704 ///
27705 /// `GET /wiki/pages`
27706 ///
27707 /// Lists the latest revisions of non-system, non-redirect pages in viewable categories. Guest category permissions are supported. Omitted/empty wiki_category_ids selects every viewable category; inaccessible IDs are silently dropped. Without query, ordering defaults to display title, then GUID. With query, default ranking prefers matching category main pages, then title matches, exact-content matches and finally matches containing all query words. Explicit order_fields overrides ranking. Pagination is applied after finding and enriching all matching pages. Text is omitted unless include\[\]=text; include\[\]=preview returns an unrendered stored-text prefix, which may contain raw HTML. searchPreview is independently included when query is supplied. meta contains page count and pagination total/limit/current/lastPage; lastPage is 0 for no results.
27708 ///
27709 /// Use [`Self::list_pages_with`] to pass query parameters.
27710 ///
27711 /// # Example
27712 ///
27713 /// ```
27714 /// # use churchtools_api::*;
27715 /// # use churchtools_api::queries::*;
27716 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27717 /// # let client = churchtools_api::replay::client("get-wiki-pages");
27718 /// for page in client.wiki().list_pages()? {
27719 /// println!("{}", page.title);
27720 /// }
27721 /// # Ok(())
27722 /// # }
27723 /// ```
27724 pub fn list_pages(&self) -> Result<Vec<models::SimpleWikiPage>> {
27725 self.list_pages_with(&Default::default())
27726 }
27727
27728 /// List wiki pages
27729 ///
27730 /// Like [`Self::list_pages`], with query parameters.
27731 ///
27732 /// `GET /wiki/pages`
27733 ///
27734 /// Lists the latest revisions of non-system, non-redirect pages in viewable categories. Guest category permissions are supported. Omitted/empty wiki_category_ids selects every viewable category; inaccessible IDs are silently dropped. Without query, ordering defaults to display title, then GUID. With query, default ranking prefers matching category main pages, then title matches, exact-content matches and finally matches containing all query words. Explicit order_fields overrides ranking. Pagination is applied after finding and enriching all matching pages. Text is omitted unless include\[\]=text; include\[\]=preview returns an unrendered stored-text prefix, which may contain raw HTML. searchPreview is independently included when query is supplied. meta contains page count and pagination total/limit/current/lastPage; lastPage is 0 for no results.
27735 pub fn list_pages_with(&self, query: &GetWikiPagesQuery) -> Result<Vec<models::SimpleWikiPage>> {
27736 let path = "/wiki/pages".to_owned();
27737 let query: Query = query.to_query();
27738 self.client.collect_pages(&path, query)
27739 }
27740
27741 /// List wiki pages
27742 ///
27743 /// Like [`Self::list_pages_with`], but lazy: each page is fetched only when the iteration reaches it.
27744 /// Breaking off early saves the remaining requests.
27745 pub fn list_pages_iter(&self, query: &GetWikiPagesQuery) -> Items<models::SimpleWikiPage> {
27746 let path = "/wiki/pages".to_owned();
27747 self.client.items(&path, query.to_query())
27748 }
27749
27750 /// Full-text search across wiki pages
27751 ///
27752 /// `GET /wiki/search`
27753 ///
27754 /// Searches latest non-system, non-redirect pages in categories the current user or guest can view. Omitted/empty wiki_category_ids means all viewable categories; inaccessible categories are silently dropped. Results are grouped by relevance: category-name main pages, title matches (shorter first), exact text matches and then matches containing all query words. Results are deduplicated by GUID and are not paginated. The query is not trimmed; SQL LIKE wildcard characters % and _ are interpreted. Results contain domain-object links and a text preview with Markdown emphasis for matches, not the full page. For paginated page resources, use GET /wiki/pages.
27755 ///
27756 /// # Example
27757 ///
27758 /// ```
27759 /// # use churchtools_api::*;
27760 /// # use churchtools_api::queries::*;
27761 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27762 /// # let client = churchtools_api::replay::client("get-wiki-search");
27763 /// let query = GetWikiSearchQuery {
27764 /// query: Some("welcome".into()),
27765 /// ..Default::default()
27766 /// };
27767 /// for search in client.wiki().list_search(&query)? {
27768 /// println!("{}", search.title);
27769 /// }
27770 /// # Ok(())
27771 /// # }
27772 /// ```
27773 pub fn list_search(&self, query: &GetWikiSearchQuery) -> Result<Vec<models::WikiSearchResult>> {
27774 let path = "/wiki/search".to_owned();
27775 let query: Query = query.to_query();
27776 self.client.request_data(Method::Get, &path, &query, None)
27777 }
27778
27779}
27780
27781/// `client.wiki().categories()`
27782#[derive(Clone, Copy)]
27783pub struct WikiCategoriesResource<'a> {
27784 client: &'a Client,
27785}
27786
27787impl<'a> WikiCategoriesResource<'a> {
27788 pub fn pages(&self) -> WikiCategoriesPagesResource<'a> {
27789 WikiCategoriesPagesResource { client: self.client }
27790 }
27791
27792 /// Create a new wiki category
27793 ///
27794 /// `POST /wiki/categories`
27795 ///
27796 /// Creates a wiki category and an initial page titled main (version 1, empty text, Markdown enabled). Requires churchwiki edit masterdata. The creator receives view category and edit category permissions for the new category if missing. A nonexistent campusId silently resolves to null. The returned category has an empty permissions object; use the list to obtain page-operation hints.
27797 ///
27798 /// # Example
27799 ///
27800 /// ```
27801 /// # use churchtools_api::*;
27802 /// # use churchtools_api::queries::*;
27803 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27804 /// # let client = churchtools_api::replay::client("post-wiki-categories");
27805 /// let body = models::WikiCategoryCreate {
27806 /// file_access_without_permission: false,
27807 /// in_menu: true,
27808 /// name: "Dokumentation".into(),
27809 /// sort_key: 10,
27810 /// ..Default::default()
27811 /// };
27812 /// let result = client.wiki().categories().create(&body)?;
27813 /// println!("{}", result.name);
27814 /// # Ok(())
27815 /// # }
27816 /// ```
27817 pub fn create(&self, body: &models::WikiCategoryCreate) -> Result<models::WikiCategory> {
27818 let path = "/wiki/categories".to_owned();
27819 let query: Query = Query::new();
27820 let body = serde_json::to_value(body).expect("request body serializes");
27821 self.client.request_data(Method::Post, &path, &query, Some(&body))
27822 }
27823
27824 /// Delete a wiki category
27825 ///
27826 /// `DELETE /wiki/categories/{wikiCategoryId}`
27827 ///
27828 /// Deletes the category, all its wiki page versions and category view/edit permission assignments. Requires churchwiki edit masterdata. Existing pages do not block this deletion, and no page-level protected-system-page check is made by this handler. A missing category normally succeeds with 204. No request body or dry-run parameter is consumed.
27829 ///
27830 /// # Example
27831 ///
27832 /// ```no_run
27833 /// # use churchtools_api::*;
27834 /// # use churchtools_api::queries::*;
27835 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27836 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27837 /// client.wiki().categories().delete(42)?;
27838 /// # Ok(())
27839 /// # }
27840 /// ```
27841 pub fn delete(&self, wiki_category_id: impl Display) -> Result<()> {
27842 let path = format!("/wiki/categories/{}", seg(wiki_category_id));
27843 let query: Query = Query::new();
27844 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
27845 }
27846
27847 /// Get all wiki categories
27848 ///
27849 /// `GET /wiki/categories`
27850 ///
27851 /// Lists wiki categories for which the current user (including a guest) has churchwiki view category permission. Categories organize pages and define their access permissions. Results are sorted by sortKey, then stored name, without pagination. inMenu does not filter this catalog. Each category’s canEdit/canDelete flags describe page operations based on edit category, not permission to rename or delete the category itself. The top-level permissions.editMasterData flag controls category administration. meta.count counts visible categories.
27852 ///
27853 /// # Example
27854 ///
27855 /// ```
27856 /// # use churchtools_api::*;
27857 /// # use churchtools_api::queries::*;
27858 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27859 /// # let client = churchtools_api::replay::client("get-wiki-categories");
27860 /// for category in client.wiki().categories().list()? {
27861 /// println!("{}", category.name);
27862 /// }
27863 /// # Ok(())
27864 /// # }
27865 /// ```
27866 pub fn list(&self) -> Result<Vec<models::WikiCategory>> {
27867 let path = "/wiki/categories".to_owned();
27868 let query: Query = Query::new();
27869 self.client.request_data(Method::Get, &path, &query, None)
27870 }
27871
27872 /// Update a wiki category
27873 ///
27874 /// `PUT /wiki/categories/{wikiCategoryId}`
27875 ///
27876 /// Replaces the category’s name, sort order, menu flag, file-access flag and optional campus association. Requires churchwiki edit masterdata. name, sortKey, inMenu and fileAccessWithoutPermission are required; omitted/null or unknown campusId clears the association. Pages and their versions are retained. The response permissions object is normally empty.
27877 ///
27878 /// # Example
27879 ///
27880 /// ```
27881 /// # use churchtools_api::*;
27882 /// # use churchtools_api::queries::*;
27883 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27884 /// # let client = churchtools_api::replay::client("put-wiki-categories-id");
27885 /// let body = models::WikiCategoryUpdate {
27886 /// file_access_without_permission: false,
27887 /// in_menu: true,
27888 /// name: "Dokumentation".into(),
27889 /// sort_key: 10,
27890 /// ..Default::default()
27891 /// };
27892 /// let result = client.wiki().categories().update(42, &body)?;
27893 /// println!("{}", result.name);
27894 /// # Ok(())
27895 /// # }
27896 /// ```
27897 pub fn update(&self, wiki_category_id: impl Display, body: &models::WikiCategoryUpdate) -> Result<models::WikiCategory> {
27898 let path = format!("/wiki/categories/{}", seg(wiki_category_id));
27899 let query: Query = Query::new();
27900 let body = serde_json::to_value(body).expect("request body serializes");
27901 self.client.request_data(Method::Put, &path, &query, Some(&body))
27902 }
27903
27904}
27905
27906/// `client.wiki().categories().pages()`
27907#[derive(Clone, Copy)]
27908pub struct WikiCategoriesPagesResource<'a> {
27909 client: &'a Client,
27910}
27911
27912impl<'a> WikiCategoriesPagesResource<'a> {
27913 pub fn versions(&self) -> WikiCategoriesPagesVersionsResource<'a> {
27914 WikiCategoriesPagesVersionsResource { client: self.client }
27915 }
27916
27917 /// Create a wiki page
27918 ///
27919 /// `POST /wiki/categories/{wikiCategoryId}/pages`
27920 ///
27921 /// Creates a page with a generated stable GUID and version 1. Requires churchwiki edit category; creating a title that resolves to a protected system page additionally requires a super administrator. The trimmed title must be unique in the category across stored versions. Unicode ellipsis is normalized to three periods. Omitted text is stored as null but returned as an empty string. isMarkdown and onStartpage default to false; this differs from the main page automatically created with a new category, which starts with Markdown enabled.
27922 ///
27923 /// # Example
27924 ///
27925 /// ```
27926 /// # use churchtools_api::*;
27927 /// # use churchtools_api::queries::*;
27928 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27929 /// # let client = churchtools_api::replay::client("post-wiki-categories-id-pages");
27930 /// let body = models::WikiPageCreate {
27931 /// title: "My new wiki page".into(),
27932 /// ..Default::default()
27933 /// };
27934 /// let result = client.wiki().categories().pages().create(42, &body)?;
27935 /// println!("{}", result.title);
27936 /// # Ok(())
27937 /// # }
27938 /// ```
27939 pub fn create(&self, wiki_category_id: impl Display, body: &models::WikiPageCreate) -> Result<models::WikiPage> {
27940 let path = format!("/wiki/categories/{}/pages", seg(wiki_category_id));
27941 let query: Query = Query::new();
27942 let body = serde_json::to_value(body).expect("request body serializes");
27943 self.client.request_data(Method::Post, &path, &query, Some(&body))
27944 }
27945
27946 /// Delete a wiki page
27947 ///
27948 /// `DELETE /wiki/categories/{wikiCategoryId}/pages/{identifier}`
27949 ///
27950 /// Deletes the page identified by GUID and every stored revision. Requires churchwiki edit category. Protected system pages in category 0 cannot be deleted through this endpoint, including by super administrators. Missing pages succeed with 204. Latest redirect pages targeting the deleted title have redirectTo cleared; older redirect revisions are retained. This deletion has no dry-run or version precondition.
27951 ///
27952 /// # Example
27953 ///
27954 /// ```no_run
27955 /// # use churchtools_api::*;
27956 /// # use churchtools_api::queries::*;
27957 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27958 /// # let client = Client::new("https://meinegemeinde.church.tools", None)?;
27959 /// client.wiki().categories().pages().delete(42, "681F54E3-2EB7-40A4-84F0-EFF8E8F05727")?;
27960 /// # Ok(())
27961 /// # }
27962 /// ```
27963 pub fn delete(&self, wiki_category_id: impl Display, identifier: impl Display) -> Result<()> {
27964 let path = format!("/wiki/categories/{}/pages/{}", seg(wiki_category_id), seg(identifier));
27965 let query: Query = Query::new();
27966 self.client.request(Method::Delete, &path, &query, None).map(|_| ())
27967 }
27968
27969 /// Get a wiki page
27970 ///
27971 /// `GET /wiki/categories/{wikiCategoryId}/pages/{identifier}`
27972 ///
27973 /// Requires churchwiki view category permission, including any permissions assigned to guests. For a protected system page in category 0, super-administrator access also permits the individual read. Returns one page revision with text: Markdown is returned as stored, legacy HTML is sanitized, and null content becomes an empty string. Prefer the stable page GUID; legacy titles are accepted and Unicode ellipsis characters in titles are normalized to three periods. A version value of 0 behaves like omission and selects the latest revision; other nonzero values select that exact revision. Redirect pages are returned as data with redirectTo rather than followed.
27974 ///
27975 /// Use [`Self::get_with`] to pass query parameters.
27976 ///
27977 /// # Example
27978 ///
27979 /// ```
27980 /// # use churchtools_api::*;
27981 /// # use churchtools_api::queries::*;
27982 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
27983 /// # let client = churchtools_api::replay::client("get-wiki-categories-id-pages-identifier");
27984 /// let page = client.wiki().categories().pages().get(42, "main")?;
27985 /// println!("{}", page.title);
27986 /// # Ok(())
27987 /// # }
27988 /// ```
27989 pub fn get(&self, wiki_category_id: impl Display, identifier: impl Display) -> Result<models::WikiPage> {
27990 self.get_with(wiki_category_id, identifier, &Default::default())
27991 }
27992
27993 /// Get a wiki page
27994 ///
27995 /// Like [`Self::get`], with query parameters.
27996 ///
27997 /// `GET /wiki/categories/{wikiCategoryId}/pages/{identifier}`
27998 ///
27999 /// Requires churchwiki view category permission, including any permissions assigned to guests. For a protected system page in category 0, super-administrator access also permits the individual read. Returns one page revision with text: Markdown is returned as stored, legacy HTML is sanitized, and null content becomes an empty string. Prefer the stable page GUID; legacy titles are accepted and Unicode ellipsis characters in titles are normalized to three periods. A version value of 0 behaves like omission and selects the latest revision; other nonzero values select that exact revision. Redirect pages are returned as data with redirectTo rather than followed.
28000 pub fn get_with(&self, wiki_category_id: impl Display, identifier: impl Display, query: &GetWikiCategoriesIdPagesIdentifierQuery) -> Result<models::WikiPage> {
28001 let path = format!("/wiki/categories/{}/pages/{}", seg(wiki_category_id), seg(identifier));
28002 let query: Query = query.to_query();
28003 self.client.request_data(Method::Get, &path, &query, None)
28004 }
28005
28006 /// List wiki pages in a category
28007 ///
28008 /// `GET /wiki/categories/{wikiCategoryId}/pages`
28009 ///
28010 /// Lists the latest version of each non-system page in this category, including redirect pages. Requires churchwiki view category permission. Page text and previews are omitted. Results are ordered by display title (main uses the category name), then GUID, without pagination; meta.count is the number of returned pages. The nested wikiCategory.permissions object is normally empty, while page.permissions contains canEdit/canDelete.
28011 ///
28012 /// # Example
28013 ///
28014 /// ```
28015 /// # use churchtools_api::*;
28016 /// # use churchtools_api::queries::*;
28017 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
28018 /// # let client = churchtools_api::replay::client("get-wiki-categories-id-pages");
28019 /// for page in client.wiki().categories().pages().list(42)? {
28020 /// println!("{}", page.title);
28021 /// }
28022 /// # Ok(())
28023 /// # }
28024 /// ```
28025 pub fn list(&self, wiki_category_id: impl Display) -> Result<Vec<models::SimpleWikiPage>> {
28026 let path = format!("/wiki/categories/{}/pages", seg(wiki_category_id));
28027 let query: Query = Query::new();
28028 self.client.request_data(Method::Get, &path, &query, None)
28029 }
28030
28031 /// Update a wiki page
28032 ///
28033 /// `PATCH /wiki/categories/{wikiCategoryId}/pages/{identifier}`
28034 ///
28035 /// Updates only supplied text, isMarkdown and onStartpage fields on the latest revision identified by GUID. Titles cannot be changed through this endpoint. Requires category edit permission; protected system pages in category 0 require a super administrator. Changed text creates the next revision with the same GUID; unchanged text or changes only to the flags modify the existing latest revision. Trimmed blank/null text clears the stored content. No expected-version or ETag precondition is accepted, so this endpoint does not provide optimistic edit-conflict protection.
28036 ///
28037 /// # Example
28038 ///
28039 /// ```
28040 /// # use churchtools_api::*;
28041 /// # use churchtools_api::queries::*;
28042 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
28043 /// # let client = churchtools_api::replay::client("patch-wiki-categories-id-pages-identifier");
28044 /// let body = models::WikiPageUpdate {
28045 /// is_markdown: Some(true),
28046 /// ..Default::default()
28047 /// };
28048 /// let result = client.wiki().categories().pages().patch(42, "681F54E3-2EB7-40A4-84F0-EFF8E8F05727", &body)?;
28049 /// println!("{}", result.title);
28050 /// # Ok(())
28051 /// # }
28052 /// ```
28053 pub fn patch(&self, wiki_category_id: impl Display, identifier: impl Display, body: &models::WikiPageUpdate) -> Result<models::WikiPage> {
28054 let path = format!("/wiki/categories/{}/pages/{}", seg(wiki_category_id), seg(identifier));
28055 let query: Query = Query::new();
28056 let body = serde_json::to_value(body).expect("request body serializes");
28057 self.client.request_data(Method::Patch, &path, &query, Some(&body))
28058 }
28059
28060}
28061
28062/// `client.wiki().categories().pages().versions()`
28063#[derive(Clone, Copy)]
28064pub struct WikiCategoriesPagesVersionsResource<'a> {
28065 client: &'a Client,
28066}
28067
28068impl<'a> WikiCategoriesPagesVersionsResource<'a> {
28069 /// Get a specific version of a wiki page
28070 ///
28071 /// `GET /wiki/categories/{wikiCategoryId}/pages/{identifier}/versions/{version}`
28072 ///
28073 /// Requires churchwiki view category permission, including any permissions assigned to guests. For a protected system page in category 0, super-administrator access also permits the individual read. Returns one page revision with text: Markdown is returned as stored, legacy HTML is sanitized, and null content becomes an empty string. Prefer the stable page GUID; legacy titles are accepted and Unicode ellipsis characters in titles are normalized to three periods. A version value of 0 behaves like omission and selects the latest revision; other nonzero values select that exact revision. Redirect pages are returned as data with redirectTo rather than followed.
28074 ///
28075 /// # Example
28076 ///
28077 /// ```
28078 /// # use churchtools_api::*;
28079 /// # use churchtools_api::queries::*;
28080 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
28081 /// # let client = churchtools_api::replay::client("get-wiki-categories-id-pages-id-versions-id");
28082 /// let version = client.wiki().categories().pages().versions().get(42, "main", 1)?;
28083 /// println!("{}", version.title);
28084 /// # Ok(())
28085 /// # }
28086 /// ```
28087 pub fn get(&self, wiki_category_id: impl Display, identifier: impl Display, version: impl Display) -> Result<models::WikiPage> {
28088 let path = format!("/wiki/categories/{}/pages/{}/versions/{}", seg(wiki_category_id), seg(identifier), seg(version));
28089 let query: Query = Query::new();
28090 self.client.request_data(Method::Get, &path, &query, None)
28091 }
28092
28093 /// List all versions of a wiki page
28094 ///
28095 /// `GET /wiki/categories/{wikiCategoryId}/pages/{identifier}/versions`
28096 ///
28097 /// Requires churchwiki view category permission, including any permissions assigned to guests. For a protected system page in category 0, super-administrator access also permits the individual read. Returns all revisions for the GUID or legacy title, newest version first, including each revision’s text. Missing pages return an empty list rather than 404. The list is not paginated; meta.count is the number of versions. Metadata and current permission hints are included for each revision. Title identifiers are deprecated for this history endpoint.
28098 ///
28099 /// # Example
28100 ///
28101 /// ```
28102 /// # use churchtools_api::*;
28103 /// # use churchtools_api::queries::*;
28104 /// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
28105 /// # let client = churchtools_api::replay::client("get-wiki-categories-id-pages-identifier-versions");
28106 /// for version in client.wiki().categories().pages().versions().list(42, "main")? {
28107 /// println!("{}", version.title);
28108 /// }
28109 /// # Ok(())
28110 /// # }
28111 /// ```
28112 pub fn list(&self, wiki_category_id: impl Display, identifier: impl Display) -> Result<Vec<models::WikiPage>> {
28113 let path = format!("/wiki/categories/{}/pages/{}/versions", seg(wiki_category_id), seg(identifier));
28114 let query: Query = Query::new();
28115 self.client.request_data(Method::Get, &path, &query, None)
28116 }
28117
28118}