SingletonApiResource.php 764 B

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