@@ -118,8 +118,12 @@ public function request(): Request
118118 $ uri ['LayerName ' ] = $ this ->LayerName ?? '' ;
119119 $ uriString = "/2018-10-31/layers/ {$ uri ['LayerName ' ]}/versions " ;
120120
121+ // Prepare Body
122+ $ bodyPayload = $ this ->requestBody ();
123+ $ body = empty ($ bodyPayload ) ? '{} ' : json_encode ($ bodyPayload );
124+
121125 // Return the Request
122- return new Request ('POST ' , $ uriString , $ query , $ headers , StreamFactory::create ($ this -> requestBody () ));
126+ return new Request ('POST ' , $ uriString , $ query , $ headers , StreamFactory::create ($ body ));
123127 }
124128
125129 /**
@@ -178,45 +182,30 @@ public function validate(): void
178182 }
179183 }
180184
181- private function requestBody (): string
185+ /**
186+ * @internal
187+ */
188+ private function requestBody (): array
182189 {
183190 $ payload = [];
184- $ indices = new \ stdClass ();
191+
185192 if (null !== $ v = $ this ->Description ) {
186193 $ payload ['Description ' ] = $ v ;
187194 }
195+ if (null !== $ v = $ this ->Content ) {
196+ $ payload ['Content ' ] = $ v ->requestBody ();
197+ }
188198
189- if (null !== $ this ->Content ) {
190- (static function (LayerVersionContentInput $ input ) use (&$ payload ) {
191- if (null !== $ v = $ input ->getS3Bucket ()) {
192- $ payload ['Content ' ]['S3Bucket ' ] = $ v ;
193- }
194-
195- if (null !== $ v = $ input ->getS3Key ()) {
196- $ payload ['Content ' ]['S3Key ' ] = $ v ;
197- }
198-
199- if (null !== $ v = $ input ->getS3ObjectVersion ()) {
200- $ payload ['Content ' ]['S3ObjectVersion ' ] = $ v ;
201- }
202-
203- if (null !== $ v = $ input ->getZipFile ()) {
204- $ payload ['Content ' ]['ZipFile ' ] = base64_encode ($ v );
205- }
206- })($ this ->Content );
199+ $ index = -1 ;
200+ foreach ($ this ->CompatibleRuntimes as $ mapValue ) {
201+ ++$ index ;
202+ $ payload ['CompatibleRuntimes ' ][$ index ] = $ mapValue ;
207203 }
208204
209- (static function (array $ input ) use (&$ payload , $ indices ) {
210- $ indices ->kea6f923 = -1 ;
211- foreach ($ input as $ value ) {
212- ++$ indices ->kea6f923 ;
213- $ payload ['CompatibleRuntimes ' ][$ indices ->kea6f923 ] = $ value ;
214- }
215- })($ this ->CompatibleRuntimes );
216205 if (null !== $ v = $ this ->LicenseInfo ) {
217206 $ payload ['LicenseInfo ' ] = $ v ;
218207 }
219208
220- return json_encode ( $ payload) ;
209+ return $ payload ;
221210 }
222211}
0 commit comments