Skip to content

Commit

Permalink
Merge pull request #1 from xervin/feature/printZLabel
Browse files Browse the repository at this point in the history
feature/printZLabel Добавлен метод для печати наклеек небольшого разм…
  • Loading branch information
ainurqa95 authored Aug 2, 2020
2 parents 2246cd7 + b98b75c commit f1f35e4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/PickPoint/PickPointConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? '');
}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/PrintLabelsAndReestrsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
/**
Expand Down

0 comments on commit f1f35e4

Please sign in to comment.