-
Notifications
You must be signed in to change notification settings - Fork 2
/
GJTrophies.hx
63 lines (42 loc) · 1.49 KB
/
GJTrophies.hx
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
/*
* Copyright (c) 2019 Charles Griffiths
*/
package gjCloud;
class GJTrophies
{
static var fetchDir:String = "/trophies/";
static var addDir:String = "/trophies/add-achieved/";
static var removeDir:String = "/trophies/remove-achieved/";
static public function fetchAll():GJTransaction
{
return new GJTransaction( fetchDir ).addGameID().addUserName().addUserToken();
}
static public function fetchAchieved():GJTransaction
{
return fetchAll().addArg( "achieved", "true" );
}
static public function fetchUnachieved():GJTransaction
{
return fetchAll().addArg( "achieved", "false" );
}
static public function fetchByID( id:Int ):GJTransaction
{
return fetchAll().addArg( "trophy_id", Std.string( id ) );
}
static public function fetchByIDs( ids:Array<Int> ):GJTransaction
{
if (null == ids || 0 == ids.length) return fetchAll();
var idlist = Std.string( ids[0] );
for (index in 1...ids.length)
idlist += "," + Std.string( ids[index] );
return fetchAll().addArg( "trophy_id", idlist );
}
static public function addAchieved( id:Int ):GJTransaction
{
return new GJTransaction( addDir ).addGameID().addUserName().addUserToken().addArg( "trophy_id", Std.string( id ) );
}
static public function removeAchieved( id:Int ):GJTransaction
{
return new GJTransaction( removeDir ).addGameID().addUserName().addUserToken().addArg( "trophy_id", Std.string( id ) );
}
}