<?php

namespace Modules\Package\Services;

use Illuminate\Http\Request;
use Modules\Order\Repositories\Payment\MyFatoorahPayment;
use Modules\Order\Services\PaymentService;
use Modules\Package\Interfaces\PackageRepositoryInterface;
use Modules\Package\Models\Package;
use Modules\Subscribe\Interfaces\SubscribeRepositoryInterface;
use Modules\Subscribe\Services\SubscribeService;

class PackageService
{
    private PackageRepositoryInterface $packageRepository ;
    public int $length = 12;
    public function __construct(PackageRepositoryInterface $packageRepository)
    {
        $this->packageRepository = $packageRepository;
    }

    public function get(Request $request)
    {
        $packages= $this->packageRepository->get($request);
        return $packages;
    }
    public function getItem(Package $package)
    {
        $package = $this->packageRepository->getItem($package);
        return $package;
    }
    public function save(Request $request, ?Package $package): Package
    {
        $package = $this->packageRepository->save($request,$package);
        return $package;
    }
    public function destroy(Request $request, int $id): array
    {
        $response = $this->packageRepository->destroy($request,$id);
        return $response;
    }
    public function destroyAll(Request $request): array
    {
        $response = $this->packageRepository->destroyAll($request);
        return $response;
    }
    public function restore(Request $request, int $id): array
    {
        $response = $this->packageRepository->restore($request,$id);
        return $response;
    }
    public function restoreAll(Request $request): array
    {
        $response = $this->packageRepository->restoreAll($request);
        return $response;
    }
    public function payment(Request $request,$package)
    {
        $url = $this->subscribeService->create($package);
        return $url;
    }
}
