@@ -122,12 +122,8 @@ public function __construct(array $config = [])
122122 */
123123 public function batchGetDocuments (array $ args )
124124 {
125- if (isset ($ args ['readTime ' ])) {
126- $ args ['readTime ' ] = $ this ->serializer ->decodeMessage (
127- new ProtobufTimestamp (),
128- $ args ['readTime ' ]
129- );
130- }
125+ $ args = $ this ->decodeTimestamp ($ args );
126+
131127 return $ this ->send ([$ this ->firestore , 'batchGetDocuments ' ], [
132128 $ this ->pluck ('database ' , $ args ),
133129 $ this ->pluck ('documents ' , $ args ),
@@ -195,6 +191,8 @@ public function batchWrite(array $args)
195191 */
196192 public function listCollectionIds (array $ args )
197193 {
194+ $ args = $ this ->decodeTimestamp ($ args );
195+
198196 return $ this ->send ([$ this ->firestore , 'listCollectionIds ' ], [
199197 $ this ->pluck ('parent ' , $ args ),
200198 $ this ->addRequestHeaders ($ args )
@@ -211,6 +209,7 @@ public function listDocuments(array $args)
211209 : [];
212210
213211 $ args ['mask ' ] = $ this ->documentMask ($ mask );
212+ $ args = $ this ->decodeTimestamp ($ args );
214213
215214 return $ this ->send ([$ this ->firestore , 'listDocuments ' ], [
216215 $ this ->pluck ('parent ' , $ args ),
@@ -242,6 +241,7 @@ public function runQuery(array $args)
242241 new StructuredQuery ,
243242 $ this ->pluck ('structuredQuery ' , $ args )
244243 );
244+ $ args = $ this ->decodeTimestamp ($ args );
245245
246246 return $ this ->send ([$ this ->firestore , 'runQuery ' ], [
247247 $ this ->pluck ('parent ' , $ args ),
@@ -278,6 +278,24 @@ private function addRequestHeaders(array $args)
278278 return $ args ;
279279 }
280280
281+ /**
282+ * Decodes the 'readTime' API format timestamp to Protobuf timestamp if
283+ * it is set.
284+ *
285+ * @param array $args
286+ * @return array
287+ */
288+ private function decodeTimestamp (array $ args )
289+ {
290+ if (isset ($ args ['readTime ' ])) {
291+ $ args ['readTime ' ] = $ this ->serializer ->decodeMessage (
292+ new ProtobufTimestamp (),
293+ $ args ['readTime ' ]
294+ );
295+ }
296+ return $ args ;
297+ }
298+
281299 /**
282300 * @access private
283301 * @codeCoverageIgnore
0 commit comments