Skip to content

Commit

Permalink
revert partly (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
niekbr authored Jul 4, 2024
1 parent 7ef1d05 commit 3dd21a1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Jobs/PushExternalProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PushExternalProduct implements ShouldQueue
use Queueable, SerializesModels, InteractsWithQueue, Dispatchable;

public function __construct(
public ExternalProduct $externalProduct
public HasExternalProduct $externalProduct
) {}

/**
Expand All @@ -45,7 +45,7 @@ public function handle()

Http::acceptJson()->withSignature(config('cashregister-bridge.secret'))->post(
$url,
$this->externalProduct->toArray(),
$this->externalProduct->toExternalProduct()->toArray(),
)->throw();
}
}
13 changes: 3 additions & 10 deletions src/Jobs/PushExternalProductItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,15 +11,14 @@
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
{
use Queueable, SerializesModels, InteractsWithQueue, Dispatchable;

public function __construct(
public ?ExternalProductItem $externalProductItem
public HasExternalProductItem $externalProductItem
) {}

/**
Expand All @@ -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();
}
}
2 changes: 1 addition & 1 deletion src/Traits/PushesExternalProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/PushesExternalProductItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3dd21a1

Please sign in to comment.