-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiGameNetwork.ml
98 lines (84 loc) · 3.35 KB
/
apiGameNetwork.ml
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(* ************************************************************************** *)
(* Project: Life - the game, Official OCaml SDK *)
(* Author: nox *)
(* Latest Version is on GitHub: https://github.com/Life-the-game/SDK-OCaml *)
(* ************************************************************************** *)
open ApiTypes
open Network
(* ************************************************************************** *)
(* API Methods *)
(* ************************************************************************** *)
(* ************************************************************************** *)
(* Get Game Network (People you follow) *)
(* ************************************************************************** *)
(* Auth is optional but gives you more info *)
let get ?(auth = None) ?(page = Page.default_parameters) ?(term = "") user =
Api.go
~path:["users"; user; "network"]
~req:(opt_auth auth)
~page:(Some page)
~get:(Network.empty_filter
[("term", term)])
(Page.from_json ApiUser.from_json)
let get_mine ~auth ?(page = Page.default_parameters) ?(term="") () =
Api.go
~path:(["network"])
~req:(Some (Auth auth))
~page:(Some page)
~get:(Network.empty_filter
[("term", term)])
(Page.from_json ApiUser.from_json)
(* ************************************************************************** *)
(* Get users who have me in their game network (People who follow you) *)
(* ************************************************************************** *)
(* Auth is optional but gives you more info *)
let get_followers ?(auth = None) ?(page = Page.default_parameters) user =
Api.go
~path:["users"; user; "others_network"]
~req:(opt_auth auth)
~page:(Some page)
(Page.from_json ApiUser.from_json)
let get_my_followers ~auth ?(page = Page.default_parameters) () =
Api.go
~path:["others_network"]
~req:(Some (Auth auth))
~page:(Some page)
(Page.from_json ApiUser.from_json)
(* ************************************************************************** *)
(* Add a user in my Game Network *)
(* ************************************************************************** *)
let add ~auth
(* PRIVATE *)
?(adder = None)
(* /PRIVATE *)
added =
Api.go
~rtype:POST
~path:(
(* PRIVATE *)
(match adder with
| Some adder -> ["users"; adder]
| None -> []) @
(* /PRIVATE *)
["network"; added])
~req:(Some (Auth auth))
Api.noop
(* ************************************************************************** *)
(* Delete a user from my Game Network *)
(* ************************************************************************** *)
let delete ~auth
(* PRIVATE *)
?(remover = None)
(* /PRIVATE *)
removed =
Api.go
~rtype:DELETE
~path:(
(* PRIVATE *)
(match remover with
| Some remover -> ["users"; remover]
| None -> []) @
(* /PRIVATE *)
["network"; removed])
~req:(Some (Auth auth))
Api.noop