Capability.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * This is an object representing a capability for a Stripe account.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/connect/account-capabilities">Account capabilities</a>
  8. *
  9. * @property string $id The identifier for the capability.
  10. * @property string $object String representing the object's type. Objects of the same type share the same value.
  11. * @property string|\Stripe\Account $account The account for which the capability enables functionality.
  12. * @property null|\Stripe\StripeObject $future_requirements
  13. * @property bool $requested Whether the capability has been requested.
  14. * @property null|int $requested_at Time at which the capability was requested. Measured in seconds since the Unix epoch.
  15. * @property null|\Stripe\StripeObject $requirements
  16. * @property string $status The status of the capability. Can be <code>active</code>, <code>inactive</code>, <code>pending</code>, or <code>unrequested</code>.
  17. */
  18. class Capability extends ApiResource
  19. {
  20. const OBJECT_NAME = 'capability';
  21. const STATUS_ACTIVE = 'active';
  22. const STATUS_INACTIVE = 'inactive';
  23. const STATUS_PENDING = 'pending';
  24. const STATUS_UNREQUESTED = 'unrequested';
  25. /**
  26. * @return string the API URL for this Stripe account reversal
  27. */
  28. public function instanceUrl()
  29. {
  30. $id = $this['id'];
  31. $account = $this['account'];
  32. if (!$id) {
  33. throw new Exception\UnexpectedValueException(
  34. 'Could not determine which URL to request: ' .
  35. "class instance has invalid ID: {$id}",
  36. null
  37. );
  38. }
  39. $id = Util\Util::utf8($id);
  40. $account = Util\Util::utf8($account);
  41. $base = Account::classUrl();
  42. $accountExtn = \urlencode($account);
  43. $extn = \urlencode($id);
  44. return "{$base}/{$accountExtn}/capabilities/{$extn}";
  45. }
  46. /**
  47. * @param array|string $_id
  48. * @param null|array|string $_opts
  49. *
  50. * @throws \Stripe\Exception\BadMethodCallException
  51. */
  52. public static function retrieve($_id, $_opts = null)
  53. {
  54. $msg = 'Capabilities cannot be retrieved without an account ID. ' .
  55. 'Retrieve a capability using `Account::retrieveCapability(' .
  56. "'account_id', 'capability_id')`.";
  57. throw new Exception\BadMethodCallException($msg);
  58. }
  59. /**
  60. * @param string $_id
  61. * @param null|array $_params
  62. * @param null|array|string $_options
  63. *
  64. * @throws \Stripe\Exception\BadMethodCallException
  65. */
  66. public static function update($_id, $_params = null, $_options = null)
  67. {
  68. $msg = 'Capabilities cannot be updated without an account ID. ' .
  69. 'Update a capability using `Account::updateCapability(' .
  70. "'account_id', 'capability_id', \$updateParams)`.";
  71. throw new Exception\BadMethodCallException($msg);
  72. }
  73. /**
  74. * @param null|array|string $opts
  75. *
  76. * @throws \Stripe\Exception\ApiErrorException if the request fails
  77. *
  78. * @return static the saved resource
  79. *
  80. * @deprecated The `save` method is deprecated and will be removed in a
  81. * future major version of the library. Use the static method `update`
  82. * on the resource instead.
  83. */
  84. public function save($opts = null)
  85. {
  86. $params = $this->serializeParameters();
  87. if (\count($params) > 0) {
  88. $url = $this->instanceUrl();
  89. list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
  90. $this->refreshFrom($response, $opts);
  91. }
  92. return $this;
  93. }
  94. }