diff --git a/src/Jobs/PushExternalProduct.php b/src/Jobs/PushExternalProduct.php index cf60cd2..f1d22a8 100644 --- a/src/Jobs/PushExternalProduct.php +++ b/src/Jobs/PushExternalProduct.php @@ -24,7 +24,7 @@ class PushExternalProduct implements ShouldQueue use Queueable, SerializesModels, InteractsWithQueue, Dispatchable; public function __construct( - public ExternalProduct $externalProduct + public HasExternalProduct $externalProduct ) {} /** @@ -45,7 +45,7 @@ public function handle() Http::acceptJson()->withSignature(config('cashregister-bridge.secret'))->post( $url, - $this->externalProduct->toArray(), + $this->externalProduct->toExternalProduct()->toArray(), )->throw(); } } diff --git a/src/Jobs/PushExternalProductItem.php b/src/Jobs/PushExternalProductItem.php index 5872a19..1aea41e 100644 --- a/src/Jobs/PushExternalProductItem.php +++ b/src/Jobs/PushExternalProductItem.php @@ -2,13 +2,7 @@ namespace EtsvThor\CashRegisterBridge\Jobs; -use App\Mail\PublicRelationsMail; -use App\Models\ContentTypes\Company; -use App\Models\Role; -use Carbon\Carbon; -use EtsvThor\CashRegisterBridge\Contracts\HasExternalProduct; use EtsvThor\CashRegisterBridge\Contracts\HasExternalProductItem; -use EtsvThor\CashRegisterBridge\DTO\ExternalProductItem; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -17,7 +11,6 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\Mail; use Illuminate\Support\Str; class PushExternalProductItem implements ShouldQueue @@ -25,7 +18,7 @@ class PushExternalProductItem implements ShouldQueue use Queueable, SerializesModels, InteractsWithQueue, Dispatchable; public function __construct( - public ?ExternalProductItem $externalProductItem + public HasExternalProductItem $externalProductItem ) {} /** @@ -47,13 +40,13 @@ public function handle() return; } - if (is_null($this->externalProductItem)) { + if (is_null($dto = $this->externalProductItem->toExternalProductItem())) { return; } Http::acceptJson()->withSignature(config('cashregister-bridge.secret'))->post( $url, - $this->externalProductItem->toArray(), + $dto->toArray(), )->throw(); } } diff --git a/src/Traits/PushesExternalProduct.php b/src/Traits/PushesExternalProduct.php index b7d4062..8304393 100644 --- a/src/Traits/PushesExternalProduct.php +++ b/src/Traits/PushesExternalProduct.php @@ -12,7 +12,7 @@ trait PushesExternalProduct public static function bootPushesExternalProduct(): void { static::saved(function (HasExternalProduct $externalProduct) { - PushExternalProduct::dispatch($externalProduct->toExternalProduct()); + PushExternalProduct::dispatch($externalProduct); }); static::deleted(function (HasExternalProduct $externalProductItem) { diff --git a/src/Traits/PushesExternalProductItem.php b/src/Traits/PushesExternalProductItem.php index d46befd..5ff394d 100644 --- a/src/Traits/PushesExternalProductItem.php +++ b/src/Traits/PushesExternalProductItem.php @@ -14,7 +14,7 @@ trait PushesExternalProductItem public static function bootPushesExternalProductItem(): void { static::saved(function (HasExternalProductItem $externalProductItem) { - PushExternalProductItem::dispatch($externalProductItem->toExternalProductItem()); + PushExternalProductItem::dispatch($externalProductItem); }); static::deleted(function (HasExternalProductItem $externalProductItem) {