PHP 8.2.31
Preview: ApiResource.php Size: 3.22 KB
/home/nshryvcy/blissfulnepal.com/wp-content/plugins/tourmaster/include/stripe/lib/ApiResource.php

<?php

namespace Stripe;

/**
 * Class ApiResource
 *
 * @package Stripe
 */
abstract class ApiResource extends StripeObject
{
    use ApiOperations\Request;

    /**
     * @return \Stripe\Util\Set A list of fields that can be their own type of
     * API resource (say a nested card under an account for example), and if
     * that resource is set, it should be transmitted to the API on a create or
     * update. Doing so is not the default behavior because API resources
     * should normally be persisted on their own RESTful endpoints.
     */
    public static function getSavedNestedResources()
    {
        static $savedNestedResources = null;
        if ($savedNestedResources === null) {
            $savedNestedResources = new Util\Set();
        }
        return $savedNestedResources;
    }

    /**
     * @var boolean A flag that can be set a behavior that will cause this
     * resource to be encoded and sent up along with an update of its parent
     * resource. This is usually not desirable because resources are updated
     * individually on their own endpoints, but there are certain cases,
     * replacing a customer's source for example, where this is allowed.
     */
    public $saveWithParent = false;

    public function __set($k, $v)
    {
        parent::__set($k, $v);
        $v = $this->$k;
        if ((static::getSavedNestedResources()->includes($k)) &&
            ($v instanceof ApiResource)) {
            $v->saveWithParent = true;
        }
        return $v;
    }

    /**
     * @return ApiResource The refreshed resource.
     */
    public function refresh()
    {
        $requestor = new ApiRequestor($this->_opts->apiKey, static::baseUrl());
        $url = $this->instanceUrl();

        list($response, $this->_opts->apiKey) = $requestor->request(
            'get',
            $url,
            $this->_retrieveOptions,
            $this->_opts->headers
        );
        $this->setLastResponse($response);
        $this->refreshFrom($response->json, $this->_opts);
        return $this;
    }

    /**
     * @return string The base URL for the given class.
     */
    public static function baseUrl()
    {
        return Stripe::$apiBase;
    }

    /**
     * @return string The endpoint URL for the given class.
     */
    public static function classUrl()
    {
        // Replace dots with slashes for namespaced resources, e.g. if the object's name is
        // "foo.bar", then its URL will be "/v1/foo/bars".
        $base = str_replace('.', '/', static::OBJECT_NAME);
        return "/v1/${base}s";
    }

    /**
     * @return string The instance endpoint URL for the given class.
     */
    public static function resourceUrl($id)
    {
        if ($id === null) {
            $class = get_called_class();
            $message = "Could not determine which URL to request: "
               . "$class instance has invalid ID: $id";
            throw new Error\InvalidRequest($message, null);
        }
        $id = Util\Util::utf8($id);
        $base = static::classUrl();
        $extn = urlencode($id);
        return "$base/$extn";
    }

    /**
     * @return string The full API URL for this API resource.
     */
    public function instanceUrl()
    {
        return static::resourceUrl($this['id']);
    }
}

Directory Contents

Dirs: 10 × Files: 74

Name Size Perms Modified Actions
- drwxr-xr-x 2024-05-28 15:48:43
Edit Download
Checkout DIR
- drwxr-xr-x 2024-05-28 15:48:43
Edit Download
Error DIR
- drwxr-xr-x 2024-05-28 15:48:44
Edit Download
- drwxr-xr-x 2024-05-28 15:48:43
Edit Download
Issuing DIR
- drwxr-xr-x 2024-05-28 15:48:43
Edit Download
Radar DIR
- drwxr-xr-x 2024-05-28 15:48:44
Edit Download
Reporting DIR
- drwxr-xr-x 2024-05-28 15:48:43
Edit Download
Sigma DIR
- drwxr-xr-x 2024-05-28 15:48:44
Edit Download
Terminal DIR
- drwxr-xr-x 2024-05-28 15:48:43
Edit Download
Util DIR
- drwxr-xr-x 2024-05-28 15:48:44
Edit Download
12.98 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
302 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
2.22 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
15.87 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
3.22 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
549 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
550 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
2.77 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.29 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
505 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
2.65 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
3.48 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.31 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
181 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
2.26 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
4.24 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
7.87 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
2.89 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
560 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
743 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
2.05 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
9.91 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
2.83 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
320 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
2.63 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
894 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
11.00 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
223 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.67 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
523 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
154 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
6.42 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
870 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
705 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
436 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
236 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
3.13 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
1.61 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
355 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
471 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
3.19 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.44 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
3.00 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
3.06 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
871 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.09 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
1.04 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
919 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
1.77 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
559 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.61 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
2.12 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
937 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
692 B lrw-r--r-- 2024-05-28 15:48:43
Edit Download
4.38 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
415 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
6.59 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
17.34 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
2.70 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.09 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
3.23 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
2.15 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
2.20 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
600 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
334 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
767 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.52 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
3.62 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download
1.42 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.21 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
383 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
1.46 KB lrw-r--r-- 2024-05-28 15:48:44
Edit Download
550 B lrw-r--r-- 2024-05-28 15:48:44
Edit Download
4.14 KB lrw-r--r-- 2024-05-28 15:48:43
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).