<?php

namespace PortalPeople\virtualstock\constants;

class ApiEndpoints
{
    public const SANDBOX    = 'https://www.sandbox.the-edge.io/restapi/v4/';
    public const PRODUCTION = 'https://www.the-edge.io/restapi/v4/';

    // Resource paths (relative to base URL)
    public const ORDERS              = 'orders/';
    public const ORDER               = 'orders/{id}/';
    public const ORDER_ACKNOWLEDGE   = 'orders/{id}/acknowledge/';
    public const ORDER_DISPATCH      = 'orders/{id}/dispatch/';
    public const ORDER_CANCEL        = 'orders/{id}/cancel/';

    public const PRODUCTS            = 'products/';
    public const PRODUCT             = 'products/{id}/';
    public const PRODUCT_STOCK       = 'products/{id}/stock/';

    public const SHIPMENTS           = 'shipments/';
    public const SHIPMENT            = 'shipments/{id}/';

    /**
     * Resolve a path template by replacing `{id}` with the given value.
     */
    public static function resolve(string $path, string $id): string
    {
        return str_replace('{id}', rawurlencode($id), $path);
    }
}
