diff --git a/src/PickPoint/PickPointConnector.php b/src/PickPoint/PickPointConnector.php index 4cc65aa..11f0eb5 100644 --- a/src/PickPoint/PickPointConnector.php +++ b/src/PickPoint/PickPointConnector.php @@ -332,7 +332,7 @@ public function getState(string $invoiceNumber, string $orderNumber = ''): State $this->checkMethodException($response, $url); - $response = $response[0] ?? []; + $response = isset($response) && is_array($response) ? array_pop($response) : []; return new State($response['State'] ?? 0, $response['StateMessage'] ?? ''); } @@ -394,6 +394,30 @@ public function printLabel(array $invoiceNumbers): string return $response; } + /** + * Marks on packages (zebra printer) + * @param array $invoiceNumbers + * @return mixed + * @throws PickPointMethodCallException + */ + public function printZLabel(array $invoiceNumbers): string + { + $invoices = !empty($invoiceNumbers) ? $invoiceNumbers : []; + + $url = $this->pickPointConf->getHost() . '/makezlabel'; + $request = $this->client->post($url, [ + 'json' => [ + 'SessionId' => $this->auth(), + "Invoices" => $invoices, + ], + ]); + $response = $request->getBody()->getContents(); + + $this->checkMethodException($response, $url); + + return $response; + } + /** * @param array $invoiceNumbers diff --git a/tests/PrintLabelsAndReestrsTest.php b/tests/PrintLabelsAndReestrsTest.php index 42382c9..5f0de37 100644 --- a/tests/PrintLabelsAndReestrsTest.php +++ b/tests/PrintLabelsAndReestrsTest.php @@ -22,6 +22,18 @@ public function testPrintLabel() $this->assertNotEmpty($pdfByteCode); } + public function testPrintZLabel() + { + /** + * Invoice $invoice + */ + $invoice = $this->createInvoice(); + $invoiceNumber = $invoice->getInvoiceNumber(); + $pdfByteCode = $this->client->printZLabel(array($invoiceNumber)); + $this->assertTrue(is_string($pdfByteCode)); + $this->assertNotEmpty($pdfByteCode); + } + public function testMakeReestr() { /**