<?php

namespace IpagWoocommerce;

class TransactionInquiryRequestTransformer implements TransformerInterface
{
    public function transform(array $request): array
    {
        $transformed = $request;

        $transformed['query'] = [];
        $transformed['body'] = null;
        $transformed['method'] = 'GET';

        if (ArrUtils::exists($request, 'body.transId')) {
            $transformed['query']['tid'] = ArrUtils::get($request, 'body.transId');
        }

        if (ArrUtils::exists($request, 'body.numPedido')) {
            $transformed['query']['order_id'] = ArrUtils::get($request, 'body.numPedido');
        }

        if (ArrUtils::exists($request, 'body.id')) {
            $transformed['query']['id'] = ArrUtils::get($request, 'body.id');
        }

        return $transformed;
    }
}
