# media-cloud-sync/1.4.1/includes/sdk/s3/Aws/Api/Serializer/QuerySerializer.php

Media Cloud Sync, version 1.4.1. 55 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.4.1/code/includes/sdk/s3/Aws/Api/Serializer/QuerySerializer.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.4.1/raw/includes/sdk/s3/Aws/Api/Serializer/QuerySerializer.php
- Modified: 2026-05-10T10:14:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.4.1/code/includes/sdk/s3/Aws/Api/Serializer/QuerySerializer.php#L10-L20`.

```php
<?php

namespace Dudlewebs\WPMCS\s3\Aws\Api\Serializer;

use Dudlewebs\WPMCS\s3\Aws\Api\Service;
use Dudlewebs\WPMCS\s3\Aws\CommandInterface;
use Dudlewebs\WPMCS\s3\Aws\EndpointV2\EndpointProviderV2;
use Dudlewebs\WPMCS\s3\Aws\EndpointV2\EndpointV2SerializerTrait;
use Dudlewebs\WPMCS\s3\Aws\EndpointV2\Ruleset\RulesetEndpoint;
use Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7\Request;
use Dudlewebs\WPMCS\s3\Psr\Http\Message\RequestInterface;
/**
 * Serializes a query protocol request.
 * @internal
 */
class QuerySerializer
{
    use EndpointV2SerializerTrait;
    private $endpoint;
    private $api;
    private $paramBuilder;
    public function __construct(Service $api, $endpoint, ?callable $paramBuilder = null)
    {
        $this->api = $api;
        $this->endpoint = $endpoint;
        $this->paramBuilder = $paramBuilder ?: new QueryParamBuilder();
    }
    /**
     * When invoked with an AWS command, returns a serialization array
     * containing "method", "uri", "headers", and "body" key value pairs.
     *
     * @param CommandInterface $command Command to serialize into a request.
     * @param null $endpoint Endpoint resolved using EndpointProviderV2
     * @return RequestInterface
     */
    public function __invoke(CommandInterface $command, $endpoint = null)
    {
        $operation = $this->api->getOperation($command->getName());
        $body = ['Action' => $command->getName(), 'Version' => $this->api->getMetadata('apiVersion')];
        $commandArgs = $command->toArray();
        // Only build up the parameters when there are parameters to build
        if ($commandArgs) {
            $body += \call_user_func($this->paramBuilder, $operation->getInput(), $commandArgs);
        }
        $body = \http_build_query($body, '', '&', \PHP_QUERY_RFC3986);
        $headers = ['Content-Length' => \strlen($body), 'Content-Type' => 'application/x-www-form-urlencoded'];
        $requestUri = $operation['http']['requestUri'] ?? null;
        if ($endpoint instanceof RulesetEndpoint) {
            $this->setEndpointV2RequestOptions($endpoint, $headers);
        }
        $absoluteUri = \str_ends_with($this->endpoint, '/') ? $this->endpoint : $this->endpoint . $requestUri;
        return new Request('POST', $absoluteUri, $headers, $body);
    }
}

```
