Skip to content

Commit f5434da

Browse files
author
SoftLayer
committed
Helper methods return the client object.
This will let you chain client methods together for clever one- liners if you wish.
1 parent 3a3e144 commit f5434da

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

SoftLayer/SoapClient.class.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,12 @@ public static function getClient($serviceName, $id = null, $username = null, $ap
283283
* @see removeHeader()
284284
* @param string $name The name of the header you wish to set
285285
* @param object $value The object you wish to set in this header
286+
* @return SoftLayer_SoapClient
286287
*/
287288
public function addHeader($name, $value)
288289
{
289290
$this->_headers[$name] = new SoapHeader($this->_endpointUrl, $name, $value);
291+
return $this;
290292
}
291293

292294
/**
@@ -296,10 +298,12 @@ public function addHeader($name, $value)
296298
*
297299
* @see addHeader()
298300
* @param string $name The name of the header you wish to remove
301+
* @return SoftLayer_SoapClient
299302
*/
300303
public function removeHeader($name)
301304
{
302305
unset($this->_headers[$name]);
306+
return $this;
303307
}
304308

305309
/**
@@ -311,6 +315,7 @@ public function removeHeader($name)
311315
* @link https://manage.softlayer.com/Administrative/apiKeychain API key management in the SoftLayer customer portal
312316
* @param string $username
313317
* @param string $apiKey
318+
* @return SoftLayer_SoapClient
314319
*/
315320
public function setAuthentication($username, $apiKey)
316321
{
@@ -330,6 +335,7 @@ public function setAuthentication($username, $apiKey)
330335
$header->apiKey = $apiKey;
331336

332337
$this->addHeader('authenticate', $header);
338+
return $this;
333339
}
334340

335341

@@ -344,6 +350,7 @@ public function setAuthentication($username, $apiKey)
344350
*
345351
* @link http://sldn.softlayer.com/wiki/index.php/Using_Initialization_Parameters_in_the_SoftLayer_API Using Initialization Parameters in the SoftLayer API
346352
* @param int $id The ID number of the SoftLayer API object you wish to instantiate.
353+
* @return SoftLayer_SoapClient
347354
*/
348355
public function setInitParameter($id)
349356
{
@@ -354,6 +361,8 @@ public function setInitParameter($id)
354361
$initParameters->id = $id;
355362
$this->addHeader($this->_serviceName . 'InitParameters', $initParameters);
356363
}
364+
365+
return $this;
357366
}
358367

359368
/**
@@ -367,6 +376,7 @@ public function setInitParameter($id)
367376
* @link http://sldn.softlayer.com/wiki/index.php/Using_Object_Masks_in_the_SoftLayer_API Using object masks in the SoftLayer API
368377
* @link http://sldn.softlayer.com/wiki/index.php/Category:API_methods_that_can_use_object_masks API methods that can use object masks
369378
* @param object $mask The object mask you wish to define
379+
* @return SoftLayer_SoapClient
370380
*/
371381
public function setObjectMask($mask)
372382
{
@@ -380,6 +390,8 @@ public function setObjectMask($mask)
380390

381391
$this->addHeader($this->_serviceName . 'ObjectMask', $objectMask);
382392
}
393+
394+
return $this;
383395
}
384396

385397
/**
@@ -393,6 +405,7 @@ public function setObjectMask($mask)
393405
* @link http://sldn.softlayer.com/wiki/index.php/Category:API_methods_that_can_use_result_limits API methods that can use result limits
394406
* @param int $limit The number of results to limit your SoftLayer API call to.
395407
* @param int $offset An optional offset to begin your SoftLayer API call's returned result set at.
408+
* @return SoftLayer_SoapClient
396409
*/
397410
public function setResultLimit($limit, $offset = 0)
398411
{
@@ -401,6 +414,7 @@ public function setResultLimit($limit, $offset = 0)
401414
$resultLimit->offset = intval($offset);
402415

403416
$this->addHeader('resultLimit', $resultLimit);
417+
return $this;
404418
}
405419

