eetlijst-python 0.0.1__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.
- eetlijst/__init__.py +3 -0
- eetlijst/eetlijst.py +37 -0
- eetlijst/exceptions.py +2 -0
- eetlijst/generated/__init__.py +1153 -0
- eetlijst/generated/all_attendances.py +13 -0
- eetlijst/generated/all_events.py +13 -0
- eetlijst/generated/all_expenses.py +13 -0
- eetlijst/generated/all_groups.py +27 -0
- eetlijst/generated/all_settlements.py +13 -0
- eetlijst/generated/all_users_in_group.py +20 -0
- eetlijst/generated/app_status.py +16 -0
- eetlijst/generated/async_base_client.py +393 -0
- eetlijst/generated/automatic_events.py +18 -0
- eetlijst/generated/base_model.py +28 -0
- eetlijst/generated/client.py +1748 -0
- eetlijst/generated/create_expense.py +15 -0
- eetlijst/generated/create_group.py +15 -0
- eetlijst/generated/create_list_item.py +15 -0
- eetlijst/generated/create_many_list_items.py +20 -0
- eetlijst/generated/create_settlement.py +15 -0
- eetlijst/generated/enums.py +555 -0
- eetlijst/generated/exceptions.py +83 -0
- eetlijst/generated/fragments.py +237 -0
- eetlijst/generated/get_attendance.py +17 -0
- eetlijst/generated/get_event.py +15 -0
- eetlijst/generated/get_group.py +20 -0
- eetlijst/generated/get_user.py +13 -0
- eetlijst/generated/get_user_in_group.py +20 -0
- eetlijst/generated/group_total_expense.py +45 -0
- eetlijst/generated/input_types.py +4702 -0
- eetlijst/generated/join_group.py +17 -0
- eetlijst/generated/list_items.py +13 -0
- eetlijst/generated/remove_account.py +16 -0
- eetlijst/generated/settle_unsettled_expenses.py +21 -0
- eetlijst/generated/settlement_expenses.py +13 -0
- eetlijst/generated/update_attendance.py +17 -0
- eetlijst/generated/update_event.py +15 -0
- eetlijst/generated/update_expense.py +20 -0
- eetlijst/generated/update_expense_distribution.py +23 -0
- eetlijst/generated/update_group.py +15 -0
- eetlijst/generated/update_list_item.py +15 -0
- eetlijst/generated/update_many_attendance.py +22 -0
- eetlijst/generated/update_user.py +15 -0
- eetlijst/generated/update_user_in_group.py +17 -0
- eetlijst/generated/update_users_in_group.py +25 -0
- eetlijst/services/__init__.py +9 -0
- eetlijst/services/app/__init__.py +1 -0
- eetlijst/services/app/app.py +20 -0
- eetlijst/services/app/transformers.py +10 -0
- eetlijst/services/event_attendance/__init__.py +1 -0
- eetlijst/services/event_attendance/event_attendance.py +94 -0
- eetlijst/services/event_attendance/transformers.py +58 -0
- eetlijst/services/events/__init__.py +1 -0
- eetlijst/services/events/events.py +148 -0
- eetlijst/services/events/transformers.py +67 -0
- eetlijst/services/expenses/__init__.py +1 -0
- eetlijst/services/expenses/expenses.py +98 -0
- eetlijst/services/expenses/transformers.py +73 -0
- eetlijst/services/expenses/utils.py +31 -0
- eetlijst/services/group_list/__init__.py +1 -0
- eetlijst/services/group_list/group_list.py +95 -0
- eetlijst/services/group_list/transformers.py +38 -0
- eetlijst/services/group_users/__init__.py +1 -0
- eetlijst/services/group_users/group_users.py +130 -0
- eetlijst/services/group_users/transformers.py +84 -0
- eetlijst/services/groups/__init__.py +1 -0
- eetlijst/services/groups/groups.py +84 -0
- eetlijst/services/groups/transformers.py +140 -0
- eetlijst/services/settlements/__init__.py +1 -0
- eetlijst/services/settlements/settlements.py +225 -0
- eetlijst/services/settlements/transformers.py +95 -0
- eetlijst/services/settlements/utils.py +84 -0
- eetlijst/services/users/__init__.py +1 -0
- eetlijst/services/users/transformers.py +103 -0
- eetlijst/services/users/users.py +44 -0
- eetlijst/utils/__init__.py +0 -0
- eetlijst/utils/datetime.py +25 -0
- eetlijst_python-0.0.1.dist-info/METADATA +80 -0
- eetlijst_python-0.0.1.dist-info/RECORD +81 -0
- eetlijst_python-0.0.1.dist-info/WHEEL +5 -0
- eetlijst_python-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1748 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Any, Optional, Union
|
|
3
|
+
|
|
4
|
+
from .all_attendances import AllAttendances
|
|
5
|
+
from .all_events import AllEvents
|
|
6
|
+
from .all_expenses import AllExpenses
|
|
7
|
+
from .all_groups import AllGroups
|
|
8
|
+
from .all_settlements import AllSettlements
|
|
9
|
+
from .all_users_in_group import AllUsersInGroup
|
|
10
|
+
from .app_status import AppStatus
|
|
11
|
+
from .async_base_client import AsyncBaseClient
|
|
12
|
+
from .automatic_events import AutomaticEvents
|
|
13
|
+
from .base_model import UNSET, UnsetType
|
|
14
|
+
from .create_expense import CreateExpense
|
|
15
|
+
from .create_group import CreateGroup
|
|
16
|
+
from .create_list_item import CreateListItem
|
|
17
|
+
from .create_many_list_items import CreateManyListItems
|
|
18
|
+
from .create_settlement import CreateSettlement
|
|
19
|
+
from .get_attendance import GetAttendance
|
|
20
|
+
from .get_event import GetEvent
|
|
21
|
+
from .get_group import GetGroup
|
|
22
|
+
from .get_user import GetUser
|
|
23
|
+
from .get_user_in_group import GetUserInGroup
|
|
24
|
+
from .group_total_expense import GroupTotalExpense
|
|
25
|
+
from .input_types import (
|
|
26
|
+
eetschema_event_attendees_bool_exp,
|
|
27
|
+
eetschema_event_attendees_insert_input,
|
|
28
|
+
eetschema_event_attendees_order_by,
|
|
29
|
+
eetschema_event_attendees_set_input,
|
|
30
|
+
eetschema_event_bool_exp,
|
|
31
|
+
eetschema_event_order_by,
|
|
32
|
+
eetschema_event_set_input,
|
|
33
|
+
eetschema_expense_bool_exp,
|
|
34
|
+
eetschema_expense_distribution_insert_input,
|
|
35
|
+
eetschema_expense_order_by,
|
|
36
|
+
eetschema_expense_set_input,
|
|
37
|
+
eetschema_group_set_input,
|
|
38
|
+
eetschema_list_bool_exp,
|
|
39
|
+
eetschema_list_insert_input,
|
|
40
|
+
eetschema_list_order_by,
|
|
41
|
+
eetschema_list_set_input,
|
|
42
|
+
eetschema_settlements_bool_exp,
|
|
43
|
+
eetschema_settlements_order_by,
|
|
44
|
+
eetschema_user_set_input,
|
|
45
|
+
eetschema_users_in_group_bool_exp,
|
|
46
|
+
eetschema_users_in_group_order_by,
|
|
47
|
+
eetschema_users_in_group_set_input,
|
|
48
|
+
eetschema_users_in_group_updates,
|
|
49
|
+
)
|
|
50
|
+
from .join_group import JoinGroup
|
|
51
|
+
from .list_items import ListItems
|
|
52
|
+
from .remove_account import RemoveAccount
|
|
53
|
+
from .settle_unsettled_expenses import SettleUnsettledExpenses
|
|
54
|
+
from .settlement_expenses import SettlementExpenses
|
|
55
|
+
from .update_attendance import UpdateAttendance
|
|
56
|
+
from .update_event import UpdateEvent
|
|
57
|
+
from .update_expense import UpdateExpense
|
|
58
|
+
from .update_expense_distribution import UpdateExpenseDistribution
|
|
59
|
+
from .update_group import UpdateGroup
|
|
60
|
+
from .update_list_item import UpdateListItem
|
|
61
|
+
from .update_many_attendance import UpdateManyAttendance
|
|
62
|
+
from .update_user import UpdateUser
|
|
63
|
+
from .update_user_in_group import UpdateUserInGroup
|
|
64
|
+
from .update_users_in_group import UpdateUsersInGroup
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def gql(q: str) -> str:
|
|
68
|
+
return q
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class GraphQlClient(AsyncBaseClient):
|
|
72
|
+
async def app_status(self, **kwargs: Any) -> AppStatus:
|
|
73
|
+
query = gql("""
|
|
74
|
+
query AppStatus {
|
|
75
|
+
eetschema_app_status {
|
|
76
|
+
id
|
|
77
|
+
beta_online
|
|
78
|
+
updated_at
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
""")
|
|
82
|
+
variables: dict[str, object] = {}
|
|
83
|
+
response = await self.execute(
|
|
84
|
+
query=query, operation_name="AppStatus", variables=variables, **kwargs
|
|
85
|
+
)
|
|
86
|
+
data = self.get_data(response)
|
|
87
|
+
return AppStatus.model_validate(data)
|
|
88
|
+
|
|
89
|
+
async def update_many_attendance(
|
|
90
|
+
self, updates: list[eetschema_event_attendees_insert_input], **kwargs: Any
|
|
91
|
+
) -> UpdateManyAttendance:
|
|
92
|
+
query = gql("""
|
|
93
|
+
mutation UpdateManyAttendance($updates: [eetschema_event_attendees_insert_input!]!) {
|
|
94
|
+
insert_eetschema_event_attendees(
|
|
95
|
+
objects: $updates
|
|
96
|
+
on_conflict: {constraint: event_attending_members_pkey, update_columns: [status, number_guests, user_changed_status, comment]}
|
|
97
|
+
) {
|
|
98
|
+
returning {
|
|
99
|
+
...AttendanceFields
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fragment AttendanceFields on eetschema_event_attendees {
|
|
105
|
+
created_at
|
|
106
|
+
updated_at
|
|
107
|
+
comment
|
|
108
|
+
number_guests
|
|
109
|
+
status
|
|
110
|
+
linked_event {
|
|
111
|
+
id
|
|
112
|
+
name
|
|
113
|
+
}
|
|
114
|
+
user_in_group {
|
|
115
|
+
order
|
|
116
|
+
user {
|
|
117
|
+
id
|
|
118
|
+
name
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
""")
|
|
123
|
+
variables: dict[str, object] = {"updates": updates}
|
|
124
|
+
response = await self.execute(
|
|
125
|
+
query=query,
|
|
126
|
+
operation_name="UpdateManyAttendance",
|
|
127
|
+
variables=variables,
|
|
128
|
+
**kwargs,
|
|
129
|
+
)
|
|
130
|
+
data = self.get_data(response)
|
|
131
|
+
return UpdateManyAttendance.model_validate(data)
|
|
132
|
+
|
|
133
|
+
async def update_attendance(
|
|
134
|
+
self,
|
|
135
|
+
event_id: str,
|
|
136
|
+
user_id: str,
|
|
137
|
+
set_: eetschema_event_attendees_set_input,
|
|
138
|
+
**kwargs: Any,
|
|
139
|
+
) -> UpdateAttendance:
|
|
140
|
+
query = gql("""
|
|
141
|
+
mutation UpdateAttendance($eventId: uuid!, $userId: String!, $_set: eetschema_event_attendees_set_input!) {
|
|
142
|
+
update_eetschema_event_attendees_by_pk(
|
|
143
|
+
pk_columns: {event_id: $eventId, user_id: $userId}
|
|
144
|
+
_set: $_set
|
|
145
|
+
) {
|
|
146
|
+
...AttendanceFields
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fragment AttendanceFields on eetschema_event_attendees {
|
|
151
|
+
created_at
|
|
152
|
+
updated_at
|
|
153
|
+
comment
|
|
154
|
+
number_guests
|
|
155
|
+
status
|
|
156
|
+
linked_event {
|
|
157
|
+
id
|
|
158
|
+
name
|
|
159
|
+
}
|
|
160
|
+
user_in_group {
|
|
161
|
+
order
|
|
162
|
+
user {
|
|
163
|
+
id
|
|
164
|
+
name
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
""")
|
|
169
|
+
variables: dict[str, object] = {
|
|
170
|
+
"eventId": event_id,
|
|
171
|
+
"userId": user_id,
|
|
172
|
+
"_set": set_,
|
|
173
|
+
}
|
|
174
|
+
response = await self.execute(
|
|
175
|
+
query=query,
|
|
176
|
+
operation_name="UpdateAttendance",
|
|
177
|
+
variables=variables,
|
|
178
|
+
**kwargs,
|
|
179
|
+
)
|
|
180
|
+
data = self.get_data(response)
|
|
181
|
+
return UpdateAttendance.model_validate(data)
|
|
182
|
+
|
|
183
|
+
async def all_attendances(
|
|
184
|
+
self,
|
|
185
|
+
where: Union[Optional[eetschema_event_attendees_bool_exp], UnsetType] = UNSET,
|
|
186
|
+
order: Union[
|
|
187
|
+
Optional[list[eetschema_event_attendees_order_by]], UnsetType
|
|
188
|
+
] = UNSET,
|
|
189
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
190
|
+
**kwargs: Any,
|
|
191
|
+
) -> AllAttendances:
|
|
192
|
+
query = gql("""
|
|
193
|
+
query AllAttendances($where: eetschema_event_attendees_bool_exp, $order: [eetschema_event_attendees_order_by!], $limit: Int) {
|
|
194
|
+
eetschema_event_attendees(where: $where, order_by: $order, limit: $limit) {
|
|
195
|
+
...AttendanceFields
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
fragment AttendanceFields on eetschema_event_attendees {
|
|
200
|
+
created_at
|
|
201
|
+
updated_at
|
|
202
|
+
comment
|
|
203
|
+
number_guests
|
|
204
|
+
status
|
|
205
|
+
linked_event {
|
|
206
|
+
id
|
|
207
|
+
name
|
|
208
|
+
}
|
|
209
|
+
user_in_group {
|
|
210
|
+
order
|
|
211
|
+
user {
|
|
212
|
+
id
|
|
213
|
+
name
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
""")
|
|
218
|
+
variables: dict[str, object] = {"where": where, "order": order, "limit": limit}
|
|
219
|
+
response = await self.execute(
|
|
220
|
+
query=query, operation_name="AllAttendances", variables=variables, **kwargs
|
|
221
|
+
)
|
|
222
|
+
data = self.get_data(response)
|
|
223
|
+
return AllAttendances.model_validate(data)
|
|
224
|
+
|
|
225
|
+
async def get_attendance(
|
|
226
|
+
self, event_id: str, user_id: str, **kwargs: Any
|
|
227
|
+
) -> GetAttendance:
|
|
228
|
+
query = gql("""
|
|
229
|
+
query GetAttendance($eventId: uuid!, $userId: String!) {
|
|
230
|
+
eetschema_event_attendees_by_pk(user_id: $userId, event_id: $eventId) {
|
|
231
|
+
...AttendanceFields
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
fragment AttendanceFields on eetschema_event_attendees {
|
|
236
|
+
created_at
|
|
237
|
+
updated_at
|
|
238
|
+
comment
|
|
239
|
+
number_guests
|
|
240
|
+
status
|
|
241
|
+
linked_event {
|
|
242
|
+
id
|
|
243
|
+
name
|
|
244
|
+
}
|
|
245
|
+
user_in_group {
|
|
246
|
+
order
|
|
247
|
+
user {
|
|
248
|
+
id
|
|
249
|
+
name
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
""")
|
|
254
|
+
variables: dict[str, object] = {"eventId": event_id, "userId": user_id}
|
|
255
|
+
response = await self.execute(
|
|
256
|
+
query=query, operation_name="GetAttendance", variables=variables, **kwargs
|
|
257
|
+
)
|
|
258
|
+
data = self.get_data(response)
|
|
259
|
+
return GetAttendance.model_validate(data)
|
|
260
|
+
|
|
261
|
+
async def update_event(
|
|
262
|
+
self,
|
|
263
|
+
event_id: str,
|
|
264
|
+
set_: eetschema_event_set_input,
|
|
265
|
+
include_attendees: Union[Optional[bool], UnsetType] = UNSET,
|
|
266
|
+
include_expenses: Union[Optional[bool], UnsetType] = UNSET,
|
|
267
|
+
**kwargs: Any,
|
|
268
|
+
) -> UpdateEvent:
|
|
269
|
+
query = gql("""
|
|
270
|
+
mutation UpdateEvent($eventId: uuid!, $_set: eetschema_event_set_input!, $includeAttendees: Boolean = false, $includeExpenses: Boolean = false) {
|
|
271
|
+
update_eetschema_event_by_pk(pk_columns: {id: $eventId}, _set: $_set) {
|
|
272
|
+
...EventFields
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
fragment AttendanceFields on eetschema_event_attendees {
|
|
277
|
+
created_at
|
|
278
|
+
updated_at
|
|
279
|
+
comment
|
|
280
|
+
number_guests
|
|
281
|
+
status
|
|
282
|
+
linked_event {
|
|
283
|
+
id
|
|
284
|
+
name
|
|
285
|
+
}
|
|
286
|
+
user_in_group {
|
|
287
|
+
order
|
|
288
|
+
user {
|
|
289
|
+
id
|
|
290
|
+
name
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
fragment EventFields on eetschema_event {
|
|
296
|
+
id
|
|
297
|
+
group_id
|
|
298
|
+
open
|
|
299
|
+
start_date
|
|
300
|
+
closed_by
|
|
301
|
+
signup_deadline
|
|
302
|
+
changed_signup_time
|
|
303
|
+
name
|
|
304
|
+
description
|
|
305
|
+
user {
|
|
306
|
+
id
|
|
307
|
+
name
|
|
308
|
+
}
|
|
309
|
+
created_at
|
|
310
|
+
updated_at
|
|
311
|
+
linked_expenses @include(if: $includeExpenses) {
|
|
312
|
+
...ExpenseFields
|
|
313
|
+
}
|
|
314
|
+
event_attendees @include(if: $includeAttendees) {
|
|
315
|
+
...AttendanceFields
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
fragment ExpenseFields on eetschema_expense {
|
|
320
|
+
id
|
|
321
|
+
event_id
|
|
322
|
+
settled_id
|
|
323
|
+
description
|
|
324
|
+
payed_amount
|
|
325
|
+
deleted
|
|
326
|
+
settlement_expense_id
|
|
327
|
+
expense_distributions {
|
|
328
|
+
id
|
|
329
|
+
count
|
|
330
|
+
payed_amount
|
|
331
|
+
user {
|
|
332
|
+
id
|
|
333
|
+
name
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
payed_at
|
|
337
|
+
payed_by: payed_by_user {
|
|
338
|
+
id
|
|
339
|
+
name
|
|
340
|
+
}
|
|
341
|
+
updated_at
|
|
342
|
+
updated_by: updatedByUser {
|
|
343
|
+
id
|
|
344
|
+
name
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
""")
|
|
348
|
+
variables: dict[str, object] = {
|
|
349
|
+
"eventId": event_id,
|
|
350
|
+
"_set": set_,
|
|
351
|
+
"includeAttendees": include_attendees,
|
|
352
|
+
"includeExpenses": include_expenses,
|
|
353
|
+
}
|
|
354
|
+
response = await self.execute(
|
|
355
|
+
query=query, operation_name="UpdateEvent", variables=variables, **kwargs
|
|
356
|
+
)
|
|
357
|
+
data = self.get_data(response)
|
|
358
|
+
return UpdateEvent.model_validate(data)
|
|
359
|
+
|
|
360
|
+
async def all_events(
|
|
361
|
+
self,
|
|
362
|
+
where: Union[Optional[eetschema_event_bool_exp], UnsetType] = UNSET,
|
|
363
|
+
order: Union[Optional[list[eetschema_event_order_by]], UnsetType] = UNSET,
|
|
364
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
365
|
+
include_attendees: Union[Optional[bool], UnsetType] = UNSET,
|
|
366
|
+
include_expenses: Union[Optional[bool], UnsetType] = UNSET,
|
|
367
|
+
**kwargs: Any,
|
|
368
|
+
) -> AllEvents:
|
|
369
|
+
query = gql("""
|
|
370
|
+
query AllEvents($where: eetschema_event_bool_exp, $order: [eetschema_event_order_by!], $limit: Int, $includeAttendees: Boolean = false, $includeExpenses: Boolean = false) {
|
|
371
|
+
eetschema_event(where: $where, order_by: $order, limit: $limit) {
|
|
372
|
+
...EventFields
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
fragment AttendanceFields on eetschema_event_attendees {
|
|
377
|
+
created_at
|
|
378
|
+
updated_at
|
|
379
|
+
comment
|
|
380
|
+
number_guests
|
|
381
|
+
status
|
|
382
|
+
linked_event {
|
|
383
|
+
id
|
|
384
|
+
name
|
|
385
|
+
}
|
|
386
|
+
user_in_group {
|
|
387
|
+
order
|
|
388
|
+
user {
|
|
389
|
+
id
|
|
390
|
+
name
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
fragment EventFields on eetschema_event {
|
|
396
|
+
id
|
|
397
|
+
group_id
|
|
398
|
+
open
|
|
399
|
+
start_date
|
|
400
|
+
closed_by
|
|
401
|
+
signup_deadline
|
|
402
|
+
changed_signup_time
|
|
403
|
+
name
|
|
404
|
+
description
|
|
405
|
+
user {
|
|
406
|
+
id
|
|
407
|
+
name
|
|
408
|
+
}
|
|
409
|
+
created_at
|
|
410
|
+
updated_at
|
|
411
|
+
linked_expenses @include(if: $includeExpenses) {
|
|
412
|
+
...ExpenseFields
|
|
413
|
+
}
|
|
414
|
+
event_attendees @include(if: $includeAttendees) {
|
|
415
|
+
...AttendanceFields
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
fragment ExpenseFields on eetschema_expense {
|
|
420
|
+
id
|
|
421
|
+
event_id
|
|
422
|
+
settled_id
|
|
423
|
+
description
|
|
424
|
+
payed_amount
|
|
425
|
+
deleted
|
|
426
|
+
settlement_expense_id
|
|
427
|
+
expense_distributions {
|
|
428
|
+
id
|
|
429
|
+
count
|
|
430
|
+
payed_amount
|
|
431
|
+
user {
|
|
432
|
+
id
|
|
433
|
+
name
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
payed_at
|
|
437
|
+
payed_by: payed_by_user {
|
|
438
|
+
id
|
|
439
|
+
name
|
|
440
|
+
}
|
|
441
|
+
updated_at
|
|
442
|
+
updated_by: updatedByUser {
|
|
443
|
+
id
|
|
444
|
+
name
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
""")
|
|
448
|
+
variables: dict[str, object] = {
|
|
449
|
+
"where": where,
|
|
450
|
+
"order": order,
|
|
451
|
+
"limit": limit,
|
|
452
|
+
"includeAttendees": include_attendees,
|
|
453
|
+
"includeExpenses": include_expenses,
|
|
454
|
+
}
|
|
455
|
+
response = await self.execute(
|
|
456
|
+
query=query, operation_name="AllEvents", variables=variables, **kwargs
|
|
457
|
+
)
|
|
458
|
+
data = self.get_data(response)
|
|
459
|
+
return AllEvents.model_validate(data)
|
|
460
|
+
|
|
461
|
+
async def automatic_events(
|
|
462
|
+
self, group_id: str, date: str, **kwargs: Any
|
|
463
|
+
) -> AutomaticEvents:
|
|
464
|
+
query = gql("""
|
|
465
|
+
query AutomaticEvents($groupId: uuid!, $date: String!) {
|
|
466
|
+
queryTodaysEvents(group_id: $groupId, date: $date) {
|
|
467
|
+
id
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
""")
|
|
471
|
+
variables: dict[str, object] = {"groupId": group_id, "date": date}
|
|
472
|
+
response = await self.execute(
|
|
473
|
+
query=query, operation_name="AutomaticEvents", variables=variables, **kwargs
|
|
474
|
+
)
|
|
475
|
+
data = self.get_data(response)
|
|
476
|
+
return AutomaticEvents.model_validate(data)
|
|
477
|
+
|
|
478
|
+
async def get_event(
|
|
479
|
+
self,
|
|
480
|
+
event_id: str,
|
|
481
|
+
include_attendees: Union[Optional[bool], UnsetType] = UNSET,
|
|
482
|
+
include_expenses: Union[Optional[bool], UnsetType] = UNSET,
|
|
483
|
+
**kwargs: Any,
|
|
484
|
+
) -> GetEvent:
|
|
485
|
+
query = gql("""
|
|
486
|
+
query GetEvent($eventId: uuid!, $includeAttendees: Boolean = false, $includeExpenses: Boolean = false) {
|
|
487
|
+
eetschema_event_by_pk(id: $eventId) {
|
|
488
|
+
...EventFields
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
fragment AttendanceFields on eetschema_event_attendees {
|
|
493
|
+
created_at
|
|
494
|
+
updated_at
|
|
495
|
+
comment
|
|
496
|
+
number_guests
|
|
497
|
+
status
|
|
498
|
+
linked_event {
|
|
499
|
+
id
|
|
500
|
+
name
|
|
501
|
+
}
|
|
502
|
+
user_in_group {
|
|
503
|
+
order
|
|
504
|
+
user {
|
|
505
|
+
id
|
|
506
|
+
name
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
fragment EventFields on eetschema_event {
|
|
512
|
+
id
|
|
513
|
+
group_id
|
|
514
|
+
open
|
|
515
|
+
start_date
|
|
516
|
+
closed_by
|
|
517
|
+
signup_deadline
|
|
518
|
+
changed_signup_time
|
|
519
|
+
name
|
|
520
|
+
description
|
|
521
|
+
user {
|
|
522
|
+
id
|
|
523
|
+
name
|
|
524
|
+
}
|
|
525
|
+
created_at
|
|
526
|
+
updated_at
|
|
527
|
+
linked_expenses @include(if: $includeExpenses) {
|
|
528
|
+
...ExpenseFields
|
|
529
|
+
}
|
|
530
|
+
event_attendees @include(if: $includeAttendees) {
|
|
531
|
+
...AttendanceFields
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
fragment ExpenseFields on eetschema_expense {
|
|
536
|
+
id
|
|
537
|
+
event_id
|
|
538
|
+
settled_id
|
|
539
|
+
description
|
|
540
|
+
payed_amount
|
|
541
|
+
deleted
|
|
542
|
+
settlement_expense_id
|
|
543
|
+
expense_distributions {
|
|
544
|
+
id
|
|
545
|
+
count
|
|
546
|
+
payed_amount
|
|
547
|
+
user {
|
|
548
|
+
id
|
|
549
|
+
name
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
payed_at
|
|
553
|
+
payed_by: payed_by_user {
|
|
554
|
+
id
|
|
555
|
+
name
|
|
556
|
+
}
|
|
557
|
+
updated_at
|
|
558
|
+
updated_by: updatedByUser {
|
|
559
|
+
id
|
|
560
|
+
name
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
""")
|
|
564
|
+
variables: dict[str, object] = {
|
|
565
|
+
"eventId": event_id,
|
|
566
|
+
"includeAttendees": include_attendees,
|
|
567
|
+
"includeExpenses": include_expenses,
|
|
568
|
+
}
|
|
569
|
+
response = await self.execute(
|
|
570
|
+
query=query, operation_name="GetEvent", variables=variables, **kwargs
|
|
571
|
+
)
|
|
572
|
+
data = self.get_data(response)
|
|
573
|
+
return GetEvent.model_validate(data)
|
|
574
|
+
|
|
575
|
+
async def create_expense(
|
|
576
|
+
self,
|
|
577
|
+
group_id: str,
|
|
578
|
+
payed_by: str,
|
|
579
|
+
data: list[eetschema_expense_distribution_insert_input],
|
|
580
|
+
description: str,
|
|
581
|
+
payed_amount: int,
|
|
582
|
+
payed_at: datetime,
|
|
583
|
+
event_id: Union[Optional[str], UnsetType] = UNSET,
|
|
584
|
+
settlement_expense_id: Union[Optional[str], UnsetType] = UNSET,
|
|
585
|
+
**kwargs: Any,
|
|
586
|
+
) -> CreateExpense:
|
|
587
|
+
query = gql("""
|
|
588
|
+
mutation CreateExpense($groupId: uuid!, $payedBy: String!, $data: [eetschema_expense_distribution_insert_input!]!, $description: String!, $payedAmount: Int!, $payedAt: timestamptz!, $eventId: uuid, $settlementExpenseId: uuid) {
|
|
589
|
+
insert_eetschema_expense_one(
|
|
590
|
+
object: {description: $description, expense_distributions: {data: $data}, group_id: $groupId, payed_by: $payedBy, payed_amount: $payedAmount, event_id: $eventId, settlement_expense_id: $settlementExpenseId, payed_at: $payedAt}
|
|
591
|
+
) {
|
|
592
|
+
...ExpenseFields
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
fragment ExpenseFields on eetschema_expense {
|
|
597
|
+
id
|
|
598
|
+
event_id
|
|
599
|
+
settled_id
|
|
600
|
+
description
|
|
601
|
+
payed_amount
|
|
602
|
+
deleted
|
|
603
|
+
settlement_expense_id
|
|
604
|
+
expense_distributions {
|
|
605
|
+
id
|
|
606
|
+
count
|
|
607
|
+
payed_amount
|
|
608
|
+
user {
|
|
609
|
+
id
|
|
610
|
+
name
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
payed_at
|
|
614
|
+
payed_by: payed_by_user {
|
|
615
|
+
id
|
|
616
|
+
name
|
|
617
|
+
}
|
|
618
|
+
updated_at
|
|
619
|
+
updated_by: updatedByUser {
|
|
620
|
+
id
|
|
621
|
+
name
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
""")
|
|
625
|
+
variables: dict[str, object] = {
|
|
626
|
+
"groupId": group_id,
|
|
627
|
+
"payedBy": payed_by,
|
|
628
|
+
"data": data,
|
|
629
|
+
"description": description,
|
|
630
|
+
"payedAmount": payed_amount,
|
|
631
|
+
"payedAt": payed_at,
|
|
632
|
+
"eventId": event_id,
|
|
633
|
+
"settlementExpenseId": settlement_expense_id,
|
|
634
|
+
}
|
|
635
|
+
response = await self.execute(
|
|
636
|
+
query=query, operation_name="CreateExpense", variables=variables, **kwargs
|
|
637
|
+
)
|
|
638
|
+
_data = self.get_data(response)
|
|
639
|
+
return CreateExpense.model_validate(_data)
|
|
640
|
+
|
|
641
|
+
async def update_expense(
|
|
642
|
+
self, expense_id: str, set_: eetschema_expense_set_input, **kwargs: Any
|
|
643
|
+
) -> UpdateExpense:
|
|
644
|
+
query = gql("""
|
|
645
|
+
mutation UpdateExpense($expenseId: uuid!, $_set: eetschema_expense_set_input!) {
|
|
646
|
+
update_eetschema_expense(where: {id: {_eq: $expenseId}}, _set: $_set) {
|
|
647
|
+
returning {
|
|
648
|
+
...ExpenseFields
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
fragment ExpenseFields on eetschema_expense {
|
|
654
|
+
id
|
|
655
|
+
event_id
|
|
656
|
+
settled_id
|
|
657
|
+
description
|
|
658
|
+
payed_amount
|
|
659
|
+
deleted
|
|
660
|
+
settlement_expense_id
|
|
661
|
+
expense_distributions {
|
|
662
|
+
id
|
|
663
|
+
count
|
|
664
|
+
payed_amount
|
|
665
|
+
user {
|
|
666
|
+
id
|
|
667
|
+
name
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
payed_at
|
|
671
|
+
payed_by: payed_by_user {
|
|
672
|
+
id
|
|
673
|
+
name
|
|
674
|
+
}
|
|
675
|
+
updated_at
|
|
676
|
+
updated_by: updatedByUser {
|
|
677
|
+
id
|
|
678
|
+
name
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
""")
|
|
682
|
+
variables: dict[str, object] = {"expenseId": expense_id, "_set": set_}
|
|
683
|
+
response = await self.execute(
|
|
684
|
+
query=query, operation_name="UpdateExpense", variables=variables, **kwargs
|
|
685
|
+
)
|
|
686
|
+
data = self.get_data(response)
|
|
687
|
+
return UpdateExpense.model_validate(data)
|
|
688
|
+
|
|
689
|
+
async def update_expense_distribution(
|
|
690
|
+
self,
|
|
691
|
+
expense_id: str,
|
|
692
|
+
objects: list[eetschema_expense_distribution_insert_input],
|
|
693
|
+
**kwargs: Any,
|
|
694
|
+
) -> UpdateExpenseDistribution:
|
|
695
|
+
query = gql("""
|
|
696
|
+
mutation UpdateExpenseDistribution($expenseId: uuid!, $objects: [eetschema_expense_distribution_insert_input!]!) {
|
|
697
|
+
delete_eetschema_expense_distribution(where: {expense_id: {_eq: $expenseId}}) {
|
|
698
|
+
affected_rows
|
|
699
|
+
}
|
|
700
|
+
insert_eetschema_expense_distribution(objects: $objects) {
|
|
701
|
+
affected_rows
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
""")
|
|
705
|
+
variables: dict[str, object] = {"expenseId": expense_id, "objects": objects}
|
|
706
|
+
response = await self.execute(
|
|
707
|
+
query=query,
|
|
708
|
+
operation_name="UpdateExpenseDistribution",
|
|
709
|
+
variables=variables,
|
|
710
|
+
**kwargs,
|
|
711
|
+
)
|
|
712
|
+
data = self.get_data(response)
|
|
713
|
+
return UpdateExpenseDistribution.model_validate(data)
|
|
714
|
+
|
|
715
|
+
async def all_expenses(
|
|
716
|
+
self,
|
|
717
|
+
where: Union[Optional[eetschema_expense_bool_exp], UnsetType] = UNSET,
|
|
718
|
+
order: Union[Optional[list[eetschema_expense_order_by]], UnsetType] = UNSET,
|
|
719
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
720
|
+
**kwargs: Any,
|
|
721
|
+
) -> AllExpenses:
|
|
722
|
+
query = gql("""
|
|
723
|
+
query AllExpenses($where: eetschema_expense_bool_exp, $order: [eetschema_expense_order_by!], $limit: Int) {
|
|
724
|
+
eetschema_expense(where: $where, order_by: $order, limit: $limit) {
|
|
725
|
+
...ExpenseFields
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
fragment ExpenseFields on eetschema_expense {
|
|
730
|
+
id
|
|
731
|
+
event_id
|
|
732
|
+
settled_id
|
|
733
|
+
description
|
|
734
|
+
payed_amount
|
|
735
|
+
deleted
|
|
736
|
+
settlement_expense_id
|
|
737
|
+
expense_distributions {
|
|
738
|
+
id
|
|
739
|
+
count
|
|
740
|
+
payed_amount
|
|
741
|
+
user {
|
|
742
|
+
id
|
|
743
|
+
name
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
payed_at
|
|
747
|
+
payed_by: payed_by_user {
|
|
748
|
+
id
|
|
749
|
+
name
|
|
750
|
+
}
|
|
751
|
+
updated_at
|
|
752
|
+
updated_by: updatedByUser {
|
|
753
|
+
id
|
|
754
|
+
name
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
""")
|
|
758
|
+
variables: dict[str, object] = {"where": where, "order": order, "limit": limit}
|
|
759
|
+
response = await self.execute(
|
|
760
|
+
query=query, operation_name="AllExpenses", variables=variables, **kwargs
|
|
761
|
+
)
|
|
762
|
+
data = self.get_data(response)
|
|
763
|
+
return AllExpenses.model_validate(data)
|
|
764
|
+
|
|
765
|
+
async def group_total_expense(
|
|
766
|
+
self, group_id: Union[Optional[str], UnsetType] = UNSET, **kwargs: Any
|
|
767
|
+
) -> GroupTotalExpense:
|
|
768
|
+
query = gql("""
|
|
769
|
+
query GroupTotalExpense($groupId: uuid) {
|
|
770
|
+
eetschema_expense_aggregate(
|
|
771
|
+
where: {group_id: {_eq: $groupId}, deleted: {_eq: false}}
|
|
772
|
+
) {
|
|
773
|
+
aggregate {
|
|
774
|
+
sum {
|
|
775
|
+
payed_amount
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
eetschema_expense_eetlijst_import_aggregate(where: {group_id: {_eq: $groupId}}) {
|
|
780
|
+
aggregate {
|
|
781
|
+
sum {
|
|
782
|
+
payed_amount
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
""")
|
|
788
|
+
variables: dict[str, object] = {"groupId": group_id}
|
|
789
|
+
response = await self.execute(
|
|
790
|
+
query=query,
|
|
791
|
+
operation_name="GroupTotalExpense",
|
|
792
|
+
variables=variables,
|
|
793
|
+
**kwargs,
|
|
794
|
+
)
|
|
795
|
+
data = self.get_data(response)
|
|
796
|
+
return GroupTotalExpense.model_validate(data)
|
|
797
|
+
|
|
798
|
+
async def create_many_list_items(
|
|
799
|
+
self, items: list[eetschema_list_insert_input], **kwargs: Any
|
|
800
|
+
) -> CreateManyListItems:
|
|
801
|
+
query = gql("""
|
|
802
|
+
mutation CreateManyListItems($items: [eetschema_list_insert_input!]!) {
|
|
803
|
+
insert_eetschema_list(objects: $items) {
|
|
804
|
+
returning {
|
|
805
|
+
...ItemFields
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
fragment ItemFields on eetschema_list {
|
|
811
|
+
active
|
|
812
|
+
checked
|
|
813
|
+
group_id
|
|
814
|
+
id
|
|
815
|
+
text
|
|
816
|
+
recipe_id
|
|
817
|
+
created_at
|
|
818
|
+
updated_at
|
|
819
|
+
}
|
|
820
|
+
""")
|
|
821
|
+
variables: dict[str, object] = {"items": items}
|
|
822
|
+
response = await self.execute(
|
|
823
|
+
query=query,
|
|
824
|
+
operation_name="CreateManyListItems",
|
|
825
|
+
variables=variables,
|
|
826
|
+
**kwargs,
|
|
827
|
+
)
|
|
828
|
+
data = self.get_data(response)
|
|
829
|
+
return CreateManyListItems.model_validate(data)
|
|
830
|
+
|
|
831
|
+
async def create_list_item(
|
|
832
|
+
self,
|
|
833
|
+
group_id: str,
|
|
834
|
+
text: str,
|
|
835
|
+
active: Union[Optional[bool], UnsetType] = UNSET,
|
|
836
|
+
checked: Union[Optional[bool], UnsetType] = UNSET,
|
|
837
|
+
recipe_id: Union[Optional[str], UnsetType] = UNSET,
|
|
838
|
+
**kwargs: Any,
|
|
839
|
+
) -> CreateListItem:
|
|
840
|
+
query = gql("""
|
|
841
|
+
mutation CreateListItem($groupId: uuid!, $text: String!, $active: Boolean = true, $checked: Boolean = false, $recipeId: uuid) {
|
|
842
|
+
insert_eetschema_list_one(
|
|
843
|
+
object: {group_id: $groupId, text: $text, active: $active, checked: $checked, recipe_id: $recipeId}
|
|
844
|
+
) {
|
|
845
|
+
...ItemFields
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
fragment ItemFields on eetschema_list {
|
|
850
|
+
active
|
|
851
|
+
checked
|
|
852
|
+
group_id
|
|
853
|
+
id
|
|
854
|
+
text
|
|
855
|
+
recipe_id
|
|
856
|
+
created_at
|
|
857
|
+
updated_at
|
|
858
|
+
}
|
|
859
|
+
""")
|
|
860
|
+
variables: dict[str, object] = {
|
|
861
|
+
"groupId": group_id,
|
|
862
|
+
"text": text,
|
|
863
|
+
"active": active,
|
|
864
|
+
"checked": checked,
|
|
865
|
+
"recipeId": recipe_id,
|
|
866
|
+
}
|
|
867
|
+
response = await self.execute(
|
|
868
|
+
query=query, operation_name="CreateListItem", variables=variables, **kwargs
|
|
869
|
+
)
|
|
870
|
+
data = self.get_data(response)
|
|
871
|
+
return CreateListItem.model_validate(data)
|
|
872
|
+
|
|
873
|
+
async def update_list_item(
|
|
874
|
+
self, id: str, set_: eetschema_list_set_input, **kwargs: Any
|
|
875
|
+
) -> UpdateListItem:
|
|
876
|
+
query = gql("""
|
|
877
|
+
mutation UpdateListItem($id: uuid!, $_set: eetschema_list_set_input!) {
|
|
878
|
+
update_eetschema_list_by_pk(pk_columns: {id: $id}, _set: $_set) {
|
|
879
|
+
...ItemFields
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
fragment ItemFields on eetschema_list {
|
|
884
|
+
active
|
|
885
|
+
checked
|
|
886
|
+
group_id
|
|
887
|
+
id
|
|
888
|
+
text
|
|
889
|
+
recipe_id
|
|
890
|
+
created_at
|
|
891
|
+
updated_at
|
|
892
|
+
}
|
|
893
|
+
""")
|
|
894
|
+
variables: dict[str, object] = {"id": id, "_set": set_}
|
|
895
|
+
response = await self.execute(
|
|
896
|
+
query=query, operation_name="UpdateListItem", variables=variables, **kwargs
|
|
897
|
+
)
|
|
898
|
+
data = self.get_data(response)
|
|
899
|
+
return UpdateListItem.model_validate(data)
|
|
900
|
+
|
|
901
|
+
async def list_items(
|
|
902
|
+
self,
|
|
903
|
+
where: Union[Optional[eetschema_list_bool_exp], UnsetType] = UNSET,
|
|
904
|
+
order: Union[Optional[list[eetschema_list_order_by]], UnsetType] = UNSET,
|
|
905
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
906
|
+
**kwargs: Any,
|
|
907
|
+
) -> ListItems:
|
|
908
|
+
query = gql("""
|
|
909
|
+
query ListItems($where: eetschema_list_bool_exp, $order: [eetschema_list_order_by!], $limit: Int) {
|
|
910
|
+
eetschema_list(where: $where, order_by: $order, limit: $limit) {
|
|
911
|
+
...ItemFields
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
fragment ItemFields on eetschema_list {
|
|
916
|
+
active
|
|
917
|
+
checked
|
|
918
|
+
group_id
|
|
919
|
+
id
|
|
920
|
+
text
|
|
921
|
+
recipe_id
|
|
922
|
+
created_at
|
|
923
|
+
updated_at
|
|
924
|
+
}
|
|
925
|
+
""")
|
|
926
|
+
variables: dict[str, object] = {"where": where, "order": order, "limit": limit}
|
|
927
|
+
response = await self.execute(
|
|
928
|
+
query=query, operation_name="ListItems", variables=variables, **kwargs
|
|
929
|
+
)
|
|
930
|
+
data = self.get_data(response)
|
|
931
|
+
return ListItems.model_validate(data)
|
|
932
|
+
|
|
933
|
+
async def join_group(
|
|
934
|
+
self, group_id: str, user_id: str, invite_id: str, **kwargs: Any
|
|
935
|
+
) -> JoinGroup:
|
|
936
|
+
query = gql("""
|
|
937
|
+
mutation JoinGroup($groupId: uuid!, $userId: String!, $inviteId: uuid!) {
|
|
938
|
+
joinGroup(group_id: $groupId, user_id: $userId, invite_id: $inviteId) {
|
|
939
|
+
accepted
|
|
940
|
+
error
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
""")
|
|
944
|
+
variables: dict[str, object] = {
|
|
945
|
+
"groupId": group_id,
|
|
946
|
+
"userId": user_id,
|
|
947
|
+
"inviteId": invite_id,
|
|
948
|
+
}
|
|
949
|
+
response = await self.execute(
|
|
950
|
+
query=query, operation_name="JoinGroup", variables=variables, **kwargs
|
|
951
|
+
)
|
|
952
|
+
data = self.get_data(response)
|
|
953
|
+
return JoinGroup.model_validate(data)
|
|
954
|
+
|
|
955
|
+
async def update_users_in_group(
|
|
956
|
+
self, updates: list[eetschema_users_in_group_updates], **kwargs: Any
|
|
957
|
+
) -> UpdateUsersInGroup:
|
|
958
|
+
query = gql("""
|
|
959
|
+
mutation UpdateUsersInGroup($updates: [eetschema_users_in_group_updates!]!) {
|
|
960
|
+
update_eetschema_users_in_group_many(updates: $updates) {
|
|
961
|
+
number_users_in_group: affected_rows
|
|
962
|
+
users_in_group: returning {
|
|
963
|
+
...UserInGroupFields
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
fragment UserFields on eetschema_user {
|
|
969
|
+
id
|
|
970
|
+
origin
|
|
971
|
+
name
|
|
972
|
+
email
|
|
973
|
+
allergies
|
|
974
|
+
birthday
|
|
975
|
+
profile_image
|
|
976
|
+
order_of_buttom_bar
|
|
977
|
+
wants_to_recieve_notifications
|
|
978
|
+
funnel_lead
|
|
979
|
+
cook_points_imports {
|
|
980
|
+
group_id
|
|
981
|
+
cook_points
|
|
982
|
+
allowed_to_edit
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
fragment UserInGroupFields on eetschema_users_in_group {
|
|
987
|
+
active
|
|
988
|
+
order
|
|
989
|
+
start_holliday
|
|
990
|
+
end_holliday
|
|
991
|
+
monday
|
|
992
|
+
tuesday
|
|
993
|
+
wednesday
|
|
994
|
+
thursday
|
|
995
|
+
friday
|
|
996
|
+
saturday
|
|
997
|
+
sunday
|
|
998
|
+
user {
|
|
999
|
+
...UserFields
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
""")
|
|
1003
|
+
variables: dict[str, object] = {"updates": updates}
|
|
1004
|
+
response = await self.execute(
|
|
1005
|
+
query=query,
|
|
1006
|
+
operation_name="UpdateUsersInGroup",
|
|
1007
|
+
variables=variables,
|
|
1008
|
+
**kwargs,
|
|
1009
|
+
)
|
|
1010
|
+
data = self.get_data(response)
|
|
1011
|
+
return UpdateUsersInGroup.model_validate(data)
|
|
1012
|
+
|
|
1013
|
+
async def update_user_in_group(
|
|
1014
|
+
self,
|
|
1015
|
+
group_id: str,
|
|
1016
|
+
user_id: str,
|
|
1017
|
+
set_: eetschema_users_in_group_set_input,
|
|
1018
|
+
**kwargs: Any,
|
|
1019
|
+
) -> UpdateUserInGroup:
|
|
1020
|
+
query = gql("""
|
|
1021
|
+
mutation UpdateUserInGroup($groupId: uuid!, $userId: String!, $_set: eetschema_users_in_group_set_input!) {
|
|
1022
|
+
update_eetschema_users_in_group_by_pk(
|
|
1023
|
+
_set: $_set
|
|
1024
|
+
pk_columns: {group_id: $groupId, user_id: $userId}
|
|
1025
|
+
) {
|
|
1026
|
+
...UserInGroupFields
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
fragment UserFields on eetschema_user {
|
|
1031
|
+
id
|
|
1032
|
+
origin
|
|
1033
|
+
name
|
|
1034
|
+
email
|
|
1035
|
+
allergies
|
|
1036
|
+
birthday
|
|
1037
|
+
profile_image
|
|
1038
|
+
order_of_buttom_bar
|
|
1039
|
+
wants_to_recieve_notifications
|
|
1040
|
+
funnel_lead
|
|
1041
|
+
cook_points_imports {
|
|
1042
|
+
group_id
|
|
1043
|
+
cook_points
|
|
1044
|
+
allowed_to_edit
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
fragment UserInGroupFields on eetschema_users_in_group {
|
|
1049
|
+
active
|
|
1050
|
+
order
|
|
1051
|
+
start_holliday
|
|
1052
|
+
end_holliday
|
|
1053
|
+
monday
|
|
1054
|
+
tuesday
|
|
1055
|
+
wednesday
|
|
1056
|
+
thursday
|
|
1057
|
+
friday
|
|
1058
|
+
saturday
|
|
1059
|
+
sunday
|
|
1060
|
+
user {
|
|
1061
|
+
...UserFields
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
""")
|
|
1065
|
+
variables: dict[str, object] = {
|
|
1066
|
+
"groupId": group_id,
|
|
1067
|
+
"userId": user_id,
|
|
1068
|
+
"_set": set_,
|
|
1069
|
+
}
|
|
1070
|
+
response = await self.execute(
|
|
1071
|
+
query=query,
|
|
1072
|
+
operation_name="UpdateUserInGroup",
|
|
1073
|
+
variables=variables,
|
|
1074
|
+
**kwargs,
|
|
1075
|
+
)
|
|
1076
|
+
data = self.get_data(response)
|
|
1077
|
+
return UpdateUserInGroup.model_validate(data)
|
|
1078
|
+
|
|
1079
|
+
async def all_users_in_group(
|
|
1080
|
+
self,
|
|
1081
|
+
group_id: str,
|
|
1082
|
+
where: Union[Optional[eetschema_users_in_group_bool_exp], UnsetType] = UNSET,
|
|
1083
|
+
order: Union[
|
|
1084
|
+
Optional[list[eetschema_users_in_group_order_by]], UnsetType
|
|
1085
|
+
] = UNSET,
|
|
1086
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
1087
|
+
**kwargs: Any,
|
|
1088
|
+
) -> AllUsersInGroup:
|
|
1089
|
+
query = gql("""
|
|
1090
|
+
query AllUsersInGroup($groupId: uuid!, $where: eetschema_users_in_group_bool_exp, $order: [eetschema_users_in_group_order_by!], $limit: Int) {
|
|
1091
|
+
eetschema_group_by_pk(id: $groupId) {
|
|
1092
|
+
users_in_groups(where: $where, order_by: $order, limit: $limit) {
|
|
1093
|
+
...UserInGroupFields
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
fragment UserFields on eetschema_user {
|
|
1099
|
+
id
|
|
1100
|
+
origin
|
|
1101
|
+
name
|
|
1102
|
+
email
|
|
1103
|
+
allergies
|
|
1104
|
+
birthday
|
|
1105
|
+
profile_image
|
|
1106
|
+
order_of_buttom_bar
|
|
1107
|
+
wants_to_recieve_notifications
|
|
1108
|
+
funnel_lead
|
|
1109
|
+
cook_points_imports {
|
|
1110
|
+
group_id
|
|
1111
|
+
cook_points
|
|
1112
|
+
allowed_to_edit
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
fragment UserInGroupFields on eetschema_users_in_group {
|
|
1117
|
+
active
|
|
1118
|
+
order
|
|
1119
|
+
start_holliday
|
|
1120
|
+
end_holliday
|
|
1121
|
+
monday
|
|
1122
|
+
tuesday
|
|
1123
|
+
wednesday
|
|
1124
|
+
thursday
|
|
1125
|
+
friday
|
|
1126
|
+
saturday
|
|
1127
|
+
sunday
|
|
1128
|
+
user {
|
|
1129
|
+
...UserFields
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
""")
|
|
1133
|
+
variables: dict[str, object] = {
|
|
1134
|
+
"groupId": group_id,
|
|
1135
|
+
"where": where,
|
|
1136
|
+
"order": order,
|
|
1137
|
+
"limit": limit,
|
|
1138
|
+
}
|
|
1139
|
+
response = await self.execute(
|
|
1140
|
+
query=query, operation_name="AllUsersInGroup", variables=variables, **kwargs
|
|
1141
|
+
)
|
|
1142
|
+
data = self.get_data(response)
|
|
1143
|
+
return AllUsersInGroup.model_validate(data)
|
|
1144
|
+
|
|
1145
|
+
async def get_user_in_group(
|
|
1146
|
+
self, group_id: str, user_id: str, **kwargs: Any
|
|
1147
|
+
) -> GetUserInGroup:
|
|
1148
|
+
query = gql("""
|
|
1149
|
+
query GetUserInGroup($groupId: uuid!, $userId: String!) {
|
|
1150
|
+
eetschema_group_by_pk(id: $groupId) {
|
|
1151
|
+
users_in_groups(where: {user_id: {_eq: $userId}}) {
|
|
1152
|
+
...UserInGroupFields
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
fragment UserFields on eetschema_user {
|
|
1158
|
+
id
|
|
1159
|
+
origin
|
|
1160
|
+
name
|
|
1161
|
+
email
|
|
1162
|
+
allergies
|
|
1163
|
+
birthday
|
|
1164
|
+
profile_image
|
|
1165
|
+
order_of_buttom_bar
|
|
1166
|
+
wants_to_recieve_notifications
|
|
1167
|
+
funnel_lead
|
|
1168
|
+
cook_points_imports {
|
|
1169
|
+
group_id
|
|
1170
|
+
cook_points
|
|
1171
|
+
allowed_to_edit
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
fragment UserInGroupFields on eetschema_users_in_group {
|
|
1176
|
+
active
|
|
1177
|
+
order
|
|
1178
|
+
start_holliday
|
|
1179
|
+
end_holliday
|
|
1180
|
+
monday
|
|
1181
|
+
tuesday
|
|
1182
|
+
wednesday
|
|
1183
|
+
thursday
|
|
1184
|
+
friday
|
|
1185
|
+
saturday
|
|
1186
|
+
sunday
|
|
1187
|
+
user {
|
|
1188
|
+
...UserFields
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
""")
|
|
1192
|
+
variables: dict[str, object] = {"groupId": group_id, "userId": user_id}
|
|
1193
|
+
response = await self.execute(
|
|
1194
|
+
query=query, operation_name="GetUserInGroup", variables=variables, **kwargs
|
|
1195
|
+
)
|
|
1196
|
+
data = self.get_data(response)
|
|
1197
|
+
return GetUserInGroup.model_validate(data)
|
|
1198
|
+
|
|
1199
|
+
async def create_group(self, name: str, user_id: str, **kwargs: Any) -> CreateGroup:
|
|
1200
|
+
query = gql("""
|
|
1201
|
+
mutation CreateGroup($name: String!, $userId: String!) {
|
|
1202
|
+
group: insert_eetschema_group_one(
|
|
1203
|
+
object: {name: $name, users_in_groups: {data: {user_id: $userId}}}
|
|
1204
|
+
) {
|
|
1205
|
+
...GroupFields
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
fragment GroupFields on eetschema_group {
|
|
1210
|
+
id
|
|
1211
|
+
name
|
|
1212
|
+
default_close_time
|
|
1213
|
+
created_at
|
|
1214
|
+
created_at_eetlijst
|
|
1215
|
+
statistics_start_date
|
|
1216
|
+
statistics_end_date
|
|
1217
|
+
invite_uuid
|
|
1218
|
+
invite_open
|
|
1219
|
+
description
|
|
1220
|
+
summary(order_by: {payed_total: desc}) {
|
|
1221
|
+
payed_total
|
|
1222
|
+
user_id
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
""")
|
|
1226
|
+
variables: dict[str, object] = {"name": name, "userId": user_id}
|
|
1227
|
+
response = await self.execute(
|
|
1228
|
+
query=query, operation_name="CreateGroup", variables=variables, **kwargs
|
|
1229
|
+
)
|
|
1230
|
+
data = self.get_data(response)
|
|
1231
|
+
return CreateGroup.model_validate(data)
|
|
1232
|
+
|
|
1233
|
+
async def update_group(
|
|
1234
|
+
self, group_id: str, set_: eetschema_group_set_input, **kwargs: Any
|
|
1235
|
+
) -> UpdateGroup:
|
|
1236
|
+
query = gql("""
|
|
1237
|
+
mutation UpdateGroup($groupId: uuid!, $_set: eetschema_group_set_input!) {
|
|
1238
|
+
group: update_eetschema_group_by_pk(pk_columns: {id: $groupId}, _set: $_set) {
|
|
1239
|
+
...GroupFields
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
fragment GroupFields on eetschema_group {
|
|
1244
|
+
id
|
|
1245
|
+
name
|
|
1246
|
+
default_close_time
|
|
1247
|
+
created_at
|
|
1248
|
+
created_at_eetlijst
|
|
1249
|
+
statistics_start_date
|
|
1250
|
+
statistics_end_date
|
|
1251
|
+
invite_uuid
|
|
1252
|
+
invite_open
|
|
1253
|
+
description
|
|
1254
|
+
summary(order_by: {payed_total: desc}) {
|
|
1255
|
+
payed_total
|
|
1256
|
+
user_id
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
""")
|
|
1260
|
+
variables: dict[str, object] = {"groupId": group_id, "_set": set_}
|
|
1261
|
+
response = await self.execute(
|
|
1262
|
+
query=query, operation_name="UpdateGroup", variables=variables, **kwargs
|
|
1263
|
+
)
|
|
1264
|
+
data = self.get_data(response)
|
|
1265
|
+
return UpdateGroup.model_validate(data)
|
|
1266
|
+
|
|
1267
|
+
async def all_groups(
|
|
1268
|
+
self,
|
|
1269
|
+
where: Union[Optional[eetschema_users_in_group_bool_exp], UnsetType] = UNSET,
|
|
1270
|
+
order: Union[
|
|
1271
|
+
Optional[list[eetschema_users_in_group_order_by]], UnsetType
|
|
1272
|
+
] = UNSET,
|
|
1273
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
1274
|
+
include_users: Union[Optional[bool], UnsetType] = UNSET,
|
|
1275
|
+
include_inactive_users: Union[Optional[bool], UnsetType] = UNSET,
|
|
1276
|
+
**kwargs: Any,
|
|
1277
|
+
) -> AllGroups:
|
|
1278
|
+
query = gql("""
|
|
1279
|
+
query AllGroups($where: eetschema_users_in_group_bool_exp, $order: [eetschema_users_in_group_order_by!], $limit: Int, $includeUsers: Boolean = false, $includeInactiveUsers: Boolean = false) {
|
|
1280
|
+
eetschema_users_in_group(where: $where, order_by: $order, limit: $limit) {
|
|
1281
|
+
group {
|
|
1282
|
+
...GroupFields
|
|
1283
|
+
users_in_groups(
|
|
1284
|
+
where: {_or: [{active: {_eq: true}}, {active: {_neq: $includeInactiveUsers}}]}
|
|
1285
|
+
order_by: {order: asc}
|
|
1286
|
+
) @include(if: $includeUsers) {
|
|
1287
|
+
...UserInGroupFields
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
fragment GroupFields on eetschema_group {
|
|
1294
|
+
id
|
|
1295
|
+
name
|
|
1296
|
+
default_close_time
|
|
1297
|
+
created_at
|
|
1298
|
+
created_at_eetlijst
|
|
1299
|
+
statistics_start_date
|
|
1300
|
+
statistics_end_date
|
|
1301
|
+
invite_uuid
|
|
1302
|
+
invite_open
|
|
1303
|
+
description
|
|
1304
|
+
summary(order_by: {payed_total: desc}) {
|
|
1305
|
+
payed_total
|
|
1306
|
+
user_id
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
fragment UserFields on eetschema_user {
|
|
1311
|
+
id
|
|
1312
|
+
origin
|
|
1313
|
+
name
|
|
1314
|
+
email
|
|
1315
|
+
allergies
|
|
1316
|
+
birthday
|
|
1317
|
+
profile_image
|
|
1318
|
+
order_of_buttom_bar
|
|
1319
|
+
wants_to_recieve_notifications
|
|
1320
|
+
funnel_lead
|
|
1321
|
+
cook_points_imports {
|
|
1322
|
+
group_id
|
|
1323
|
+
cook_points
|
|
1324
|
+
allowed_to_edit
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
fragment UserInGroupFields on eetschema_users_in_group {
|
|
1329
|
+
active
|
|
1330
|
+
order
|
|
1331
|
+
start_holliday
|
|
1332
|
+
end_holliday
|
|
1333
|
+
monday
|
|
1334
|
+
tuesday
|
|
1335
|
+
wednesday
|
|
1336
|
+
thursday
|
|
1337
|
+
friday
|
|
1338
|
+
saturday
|
|
1339
|
+
sunday
|
|
1340
|
+
user {
|
|
1341
|
+
...UserFields
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
""")
|
|
1345
|
+
variables: dict[str, object] = {
|
|
1346
|
+
"where": where,
|
|
1347
|
+
"order": order,
|
|
1348
|
+
"limit": limit,
|
|
1349
|
+
"includeUsers": include_users,
|
|
1350
|
+
"includeInactiveUsers": include_inactive_users,
|
|
1351
|
+
}
|
|
1352
|
+
response = await self.execute(
|
|
1353
|
+
query=query, operation_name="AllGroups", variables=variables, **kwargs
|
|
1354
|
+
)
|
|
1355
|
+
data = self.get_data(response)
|
|
1356
|
+
return AllGroups.model_validate(data)
|
|
1357
|
+
|
|
1358
|
+
async def get_group(
|
|
1359
|
+
self,
|
|
1360
|
+
group_id: str,
|
|
1361
|
+
include_users: Union[Optional[bool], UnsetType] = UNSET,
|
|
1362
|
+
include_inactive_users: Union[Optional[bool], UnsetType] = UNSET,
|
|
1363
|
+
**kwargs: Any,
|
|
1364
|
+
) -> GetGroup:
|
|
1365
|
+
query = gql("""
|
|
1366
|
+
query GetGroup($groupId: uuid!, $includeUsers: Boolean = false, $includeInactiveUsers: Boolean = false) {
|
|
1367
|
+
eetschema_group_by_pk(id: $groupId) {
|
|
1368
|
+
...GroupFields
|
|
1369
|
+
users_in_groups(
|
|
1370
|
+
where: {_or: [{active: {_eq: true}}, {active: {_neq: $includeInactiveUsers}}]}
|
|
1371
|
+
order_by: {order: asc}
|
|
1372
|
+
) @include(if: $includeUsers) {
|
|
1373
|
+
...UserInGroupFields
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
fragment GroupFields on eetschema_group {
|
|
1379
|
+
id
|
|
1380
|
+
name
|
|
1381
|
+
default_close_time
|
|
1382
|
+
created_at
|
|
1383
|
+
created_at_eetlijst
|
|
1384
|
+
statistics_start_date
|
|
1385
|
+
statistics_end_date
|
|
1386
|
+
invite_uuid
|
|
1387
|
+
invite_open
|
|
1388
|
+
description
|
|
1389
|
+
summary(order_by: {payed_total: desc}) {
|
|
1390
|
+
payed_total
|
|
1391
|
+
user_id
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
fragment UserFields on eetschema_user {
|
|
1396
|
+
id
|
|
1397
|
+
origin
|
|
1398
|
+
name
|
|
1399
|
+
email
|
|
1400
|
+
allergies
|
|
1401
|
+
birthday
|
|
1402
|
+
profile_image
|
|
1403
|
+
order_of_buttom_bar
|
|
1404
|
+
wants_to_recieve_notifications
|
|
1405
|
+
funnel_lead
|
|
1406
|
+
cook_points_imports {
|
|
1407
|
+
group_id
|
|
1408
|
+
cook_points
|
|
1409
|
+
allowed_to_edit
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
fragment UserInGroupFields on eetschema_users_in_group {
|
|
1414
|
+
active
|
|
1415
|
+
order
|
|
1416
|
+
start_holliday
|
|
1417
|
+
end_holliday
|
|
1418
|
+
monday
|
|
1419
|
+
tuesday
|
|
1420
|
+
wednesday
|
|
1421
|
+
thursday
|
|
1422
|
+
friday
|
|
1423
|
+
saturday
|
|
1424
|
+
sunday
|
|
1425
|
+
user {
|
|
1426
|
+
...UserFields
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
""")
|
|
1430
|
+
variables: dict[str, object] = {
|
|
1431
|
+
"groupId": group_id,
|
|
1432
|
+
"includeUsers": include_users,
|
|
1433
|
+
"includeInactiveUsers": include_inactive_users,
|
|
1434
|
+
}
|
|
1435
|
+
response = await self.execute(
|
|
1436
|
+
query=query, operation_name="GetGroup", variables=variables, **kwargs
|
|
1437
|
+
)
|
|
1438
|
+
data = self.get_data(response)
|
|
1439
|
+
return GetGroup.model_validate(data)
|
|
1440
|
+
|
|
1441
|
+
async def create_settlement(self, group_id: str, **kwargs: Any) -> CreateSettlement:
|
|
1442
|
+
query = gql("""
|
|
1443
|
+
mutation CreateSettlement($groupId: uuid!) {
|
|
1444
|
+
settlement: insert_eetschema_settlements_one(object: {group_id: $groupId}) {
|
|
1445
|
+
...SettlementFields
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
fragment SettlementFields on eetschema_settlements {
|
|
1450
|
+
id
|
|
1451
|
+
group_id
|
|
1452
|
+
created_at
|
|
1453
|
+
updated_at
|
|
1454
|
+
created_by: user {
|
|
1455
|
+
id
|
|
1456
|
+
name
|
|
1457
|
+
}
|
|
1458
|
+
expenses_total: expenses_aggregate(
|
|
1459
|
+
where: {settlement_expense_id: {_is_null: true}}
|
|
1460
|
+
) {
|
|
1461
|
+
aggregate {
|
|
1462
|
+
sum {
|
|
1463
|
+
payed_amount
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
adjustments_total: expenses_aggregate(
|
|
1468
|
+
where: {settlement_expense_id: {_is_null: false}}
|
|
1469
|
+
) {
|
|
1470
|
+
aggregate {
|
|
1471
|
+
sum {
|
|
1472
|
+
payed_amount
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
""")
|
|
1478
|
+
variables: dict[str, object] = {"groupId": group_id}
|
|
1479
|
+
response = await self.execute(
|
|
1480
|
+
query=query,
|
|
1481
|
+
operation_name="CreateSettlement",
|
|
1482
|
+
variables=variables,
|
|
1483
|
+
**kwargs,
|
|
1484
|
+
)
|
|
1485
|
+
data = self.get_data(response)
|
|
1486
|
+
return CreateSettlement.model_validate(data)
|
|
1487
|
+
|
|
1488
|
+
async def settle_unsettled_expenses(
|
|
1489
|
+
self, settlement_id: str, where: eetschema_expense_bool_exp, **kwargs: Any
|
|
1490
|
+
) -> SettleUnsettledExpenses:
|
|
1491
|
+
query = gql("""
|
|
1492
|
+
mutation SettleUnsettledExpenses($settlementId: uuid!, $where: eetschema_expense_bool_exp!) {
|
|
1493
|
+
update_eetschema_expense(where: $where, _set: {settled_id: $settlementId}) {
|
|
1494
|
+
number_expenses: affected_rows
|
|
1495
|
+
expenses: returning {
|
|
1496
|
+
...ExpenseFields
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
fragment ExpenseFields on eetschema_expense {
|
|
1502
|
+
id
|
|
1503
|
+
event_id
|
|
1504
|
+
settled_id
|
|
1505
|
+
description
|
|
1506
|
+
payed_amount
|
|
1507
|
+
deleted
|
|
1508
|
+
settlement_expense_id
|
|
1509
|
+
expense_distributions {
|
|
1510
|
+
id
|
|
1511
|
+
count
|
|
1512
|
+
payed_amount
|
|
1513
|
+
user {
|
|
1514
|
+
id
|
|
1515
|
+
name
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
payed_at
|
|
1519
|
+
payed_by: payed_by_user {
|
|
1520
|
+
id
|
|
1521
|
+
name
|
|
1522
|
+
}
|
|
1523
|
+
updated_at
|
|
1524
|
+
updated_by: updatedByUser {
|
|
1525
|
+
id
|
|
1526
|
+
name
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
""")
|
|
1530
|
+
variables: dict[str, object] = {"settlementId": settlement_id, "where": where}
|
|
1531
|
+
response = await self.execute(
|
|
1532
|
+
query=query,
|
|
1533
|
+
operation_name="SettleUnsettledExpenses",
|
|
1534
|
+
variables=variables,
|
|
1535
|
+
**kwargs,
|
|
1536
|
+
)
|
|
1537
|
+
data = self.get_data(response)
|
|
1538
|
+
return SettleUnsettledExpenses.model_validate(data)
|
|
1539
|
+
|
|
1540
|
+
async def all_settlements(
|
|
1541
|
+
self,
|
|
1542
|
+
where: Union[Optional[eetschema_settlements_bool_exp], UnsetType] = UNSET,
|
|
1543
|
+
order: Union[Optional[list[eetschema_settlements_order_by]], UnsetType] = UNSET,
|
|
1544
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
1545
|
+
**kwargs: Any,
|
|
1546
|
+
) -> AllSettlements:
|
|
1547
|
+
query = gql("""
|
|
1548
|
+
query AllSettlements($where: eetschema_settlements_bool_exp, $order: [eetschema_settlements_order_by!], $limit: Int) {
|
|
1549
|
+
eetschema_settlements(where: $where, order_by: $order, limit: $limit) {
|
|
1550
|
+
...SettlementFields
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
fragment SettlementFields on eetschema_settlements {
|
|
1555
|
+
id
|
|
1556
|
+
group_id
|
|
1557
|
+
created_at
|
|
1558
|
+
updated_at
|
|
1559
|
+
created_by: user {
|
|
1560
|
+
id
|
|
1561
|
+
name
|
|
1562
|
+
}
|
|
1563
|
+
expenses_total: expenses_aggregate(
|
|
1564
|
+
where: {settlement_expense_id: {_is_null: true}}
|
|
1565
|
+
) {
|
|
1566
|
+
aggregate {
|
|
1567
|
+
sum {
|
|
1568
|
+
payed_amount
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
adjustments_total: expenses_aggregate(
|
|
1573
|
+
where: {settlement_expense_id: {_is_null: false}}
|
|
1574
|
+
) {
|
|
1575
|
+
aggregate {
|
|
1576
|
+
sum {
|
|
1577
|
+
payed_amount
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
""")
|
|
1583
|
+
variables: dict[str, object] = {"where": where, "order": order, "limit": limit}
|
|
1584
|
+
response = await self.execute(
|
|
1585
|
+
query=query, operation_name="AllSettlements", variables=variables, **kwargs
|
|
1586
|
+
)
|
|
1587
|
+
data = self.get_data(response)
|
|
1588
|
+
return AllSettlements.model_validate(data)
|
|
1589
|
+
|
|
1590
|
+
async def settlement_expenses(
|
|
1591
|
+
self,
|
|
1592
|
+
where: Union[Optional[eetschema_expense_bool_exp], UnsetType] = UNSET,
|
|
1593
|
+
order: Union[Optional[list[eetschema_expense_order_by]], UnsetType] = UNSET,
|
|
1594
|
+
limit: Union[Optional[int], UnsetType] = UNSET,
|
|
1595
|
+
**kwargs: Any,
|
|
1596
|
+
) -> SettlementExpenses:
|
|
1597
|
+
query = gql("""
|
|
1598
|
+
query SettlementExpenses($where: eetschema_expense_bool_exp, $order: [eetschema_expense_order_by!], $limit: Int) {
|
|
1599
|
+
eetschema_expense(where: $where, order_by: $order, limit: $limit) {
|
|
1600
|
+
...ExpenseFields
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
fragment ExpenseFields on eetschema_expense {
|
|
1605
|
+
id
|
|
1606
|
+
event_id
|
|
1607
|
+
settled_id
|
|
1608
|
+
description
|
|
1609
|
+
payed_amount
|
|
1610
|
+
deleted
|
|
1611
|
+
settlement_expense_id
|
|
1612
|
+
expense_distributions {
|
|
1613
|
+
id
|
|
1614
|
+
count
|
|
1615
|
+
payed_amount
|
|
1616
|
+
user {
|
|
1617
|
+
id
|
|
1618
|
+
name
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
payed_at
|
|
1622
|
+
payed_by: payed_by_user {
|
|
1623
|
+
id
|
|
1624
|
+
name
|
|
1625
|
+
}
|
|
1626
|
+
updated_at
|
|
1627
|
+
updated_by: updatedByUser {
|
|
1628
|
+
id
|
|
1629
|
+
name
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
""")
|
|
1633
|
+
variables: dict[str, object] = {"where": where, "order": order, "limit": limit}
|
|
1634
|
+
response = await self.execute(
|
|
1635
|
+
query=query,
|
|
1636
|
+
operation_name="SettlementExpenses",
|
|
1637
|
+
variables=variables,
|
|
1638
|
+
**kwargs,
|
|
1639
|
+
)
|
|
1640
|
+
data = self.get_data(response)
|
|
1641
|
+
return SettlementExpenses.model_validate(data)
|
|
1642
|
+
|
|
1643
|
+
async def remove_account(
|
|
1644
|
+
self,
|
|
1645
|
+
user_id: str,
|
|
1646
|
+
reason_to_remove_account_text: str,
|
|
1647
|
+
reason_to_remove_account_selection: Union[
|
|
1648
|
+
Optional[list[str]], UnsetType
|
|
1649
|
+
] = UNSET,
|
|
1650
|
+
reason_to_remove_account_selection_all_options: Union[
|
|
1651
|
+
Optional[list[str]], UnsetType
|
|
1652
|
+
] = UNSET,
|
|
1653
|
+
**kwargs: Any,
|
|
1654
|
+
) -> RemoveAccount:
|
|
1655
|
+
query = gql("""
|
|
1656
|
+
mutation RemoveAccount($user_id: String!, $reason_to_remove_account_selection: [String!] = "", $reason_to_remove_account_selection_all_options: [String!] = "", $reason_to_remove_account_text: String! = "") {
|
|
1657
|
+
update_eetschema_user_by_pk(
|
|
1658
|
+
pk_columns: {id: $user_id}
|
|
1659
|
+
_set: {reason_to_remove_account_selection: $reason_to_remove_account_selection, reason_to_remove_account_selection_all_options: $reason_to_remove_account_selection_all_options, reason_to_remove_account_text: $reason_to_remove_account_text}
|
|
1660
|
+
) {
|
|
1661
|
+
reason_to_remove_account_text
|
|
1662
|
+
reason_to_remove_account_selection
|
|
1663
|
+
reason_to_remove_account_selection_all_options
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
""")
|
|
1667
|
+
variables: dict[str, object] = {
|
|
1668
|
+
"user_id": user_id,
|
|
1669
|
+
"reason_to_remove_account_selection": reason_to_remove_account_selection,
|
|
1670
|
+
"reason_to_remove_account_selection_all_options": reason_to_remove_account_selection_all_options,
|
|
1671
|
+
"reason_to_remove_account_text": reason_to_remove_account_text,
|
|
1672
|
+
}
|
|
1673
|
+
response = await self.execute(
|
|
1674
|
+
query=query, operation_name="RemoveAccount", variables=variables, **kwargs
|
|
1675
|
+
)
|
|
1676
|
+
data = self.get_data(response)
|
|
1677
|
+
return RemoveAccount.model_validate(data)
|
|
1678
|
+
|
|
1679
|
+
async def update_user(
|
|
1680
|
+
self, user_id: str, set_: eetschema_user_set_input, **kwargs: Any
|
|
1681
|
+
) -> UpdateUser:
|
|
1682
|
+
query = gql("""
|
|
1683
|
+
mutation UpdateUser($userId: String!, $_set: eetschema_user_set_input!) {
|
|
1684
|
+
update_eetschema_user_by_pk(pk_columns: {id: $userId}, _set: $_set) {
|
|
1685
|
+
...UserFields
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
fragment UserFields on eetschema_user {
|
|
1690
|
+
id
|
|
1691
|
+
origin
|
|
1692
|
+
name
|
|
1693
|
+
email
|
|
1694
|
+
allergies
|
|
1695
|
+
birthday
|
|
1696
|
+
profile_image
|
|
1697
|
+
order_of_buttom_bar
|
|
1698
|
+
wants_to_recieve_notifications
|
|
1699
|
+
funnel_lead
|
|
1700
|
+
cook_points_imports {
|
|
1701
|
+
group_id
|
|
1702
|
+
cook_points
|
|
1703
|
+
allowed_to_edit
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
""")
|
|
1707
|
+
variables: dict[str, object] = {"userId": user_id, "_set": set_}
|
|
1708
|
+
response = await self.execute(
|
|
1709
|
+
query=query, operation_name="UpdateUser", variables=variables, **kwargs
|
|
1710
|
+
)
|
|
1711
|
+
data = self.get_data(response)
|
|
1712
|
+
return UpdateUser.model_validate(data)
|
|
1713
|
+
|
|
1714
|
+
async def get_user(self, user_id: str, **kwargs: Any) -> GetUser:
|
|
1715
|
+
query = gql("""
|
|
1716
|
+
query GetUser($userId: String!) {
|
|
1717
|
+
eetschema_user_private(where: {id: {_eq: $userId}}) {
|
|
1718
|
+
...UserFieldsPrivate
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
fragment UserFieldsPrivate on eetschema_user_private {
|
|
1723
|
+
id
|
|
1724
|
+
active
|
|
1725
|
+
origin
|
|
1726
|
+
last_seen
|
|
1727
|
+
name
|
|
1728
|
+
email
|
|
1729
|
+
address
|
|
1730
|
+
phone_nr
|
|
1731
|
+
bank_account
|
|
1732
|
+
allergies
|
|
1733
|
+
birthday
|
|
1734
|
+
profile_image
|
|
1735
|
+
order_of_buttom_bar
|
|
1736
|
+
default_landingpage
|
|
1737
|
+
wants_to_recieve_notifications
|
|
1738
|
+
is_color_blind
|
|
1739
|
+
created_at
|
|
1740
|
+
updated_at
|
|
1741
|
+
}
|
|
1742
|
+
""")
|
|
1743
|
+
variables: dict[str, object] = {"userId": user_id}
|
|
1744
|
+
response = await self.execute(
|
|
1745
|
+
query=query, operation_name="GetUser", variables=variables, **kwargs
|
|
1746
|
+
)
|
|
1747
|
+
data = self.get_data(response)
|
|
1748
|
+
return GetUser.model_validate(data)
|