Skip to content

Commit

Permalink
use seven client; require php8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiez committed Nov 22, 2024
1 parent 9c0996c commit 07aae0f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"name": "seven.io/sylius",
"prefer-stable": true,
"require": {
"php": "^8.0",
"sms77/api": "v2.5.0",
"php": "^8.2",
"seven.io/api": "v5.0.0",
"sylius/sylius": "~1.09.0 || ~1.10.0 || ~1.11.0 || ~1.12.0 || ~1.13.0 || ~1.14.0"
},
"require-dev": {
Expand Down
5 changes: 3 additions & 2 deletions src/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Seven\SyliusPlugin\Api;

use Sms77\Api\Client as ApiClient;
use Seven\Api\Client as ApiClient;
use Seven\Api\Resource\Sms\SmsResource;
use Seven\SyliusPlugin\Entity\Config;
use Seven\SyliusPlugin\Repository\ConfigRepository;
use Sylius\Component\Core\Model\OrderInterface;
Expand Down Expand Up @@ -35,7 +36,7 @@ public function sms($data): void {
->setText($text)
->setTo($to);

$client->sms($params);
(new SmsResource($client))->dispatch($params);
}

private function orderToPhone(OrderInterface $order): ?string {
Expand Down
12 changes: 8 additions & 4 deletions src/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace Seven\SyliusPlugin\Controller;

use FOS\RestBundle\View\View;
use Sms77\Api\Client;
use Sms77\Api\Params\SmsParams;
use Sms77\Api\Params\VoiceParams;
use Seven\Api\Client;
use Seven\Api\Resource\Sms\SmsParams;
use Seven\Api\Resource\Sms\SmsResource;
use Seven\Api\Resource\Voice\VoiceParams;
use Seven\Api\Resource\Voice\VoiceResource;
use Seven\SyliusPlugin\Entity\AbstractMessage;
use Seven\SyliusPlugin\Entity\Config;
use Seven\SyliusPlugin\Entity\Message;
Expand Down Expand Up @@ -131,7 +133,9 @@ private function getApiResponse(AbstractMessage $newResource): array {
$params = clone $params;
$params->setText($text);
$params->setTo($to);
$responses[] = $client->{$isSMS ? 'smsJson' : 'voiceJson'}($params);
$responses[] = $isSMS
? (new SmsResource($client))->dispatch($params)
: (new VoiceResource($client))->call($params);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/SmsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Seven\SyliusPlugin\Controller;

use Sms77\Api\Params\SmsParams;
use Seven\Api\Resource\Sms\SmsParams;
use Seven\SyliusPlugin\Entity\Config;

class SmsController extends AbstractController {
protected function buildParams(Config $cfg): SmsParams {
$params = new SmsParams;
$params = new SmsParams('', '');

$params->setDelay($cfg->getDelay());
$params->setFlash($cfg->getFlash());
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/VoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Seven\SyliusPlugin\Controller;

use Sms77\Api\Params\VoiceParams;
use Seven\Api\Resource\Voice\VoiceParams;
use Seven\SyliusPlugin\Entity\Config;

class VoiceController extends AbstractController {
protected function buildParams(Config $cfg): VoiceParams {
$params = new VoiceParams;
$params = new VoiceParams('', '');

return $params;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Table;
use Sms77\Api\Params\SmsParams;
use Sms77\Api\Params\VoiceParams;
use Seven\Api\Resource\Sms\SmsParams;
use Seven\Api\Resource\Voice\VoiceParams;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Model\TranslatableInterface;
use Sylius\Component\Resource\Model\TranslatableTrait;
Expand Down Expand Up @@ -205,7 +205,7 @@ public function getShippingText(): ?string {
}

public function getSmsParams(): SmsParams {
return (new SmsParams)
return (new SmsParams('', ''))
->setDelay($this->getDelay())
->setFlash($this->getFlash())
->setForeignId($this->getForeignId())
Expand All @@ -218,7 +218,7 @@ public function getSmsParams(): SmsParams {
}

public function getVoiceParams(): VoiceParams {
return (new VoiceParams)
return (new VoiceParams('', ''))
->setFrom($this->getFrom())
;
}
Expand Down

0 comments on commit 07aae0f

Please sign in to comment.