SingletonApiResource.php 704 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Stripe;
  3. abstract class SingletonApiResource extends ApiResource
  4. {
  5. protected static function _singletonRetrieve($options = null)
  6. {
  7. $opts = Util\RequestOptions::parse($options);
  8. $instance = new static(null, $opts);
  9. $instance->refresh();
  10. return $instance;
  11. }
  12. /**
  13. * @return string The endpoint associated with this singleton class.
  14. */
  15. public static function classUrl()
  16. {
  17. $base = static::className();
  18. return "/v1/${base}";
  19. }
  20. /**
  21. * @return string The endpoint associated with this singleton API resource.
  22. */
  23. public function instanceUrl()
  24. {
  25. return static::classUrl();
  26. }
  27. }