406420
/**

SoftLayer/XmlrpcClient.class.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public static function getClient($serviceName, $id = null, $username = null, $ap
234234
* @see removeHeader()
235235
* @param string $name The name of the header you wish to set
236236
* @param object $value The object you wish to set in this header
237+
* @return SoftLayer_XmlrpcClient
237238
*/
238239
public function addHeader($name, $value)
239240
{
@@ -242,6 +243,7 @@ public function addHeader($name, $value)
242243
}
243244

244245
$this->_headers[$name] = $value;
246+
return $this;
245247
}
246248

247249
/**
@@ -251,10 +253,12 @@ public function addHeader($name, $value)
251253
*
252254
* @see addHeader()
253255
* @param string $name The name of the header you wish to remove
256+
* @return SoftLayer_XmlrpcClient
254257
*/
255258
public function removeHeader($name)
256259
{
257260
unset($this->_headers[$name]);
261+
return $this;
258262
}
259263

260264
/**
@@ -266,6 +270,7 @@ public function removeHeader($name)
266270
* @link https://manage.softlayer.com/Administrative/apiKeychain API key management in the SoftLayer customer portal
267271
* @param string $username
268272
* @param string $apiKey
273+
* @return SoftLayer_XmlrpcClient
269274
*/
270275
public function setAuthentication($username, $apiKey)
271276
{
@@ -285,9 +290,9 @@ public function setAuthentication($username, $apiKey)
285290
$header->apiKey = $apiKey;
286291

287292
$this->addHeader('authenticate', $header);
293+
return $this;
288294
}
289295

290-
291296
/**
292297
* Set an initialization parameter header on a SoftLayer API call
293298
*
@@ -299,6 +304,7 @@ public function setAuthentication($username, $apiKey)
299304
*
300305
* @link http://sldn.softlayer.com/wiki/index.php/Using_Initialization_Parameters_in_the_SoftLayer_API Using Initialization Parameters in the SoftLayer API
301306
* @param int $id The ID number of the SoftLayer API object you wish to instantiate.
307+
* @return SoftLayer_XmlrpcClient
302308
*/
303309
public function setInitParameter($id)
304310
{
@@ -309,6 +315,8 @@ public function setInitParameter($id)
309315
$initParameters->id = $id;
310316
$this->addHeader($this->_serviceName . 'InitParameters', $initParameters);
311317
}
318+
319+
return $this;
312320
}
313321

314322
/**
@@ -322,6 +330,7 @@ public function setInitParameter($id)
322330
* @link http://sldn.softlayer.com/wiki/index.php/Using_Object_Masks_in_the_SoftLayer_API Using object masks in the SoftLayer API
323331
* @link http://sldn.softlayer.com/wiki/index.php/Category:API_methods_that_can_use_object_masks API methods that can use object masks
324332
* @param object $mask The object mask you wish to define
333+
* @return SoftLayer_XmlrpcClient
325334
*/
326335
public function setObjectMask($mask)
327336
{
@@ -335,6 +344,8 @@ public function setObjectMask($mask)
335344

336345
$this->addHeader($this->_serviceName . 'ObjectMask', $objectMask);
337346
}
347+
348+
return $this;
338349
}
339350

340351
/**
@@ -348,6 +359,7 @@ public function setObjectMask($mask)
348359
* @link http://sldn.softlayer.com/wiki/index.php/Category:API_methods_that_can_use_result_limits API methods that can use result limits
349360
* @param int $limit The number of results to limit your SoftLayer API call to.
350361
* @param int $offset An optional offset to begin your SoftLayer API call's returned result set at.
362+
* @return SoftLayer_XmlrpcClient
351363
*/
352364
public function setResultLimit($limit, $offset = 0)
353365
{
@@ -356,6 +368,7 @@ public function setResultLimit($limit, $offset = 0)
356368
$resultLimit->offset = intval($offset);
357369

358370
$this->addHeader('resultLimit', $resultLimit);
371+
return $this;
359372
}
360373

361374
/**

0 commit comments

Comments
 (0)