/** * @var data * protected $data =array(); */ public function decideAPICall($functionName, $params) { $data = array(); switch ($functionName) { case 'SystemConnect': $obj_connectapifunction = new App_Model_ConnectAPIFunction(); $data = $obj_connectapifunction->systemConnect($params); break; case 'SignIn': $obj_userapifunction = new App_Model_UserAPIFunction(); $data = $obj_userapifunction->addUser($params); break; case 'UpdateAccount': $obj_userapifunction = new App_Model_UserAPIFunction(); $data = $obj_userapifunction->updateUser($params); break; case 'SignOut': $obj_userapifunction = new App_Model_UserAPIFunction(); $data = $obj_userapifunction->signoutUser($params); break; case 'GetDeals': $obj_dealapifunction = new App_Model_DealAPIFunction(); $data = $obj_dealapifunction->listDeal($params); break; case 'GetDealDetails': $obj_dealapifunction = new App_Model_DealAPIFunction(); $data = $obj_dealapifunction->detailDeals($params); break; case 'MarkAsFavourite': $obj_dealapifunction = new App_Model_DealAPIFunction(); $data = $obj_dealapifunction->makAsFavourite($params); break; case 'GetUserFavouriteDeals': $obj_dealapifunction = new App_Model_DealAPIFunction(); $data = $obj_dealapifunction->getUserFavouriteDeals($params); break; case 'GetUserFavoritesBusinesses': $obj_businessapifunction = new App_Model_BusinessAPIFunction(); $data = $obj_businessapifunction->getUserFavoritesBusinesses($params); break; case 'GetCategories': $obj_categoryapifunction = new App_Model_CategoryAPIFunction(); $data = $obj_categoryapifunction->getCategory($params); break; case 'GetSubCategories': $obj_categoryapifunction = new App_Model_SubCategoryAPIFunction(); $data1 = $obj_categoryapifunction->getSubCategory($params, ''); if (sizeof($data1) == 2) { $data = $data1[0]; } else { $data = $data1; } break; default: $data = array("No API called"); } return $data; }
public function createObj($paginator, $flag) { $tag_arr = array(); $all_tags_arr = array(); $sub_cat_data = ""; $all_tags_str = ""; $obj_user->success = "true"; $user_id = 0; if ($flag == "deal") { $obj_user->Deals = new stdClass(); } if ($flag == "business") { $obj_user->Businesses = new stdClass(); } $arr = array(); foreach ($paginator as $item) { $obj_deal = new App_Model_Deal(); $obj_name = 'object'; $obj_name = new stdClass(); if (isset($item['user_id'])) { $user_id = $item['user_id']; } if (isset($item['id']) && $flag == "deal") { $obj_name->deal_id = $item['id']; } if (isset($item['type'])) { $obj_name->deal_type = $item['type']; } if (isset($item['business_id']) && $flag == "business") { $obj_name->business_id = $item['business_id']; } if (isset($item['id'])) { $mark_as_fav_status_deal = $obj_deal->checkFavouriteDealBusinesssModule($user_id, $item['id'], 'deal'); } $obj_name->favourite_flag_deal = $mark_as_fav_status_deal; if (isset($item['business_id'])) { $mark_as_fav_status_business = $obj_deal->checkFavouriteDealBusinesssModule($user_id, $item['business_id'], 'business'); $obj_name->favourite_flag_business = $mark_as_fav_status_business; } $obj_name->title = $item['tiny_description']; $obj_name->latitude = $item['latitude']; $obj_name->longitude = $item['longitude']; $obj_name->address = $item['address']; $obj_name->description = $item['description']; if (isset($item['user_id'])) { $obj_name->user_id = $item['user_id']; } if (isset($item['buss_cat_id'])) { $obj_name->category_id = $item['buss_cat_id']; $obj_subcategoryapifunction = new App_Model_SubCategoryAPIFunction(); $sub_cat_data = $obj_subcategoryapifunction->getSubCategory($item['buss_cat_id'], $item['id']); } if (isset($item['buss_id'])) { $obj_name->business_id = $item['buss_id']; } if (isset($item['buss_name'])) { $obj_name->business_name = $item['buss_name']; } if (isset($sub_cat_data)) { if (sizeof($sub_cat_data) > 1) { $obj_name->tags = $sub_cat_data[1]; } } if (sizeof($sub_cat_data) > 1) { $all_tags_str .= $sub_cat_data[2]; } array_push($arr, $obj_name); } //end of for if ($flag == "deal") { $obj_user->Deals->record = $arr; } if ($flag == "business") { $obj_user->Businesses->record = $arr; } $total_records_count = $paginator->getTotalItemCount(); $obj_user->totalrecord = $total_records_count; if (isset($sub_cat_data)) { $all_tags_arr = explode("|", $all_tags_str); array_pop($all_tags_arr); $all_tags_arr_unique = array_unique($all_tags_arr); $obj_user->AllTagArr = $all_tags_arr_unique; } return $obj_user; }