Location.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Terminal;
  4. /**
  5. * A Location represents a grouping of readers.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/terminal/fleet/locations">Fleet management</a>
  8. *
  9. * @property string $id Unique identifier for the object.
  10. * @property string $object String representing the object's type. Objects of the same type share the same value.
  11. * @property \Stripe\StripeObject $address
  12. * @property null|string $configuration_overrides The ID of a configuration that will be used to customize all readers in this location.
  13. * @property string $display_name The display name of the location.
  14. * @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.
  15. * @property \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.
  16. */
  17. class Location extends \Stripe\ApiResource
  18. {
  19. const OBJECT_NAME = 'terminal.location';
  20. use \Stripe\ApiOperations\Update;
  21. /**
  22. * Creates a new <code>Location</code> object. For further details, including which
  23. * address fields are required in each country, see the <a
  24. * href="/docs/terminal/fleet/locations">Manage locations</a> guide.
  25. *
  26. * @param null|array $params
  27. * @param null|array|string $options
  28. *
  29. * @throws \Stripe\Exception\ApiErrorException if the request fails
  30. *
  31. * @return \Stripe\Terminal\Location the created resource
  32. */
  33. public static function create($params = null, $options = null)
  34. {
  35. self::_validateParams($params);
  36. $url = static::classUrl();
  37. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  38. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  39. $obj->setLastResponse($response);
  40. return $obj;
  41. }
  42. /**
  43. * Deletes a <code>Location</code> object.
  44. *
  45. * @param null|array $params
  46. * @param null|array|string $opts
  47. *
  48. * @throws \Stripe\Exception\ApiErrorException if the request fails
  49. *
  50. * @return \Stripe\Terminal\Location the deleted resource
  51. */
  52. public function delete($params = null, $opts = null)
  53. {
  54. self::_validateParams($params);
  55. $url = $this->instanceUrl();
  56. list($response, $opts) = $this->_request('delete', $url, $params, $opts);
  57. $this->refreshFrom($response, $opts);
  58. return $this;
  59. }
  60. /**
  61. * Returns a list of <code>Location</code> objects.
  62. *
  63. * @param null|array $params
  64. * @param null|array|string $opts
  65. *
  66. * @throws \Stripe\Exception\ApiErrorException if the request fails
  67. *
  68. * @return \Stripe\Collection<\Stripe\Terminal\Location> of ApiResources
  69. */
  70. public static function all($params = null, $opts = null)
  71. {
  72. $url = static::classUrl();
  73. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  74. }
  75. /**
  76. * Retrieves a <code>Location</code> object.
  77. *
  78. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  79. * @param null|array|string $opts
  80. *
  81. * @throws \Stripe\Exception\ApiErrorException if the request fails
  82. *
  83. * @return \Stripe\Terminal\Location
  84. */
  85. public static function retrieve($id, $opts = null)
  86. {
  87. $opts = \Stripe\Util\RequestOptions::parse($opts);
  88. $instance = new static($id, $opts);
  89. $instance->refresh();
  90. return $instance;
  91. }
  92. /**
  93. * Updates a <code>Location</code> object by setting the values of the parameters
  94. * passed. Any parameters not provided will be left unchanged.
  95. *
  96. * @param string $id the ID of the resource to update
  97. * @param null|array $params
  98. * @param null|array|string $opts
  99. *
  100. * @throws \Stripe\Exception\ApiErrorException if the request fails
  101. *
  102. * @return \Stripe\Terminal\Location the updated resource
  103. */
  104. public static function update($id, $params = null, $opts = null)
  105. {
  106. self::_validateParams($params);
  107. $url = static::resourceUrl($id);
  108. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  109. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  110. $obj->setLastResponse($response);
  111. return $obj;
  112. }
  113. }