PluginProbe
Media Cloud Sync / 1.2.11
Media Cloud Sync v1.2.11
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 / RestJsonSerializer.php

RestJsonSerializer.php in Media Cloud Sync 1.2.11, at includes/sdk/s3/Aws/Api/Serializer/RestJsonSerializer.php

35 lines 1.1 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\Api\StructureShape;
7 /**
8 * Serializes requests for the REST-JSON protocol.
9 * @internal
10 */
11 class RestJsonSerializer extends RestSerializer
12 {
13 /** @var JsonBody */
14 private $jsonFormatter;
15 /** @var string */
16 private $contentType;
17 /**
18 * @param Service $api Service API description
19 * @param string $endpoint Endpoint to connect to
20 * @param JsonBody $jsonFormatter Optional JSON formatter to use
21 */
22 public function __construct(Service $api, $endpoint, JsonBody $jsonFormatter = null)
23 {
24 parent::__construct($api, $endpoint);
25 $this->contentType = JsonBody::getContentType($api);
26 $this->jsonFormatter = $jsonFormatter ?: new JsonBody($api);
27 }
28 protected function payload(StructureShape $member, array $value, array &$opts)
29 {
30 $body = isset($value) ? (string) $this->jsonFormatter->build($member, $value) : "{}";
31 $opts['headers']['Content-Type'] = $this->contentType;
32 $opts['body'] = $body;
33 }
34 }
35