<?php

namespace SoftminalB2B\Http\Routes;

use SoftminalB2B\Http\Routes\Route;

if (!defined('ABSPATH')) {
    exit;
}

class Router {
    private $namespace;

    public function __construct() {
        $this->namespace = SMB2B_API_NAMESPACE;
    }

    public function init() {
        require_once SMB2B_DIR . 'includes/Http/api.php';
        add_action('rest_api_init', [$this, 'registerRoutes']);
    }

    public function registerRoutes() {
        if (empty($this->namespace)) {
            return;
        }

        try {
            Route::registerRoutes($this->namespace);
        } catch (\Exception $e) {
        }
    }
}
