@@ -48,6 +48,13 @@ class SauceRest
48
48
*/
49
49
private $ curlService ;
50
50
51
+ /**
52
+ * Transient options
53
+ *
54
+ * @var array
55
+ */
56
+ private $ transientOptions ;
57
+
51
58
/**
52
59
* Constructor
53
60
*
@@ -80,20 +87,31 @@ public function getCurlService()
80
87
return $ this ->curlService ?: ServiceFactory::getInstance ()->getService ('service.curl ' );
81
88
}
82
89
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
+
83
100
/**
84
101
* Execute Sauce Labs REST API command
85
102
*
86
103
* @param string $requestMethod HTTP request method
87
104
* @param string $url URL
88
105
* @param mixed $parameters Parameters
106
+ * @param array $extraOptions key=>value pairs of curl options to pass to curl_setopt()
89
107
*
90
108
* @return mixed
91
109
*
92
110
* @throws \WebDriver\Exception\CurlExec
93
111
*
94
112
* @see http://saucelabs.com/docs/saucerest
95
113
*/
96
- protected function execute ($ requestMethod , $ url , $ parameters = null )
114
+ protected function execute ($ requestMethod , $ url , $ parameters = null , $ extraOptions = array () )
97
115
{
98
116
$ extraOptions = array (
99
117
CURLOPT_HTTPAUTH => CURLAUTH_BASIC ,
@@ -109,7 +127,9 @@ protected function execute($requestMethod, $url, $parameters = null)
109
127
110
128
$ url = 'https://saucelabs.com/rest/v1/ ' . $ url ;
111
129
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 ();
113
133
114
134
return json_decode ($ rawResult , true );
115
135
}
0 commit comments