Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/parcel template #24

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Api/WebClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ final class WebClient implements WebClientInterface

private ShippingGatewayInterface $shippingGateway;

public function __construct(Client $client)
private string $labelType = 'normal';

private string $parcelTemplate = 'large';

public function __construct(Client $client, string $labelType, string $parcelTemplate)
{
$this->apiClient = $client;
$this->labelType = $labelType;
$this->parcelTemplate = $parcelTemplate;
}

public function setShippingGateway(ShippingGatewayInterface $shippingGateway): WebClientInterface
Expand Down Expand Up @@ -120,6 +126,7 @@ public function getLabels(array $shipmentIds): ?string

$data = [
'format' => 'pdf',
'type' => $this->labelType,
'shipment_ids' => $shipmentIds,
];

Expand Down Expand Up @@ -303,7 +310,7 @@ private function createParcel(ShipmentInterface $shipment): array
'unit' => 'kg',
],
'dimensions' => [],
'template' => 'large',
'template' => $this->parcelTemplate,
'tracking_number' => null,
'is_non_standard' => false,
];
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/assets/shop/js/inpostPointEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class InpostPointEvents {
);
});

if (!validateNextBtn) {
if (!ValidateNextBtn) {
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
parameters:
bitbag.inpost.label_type: 'normal'
bitbag.inpost.parcel_template: 'large'
imports:
- { resource: "@BitBagSyliusInPostPlugin/Resources/config/services.xml" }
- { resource: "@BitBagSyliusInPostPlugin/Resources/config/resource/bitbag_inpost.yml" }
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
id="bitbag.sylius_inpost_plugin.api.web_client"
>
<argument type="service" id="sylius.http_client"/>
<argument>%bitbag.inpost.label_type%</argument>
<argument>%bitbag.inpost.parcel_template%</argument>
</service>

<service
Expand Down