From 3244c8d5705400fb742b75c1b54315a87e3ce5ea Mon Sep 17 00:00:00 2001 From: Zachary Carlson <22893164+zack-carlson@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:36:36 -0600 Subject: [PATCH 1/3] Update CsvFormatter.php For Bulk Queries with CSVs that rely on chunking, users may need to return headers with the following values: 'Sforce-Limit-Info' => 'Sforce-Locator' => 'Sforce-NumberOfRecords' => This proposed change would allow that. --- src/Omniphx/Forrest/Formatters/CsvFormatter.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Omniphx/Forrest/Formatters/CsvFormatter.php b/src/Omniphx/Forrest/Formatters/CsvFormatter.php index b8a6eae..5fb6c3d 100644 --- a/src/Omniphx/Forrest/Formatters/CsvFormatter.php +++ b/src/Omniphx/Forrest/Formatters/CsvFormatter.php @@ -47,8 +47,14 @@ public function setBody($data) public function formatResponse($response) { $body = $response->getBody(); + $header = $response->getHeaders(); $contents = (string) $body; - return $contents; + + return [ + 'header' => $header, + 'body' => $contents, + + ]; } public function getDefaultMIMEType() From f67932d3270b250f5042a977ccb4baefd647c313 Mon Sep 17 00:00:00 2001 From: Zack Carlson Date: Fri, 22 Mar 2024 13:39:19 -0500 Subject: [PATCH 2/3] updates --- .../Forrest/Formatters/CsvFormatter.php | 132 +++++++++--------- .../Formatters/CsvHeadersFormatter.php | 69 +++++++++ 2 files changed, 132 insertions(+), 69 deletions(-) create mode 100644 src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php diff --git a/src/Omniphx/Forrest/Formatters/CsvFormatter.php b/src/Omniphx/Forrest/Formatters/CsvFormatter.php index 5fb6c3d..757305b 100644 --- a/src/Omniphx/Forrest/Formatters/CsvFormatter.php +++ b/src/Omniphx/Forrest/Formatters/CsvFormatter.php @@ -1,69 +1,63 @@ -tokenRepository = $tokenRepository; - $this->settings = $settings; - } - - public function setHeaders() - { - $accessToken = $this->tokenRepository->get()['access_token']; - $tokenType = $this->tokenRepository->get()['token_type']; - - $this->headers['Accept'] = $this->getDefaultAcceptMIMEType(); - $this->headers['Content-Type'] = $this->getDefaultMIMEType(); - $this->headers['Authorization'] = "$tokenType $accessToken"; - - $this->setCompression(); - - return $this->headers; - } - - private function setCompression() - { - if (!$this->settings['defaults']['compression']) return; - - $this->headers['Accept-Encoding'] = $this->settings['defaults']['compressionType']; - $this->headers['Content-Encoding'] = $this->settings['defaults']['compressionType']; - } - - public function setBody($data) - { - return $data; - } - - public function formatResponse($response) - { - $body = $response->getBody(); - $header = $response->getHeaders(); - $contents = (string) $body; - - return [ - 'header' => $header, - 'body' => $contents, - - ]; - } - - public function getDefaultMIMEType() - { - return $this->mimeType; - } - - public function getDefaultAcceptMIMEType() - { - return $this->acceptMimeType; - } -} +tokenRepository = $tokenRepository; + $this->settings = $settings; + } + + public function setHeaders() + { + $accessToken = $this->tokenRepository->get()['access_token']; + $tokenType = $this->tokenRepository->get()['token_type']; + + $this->headers['Accept'] = $this->getDefaultAcceptMIMEType(); + $this->headers['Content-Type'] = $this->getDefaultMIMEType(); + $this->headers['Authorization'] = "$tokenType $accessToken"; + + $this->setCompression(); + + return $this->headers; + } + + private function setCompression() + { + if (!$this->settings['defaults']['compression']) return; + + $this->headers['Accept-Encoding'] = $this->settings['defaults']['compressionType']; + $this->headers['Content-Encoding'] = $this->settings['defaults']['compressionType']; + } + + public function setBody($data) + { + return $data; + } + + public function formatResponse($response) + { + $body = $response->getBody(); + $contents = (string) $body; + return $contents; + } + + public function getDefaultMIMEType() + { + return $this->mimeType; + } + + public function getDefaultAcceptMIMEType() + { + return $this->acceptMimeType; + } +} \ No newline at end of file diff --git a/src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php b/src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php new file mode 100644 index 0000000..5fb6c3d --- /dev/null +++ b/src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php @@ -0,0 +1,69 @@ +tokenRepository = $tokenRepository; + $this->settings = $settings; + } + + public function setHeaders() + { + $accessToken = $this->tokenRepository->get()['access_token']; + $tokenType = $this->tokenRepository->get()['token_type']; + + $this->headers['Accept'] = $this->getDefaultAcceptMIMEType(); + $this->headers['Content-Type'] = $this->getDefaultMIMEType(); + $this->headers['Authorization'] = "$tokenType $accessToken"; + + $this->setCompression(); + + return $this->headers; + } + + private function setCompression() + { + if (!$this->settings['defaults']['compression']) return; + + $this->headers['Accept-Encoding'] = $this->settings['defaults']['compressionType']; + $this->headers['Content-Encoding'] = $this->settings['defaults']['compressionType']; + } + + public function setBody($data) + { + return $data; + } + + public function formatResponse($response) + { + $body = $response->getBody(); + $header = $response->getHeaders(); + $contents = (string) $body; + + return [ + 'header' => $header, + 'body' => $contents, + + ]; + } + + public function getDefaultMIMEType() + { + return $this->mimeType; + } + + public function getDefaultAcceptMIMEType() + { + return $this->acceptMimeType; + } +} From faa6e76fc040972cef2bfdcfb209d49ec04360c1 Mon Sep 17 00:00:00 2001 From: Zack Carlson Date: Fri, 22 Mar 2024 13:53:26 -0500 Subject: [PATCH 3/3] updates --- src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php b/src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php index 5fb6c3d..9d61e40 100644 --- a/src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php +++ b/src/Omniphx/Forrest/Formatters/CsvHeadersFormatter.php @@ -4,7 +4,7 @@ use Omniphx\Forrest\Interfaces\FormatterInterface; -class CsvFormatter implements FormatterInterface +class CsvHeadersFormatter implements FormatterInterface { protected $tokenRepository; protected $settings;