-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathmappers.py
More file actions
44 lines (36 loc) · 1.59 KB
/
Copy pathmappers.py
File metadata and controls
44 lines (36 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""GraphQL payload data mappers for user operations."""
from kili.domain.user import UserFilter
from .types import CreateUserDataKiliGatewayInput, UserDataKiliGatewayInput
def user_where_mapper(filters: UserFilter) -> dict:
"""Build the GraphQL UserWhere variable to be sent in an operation."""
return {
"activated": filters.activated,
"email": filters.email,
"id": filters.id,
"idIn": filters.id_in,
"organization": {"id": filters.organization_id},
}
def create_user_data_mapper(data: CreateUserDataKiliGatewayInput) -> dict:
"""Build the CreateUserDataKiliGatewayInput data variable to be sent in an operation."""
return {
"email": data.email.lower(),
"firstname": data.firstname,
"lastname": data.lastname,
"password": data.password,
"organizationRole": data.organization_role,
}
def update_user_data_mapper(data: UserDataKiliGatewayInput) -> dict:
"""Build the UserDataKiliGatewayInput data variable to be sent in an operation."""
return {
"activated": data.activated,
"apiKey": data.api_key,
# "auth0Id": data.auth0_id, # refused by the backend: only used for service account # noqa: ERA001
"email": data.email,
"firstname": data.firstname,
"hasCompletedLabelingTour": data.has_completed_labeling_tour,
"hubspotSubscriptionStatus": data.hubspot_subscription_status,
"lastname": data.lastname,
"organization": data.organization,
"organizationId": data.organization_id,
"organizationRole": data.organization_role,
}