Configuration.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\BillingPortal;
  4. /**
  5. * A portal configuration describes the functionality and behavior of a portal session.
  6. *
  7. * @property string $id Unique identifier for the object.
  8. * @property string $object String representing the object's type. Objects of the same type share the same value.
  9. * @property bool $active Whether the configuration is active and can be used to create portal sessions.
  10. * @property null|string|\Stripe\Application $application ID of the Connect Application that created the configuration.
  11. * @property \Stripe\StripeObject $business_profile
  12. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  13. * @property null|string $default_return_url The default URL to redirect customers to when they click on the portal's link to return to your website. This can be <a href="https://stripe.com/docs/api/customer_portal/sessions/create#create_portal_session-return_url">overriden</a> when creating the session.
  14. * @property \Stripe\StripeObject $features
  15. * @property bool $is_default Whether the configuration is the default. If <code>true</code>, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.
  16. * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
  17. * @property \Stripe\StripeObject $login_page
  18. * @property null|\Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  19. * @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
  20. */
  21. class Configuration extends \Stripe\ApiResource
  22. {
  23. const OBJECT_NAME = 'billing_portal.configuration';
  24. use \Stripe\ApiOperations\Update;
  25. /**
  26. * Creates a configuration that describes the functionality and behavior of a
  27. * PortalSession.
  28. *
  29. * @param null|array $params
  30. * @param null|array|string $options
  31. *
  32. * @throws \Stripe\Exception\ApiErrorException if the request fails
  33. *
  34. * @return \Stripe\BillingPortal\Configuration the created resource
  35. */
  36. public static function create($params = null, $options = null)
  37. {
  38. self::_validateParams($params);
  39. $url = static::classUrl();
  40. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  41. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  42. $obj->setLastResponse($response);
  43. return $obj;
  44. }
  45. /**
  46. * Returns a list of configurations that describe the functionality of the customer
  47. * portal.
  48. *
  49. * @param null|array $params
  50. * @param null|array|string $opts
  51. *
  52. * @throws \Stripe\Exception\ApiErrorException if the request fails
  53. *
  54. * @return \Stripe\Collection<\Stripe\BillingPortal\Configuration> of ApiResources
  55. */
  56. public static function all($params = null, $opts = null)
  57. {
  58. $url = static::classUrl();
  59. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  60. }
  61. /**
  62. * Retrieves a configuration that describes the functionality of the customer
  63. * portal.
  64. *
  65. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  66. * @param null|array|string $opts
  67. *
  68. * @throws \Stripe\Exception\ApiErrorException if the request fails
  69. *
  70. * @return \Stripe\BillingPortal\Configuration
  71. */
  72. public static function retrieve($id, $opts = null)
  73. {
  74. $opts = \Stripe\Util\RequestOptions::parse($opts);
  75. $instance = new static($id, $opts);
  76. $instance->refresh();
  77. return $instance;
  78. }
  79. /**
  80. * Updates a configuration that describes the functionality of the customer portal.
  81. *
  82. * @param string $id the ID of the resource to update
  83. * @param null|array $params
  84. * @param null|array|string $opts
  85. *
  86. * @throws \Stripe\Exception\ApiErrorException if the request fails
  87. *
  88. * @return \Stripe\BillingPortal\Configuration the updated resource
  89. */
  90. public static function update($id, $params = null, $opts = null)
  91. {
  92. self::_validateParams($params);
  93. $url = static::resourceUrl($id);
  94. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  95. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  96. $obj->setLastResponse($response);
  97. return $obj;
  98. }
  99. }