false, 'error' => $res['error']]; } $data = array(); foreach ($res['data'] as $addr) { $data[] = $this->parse_phone($addr); } $totalPage = isset($res['total']) ? $res['total'] : 0; $page = isset($res['page']) ? $res['page'] : 0; return [ 'list' => $data, 'totalItems' => $totalPage, 'page' => $page, ]; } public function getPhoneById($id) { $res = AutomaticServerAPI::get("phone-farm-phones/$id", NULL); $res['data'] = $this->parse_phone($res['data']); return $res; } public function createPhone($params) { return AutomaticServerAPI::post('phone-farm-phones', $params); } public function removePhoneById($phoneId) { return AutomaticServerAPI::delete("phone-farm-phones/$phoneId"); } public function updatePhoneById($phoneId, $params) { return AutomaticServerAPI::put("phone-farm-phones/$phoneId", $params); } private function parse_phone($originData) { return $this->phone_farm_phone($originData); } }