Overview

Namespaces

  • PHP
  • Upwork
    • API
      • AuthTypes
      • Interfaces
      • Routers
        • Activities
        • Freelancers
        • Hr
          • Clients
          • Freelancers
        • Jobs
        • Organization
        • Reports
          • Finance

Classes

  • Auth
  • Mc
  • Metadata
  • Payments
  • Snapshot
  • Teams
  • Workdays
  • Workdiary
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Upwork auth library for using with public API by OAuth
  4:  *
  5:  * @final
  6:  * @package     UpworkAPI
  7:  * @since       04/21/2014
  8:  * @copyright   Copyright 2014(c) Upwork.com
  9:  * @author      Maksym Novozhylov <mnovozhilov@upwork.com>
 10:  * @license     Upwork's API Terms of Use {@link https://developers.upwork.com/api-tos.html}
 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:  * Message Center
 20:  *
 21:  * @link http://developers.upwork.com/Message-Center-API
 22:  */
 23: final class Mc extends ApiClient
 24: {
 25:     const ENTRY_POINT = UPWORK_API_EP_NAME;
 26: 
 27:     /**
 28:      * @var Client instance
 29:      */
 30:     private $_client;
 31: 
 32:     /**
 33:      * Constructor
 34:      *
 35:      * @param   ApiClient $client Client object
 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:      * Get trays
 46:      *
 47:      * @access  public
 48:      * @return  object
 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:      * Get tray by type
 62:      *
 63:      * @param   string $username Username
 64:      * @param   string $type Tray type/name
 65:      * @access  public
 66:      * @return  object
 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:      * List thread details based on thread id
 80:      *
 81:      * @param   string $username Username
 82:      * @param   integer $threadId Thread ID
 83:      * @access  public
 84:      * @return  object
 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:      * Get a specific thread by context
 98:      *
 99:      * @param   string $username Username
100:      * @param   string $jobKey Job key
101:      * @param   integer $applicationId Application ID
102:      * @param   string $context (Optional) Context
103:      * @access  public
104:      * @return  object
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:      * Get a specific thread by context (last message content)
119:      *
120:      * @param   string $username Username
121:      * @param   string $jobKey Job key
122:      * @param   integer $applicationId Application ID
123:      * @param   string $context (Optional) Context
124:      * @access  public
125:      * @return  object
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:      * Update threads based on user actions
139:      *
140:      * @param   string $username Username
141:      * @param   integer $threadId Thread ID
142:      * @param   array $params Parameters
143:      * @access  public
144:      * @return  object
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:      * Send new message
158:      *
159:      * @param   string $username User ID
160:      * @param   array $params Parameters
161:      * @access  public
162:      * @return  object
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:      * Reply to existend thread
176:      *
177:      * @param   string $username User ID
178:      * @param   integer $threadId Thread ID
179:      * @param   array $params Parameters
180:      * @access  public
181:      * @return  object
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: 
API documentation generated by ApiGen 2.8.0