Skip to content

Commit a432d64

Browse files
committed
Normalize differences between bulk csv response and bulk json response
1 parent e1fa1cb commit a432d64

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/Salesforce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ public function call_api($method, $url, $options = [], $debug_info = [])
494494
$json = json_encode($xml);
495495
$response_array = json_decode($json,TRUE);
496496
}elseif($format == 'csv'){
497-
$response_array = csvToArray((string) $response->getBody());
497+
$response_array = csvToArray((string) $response->getBody(), $lowerCaseHeaders=true);
498498
}else{
499499
$response_array = json_decode((string) $response->getBody(), true);
500500
}

src/helpers.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ function str_putcsv($input, $delimiter = ',', $enclosure = '"') {
6565
}
6666

6767
if (!function_exists('csvToArray')) {
68-
function csvToArray($csv_string)
68+
function csvToArray($csv_string, $lowerCaseHeaders=false)
6969
{
7070
$csv = array_map('str_getcsv',explode("\n", $csv_string));
7171
$header = array_shift($csv);
7272

73+
if($lowerCaseHeaders){
74+
$header = array_map('strtolower', $header);
75+
}
76+
7377
$result = [];
7478

7579
foreach($csv as $row){

tests/BulkTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public function dataResultArray()
377377

378378
public function dataResultCsv()
379379
{
380-
return 'success,created,id,errors
380+
return 'Success,Created,Id,Errors
381381
true,true,001xx000003DHP1AAO,';
382382
}
383383

0 commit comments

Comments
 (0)