/**
  * sample_GetCategorySpecifics::dispatchCall()
  * 
  * Dispatch the call
  *
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $req = new GetCategorySpecificsRequestType();
     $req->setCategoryID($params['CategoryID']);
     $res = $this->proxy->GetCategorySpecifics($req);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         return true;
     } else {
         return false;
     }
 }
 /**
  * @return GetCategorySpecificsResponseType
  * @param GetCategorySpecificsRequestType $request 
  */
 function GetCategorySpecifics($request)
 {
     $request->setVersion(EBAY_WSDL_VERSION);
     return $this->call('GetCategorySpecifics', $request);
 }
 function fetchCategorySpecifics($session, $category_id, $site_id = false)
 {
     // adjust Site if required - eBay Motors (beta)
     $test_site_id = $site_id == 0 ? 100 : $site_id;
     $primary_category = $this->getItem($category_id, $test_site_id);
     WPLE()->logger->info("fetchCategorySpecifics( {$category_id}, {$test_site_id} ) primary_category: " . print_r($primary_category, 1));
     if ($primary_category && $primary_category['site_id'] == 100) {
         $session->setSiteId(100);
         $site_id = 100;
     }
     $this->initServiceProxy($session);
     // download store categories
     $req = new GetCategorySpecificsRequestType();
     $req->setCategoryID($category_id);
     $req->setDetailLevel('ReturnAll');
     $req->setMaxNames(15);
     // eBay default is 10 - maximum is 30
     $req->setMaxValuesPerName(250);
     // eBay default is 25 - no maximum
     $res = $this->_cs->GetCategorySpecifics($req);
     WPLE()->logger->info('fetchCategorySpecifics() for category ID ' . $category_id);
     // build $specifics array
     $specifics = array();
     if (count($res->Recommendations[0]->NameRecommendation) > 0) {
         foreach ($res->Recommendations[0]->NameRecommendation as $Recommendation) {
             // ignore invalid data - Name is required
             // if ( empty( $Recommendation->getName() ) ) continue; // does not work in PHP 5.4 and before (Fatal Error: Can't use method return value in write context)
             if (!$Recommendation->getName()) {
                 continue;
             }
             // works in all PHP versions
             $new_specs = new stdClass();
             $new_specs->Name = $Recommendation->Name;
             $new_specs->ValueType = $Recommendation->ValidationRules->ValueType;
             $new_specs->MinValues = $Recommendation->ValidationRules->MinValues;
             $new_specs->MaxValues = $Recommendation->ValidationRules->MaxValues;
             $new_specs->SelectionMode = $Recommendation->ValidationRules->SelectionMode;
             if (is_array($Recommendation->ValueRecommendation)) {
                 foreach ($Recommendation->ValueRecommendation as $recommendedValue) {
                     // WPLE()->logger->info('*** '.$Recommendation->Name.' recommendedValue: '.$recommendedValue->Value);
                     if (strpos($recommendedValue->Value, chr(239))) {
                         continue;
                     }
                     // skip values with 0xEF / BOM (these are broken an eBay and cause problems on some servers)
                     $new_specs->recommendedValues[] = $recommendedValue->Value;
                 }
             }
             $specifics[] = $new_specs;
         }
     }
     // WPLE()->logger->info('fetchCategorySpecifics: '.print_r($specifics,1));
     if (!is_array($specifics)) {
         $specifics = 'none';
     }
     // store result in ebay_categories table
     global $wpdb;
     $data = array();
     $data['specifics'] = serialize($specifics);
     $data['last_updated'] = date('Y-m-d H:i:s');
     $wpdb->update($wpdb->prefix . self::table, $data, array('cat_id' => $category_id, 'site_id' => $site_id));
     WPLE()->logger->info('category specifics were stored...' . $wpdb->last_error);
     // legacy return format
     return array($category_id => $specifics);
 }