Exemple #1
0
 /**
  * @param string[]|int[]|mixed $consignments
  * @param string $type
  * @param int $firstPosition
  * @param int $labelsPerPage
  * @param string|null $shopId
  * @param string|null $apiKey
  * @return GetLabelsResponse
  * @throws \Exception
  */
 public function getLabels($consignments = [], $type = LabelAttr::TYPE_PDF, $firstPosition = 1, $labelsPerPage = 4, $shopId = null, $apiKey = null)
 {
     $shop = isset($shopId) ? $shopId : $this->shopId;
     $key = isset($apiKey) ? $apiKey : $this->apiKey;
     $resource = Resource::LABELS;
     $labelRequest = new LabelRequest($consignments, $type, $firstPosition, $labelsPerPage);
     $data = $this->formatter->formatGetLabelsRequest($labelRequest);
     $requestEnvelope = new RequestEnvelope($data, $resource, Method::POST, $shop, $key);
     $requestEnvelopeWithHeaders = $this->attachBasicHeadersToRequest($requestEnvelope);
     $connectorResponse = $this->connector->sendRequest($requestEnvelopeWithHeaders);
     $formattedResponse = $this->formatter->formatGetLabelsResponse($connectorResponse);
     return $formattedResponse;
 }