PPPStripeCollection

Class Collection.

Defined (1)

The class is defined in the following location(s).

/includes/api/stripe-php/lib/Collection.php  
  1. class Collection extends ApiResource 
  2. protected $_requestParams = array(); 
  3.  
  4. public function setRequestParams($params) 
  5. $this->_requestParams = $params; 
  6.  
  7. public function all($params = null, $opts = null) 
  8. list($url, $params) = $this->extractPathAndUpdateParams($params); 
  9.  
  10. list($response, $opts) = $this->_request('get', $url, $params, $opts); 
  11. $this->_requestParams = $params; 
  12. return Util\Util::convertToStripeObject($response, $opts); 
  13.  
  14. public function create($params = null, $opts = null) 
  15. list($url, $params) = $this->extractPathAndUpdateParams($params); 
  16.  
  17. list($response, $opts) = $this->_request('post', $url, $params, $opts); 
  18. $this->_requestParams = $params; 
  19. return Util\Util::convertToStripeObject($response, $opts); 
  20.  
  21. public function retrieve($id, $params = null, $opts = null) 
  22. list($url, $params) = $this->extractPathAndUpdateParams($params); 
  23.  
  24. $id = Util\Util::utf8($id); 
  25. $extn = urlencode($id); 
  26. list($response, $opts) = $this->_request( 
  27. 'get',  
  28. "$url/$extn",  
  29. $params,  
  30. $opts 
  31. ); 
  32. $this->_requestParams = $params; 
  33. return Util\Util::convertToStripeObject($response, $opts); 
  34.  
  35. /** 
  36. * @return AutoPagingIterator An iterator that can be used to iterate 
  37. * across all objects across all pages. As page boundaries are 
  38. * encountered, the next page will be fetched automatically for 
  39. * continued iteration. 
  40. */ 
  41. public function autoPagingIterator() 
  42. return new Util\AutoPagingIterator($this, $this->_requestParams); 
  43.  
  44. private function extractPathAndUpdateParams($params) 
  45. $url = parse_url($this->url); 
  46. if (!isset($url['path'])) { 
  47. throw new Error\Api("Could not parse list url into parts: $url"); 
  48.  
  49. if (isset($url['query'])) { 
  50. // If the URL contains a query param, parse it out into $params so they 
  51. // don't interact weirdly with each other. 
  52. $query = array(); 
  53. parse_str($url['query'], $query); 
  54. // PHP 5.2 doesn't support the ?: operator :( 
  55. $params = array_merge($params ? $params : array(), $query); 
  56.  
  57. return array($url['path'], $params);