mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-14 02:27:23 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
|
@ -58,6 +58,9 @@ class JsonBody
|
|||
= $this->format($valueShape, $v);
|
||||
}
|
||||
}
|
||||
if (empty($data)) {
|
||||
return new \stdClass;
|
||||
}
|
||||
return $data;
|
||||
|
||||
case 'list':
|
||||
|
@ -81,7 +84,10 @@ class JsonBody
|
|||
return base64_encode($value);
|
||||
|
||||
case 'timestamp':
|
||||
return TimestampShape::format($value, 'unixTimestamp');
|
||||
$timestampFormat = !empty($shape['timestampFormat'])
|
||||
? $shape['timestampFormat']
|
||||
: 'unixTimestamp';
|
||||
return TimestampShape::format($value, $timestampFormat);
|
||||
|
||||
default:
|
||||
return $value;
|
||||
|
|
|
@ -144,7 +144,10 @@ class QueryParamBuilder
|
|||
$prefix,
|
||||
array &$query
|
||||
) {
|
||||
$query[$prefix] = TimestampShape::format($value, 'iso8601');
|
||||
$timestampFormat = !empty($shape['timestampFormat'])
|
||||
? $shape['timestampFormat']
|
||||
: 'iso8601';
|
||||
$query[$prefix] = TimestampShape::format($value, $timestampFormat);
|
||||
}
|
||||
|
||||
protected function format_boolean(Shape $shape, $value, $prefix, array &$query)
|
||||
|
|
|
@ -27,7 +27,7 @@ class RestJsonSerializer extends RestSerializer
|
|||
JsonBody $jsonFormatter = null
|
||||
) {
|
||||
parent::__construct($api, $endpoint);
|
||||
$this->contentType = JsonBody::getContentType($api);
|
||||
$this->contentType = 'application/json';
|
||||
$this->jsonFormatter = $jsonFormatter ?: new JsonBody($api);
|
||||
}
|
||||
|
||||
|
|
|
@ -123,8 +123,11 @@ abstract class RestSerializer
|
|||
|
||||
private function applyHeader($name, Shape $member, $value, array &$opts)
|
||||
{
|
||||
if ($member->getType() == 'timestamp') {
|
||||
$value = TimestampShape::format($value, 'rfc822');
|
||||
if ($member->getType() === 'timestamp') {
|
||||
$timestampFormat = !empty($member['timestampFormat'])
|
||||
? $member['timestampFormat']
|
||||
: 'rfc822';
|
||||
$value = TimestampShape::format($value, $timestampFormat);
|
||||
}
|
||||
if ($member['jsonvalue']) {
|
||||
$value = json_encode($value);
|
||||
|
@ -157,8 +160,14 @@ abstract class RestSerializer
|
|||
? $opts['query'] + $value
|
||||
: $value;
|
||||
} elseif ($value !== null) {
|
||||
if ($member->getType() === 'boolean') {
|
||||
$type = $member->getType();
|
||||
if ($type === 'boolean') {
|
||||
$value = $value ? 'true' : 'false';
|
||||
} elseif ($type === 'timestamp') {
|
||||
$timestampFormat = !empty($member['timestampFormat'])
|
||||
? $member['timestampFormat']
|
||||
: 'iso8601';
|
||||
$value = TimestampShape::format($value, $timestampFormat);
|
||||
}
|
||||
|
||||
$opts['query'][$member['locationName'] ?: $name] = $value;
|
||||
|
@ -186,11 +195,13 @@ abstract class RestSerializer
|
|||
$k = $isGreedy ? substr($matches[1], 0, -1) : $matches[1];
|
||||
if (!isset($varspecs[$k])) {
|
||||
return '';
|
||||
} elseif ($isGreedy) {
|
||||
return str_replace('%2F', '/', rawurlencode($varspecs[$k]));
|
||||
} else {
|
||||
return rawurlencode($varspecs[$k]);
|
||||
}
|
||||
|
||||
if ($isGreedy) {
|
||||
return str_replace('%2F', '/', rawurlencode($varspecs[$k]));
|
||||
}
|
||||
|
||||
return rawurlencode($varspecs[$k]);
|
||||
},
|
||||
$operation['http']['requestUri']
|
||||
);
|
||||
|
@ -201,6 +212,12 @@ abstract class RestSerializer
|
|||
$relative .= strpos($relative, '?') ? "&{$append}" : "?$append";
|
||||
}
|
||||
|
||||
// If endpoint has path, remove leading '/' to preserve URI resolution.
|
||||
$path = $this->endpoint->getPath();
|
||||
if ($path && $relative[0] === '/') {
|
||||
$relative = substr($relative, 1);
|
||||
}
|
||||
|
||||
// Expand path place holders using Amazon's slightly different URI
|
||||
// template syntax.
|
||||
return UriResolver::resolve($this->endpoint, new Uri($relative));
|
||||
|
|
|
@ -80,7 +80,7 @@ class XmlBody
|
|||
private function defaultShape(Shape $shape, $name, $value, XMLWriter $xml)
|
||||
{
|
||||
$this->startElement($shape, $name, $xml);
|
||||
$xml->writeRaw($value);
|
||||
$xml->text($value);
|
||||
$xml->endElement();
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,10 @@ class XmlBody
|
|||
XMLWriter $xml
|
||||
) {
|
||||
$this->startElement($shape, $name, $xml);
|
||||
$xml->writeRaw(TimestampShape::format($value, 'iso8601'));
|
||||
$timestampFormat = !empty($shape['timestampFormat'])
|
||||
? $shape['timestampFormat']
|
||||
: 'iso8601';
|
||||
$xml->writeRaw(TimestampShape::format($value, $timestampFormat));
|
||||
$xml->endElement();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue