campai-api 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,239 @@
1
+ # SPDX-FileCopyrightText: 2026 2026 Stephan Lukasczyk <stephan@dante.de>
2
+ #
3
+ # SPDX-License-Identifier: EUPL-1.2
4
+
5
+ """Data models for finance, receipts, invoices, and accounting settings."""
6
+
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass, field
10
+ from typing import TYPE_CHECKING, Any
11
+
12
+ if TYPE_CHECKING:
13
+ from campai_api.models.members import Address
14
+
15
+
16
+ @dataclass(slots=True, kw_only=True)
17
+ class FinanceDatevSettings:
18
+ """DATEV accounting integration settings."""
19
+
20
+ advisor_number: str | None = None
21
+ mandate_number: str | None = None
22
+
23
+
24
+ @dataclass(slots=True, kw_only=True)
25
+ class FinanceSettings:
26
+ """Campai organization finance settings."""
27
+
28
+ vat_id: str | None = field(default=None, metadata={"alias": "vatID"})
29
+ tax_id: str | None = field(default=None, metadata={"alias": "taxID"})
30
+ tax_office_name: str | None = None
31
+ vat_due_method: str | None = None
32
+ fiscal_month_start: int | None = None
33
+ accounting_mode: str | None = None
34
+ reverse_postings_on_cancelation: bool | None = None
35
+ donation_enabled: bool | None = None
36
+ donation_membership_fees: bool | None = None
37
+ datev: FinanceDatevSettings | dict[str, Any] | None = None
38
+ reminders: dict[str, Any] = field(default_factory=dict)
39
+ payment_methods: dict[str, Any] = field(default_factory=dict)
40
+ returned_payment_notification: dict[str, Any] = field(default_factory=dict)
41
+ receipt_number_formats: dict[str, Any] = field(default_factory=dict)
42
+ receipt_number_scope: str | None = None
43
+
44
+
45
+ @dataclass(slots=True, kw_only=True)
46
+ class FinanceSettingsUpdateRequest:
47
+ """Request payload for updating organization finance settings."""
48
+
49
+ vat_id: str | None = field(default=None, metadata={"alias": "vatID"})
50
+ tax_id: str | None = field(default=None, metadata={"alias": "taxID"})
51
+ tax_office_name: str | None = None
52
+ vat_due_method: str | None = None
53
+ fiscal_month_start: int | None = None
54
+ accounting_mode: str | None = None
55
+ reverse_postings_on_cancelation: bool | None = None
56
+ automatic_reminders: bool | None = None
57
+ donation_reminders_automatic_reminders: bool | None = None
58
+ datev: FinanceDatevSettings | dict[str, Any] | None = None
59
+ payment_methods: dict[str, Any] | None = None
60
+ returned_payment_notification: dict[str, Any] | None = None
61
+
62
+
63
+ @dataclass(slots=True, kw_only=True)
64
+ class ReceiptPosition:
65
+ """Line item position in a receipt or invoice (amounts in integer cents)."""
66
+
67
+ amount: int | None = None # integer cents, present in GET responses
68
+ unit_amount: int | None = None # integer cents
69
+ discount: int = 0 # integer cents
70
+ description: str | None = None
71
+ account: int | None = None
72
+ quantity: float = 1.0
73
+ unit: str = ""
74
+ details: str = ""
75
+ tax_code: str | None = None
76
+ cost_center1: float | int | None = None
77
+ cost_center2: float | int | None = None
78
+ reference: str | None = None
79
+ secondary_reference: str | None = None
80
+ product: str | None = None
81
+ sales_period: str | None = None
82
+
83
+
84
+ @dataclass(slots=True, kw_only=True)
85
+ class InvoicePositionRequest:
86
+ """Line item position for creating or updating an invoice."""
87
+
88
+ description: str
89
+ unit_amount: int # integer cents
90
+ account: int
91
+ discount: int = 0 # integer cents
92
+ quantity: float = 1.0
93
+ unit: str | None = None
94
+ details: str | None = None
95
+ tax_code: str | None = None
96
+ cost_center1: float | int | None = None
97
+ cost_center2: float | int | None = None
98
+ reference: str | None = None
99
+ secondary_reference: str | None = None
100
+ product: str | None = None
101
+ sales_period: str | None = None
102
+ package: dict[str, Any] | None = None
103
+
104
+
105
+ @dataclass(slots=True, kw_only=True)
106
+ class Receipt:
107
+ """Campai receipt or invoice record."""
108
+
109
+ id: str | None = field(default=None, metadata={"alias": "_id"})
110
+ receipt_number: str | None = None
111
+ receipt_date: str | None = None
112
+ due_date: str | None = None
113
+ total_gross_amount: int | None = None # integer cents
114
+ total_amount_left_to_pay: int | None = None # integer cents
115
+ payment_status: str | None = None
116
+ payment_method: dict[str, Any] | None = None
117
+ customer_number: list[str] = field(default_factory=list)
118
+ customer_type: str | None = None
119
+ title: str | None = None
120
+ description: str | None = None
121
+ is_net: bool = False
122
+ draft: bool = False
123
+ type: str | None = None
124
+ invoice_type: str | None = None
125
+ positions: list[ReceiptPosition] = field(default_factory=list)
126
+ address: Address | dict[str, Any] | None = None
127
+ tags: list[str] = field(default_factory=list)
128
+ created_at: str | None = None
129
+ updated_at: str | None = None
130
+
131
+
132
+ @dataclass(slots=True, kw_only=True)
133
+ class ReceiptsListResponse:
134
+ """Response containing a list of receipts and total count."""
135
+
136
+ receipts: list[Receipt] = field(default_factory=list)
137
+ count: int = 0
138
+
139
+
140
+ @dataclass(slots=True, kw_only=True)
141
+ class InvoiceCreateRequest:
142
+ """Request payload for creating an invoice."""
143
+
144
+ draft: bool
145
+ address: Address | dict[str, Any]
146
+ delivery_date_type: str | None = field(metadata={"keep_none": True})
147
+ title: str
148
+ intro: str
149
+ account: int
150
+ receipt_date: str
151
+ due_date: str
152
+ positions: list[InvoicePositionRequest | dict[str, Any]]
153
+ account_name: str | None = None
154
+ confirmation_receipt: str | None = None
155
+ contribution_ids: list[str] | None = None
156
+ customer_number: list[str] | None = None
157
+ customer_type: str | None = None
158
+ delivery_date: str | None = None
159
+ delivery_date_start: str | None = None
160
+ delivery_date_end: str | None = None
161
+ description: str | None = None
162
+ discount: int | None = None
163
+ discount_type: str | None = None
164
+ do_not_send_receipt: bool | None = None
165
+ electronic: bool | None = None
166
+ email: str | None = None
167
+ email_texts: dict[str, Any] | None = None
168
+ invoice_type: str | None = None
169
+ is_net: bool | None = None
170
+ note: str | None = None
171
+ offer_receipt: str | None = None
172
+ payment: dict[str, Any] | None = None
173
+ payment_method: dict[str, Any] | None = None
174
+ payment_sepa_credit_transfer_data: dict[str, Any] | None = None
175
+ payment_sepa_credit_transfer_id: str | None = None
176
+ payment_terms: dict[str, Any] | None = None
177
+ queue_receipt_document: bool | None = None
178
+ receipt_number: str | None = None
179
+ receipt_template: str | None = None
180
+ refund: dict[str, Any] | None = None
181
+ refund_receipt: str | None = None
182
+ send_method: str | None = None
183
+ supplier_number: str | None = None
184
+ tags: list[str] | None = None
185
+ use_deposit_receipts: bool | None = None
186
+
187
+
188
+ @dataclass(slots=True, kw_only=True)
189
+ class InvoiceUpdateRequest:
190
+ """Request payload for updating an invoice."""
191
+
192
+ draft: bool
193
+ address: Address | dict[str, Any]
194
+ delivery_date_type: str | None = field(metadata={"keep_none": True})
195
+ title: str
196
+ intro: str
197
+ account: int
198
+ receipt_date: str
199
+ due_date: str
200
+ positions: list[InvoicePositionRequest | dict[str, Any]]
201
+ account_name: str | None = None
202
+ cash_transaction_payment: dict[str, Any] | None = None
203
+ confirmation_receipt: str | None = None
204
+ customer_number: list[str] | None = None
205
+ customer_type: str | None = None
206
+ delivery_date: str | None = None
207
+ delivery_date_start: str | None = None
208
+ delivery_date_end: str | None = None
209
+ description: str | None = None
210
+ discount: int | None = None
211
+ discount_type: str | None = None
212
+ do_not_send_receipt: bool | None = None
213
+ electronic: bool | None = None
214
+ email: str | None = None
215
+ email_texts: dict[str, Any] | None = None
216
+ invoice_type: str | None = None
217
+ is_net: bool | None = None
218
+ note: str | None = None
219
+ offer_receipt: str | None = None
220
+ payment_method: dict[str, Any] | None = None
221
+ payment_sepa_credit_transfer_data: dict[str, Any] | None = None
222
+ payment_sepa_credit_transfer_id: str | None = None
223
+ payment_terms: dict[str, Any] | None = None
224
+ queue_receipt_document: bool | None = None
225
+ receipt_number: str | None = None
226
+ receipt_template: str | None = None
227
+ refund: dict[str, Any] | None = None
228
+ refund_receipt: str | None = None
229
+ send_method: str | None = None
230
+ supplier_number: str | None = None
231
+ use_deposit_receipts: bool | None = None
232
+
233
+
234
+ @dataclass(slots=True, kw_only=True)
235
+ class InvoiceCreateResult:
236
+ """Result returned when an invoice is created or updated."""
237
+
238
+ id: str = field(metadata={"alias": "_id"})
239
+ already_collected: bool | None = None
@@ -0,0 +1,257 @@
1
+ # SPDX-FileCopyrightText: 2026 2026 Stephan Lukasczyk <stephan@dante.de>
2
+ #
3
+ # SPDX-License-Identifier: EUPL-1.2
4
+
5
+ """Data models for CRM contacts and members."""
6
+
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass, field
10
+ from typing import Any
11
+
12
+
13
+ @dataclass(slots=True, kw_only=True)
14
+ class Address:
15
+ """Postal address for a contact or organization."""
16
+
17
+ country: str | None = None
18
+ state: str | None = None
19
+ zip: str | None = None
20
+ city: str | None = None
21
+ address_line: str | None = None
22
+ details1: str | None = None
23
+ details2: str | None = None
24
+
25
+
26
+ @dataclass(slots=True, kw_only=True)
27
+ class Person:
28
+ """Personal identity information."""
29
+
30
+ salutation: str | None = None
31
+ gender: str | None = None
32
+ title: str | None = None
33
+ first_name: str | None = None
34
+ last_name: str | None = None
35
+ institution_name: str | None = None
36
+ print_institution_on_address: bool | None = None
37
+ birthdate: str | None = None
38
+ age: int | None = None
39
+ birthdate_day_of_year: int | None = None
40
+
41
+
42
+ @dataclass(slots=True, kw_only=True)
43
+ class Institution:
44
+ """Institutional / company information."""
45
+
46
+ type: str | None = None
47
+ name: str | None = None
48
+
49
+
50
+ @dataclass(slots=True, kw_only=True)
51
+ class Communication:
52
+ """Contact communication channels."""
53
+
54
+ email: str | None = None
55
+ phone: str | None = None
56
+ mobile_phone: str | None = None
57
+ mailing: bool | None = None
58
+ mailing_tags: list[str] = field(default_factory=list)
59
+ mailing_unsubscriptions: list[dict[str, Any]] = field(default_factory=list)
60
+ greetings: str | None = None
61
+
62
+
63
+ @dataclass(slots=True, kw_only=True)
64
+ class MemberData:
65
+ """Membership-specific data for a CRM contact."""
66
+
67
+ entry_at: str | None = None
68
+ exit_at: str | None = None
69
+ terminated_at: str | None = None
70
+ termination_reason: dict[str, Any] | None = None
71
+ membership_duration: int | None = None
72
+ entry_at_day_of_year: int | None = None
73
+ exit_at_day_of_year: int | None = None
74
+
75
+
76
+ @dataclass(slots=True, kw_only=True)
77
+ class ContactDepartment:
78
+ """Department assignment in a contact response."""
79
+
80
+ department: str | None = None
81
+ name: str | None = None
82
+ color: str | None = None
83
+ contact_types: list[str] = field(default_factory=list)
84
+ entry_at: str | None = None
85
+ exit_at: str | None = None
86
+
87
+
88
+ @dataclass(slots=True, kw_only=True)
89
+ class ContactDepartmentAssignment:
90
+ """Department assignment payload for creating or updating a contact."""
91
+
92
+ department_id: str = field(metadata={"alias": "departmentId"})
93
+ entry_at: str | None = field(metadata={"keep_none": True})
94
+ exit_at: str | None = field(metadata={"keep_none": True})
95
+
96
+
97
+ @dataclass(slots=True, kw_only=True)
98
+ class PersonCreateInput:
99
+ """``person`` object of a contact creation request (all keys required by the API)."""
100
+
101
+ title: str
102
+ first_name: str
103
+ last_name: str
104
+ birthdate: str | None = field(metadata={"keep_none": True})
105
+ gender: str | None = field(metadata={"keep_none": True})
106
+
107
+
108
+ @dataclass(slots=True, kw_only=True)
109
+ class PersonUpdateInput:
110
+ """``person`` object of a contact update request (all keys required by the API)."""
111
+
112
+ salutation: str
113
+ gender: str | None = field(metadata={"keep_none": True})
114
+ title: str
115
+ first_name: str
116
+ last_name: str
117
+ institution_name: str
118
+ print_institution_on_address: bool
119
+ birthdate: str | None = field(metadata={"keep_none": True})
120
+
121
+
122
+ @dataclass(slots=True, kw_only=True)
123
+ class MemberCreateInput:
124
+ """``member`` object of a contact creation request."""
125
+
126
+ entry_at: str | None = field(metadata={"keep_none": True})
127
+
128
+
129
+ @dataclass(slots=True, kw_only=True)
130
+ class MemberUpdateInput:
131
+ """``member`` object of a contact update request."""
132
+
133
+ entry_at: str | None = field(metadata={"keep_none": True})
134
+ exit_at: str | None = field(metadata={"keep_none": True})
135
+
136
+
137
+ @dataclass(slots=True, kw_only=True)
138
+ class CommunicationCreateInput:
139
+ """``communication`` object of a contact creation request."""
140
+
141
+ email: str
142
+
143
+
144
+ @dataclass(slots=True, kw_only=True)
145
+ class MailingUnsubscriptionInput:
146
+ """Mailing unsubscription entry of a contact update request."""
147
+
148
+ email: str
149
+ unsubscribed_at: str | None = field(metadata={"keep_none": True})
150
+ tags: list[str]
151
+ all: bool
152
+
153
+
154
+ @dataclass(slots=True, kw_only=True)
155
+ class CommunicationUpdateInput:
156
+ """``communication`` object of a contact update request (all keys required by the API)."""
157
+
158
+ email: str
159
+ phone: str
160
+ mobile_phone: str
161
+ mailing: bool
162
+ mailing_tags: list[str]
163
+ mailing_unsubscriptions: list[MailingUnsubscriptionInput | dict[str, Any]]
164
+
165
+
166
+ @dataclass(slots=True, kw_only=True)
167
+ class Contact:
168
+ """Campai CRM contact / member."""
169
+
170
+ id: str | None = field(default=None, metadata={"alias": "_id"})
171
+ name: str | None = None
172
+ name_normalized: str | None = None
173
+ name_sort: str | None = None
174
+ language: str | None = None
175
+ mandates: list[str] = field(default_factory=list)
176
+ types: list[str] = field(default_factory=list)
177
+ debtor: dict[str, Any] | None = None
178
+ creditor: dict[str, Any] | None = None
179
+ groups: list[dict[str, Any]] = field(default_factory=list)
180
+ segments: list[str] = field(default_factory=list)
181
+ tags: list[str] = field(default_factory=list)
182
+ teams: list[dict[str, Any]] = field(default_factory=list)
183
+ contact_numbers: dict[str, Any] = field(default_factory=dict)
184
+ address: Address | None = None
185
+ person: Person | None = None
186
+ institution: Institution | None = None
187
+ communication: Communication | None = None
188
+ member: MemberData | dict[str, Any] | None = None
189
+ departments: list[ContactDepartment] = field(default_factory=list)
190
+ custom_fields: dict[str, Any] = field(default_factory=dict)
191
+ image: dict[str, Any] | None = None
192
+ employee: dict[str, Any] | None = None
193
+ contributor: dict[str, Any] | None = None
194
+ created_at: str | None = None
195
+ updated_at: str | None = None
196
+
197
+
198
+ @dataclass(slots=True, kw_only=True)
199
+ class ContactsListResponse:
200
+ """Response containing a list of contacts and total count."""
201
+
202
+ contacts: list[Contact] = field(default_factory=list)
203
+ count: int = 0
204
+
205
+
206
+ @dataclass(slots=True, kw_only=True)
207
+ class ContactCreateResult:
208
+ """Result returned when a contact is created."""
209
+
210
+ id: str = field(metadata={"alias": "_id"})
211
+ debtor_account: int | None = None
212
+
213
+
214
+ @dataclass(slots=True, kw_only=True)
215
+ class ContactCreateRequest:
216
+ """Request payload for creating a contact."""
217
+
218
+ type: str
219
+ language: str | None = None
220
+ address: Address | dict[str, Any] | None = None
221
+ communication: CommunicationCreateInput | dict[str, Any] | None = None
222
+ person: PersonCreateInput | dict[str, Any] | None = None
223
+ institution: Institution | dict[str, Any] | None = None
224
+ member: MemberCreateInput | dict[str, Any] | None = None
225
+ employee: dict[str, Any] | None = None
226
+ contributor: dict[str, Any] | None = None
227
+ contact_number: str | None = None
228
+ departments: list[ContactDepartmentAssignment | dict[str, Any]] | None = None
229
+ eventim: dict[str, Any] | None = None
230
+ update: dict[str, Any] | None = None
231
+ attach_debtor: bool | int | None = None
232
+ attach_creditor: bool | int | None = None
233
+ make_duplicate_check: bool | None = None
234
+
235
+
236
+ @dataclass(slots=True, kw_only=True)
237
+ class ContactUpdateRequest:
238
+ """Request payload for updating an existing contact."""
239
+
240
+ language: str | None = None
241
+ address: Address | dict[str, Any] | None = None
242
+ communication: CommunicationUpdateInput | dict[str, Any] | None = None
243
+ person: PersonUpdateInput | dict[str, Any] | None = None
244
+ institution: Institution | dict[str, Any] | None = None
245
+ member: MemberUpdateInput | dict[str, Any] | None = None
246
+ employee: dict[str, Any] | None = None
247
+ contributor: dict[str, Any] | None = None
248
+ contact_number: str | None = None
249
+ contact_type: str | None = None
250
+ departments: list[ContactDepartmentAssignment | dict[str, Any]] | None = None
251
+ eventim: dict[str, Any] | None = None
252
+ tags: list[str] | None = None
253
+ custom_fields: dict[str, Any] | None = None
254
+ alternative_communications: list[dict[str, Any]] | None = None
255
+ data_propagation_targets: list[str] | None = None
256
+ image: dict[str, Any] | None = None
257
+ network_consent: dict[str, Any] | None = None
@@ -0,0 +1,32 @@
1
+ # SPDX-FileCopyrightText: 2026 2026 Stephan Lukasczyk <stephan@dante.de>
2
+ #
3
+ # SPDX-License-Identifier: EUPL-1.2
4
+
5
+ """Data models for webhook trigger operations.
6
+
7
+ Note:
8
+ Campai REST API OpenAPI specification supports webhook triggering for
9
+ existing contacts and members (`POST /{organizationId}/oldContacts/{contactId}/triggerWebhooks`
10
+ and `POST /{organizationId}/oldMembers/{contactId}/triggerWebhooks`).
11
+ Webhook subscription management (CRUD on webhook endpoints) is not provided by the API.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from dataclasses import dataclass
17
+ from enum import StrEnum
18
+
19
+
20
+ class WebhookTriggerEvent(StrEnum):
21
+ """Allowed event types for triggering webhooks."""
22
+
23
+ CREATED = "created"
24
+ UPDATED = "updated"
25
+ DELETED = "deleted"
26
+
27
+
28
+ @dataclass(slots=True, kw_only=True)
29
+ class WebhookTriggerRequest:
30
+ """Request payload for triggering contact or member webhooks."""
31
+
32
+ event: WebhookTriggerEvent | str
@@ -0,0 +1,26 @@
1
+ # SPDX-FileCopyrightText: 2026 2026 Stephan Lukasczyk <stephan@dante.de>
2
+ #
3
+ # SPDX-License-Identifier: EUPL-1.2
4
+
5
+ """Domain resource namespaces for Campai API."""
6
+
7
+ from __future__ import annotations
8
+
9
+ from campai_api.resources.auth import AsyncAuthResource, AuthResource
10
+ from campai_api.resources.base import AsyncBaseResource, BaseResource
11
+ from campai_api.resources.finance import AsyncFinanceResource, FinanceResource
12
+ from campai_api.resources.members import AsyncMembersResource, MembersResource
13
+ from campai_api.resources.webhooks import AsyncWebhooksResource, WebhooksResource
14
+
15
+ __all__ = [
16
+ "AsyncAuthResource",
17
+ "AsyncBaseResource",
18
+ "AsyncFinanceResource",
19
+ "AsyncMembersResource",
20
+ "AsyncWebhooksResource",
21
+ "AuthResource",
22
+ "BaseResource",
23
+ "FinanceResource",
24
+ "MembersResource",
25
+ "WebhooksResource",
26
+ ]
@@ -0,0 +1,134 @@
1
+ # SPDX-FileCopyrightText: 2026 2026 Stephan Lukasczyk <stephan@dante.de>
2
+ #
3
+ # SPDX-License-Identifier: EUPL-1.2
4
+
5
+ """Authentication, organization, and mandate resources for Campai API."""
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import TYPE_CHECKING, Any
10
+
11
+ if TYPE_CHECKING:
12
+ from collections.abc import Sequence
13
+
14
+ from campai_api.models.auth import ApiKeyInfo, Mandate, MandatesListResponse, Organization
15
+ from campai_api.resources.base import AsyncBaseResource, BaseResource
16
+ from campai_api.transport import quote_path_segment
17
+
18
+
19
+ class AuthResource(BaseResource):
20
+ """Synchronous operations for API key info, organizations, and mandates."""
21
+
22
+ def get_api_key_info(self) -> ApiKeyInfo:
23
+ """Retrieve API key metadata and permissions mapping."""
24
+ return self._transport.request_model("GET", "apiKey/info", ApiKeyInfo)
25
+
26
+ def get_info(self) -> ApiKeyInfo:
27
+ """Alias for get_api_key_info."""
28
+ return self.get_api_key_info()
29
+
30
+ def get_organization(self, organization_id: str) -> Organization:
31
+ """Retrieve organization details by ID."""
32
+ org_id = quote_path_segment(organization_id)
33
+ return self._transport.request_model("GET", f"organizations/{org_id}", Organization)
34
+
35
+ def list_mandates(
36
+ self,
37
+ organization_id: str,
38
+ *,
39
+ limit: int = 50,
40
+ offset: int = 0,
41
+ return_count: bool = True,
42
+ search_term: str | None = None,
43
+ selection: list[str] | Sequence[str] | dict[str, Any] | None = None,
44
+ sort: dict[str, Any] | None = None,
45
+ ) -> MandatesListResponse:
46
+ """List mandates for an organization."""
47
+ org_id = quote_path_segment(organization_id)
48
+ payload: dict[str, Any] = {
49
+ "limit": limit,
50
+ "offset": offset,
51
+ "returnCount": return_count,
52
+ }
53
+ if search_term is not None:
54
+ payload["searchTerm"] = search_term
55
+ if selection is not None:
56
+ payload["selection"] = selection
57
+ if sort is not None:
58
+ payload["sort"] = sort
59
+
60
+ return self._transport.request_model(
61
+ "POST",
62
+ f"organizations/{org_id}/mandates/list",
63
+ MandatesListResponse,
64
+ json=payload,
65
+ )
66
+
67
+ def get_mandate(self, organization_id: str, mandate_id: str) -> Mandate:
68
+ """Retrieve mandate details by ID."""
69
+ org_id = quote_path_segment(organization_id)
70
+ m_id = quote_path_segment(mandate_id)
71
+ return self._transport.request_model(
72
+ "GET",
73
+ f"organizations/{org_id}/mandates/{m_id}",
74
+ Mandate,
75
+ )
76
+
77
+
78
+ class AsyncAuthResource(AsyncBaseResource):
79
+ """Asynchronous operations for API key info, organizations, and mandates."""
80
+
81
+ async def get_api_key_info(self) -> ApiKeyInfo:
82
+ """Retrieve API key metadata and permissions mapping."""
83
+ return await self._transport.request_model("GET", "apiKey/info", ApiKeyInfo)
84
+
85
+ async def get_info(self) -> ApiKeyInfo:
86
+ """Alias for get_api_key_info."""
87
+ return await self.get_api_key_info()
88
+
89
+ async def get_organization(self, organization_id: str) -> Organization:
90
+ """Retrieve organization details by ID."""
91
+ org_id = quote_path_segment(organization_id)
92
+ return await self._transport.request_model("GET", f"organizations/{org_id}", Organization)
93
+
94
+ async def list_mandates(
95
+ self,
96
+ organization_id: str,
97
+ *,
98
+ limit: int = 50,
99
+ offset: int = 0,
100
+ return_count: bool = True,
101
+ search_term: str | None = None,
102
+ selection: list[str] | Sequence[str] | dict[str, Any] | None = None,
103
+ sort: dict[str, Any] | None = None,
104
+ ) -> MandatesListResponse:
105
+ """List mandates for an organization."""
106
+ org_id = quote_path_segment(organization_id)
107
+ payload: dict[str, Any] = {
108
+ "limit": limit,
109
+ "offset": offset,
110
+ "returnCount": return_count,
111
+ }
112
+ if search_term is not None:
113
+ payload["searchTerm"] = search_term
114
+ if selection is not None:
115
+ payload["selection"] = selection
116
+ if sort is not None:
117
+ payload["sort"] = sort
118
+
119
+ return await self._transport.request_model(
120
+ "POST",
121
+ f"organizations/{org_id}/mandates/list",
122
+ MandatesListResponse,
123
+ json=payload,
124
+ )
125
+
126
+ async def get_mandate(self, organization_id: str, mandate_id: str) -> Mandate:
127
+ """Retrieve mandate details by ID."""
128
+ org_id = quote_path_segment(organization_id)
129
+ m_id = quote_path_segment(mandate_id)
130
+ return await self._transport.request_model(
131
+ "GET",
132
+ f"organizations/{org_id}/mandates/{m_id}",
133
+ Mandate,
134
+ )