| Total Complexity | 8 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | abstract class CreateLabelBuilder implements HttpRequestBuilderInterface |
||
| 10 | { |
||
| 11 | public function __construct( |
||
| 12 | protected readonly string $reference, |
||
| 13 | protected readonly LabelFormat $labelFormat, |
||
| 14 | protected readonly bool $asPdf, |
||
| 15 | protected readonly bool $withReturnLabels, |
||
| 16 | ) {} |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @return string |
||
| 20 | */ |
||
| 21 | abstract protected function getUrlPrefix(): string; |
||
| 22 | |||
| 23 | public function getXml(): ?string |
||
| 24 | { |
||
| 25 | return null; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function getHeaders(): array |
||
| 29 | { |
||
| 30 | $media = $this->asPdf ? 'pdf' : 'image'; |
||
| 31 | |||
| 32 | return [ |
||
| 33 | 'Accept: application/vnd.bpost.shm-label-' . $media . '-' . ApiVersions::V3_4 . '+XML', |
||
| 34 | 'Content-Type: application/vnd.bpost.shm-labelRequest-' . ApiVersions::V3 . '+XML', |
||
| 35 | ]; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function getUrl(): string |
||
| 39 | { |
||
| 40 | return sprintf( |
||
| 41 | '/%s/%s/labels/%s%s', |
||
| 42 | $this->getUrlPrefix(), |
||
| 43 | $this->reference, |
||
| 44 | $this->labelFormat->getValue(), |
||
| 45 | $this->withReturnLabels ? '/withReturnLabels' : '' |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function getMethod(): string |
||
| 52 | } |
||
| 53 | |||
| 54 | public function isExpectXml(): bool |
||
| 55 | { |
||
| 57 | } |
||
| 58 | } |