PluginProbe
Media Cloud Sync / 1.2.0
Media Cloud Sync v1.2.0
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / Api / Serializer / QuerySerializer.php

QuerySerializer.php in Media Cloud Sync 1.2.0, at includes/sdk/s3/Aws/Api/Serializer/QuerySerializer.php

45 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Api\Serializer;
4
5 use Dudlewebs\WPMCS\s3\Aws\Api\Service;
6 use Dudlewebs\WPMCS\s3\Aws\CommandInterface;
7 use Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7\Request;
8 use Dudlewebs\WPMCS\s3\Psr\Http\Message\RequestInterface;
9 /**
10 * Serializes a query protocol request.
11 * @internal
12 */
13 class QuerySerializer
14 {
15 private $endpoint;
16 private $api;
17 private $paramBuilder;
18 public function __construct(Service $api, $endpoint, callable $paramBuilder = null)
19 {
20 $this->api = $api;
21 $this->endpoint = $endpoint;
22 $this->paramBuilder = $paramBuilder ?: new QueryParamBuilder();
23 }
24 /**
25 * When invoked with an AWS command, returns a serialization array
26 * containing "method", "uri", "headers", and "body" key value pairs.
27 *
28 * @param CommandInterface $command
29 *
30 * @return RequestInterface
31 */
32 public function __invoke(CommandInterface $command)
33 {
34 $operation = $this->api->getOperation($command->getName());
35 $body = ['Action' => $command->getName(), 'Version' => $this->api->getMetadata('apiVersion')];
36 $params = $command->toArray();
37 // Only build up the parameters when there are parameters to build
38 if ($params) {
39 $body += \call_user_func($this->paramBuilder, $operation->getInput(), $params);
40 }
41 $body = \http_build_query($body, '', '&', \PHP_QUERY_RFC3986);
42 return new Request('POST', $this->endpoint, ['Content-Length' => \strlen($body), 'Content-Type' => 'application/x-www-form-urlencoded'], $body);
43 }
44 }
45