/** * Push users to Desk.com API * * @param $users */ private function pushUsersToDesk($users) { $desk = new DeskAPI(false); if (!empty($users)) { foreach ($users as $user) { $response = $desk->createCustomer($user); /** Display Desk Api connection errors. */ if (isset($response['error'])) { $this->out($response['error'], 1, Shell::NORMAL); } } } else { $this->error('No users found.'); } }
/** * Add customer to Desk.com * * @see DeskAPI::crateCustomer($user) * * @param $user_id */ public function desk_account($user_id) { $user = $this->User->accountInfo($user_id); if (!empty($user)) { /** Setup presenter status color */ $status = $this->User->getStatusLevel($user['Presenter']['PresenterType'][0][0]['presentertypes_id']); $user['Presenter']['PresenterType'] = $status; /** Setup market */ $market = $this->Market->find('first', array('fields' => array('name'), 'conditions' => array('id =' => $user['Presenter']['market_id']))); $user['Presenter']['market_name'] = str_replace('.', '', $market['Market']['name']); $desk = new DeskAPI(); $response = $desk->createCustomer($user); $this->sendSuccess(array('customer' => $user, 'response' => $response)); return; } else { $this->sendSuccess(array('customer' => null, 'response' => 'No user account found by id: ' . $user_id)); } }