@@ -48,6 +48,13 @@ class SauceRest
4848 */
4949 private $ curlService ;
5050
51+ /**
52+ * Transient options
53+ *
54+ * @var array
55+ */
56+ private $ transientOptions ;
57+
5158 /**
5259 * Constructor
5360 *
@@ -80,20 +87,31 @@ public function getCurlService()
8087 return $ this ->curlService ?: ServiceFactory::getInstance ()->getService ('service.curl ' );
8188 }
8289
90+ /**
91+ * Set transient options
92+ *
93+ * @param array $transientOptions
94+ */
95+ public function setTransientOptions ($ transientOptions )
96+ {
97+ $ this ->transientOptions = is_array ($ transientOptions ) ? $ transientOptions : array ();
98+ }
99+
83100 /**
84101 * Execute Sauce Labs REST API command
85102 *
86103 * @param string $requestMethod HTTP request method
87104 * @param string $url URL
88105 * @param mixed $parameters Parameters
106+ * @param array $extraOptions key=>value pairs of curl options to pass to curl_setopt()
89107 *
90108 * @return mixed
91109 *
92110 * @throws \WebDriver\Exception\CurlExec
93111 *
94112 * @see http://saucelabs.com/docs/saucerest
95113 */
96- protected function execute ($ requestMethod , $ url , $ parameters = null )
114+ protected function execute ($ requestMethod , $ url , $ parameters = null , $ extraOptions = array () )
97115 {
98116 $ extraOptions = array (
99117 CURLOPT_HTTPAUTH => CURLAUTH_BASIC ,
@@ -109,7 +127,9 @@ protected function execute($requestMethod, $url, $parameters = null)
109127
110128 $ url = 'https://saucelabs.com/rest/v1/ ' . $ url ;
111129
112- list ($ rawResult , $ info ) = $ this ->curlService ->execute ($ requestMethod , $ url , $ parameters , $ extraOptions );
130+ list ($ rawResult , $ info ) = $ this ->curlService ->execute ($ requestMethod , $ url , $ parameters , array_merge ($ extraOptions , $ this ->transientOptions ));
131+
132+ $ this ->transientOptions = array ();
113133
114134 return json_decode ($ rawResult , true );
115135 }
0 commit comments