Skip to content

Commit

Permalink
LIMS-933: Build shipping headers when building request
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPrit committed Sep 29, 2023
1 parent 0927857 commit cc87d19
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions api/src/Shipment/ShippingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class ShippingService
{
private $shipping_api_url;
private $shipping_app_url;
private $headers;
public const JOURNEY_TO_FACILITY = "TO_FACILITY";
public const JOURNEY_FROM_FACILITY = "FROM_FACILITY";

Expand Down Expand Up @@ -45,18 +44,18 @@ function __construct()
global $shipping_service_app_url;
$this->shipping_api_url = $shipping_service_api_url;
$this->shipping_app_url = $shipping_service_app_url;
$this->headers = $this->_build_headers();
}


function _send_request($url, $type, $data, $expected_status_code)
{
$ch = curl_init($url);
$base_headers = $this->_build_headers();
curl_setopt_array(
$ch,
array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => $this->headers,
CURLOPT_HTTPHEADER => $base_headers,
CURLOPT_TIMEOUT => 5
)
);
Expand All @@ -77,7 +76,7 @@ function _send_request($url, $type, $data, $expected_status_code)
$ch,
array(
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => array_merge($this->headers, array('Content-Length: ' . strlen(json_encode($data)))),
CURLOPT_HTTPHEADER => array_merge($base_headers, array('Content-Length: ' . strlen(json_encode($data)))),
CURLOPT_POSTFIELDS => json_encode($data),
)
);
Expand Down

0 comments on commit cc87d19

Please sign in to comment.