@@ -51,40 +51,59 @@ public function __construct(string $collectionName, ApiCall $apiCall)
5151 */
5252 private function endPointPath (string $ action = '' ): string
5353 {
54- return sprintf ('%s/%s/%s/%s ' , Collections::RESOURCE_PATH , $ this ->collectionName , static ::RESOURCE_PATH , $ action );
54+ return sprintf (
55+ '%s/%s/%s/%s ' ,
56+ Collections::RESOURCE_PATH ,
57+ $ this ->collectionName ,
58+ static ::RESOURCE_PATH ,
59+ $ action
60+ );
5561 }
5662
5763 /**
5864 * @param array $document
65+ * @param array $options
5966 *
6067 * @return array
6168 * @throws TypesenseClientError|HttpClientException
6269 */
63- public function create (array $ document ): array
70+ public function create (array $ document, array $ options = [] ): array
6471 {
65- return $ this ->apiCall ->post ($ this ->endPointPath ('' ), $ document , true );
72+ return $ this ->apiCall ->post ($ this ->endPointPath ('' ), $ document , true , $ options );
6673 }
6774
6875 /**
6976 * @param array $document
77+ * @param array $options
7078 *
7179 * @return array
7280 * @throws TypesenseClientError|HttpClientException
7381 */
74- public function upsert (array $ document ): array
82+ public function upsert (array $ document, array $ options = [] ): array
7583 {
76- return $ this ->apiCall ->post ($ this ->endPointPath ('' ), $ document , true , ['action ' => 'upsert ' ]);
84+ return $ this ->apiCall ->post (
85+ $ this ->endPointPath ('' ),
86+ $ document ,
87+ true ,
88+ array_merge ($ options , ['action ' => 'upsert ' ])
89+ );
7790 }
7891
7992 /**
8093 * @param array $document
94+ * @param array $options
8195 *
8296 * @return array
8397 * @throws TypesenseClientError|HttpClientException
8498 */
85- public function update (array $ document ): array
99+ public function update (array $ document, array $ options = [] ): array
86100 {
87- return $ this ->apiCall ->post ($ this ->endPointPath ('' ), $ document , true , ['action ' => 'update ' ]);
101+ return $ this ->apiCall ->post (
102+ $ this ->endPointPath ('' ),
103+ $ document ,
104+ true ,
105+ array_merge ($ options , ['action ' => 'update ' ])
106+ );
88107 }
89108
90109 /**
@@ -109,8 +128,7 @@ public function createMany(array $documents, array $options = []): array
109128 *
110129 * @return string|array
111130 * @throws TypesenseClientError
112- * @throws GuzzleException
113- * @throws \JsonException
131+ * @throws \JsonException|HttpClientException
114132 */
115133 public function import ($ documents , array $ options = [])
116134 {
0 commit comments