if (file_exists($fileName)) { try { # Open the input file. $handle = fopen($fileName, "r"); $fieldList = array(); $dataHeader = array(); $payload = array(); $counter = 0; $error = false; # Load the data. while (($line = fgetcsv($handle, 0, $SEPARATOR, $TEXT_QUALIFIER)) !== FALSE) { # Load and validate the header. if ($counter == 0) { $header = $line; # Validate the header. $fields = ZuoraAPIHelper::getFieldList($wsdl, $object); # Need to add the fieldsToNull and Id field, since they're part of ZObject. array_unshift($fields, $FIELDSTONULL_FIELD); array_unshift($fields, $ID_FIELD); $errorFields = array(); for ($i = 0; $i < count($header); $i++) { $found = false; for ($j = 0; $j < count($fields); $j++) { if (strcasecmp(trim($header[$i]), $fields[$j]) == 0) { $found = true; break; } } if (!$found) { // Exclude custom fields from validation. if (strpos($header[$i], "__")) {
public static function printTemplateWithNS($wsdl, $call, $object, $debug, $offset, $apiNamespace, $objectNamespace) { /* // Handle "delete". if ($call == "delete") { $payload = str_repeat(" ", $offset) . "<" . $apiNamespace . ":delete>\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":type>" . $object . "</" . $apiNamespace . ":type>\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":ids></" . $apiNamespace . ":ids>\n"; $payload .= str_repeat(" ", $offset) . "</" . $apiNamespace . ":delete>\n"; return $payload; } // Handle "create"/"update"/"query". $fieldNames = ZuoraAPIHelper::getFieldList($wsdl, $object); if ($call == "query") { $payload = str_repeat(" ", $offset) . "<" . $apiNamespace . ":query>\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":queryString>select "; $payload .= "Id"; } else { $payload = str_repeat(" ", $offset) . "<" . $apiNamespace . ":" . $call . ">\n"; $payload .= str_repeat(" ", $offset) . " <" . $apiNamespace . ":zObjects xsi:type=\"" . $objectNamespace . ":" . $object . "\">\n"; if ($call == "update") { // Assume zObject base. $payload .= str_repeat(" ", $offset) . " <" . $objectNamespace . ":" . "Id" . "></" . $objectNamespace . ":" . "Id" . ">\n"; } } for ($i = 0; $i < count($fieldNames); $i++) { if ($call == "query") { $payload .= "," . $fieldNames[$i]; } else { $payload .= str_repeat(" ", $offset) . " <" . $objectNamespace . ":" . $fieldNames[$i] . "></" . $objectNamespace . ":" . $fieldNames[$i] . ">\n"; } } if ($call == "query") { $payload .= " from " . $object . "</" . $apiNamespace . ":queryString>\n"; $payload .= str_repeat(" ", $offset) . "</" . $apiNamespace . ":query>\n"; } else { $payload .= str_repeat(" ", $offset) . " </" . $apiNamespace . ":zObjects>\n"; $payload .= str_repeat(" ", $offset) . "</" . $apiNamespace . ":" . $call . ">\n"; } return $payload; / /*/ $fieldNames = ZuoraAPIHelper::getFieldList($wsdl, $object); return ZuoraAPIHelper::printXMLWithNS($call, $object, $fieldNames, array(), $debug, $offset, $apiNamespace, $objectNamespace, true); }