<?php

namespace Bixo\Payment\Policies;

use Bixo\Payment\Models\Gateway;
use Illuminate\Foundation\Auth\User as Authenticatable;

trait GatewayWorkflow
{

    /**
     * Determine if the given user can approve the given gateway.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function approve(Authenticatable $user, Gateway $gateway)
    {
        if ($user->canDo('payment.gateway.approve')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given gateway.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function submit(Authenticatable $user, Gateway $gateway)
    {
        if ($user->canDo('payment.gateway.submit')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given gateway.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function publish(Authenticatable $user, Gateway $gateway)
    {
        if ($user->canDo('payment.gateway.publish')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given gateway.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function unpublish(Authenticatable $user, Gateway $gateway)
    {
        if ($user->canDo('payment.gateway.unpublish')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given gateway.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function archive(Authenticatable $user, Gateway $gateway)
    {
        if ($user->canDo('payment.gateway.archive')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given gateway.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function unarchive(Authenticatable $user, Gateway $gateway)
    {
        if ($user->canDo('payment.gateway.unarchive')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given gateway.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function reject(Authenticatable $user, Gateway $gateway)
    {
        if ($user->canDo('payment.gateway.reject')) {
            return true;
        }

        return false;
    }

}