Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/./../app/.././../../finland.picotech.app/public_html/storage/../vendor/./nikic/../dompdf/../alexandr-mironov/../monolog/../unicodeveloper/../dragonmantank/../telnyx/../filp/../phpstan/../nikic/../psy/.././messagebird/.././doctrine/.././telnyx/../ralouphie/../telnyx/telnyx-php/lib
الملفات الموجودة في هذا الـ Path:
.
..
Address.php
AlphanumericSenderID.php
ApiOperations
ApiRequestor.php
ApiResource.php
ApiResponse.php
AvailablePhoneNumber.php
Balance.php
BillingGroup.php
Brand.php
Call.php
CallControlApplication.php
Campaign.php
Collection.php
Conference.php
Connection.php
CredentialConnection.php
ErrorObject.php
Event.php
Exception
FQDN.php
FQDNConnection.php
Fax.php
FaxApplication.php
HttpClient
IP.php
IPConnection.php
InboundChannel.php
Message.php
MessagingHostedNumberOrder.php
MessagingPhoneNumber.php
MessagingProfile.php
MobileOperatorNetwork.php
NumberLookup.php
NumberOrder.php
NumberOrderDocument.php
NumberReservation.php
OtaUpdate.php
OutboundVoiceProfile.php
PhoneNumber
PhoneNumber.php
PhoneNumberAssignmentByProfile.php
PhoneNumberCampaign.php
PortingOrder.php
PortingPhoneNumber.php
Portout.php
RegulatoryRequirement.php
RequestTelemetry.php
ShortCode.php
SimCard.php
TelephonyCredential.php
Telnyx.php
TelnyxObject.php
Util
Verification.php
VerifyProfile.php
VerifyVerification.php
Webhook.php
WebhookSignature.php

مشاهدة ملف: ApiResource.php

<?php

namespace Telnyx;

/**
 * Class ApiResource
 *
 * @package Telnyx
 */
abstract class ApiResource extends TelnyxObject
{
    use ApiOperations\Request;

    /**
     * @return \Telnyx\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 Telnyx::$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 "/v2/foo/bars".
        $base = str_replace('.', '/', static::OBJECT_NAME);
        return "/v2/${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 Exception\UnexpectedValueException($message);
        }
        $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']);
    }
}