1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace Upwork\API\Routers;
14:
15: use Upwork\API\Debug as ApiDebug;
16: use Upwork\API\Client as ApiClient;
17:
18: 19: 20: 21: 22:
23: final class Mc extends ApiClient
24: {
25: const ENTRY_POINT = UPWORK_API_EP_NAME;
26:
27: 28: 29:
30: private $_client;
31:
32: 33: 34: 35: 36:
37: public function __construct(ApiClient $client)
38: {
39: ApiDebug::p('init ' . __CLASS__ . ' router');
40: $this->_client = $client;
41: parent::$_epoint = self::ENTRY_POINT;
42: }
43:
44: 45: 46: 47: 48: 49:
50: public function getTrays()
51: {
52: ApiDebug::p(__FUNCTION__);
53:
54: $response = $this->_client->get('/mc/v1/trays');
55: ApiDebug::p('found trays', $response);
56:
57: return $response;
58: }
59:
60: 61: 62: 63: 64: 65: 66: 67:
68: public function getTrayByType($username, $type)
69: {
70: ApiDebug::p(__FUNCTION__);
71:
72: $response = $this->_client->get('/mc/v1/trays/' . $username . '/' . $type);
73: ApiDebug::p('found tray', $response);
74:
75: return $response;
76: }
77:
78: 79: 80: 81: 82: 83: 84: 85:
86: public function getThreadDetails($username, $threadId)
87: {
88: ApiDebug::p(__FUNCTION__);
89:
90: $response = $this->_client->get('/mc/v1/threads/' . $username . '/' . $threadId);
91: ApiDebug::p('found thread', $response);
92:
93: return $response;
94: }
95:
96: 97: 98: 99: 100: 101: 102: 103: 104: 105:
106: public function getThreadByContext($username, $jobKey, $applicationId, $context = 'Interviews')
107: {
108: ApiDebug::p(__FUNCTION__);
109:
110: $response = $this->_client->get('/mc/v1/contexts/' . $username . '/' . $context . ':' . $jobKey . ':' . $applicationId);
111: ApiDebug::p('found thread', $response);
112:
113: return $response;
114: }
115:
116:
117: 118: 119: 120: 121: 122: 123: 124: 125: 126:
127: public function getThreadByContextLastPosts($username, $jobKey, $applicationId, $context = 'Interviews')
128: {
129: ApiDebug::p(__FUNCTION__);
130:
131: $response = $this->_client->get('/mc/v1/contexts/' . $username . '/' . $context . ':' . $jobKey . ':' . $applicationId . '/last_posts');
132: ApiDebug::p('found thread', $response);
133:
134: return $response;
135: }
136:
137: 138: 139: 140: 141: 142: 143: 144: 145:
146: public function markThread($username, $threadId, $params)
147: {
148: ApiDebug::p(__FUNCTION__);
149:
150: $response = $this->_client->put('/mc/v1/threads/' . $username . '/' . $threadId, $params);
151: ApiDebug::p('found response', $response);
152:
153: return $response;
154: }
155:
156: 157: 158: 159: 160: 161: 162: 163:
164: public function startNewThread($username, $params)
165: {
166: ApiDebug::p(__FUNCTION__);
167:
168: $response = $this->_client->post('/mc/v1/threads/' . $username, $params);
169: ApiDebug::p('found response', $response);
170:
171: return $response;
172: }
173:
174: 175: 176: 177: 178: 179: 180: 181: 182:
183: public function replyToThread($username, $threadId, $params)
184: {
185: ApiDebug::p(__FUNCTION__);
186:
187: $response = $this->_client->post('/mc/v1/threads/' . $username . '/' . $threadId, $params);
188: ApiDebug::p('found response', $response);
189:
190: return $response;
191: }
192: }
193: