Settings.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Tax;
  4. /**
  5. * You can use Tax <code>Settings</code> to manage configurations used by Stripe Tax calculations.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/tax/settings-api">Using the Settings API</a>
  8. *
  9. * @property string $object String representing the object's type. Objects of the same type share the same value.
  10. * @property \Stripe\StripeObject $defaults
  11. * @property null|\Stripe\StripeObject $head_office The place where your business is located.
  12. * @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.
  13. * @property string $status The <code>active</code> status indicates you have all required settings to calculate tax. A status can transition out of <code>active</code> when new required settings are introduced.
  14. * @property \Stripe\StripeObject $status_details
  15. */
  16. class Settings extends \Stripe\SingletonApiResource
  17. {
  18. const OBJECT_NAME = 'tax.settings';
  19. const STATUS_ACTIVE = 'active';
  20. const STATUS_PENDING = 'pending';
  21. /**
  22. * Retrieves Tax <code>Settings</code> for a merchant.
  23. *
  24. * @param null|array|string $opts
  25. *
  26. * @throws \Stripe\Exception\ApiErrorException if the request fails
  27. *
  28. * @return \Stripe\Tax\Settings
  29. */
  30. public static function retrieve($opts = null)
  31. {
  32. $opts = \Stripe\Util\RequestOptions::parse($opts);
  33. $instance = new static(null, $opts);
  34. $instance->refresh();
  35. return $instance;
  36. }
  37. /**
  38. * @param null|array $params
  39. * @param null|array|string $opts
  40. *
  41. * @throws \Stripe\Exception\ApiErrorException if the request fails
  42. *
  43. * @return static the updated resource
  44. */
  45. public static function update($params = null, $opts = null)
  46. {
  47. self::_validateParams($params);
  48. $url = '/v1/tax/settings';
  49. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  50. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  51. $obj->setLastResponse($response);
  52. return $obj;
  53. }
  54. /**
  55. * @param null|array|string $opts
  56. *
  57. * @throws \Stripe\Exception\ApiErrorException if the request fails
  58. *
  59. * @return static the saved resource
  60. *
  61. * @deprecated The `save` method is deprecated and will be removed in a
  62. * future major version of the library. Use the static method `update`
  63. * on the resource instead.
  64. */
  65. public function save($opts = null)
  66. {
  67. $params = $this->serializeParameters();
  68. if (\count($params) > 0) {
  69. $url = $this->instanceUrl();
  70. list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
  71. $this->refreshFrom($response, $opts);
  72. }
  73. return $this;
  74. }
  75. }