Skip to content

Commit 09f06c2

Browse files
committed
Be able to fetch the contents of the PDF label.
1 parent 30369e5 commit 09f06c2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/Picqer/Carriers/SendCloud/Connection.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,22 @@ public function setEnvironment($environment)
250250
$this->environment = $environment;
251251
}
252252

253+
/**
254+
* Download a resource.
255+
*
256+
* @param string $url
257+
*
258+
* @return string
259+
*/
260+
public function download($url)
261+
{
262+
try {
263+
$result = $this->client()->get($url);
264+
} catch (RequestException $e) {
265+
throw new SendCloudApiException('SendCloud error: (no error message provided)' . $e->getResponse());
266+
}
267+
268+
return $result->getBody()->getContents();
269+
}
253270
}
254271

src/Picqer/Carriers/SendCloud/Label.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@ class Label extends Model {
1616
'plural' => 'labels'
1717
];
1818

19-
}
19+
/**
20+
* Returns the label content (PDF) in A6 format.
21+
*
22+
* @return string
23+
*/
24+
public function labelPrinterContent()
25+
{
26+
$url = str_replace($this->connection->apiUrl(), '', $this->label_printer);
27+
28+
return $this->connection->download($url);
29+
}
30+
}

0 commit comments

Comments
 (0)