@@ -33,6 +33,7 @@ public function __construct(string $apiKey, callable $loggingFunction = null, in
3333 }
3434
3535 //region public API request functions
36+
3637 /**
3738 * This function should be used to effectively query Versium REACH APIs. See our API Documentation for more information
3839 * https://api-documentation.versium.com/reference/welcome
@@ -44,13 +45,15 @@ public function __construct(string $apiKey, callable $loggingFunction = null, in
4445 * ex. $inputData[0] = ["first" => "someFirstName", "last" => "someLastName", "email" => "someEmailAddress"];
4546 * @param array $outputTypes
4647 * This array should contain a list of strings where each string is a desired output type. This parameter is optional if the API you are using does not require output types
48+ * @param array $config
4749 * @return Generator
4850 */
49- public function append (string $ dataTool , array $ inputData , array $ outputTypes = []): Generator
51+ public function append (string $ dataTool , array $ inputData , array $ outputTypes = [], array $ config = [] ): Generator
5052 {
5153 $ requests = [];
5254 $ ctr = 0 ;
5355 $ baseURL = $ this ->constructAPIURL ($ dataTool );
56+ $ baseParams = [];
5457
5558 if (empty ($ inputData )) {
5659 $ this ->log ("append::No input data was given. " );
@@ -61,21 +64,25 @@ public function append(string $dataTool, array $inputData, array $outputTypes =
6164 $ baseURL .= "output[]= " . urlencode ($ outputType ) . "& " ;
6265 }
6366
67+ if ($ this ->timeout > 0 ) {
68+ $ baseParams ['rcfg_max_time ' ] = max ($ this ->timeout - .2 , .1 );
69+ }
70+
71+ if (!empty ($ config )) {
72+ $ baseParams = array_replace ($ baseParams , $ config );
73+ }
74+
6475 foreach ($ inputData as $ i => $ row ) {
6576 $ ctr ++;
6677 $ requests [$ i ] = [
67- 'url ' => $ baseURL . http_build_query ($ row ),
78+ 'url ' => $ baseURL . http_build_query (array_merge ( $ row, $ baseParams ) ),
6879 'headers ' => [
6980 "Accept: application/json " ,
7081 "x-versium-api-key: " . $ this ->apiKey ,
7182 ],
7283 'inputs ' => $ row
7384 ];
7485
75- if ($ this ->timeout > 0 ) {
76- $ requests [$ i ]['rcfg_max_time ' ] = max ($ this ->timeout - .2 , .1 );
77- }
78-
7986 if ($ ctr >= $ this ->qps ) {
8087 yield $ this ->createAndLimitRequests ($ requests );
8188
0 commit comments