1: <?php
2: 3: 4: 5: 6: 7: 8:
9:
10: namespace Maniaplanet\WebServices;
11:
12: class Competitions extends HTTPClient
13: {
14: const REGISTRATION_MODE_OPEN = 1;
15: const REGISTRATION_MODE_OPEN_VALIDATION_NEEDED = 2;
16: const REGISTRATION_MODE_CLOSED = 3;
17:
18: 19: 20: 21: 22: 23:
24: function getMapPool($competitionId)
25: {
26: if(!$competitionId)
27: {
28: throw new Exception('Invalid competitionId');
29: }
30:
31: return $this->execute('GET', '/competitions/%d/maps/', array($competitionId));
32: }
33:
34: function getInvitationKey($competitionId, $offset = 0, $length = 20)
35: {
36: if(!$competitionId)
37: {
38: throw new Exception('Invalid competitionId');
39: }
40: return $this->execute('GET', '/competitions/%d/keys/', array($competitionId));
41: }
42:
43: function inviteTeam($competitionId, $teamId)
44: {
45: if(!$competitionId)
46: {
47: throw new Exception('Invalid competitionId');
48: }
49: if(!$teamId)
50: {
51: throw new Exception('Invalid teamId');
52: }
53:
54: return $this->execute('POST', '/competitions/%d/invite/', array($competitionId, array('teamId' => $teamId)));
55: }
56:
57: function create($name, $titleIdString, $isLan, $registrationMode = self::REGISTRATION_MODE_OPEN)
58: {
59: if(!$name)
60: {
61: throw new Exception('Invalid name');
62: }
63: if(!$titleIdString)
64: {
65: throw new Exception;
66: }
67:
68: return $this->execute('POST', '/competitions/',
69: array(array(
70: 'name' => $name,
71: 'titleId' => $titleIdString,
72: 'lan' => $isLan,
73: 'registrationMode' => $registrationMode
74: )));
75: }
76:
77: function update($id, $name, $titleIdString, $isLan, $registrationMode = self::REGISTRATION_MODE_OPEN,
78: $registrationStartDate = null, $registrationEndDate = null, $startDate = null, $endDate = null,
79: $minOpponents = 8, $maxOpponents = 16, $visibility = 0, $registrationCost = 0)
80: {
81: if(!$name)
82: {
83: throw new Exception('Invalid name');
84: }
85: if(!$id)
86: {
87: throw new Exception;
88: }
89: if(!$titleIdString)
90: {
91: throw new Exception;
92: }
93:
94: return $this->execute('PUT', '/competitions/%d/',
95: array($id, array(
96: 'id' => $id,
97: 'name' => $name,
98: 'titleId' => $titleIdString,
99: 'lan' => $isLan,
100: 'registrationMode' => $registrationMode,
101: 'registrationStartDate' => $registrationStartDate,
102: 'registrationEndDate' => $registrationEndDate,
103: 'startDate' => $startDate,
104: 'endDate' => $endDate,
105: 'minOpponents' => $minOpponents,
106: 'maxOpponents' => $maxOpponents,
107: 'visibility' => $visibility,
108: 'registrationCost' => $registrationCost,
109: )));
110: }
111:
112: 113: 114: 115: 116:
117: function registerResults($competitionId, array $results)
118: {
119: if(!$competitionId)
120: {
121: throw new Exception;
122: }
123: if(!$results)
124: {
125: throw new Exception;
126: }
127: return $this->execute('POST', '/competitions/%d/results/', array($competitionId, array($results)));
128: }
129:
130: }
131:
132: ?>