-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreg_call.py
44 lines (32 loc) · 1.26 KB
/
reg_call.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
from gitflic import Gitflic, GitflicAuth
# Your authentication token.
# See: https://gitflic.ru/settings/oauth/token/create
token = "token_here"
# Creating authorized session with our token.
gf_session = GitflicAuth(token)
gf = Gitflic(gf_session)
def main():
print("Simple call:")
# Call method "https://api.gitflic.ru/user/me"
call = gf.call("/user/me")
print("gf.call:", call)
print("\nSimple register call:")
# Register call
gf.user_simple = gf.reg_call("/user")
# Request "https://api.gitflic.ru/user/me"
reg_user_simple = gf.user_simple(end="/me")
print("reg_user_simple:", reg_user_simple)
print("Is reg_user_simple equals call:", reg_user_simple == call)
print("\nAnother register call:")
# Another way to register
# Add at v0.11
gf.user = gf.reg_call("/user/{user}") # Supports "/user/{}" and "/user/%(user)s" and "/user/%s"
# Request "https://api.gitflic.ru/user/me"
reg_user = gf.user(user="me")
print("reg_user:", reg_user)
print("Is reg_user equals call:", reg_user == call)
# Request "https://api.gitflic.ru/user/a4189db1-3e4f-4c2e-8adf-19c58c28e61f"
author = gf.user(user="a4189db1-3e4f-4c2e-8adf-19c58c28e61f")
print("\nAuthor: ", author)
if __name__ == '__main__':
main()