-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.py
56 lines (52 loc) · 1.41 KB
/
query.py
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
45
46
47
48
49
50
51
52
53
54
55
56
import json
transaction_metadata = """
adds
consenter_ids
created
creator
drops
league_id
leg
metadata
roster_ids
settings
status
status_updated
transaction_id
draft_picks
type
player_map
waiver_budget
]
]
"""
draft_metadata = """
draft_id
pick_no
player_id
picked_by
is_keeper
metadata
]
]
"""
def update_draft(operation, player, draft, slot, value):
query_line = f"mutation {operation} [\n {operation}(sport: \"nfl\", player_id: \"{player}\", draft_id: \"{draft}\", slot: {slot}, amount: {value['Keeper Value']}, is_keeper: true)["
query_line = query_line + draft_metadata
query_line = query_line.replace("[","{")
query_line = query_line.replace("]","}")
return json.dumps({
'operationName': operation,
'variables': {},
'query': query_line
})
def transaction_check(operation, league, player):
query_line = f'query {operation} [\n {operation}(league_id: \"{league}\", player_id: \"{player}\")['
query_line = query_line + transaction_metadata
query_line = query_line.replace("[","{")
query_line = query_line.replace("]","}")
return json.dumps({
'operationName': operation,
'variables': {},
'query': query_line
})