Skip to content

Commit

Permalink
feat!: remove src from namespace and deprecated items
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen committed Feb 3, 2025
1 parent 674628d commit 3e730ad
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 550 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,7 @@ public function isPickup(): bool
return false;
}

return in_array(
$this->deliveryType,
[
AbstractConsignment::DELIVERY_TYPE_PICKUP_NAME,
AbstractConsignment::DELIVERY_TYPE_PICKUP_EXPRESS_NAME,
]
);
return AbstractConsignment::DELIVERY_TYPE_PICKUP_NAME == $this->deliveryType;
}

/**
Expand Down
9 changes: 0 additions & 9 deletions src/Adapter/DeliveryOptions/AbstractPickupLocationAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ public function getLocationCode(): string
return $this->location_code;
}

/**
* @return string|null
* @deprecated Use getRetailNetworkId instead
*/
public function getPickupNetworkId(): string
{
return $this->getRetailNetworkId();
}

/**
* @return string|null
*/
Expand Down
9 changes: 3 additions & 6 deletions src/Concerns/HasApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ trait HasApiKey
{
/**
* @var string|null
* @deprecated This property will lose public access in the future. Use getApiKey() instead.
*/
public $apiKey;
protected ?string $apiKey;

/**
* @return string|null
Expand All @@ -27,13 +26,11 @@ public function getApiKey(): ?string
*/
public function ensureHasApiKey(): string
{
$apiKey = $this->getApiKey();

if (! $apiKey) {
if (! isset($this->apiKey) || '' === trim($this->apiKey)) {
throw new Exception('API key is missing. Please use setApiKey(string) first.');
}

return $apiKey;
return $this->apiKey;
}

/**
Expand Down
67 changes: 0 additions & 67 deletions src/Helper/CheckoutFields.php

This file was deleted.

63 changes: 8 additions & 55 deletions src/Helper/MyParcelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,6 @@ public function getConsignmentsByReferenceIdGroup($groupId): self
return $this->findByReferenceIdGroup($groupId);
}

/**
* This is deprecated because there may be multiple consignments with the same reference id
*
* @param $id
*
* @return mixed
* @deprecated Use getConsignmentsByReferenceId()->first() instead
*
*/
public function getConsignmentByReferenceId($id)
{
return $this->getConsignmentsByReferenceId($id)->first();
}

/**
* @param int $id
*
Expand Down Expand Up @@ -225,7 +211,7 @@ public function addConsignmentByReferenceIds($ids, $apiKey): self
foreach ($ids as $referenceId) {
$consignment = (new BaseConsignment())
->setApiKey($apiKey)
->setReferenceId($referenceId);
->setReferenceIdentifier($referenceId);

$this->addConsignment($consignment);
}
Expand All @@ -245,8 +231,8 @@ public function addMultiCollo(AbstractConsignment $consignment, $amount): self
$consignment->setMultiCollo();
}

if ($consignment->isPartOfMultiCollo() && ! $consignment->getReferenceId()) {
$consignment->setReferenceId('random_multi_collo_' . uniqid('', true));
if ($consignment->isPartOfMultiCollo() && ! $consignment->getReferenceIdentifier()) {
$consignment->setReferenceIdentifier('random_multi_collo_' . uniqid('', true));
}

for ($i = 1; $i <= $amount; $i++) {
Expand Down Expand Up @@ -284,7 +270,7 @@ public function createConcepts(): self
$request = (new MyParcelRequest())
->setUserAgents($this->getUserAgent())
->setRequestParameters(
$consignments->first()->apiKey,
$consignments->first()->getApiKey(),
$data,
$headers
)
Expand Down Expand Up @@ -379,25 +365,6 @@ public function setLatestData($size = 300): self
return $this;
}

/**
* Get all the information about the last created shipments
*
* @param $key
* @param int $size
*
* @return self
* @throws \MyParcelNL\Sdk\Exception\AccountNotActiveException
* @throws \MyParcelNL\Sdk\Exception\ApiException
* @throws \MyParcelNL\Sdk\Exception\MissingFieldException
* @deprecated use MyParcelCollection::query($key, ['size' => 300]) instead
*/
public function setLatestDataWithoutIds($key, $size = 300): self
{
$params = ['size' => $size];

return self::query($key, $params);
}

/**
* Get link of labels
*
Expand Down Expand Up @@ -577,20 +544,6 @@ public function generateReturnConsignments(bool $sendMail, Closure $modifier = n
return $this;
}

/**
* Send return label to customer. The customer can pay and download the label.
*
* @return self
* @throws \MyParcelNL\Sdk\Exception\AccountNotActiveException
* @throws \MyParcelNL\Sdk\Exception\ApiException
* @throws \MyParcelNL\Sdk\Exception\MissingFieldException
* @deprecated Use generateReturnConsignments instead
*/
public function sendReturnLabelMails(): self
{
return $this->generateReturnConsignments(true);
}

/**
* Get all consignment ids
*
Expand Down Expand Up @@ -742,7 +695,7 @@ public static function findManyByReferenceId(array $referenceIds, string $apiKey

foreach ($referenceIds as $id) {
$consignment = new BaseConsignment();
$consignment->setReferenceId($id);
$consignment->setReferenceIdentifier($id);
$consignment->setApiKey($apiKey);

$collection->addConsignment($consignment);
Expand Down Expand Up @@ -877,8 +830,8 @@ private function getNewCollectionFromResult($result): self
private function addMissingReferenceId(): void
{
$this->transform(function (AbstractConsignment $consignment) {
if (! $consignment->getReferenceId()) {
$consignment->setReferenceId('random_' . uniqid('', true));
if (! $consignment->getReferenceIdentifier()) {
$consignment->setReferenceIdentifier('random_' . uniqid('', true));
}

return $consignment;
Expand All @@ -896,7 +849,7 @@ private function findByReferenceIdGroup($id): self
/**
* @var AbstractConsignment $consignment
*/
return Str::startsWith($consignment->getReferenceId(), $id);
return Str::startsWith($consignment->getReferenceIdentifier(), $id);
});
}

Expand Down
25 changes: 0 additions & 25 deletions src/Helper/SplitStreet.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,6 @@ public static function getStreetParts($street)
return $parts;
}

/**
* @param string $fullStreet
* @param string $localCountry
* @param string|null $destinationCountry
*
* @return bool
* @deprecated use ValidateStreet::validate instead
*/
public static function isCorrectStreet(string $fullStreet, string $localCountry, ?string $destinationCountry): bool
{
return ValidateStreet::validate($fullStreet, $localCountry, $destinationCountry);
}

/**
* @param string $local
* @param string $destination
*
* @return null|string
* @deprecated use ValidateStreet::getStreetRegexByCountry instead
*/
public static function getRegexByCountry(string $local, string $destination): ?string
{
return ValidateStreet::getStreetRegexByCountry($local, $destination);
}

/**
* @param string $fullStreet
* @param int $result
Expand Down
Loading

0 comments on commit 3e730ad

Please sign in to comment.