|
| 1 | +<?php |
| 2 | + |
| 3 | +// File generated from our OpenAPI spec |
| 4 | + |
| 5 | +namespace Stripe; |
| 6 | + |
| 7 | +/** |
| 8 | + * Represents third-party gift cards that can be used as a payment method through Stripe. |
| 9 | + * |
| 10 | + * @property string $id Unique identifier for the object. |
| 11 | + * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 12 | + * @property string $brand The brand of the gift card. |
| 13 | + * @property null|int $exp_month The expiration month of the gift card. |
| 14 | + * @property null|int $exp_year The expiration year of the gift card. |
| 15 | + * @property null|GiftCardOperation|string $last_operation The last operation performed on this gift card. |
| 16 | + * @property null|string $last4 The last four digits of the gift card number. |
| 17 | + * @property bool $livemode If the object exists in live mode, the value is <code>true</code>. If the object exists in test mode, the value is <code>false</code>. |
| 18 | + */ |
| 19 | +class GiftCard extends ApiResource |
| 20 | +{ |
| 21 | + const OBJECT_NAME = 'gift_card'; |
| 22 | + |
| 23 | + const BRAND_FISERV_VALUELINK = 'fiserv_valuelink'; |
| 24 | + const BRAND_GIVEX = 'givex'; |
| 25 | + const BRAND_SVS = 'svs'; |
| 26 | + |
| 27 | + /** |
| 28 | + * Creates a gift card object. |
| 29 | + * |
| 30 | + * @param null|array{brand: string, exp_month?: int, exp_year?: int, expand?: string[], number?: string, pin?: string} $params |
| 31 | + * @param null|array|string $options |
| 32 | + * |
| 33 | + * @return GiftCard the created resource |
| 34 | + * |
| 35 | + * @throws Exception\ApiErrorException if the request fails |
| 36 | + */ |
| 37 | + public static function create($params = null, $options = null) |
| 38 | + { |
| 39 | + self::_validateParams($params); |
| 40 | + $url = static::classUrl(); |
| 41 | + |
| 42 | + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 43 | + $obj = Util\Util::convertToStripeObject($response->json, $opts); |
| 44 | + $obj->setLastResponse($response); |
| 45 | + |
| 46 | + return $obj; |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Retrieves a third-party gift card object. |
| 51 | + * |
| 52 | + * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key |
| 53 | + * @param null|array|string $opts |
| 54 | + * |
| 55 | + * @return GiftCard |
| 56 | + * |
| 57 | + * @throws Exception\ApiErrorException if the request fails |
| 58 | + */ |
| 59 | + public static function retrieve($id, $opts = null) |
| 60 | + { |
| 61 | + $opts = Util\RequestOptions::parse($opts); |
| 62 | + $instance = new static($id, $opts); |
| 63 | + $instance->refresh(); |
| 64 | + |
| 65 | + return $instance; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * @param null|array $params |
| 70 | + * @param null|array|string $opts |
| 71 | + * |
| 72 | + * @return GiftCardOperation the activated gift card operation |
| 73 | + * |
| 74 | + * @throws Exception\ApiErrorException if the request fails |
| 75 | + */ |
| 76 | + public function activate($params = null, $opts = null) |
| 77 | + { |
| 78 | + $url = $this->instanceUrl() . '/activate'; |
| 79 | + list($response, $opts) = $this->_request('post', $url, $params, $opts); |
| 80 | + $this->refreshFrom($response, $opts); |
| 81 | + |
| 82 | + return $this; |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * @param null|array $params |
| 87 | + * @param null|array|string $opts |
| 88 | + * |
| 89 | + * @return GiftCardOperation the cashouted gift card operation |
| 90 | + * |
| 91 | + * @throws Exception\ApiErrorException if the request fails |
| 92 | + */ |
| 93 | + public function cashout($params = null, $opts = null) |
| 94 | + { |
| 95 | + $url = $this->instanceUrl() . '/cashout'; |
| 96 | + list($response, $opts) = $this->_request('post', $url, $params, $opts); |
| 97 | + $this->refreshFrom($response, $opts); |
| 98 | + |
| 99 | + return $this; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * @param null|array $params |
| 104 | + * @param null|array|string $opts |
| 105 | + * |
| 106 | + * @return GiftCardOperation the checked gift card operation |
| 107 | + * |
| 108 | + * @throws Exception\ApiErrorException if the request fails |
| 109 | + */ |
| 110 | + public function checkBalance($params = null, $opts = null) |
| 111 | + { |
| 112 | + $url = $this->instanceUrl() . '/check_balance'; |
| 113 | + list($response, $opts) = $this->_request('post', $url, $params, $opts); |
| 114 | + $this->refreshFrom($response, $opts); |
| 115 | + |
| 116 | + return $this; |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * @param null|array $params |
| 121 | + * @param null|array|string $opts |
| 122 | + * |
| 123 | + * @return GiftCardOperation the reloaded gift card operation |
| 124 | + * |
| 125 | + * @throws Exception\ApiErrorException if the request fails |
| 126 | + */ |
| 127 | + public function reload($params = null, $opts = null) |
| 128 | + { |
| 129 | + $url = $this->instanceUrl() . '/reload'; |
| 130 | + list($response, $opts) = $this->_request('post', $url, $params, $opts); |
| 131 | + $this->refreshFrom($response, $opts); |
| 132 | + |
| 133 | + return $this; |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * @param null|array $params |
| 138 | + * @param null|array|string $opts |
| 139 | + * |
| 140 | + * @return GiftCardOperation the voided gift card operation |
| 141 | + * |
| 142 | + * @throws Exception\ApiErrorException if the request fails |
| 143 | + */ |
| 144 | + public function voidOperation($params = null, $opts = null) |
| 145 | + { |
| 146 | + $url = $this->instanceUrl() . '/void_operation'; |
| 147 | + list($response, $opts) = $this->_request('post', $url, $params, $opts); |
| 148 | + $this->refreshFrom($response, $opts); |
| 149 | + |
| 150 | + return $this; |
| 151 | + } |
| 152 | +} |
0 commit comments