Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/./../app/.././../../finland.picotech.app/public_html/storage/../vendor/./phpoption/../laravel/../tijsverkoyen/../barryvdh/laravel-dompdf/../../maennchen/zipstream-php/./src/.././../../barryvdh/../doctrine/../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

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

<?php

namespace Telnyx;

/**
 * Class TelephonyCredential
 *
 * @package Telnyx
 */
class TelephonyCredential extends ApiResource
{
    const OBJECT_NAME = "credential"; // The record_type is 'credential' and the endpoint is /telephony_credentials which is changed in classUrl() below

    use ApiOperations\All;
    use ApiOperations\Create;
    use ApiOperations\Retrieve;
    use ApiOperations\Update;
    use ApiOperations\Delete;

    /**
     * @return string The endpoint URL for the given class.
     */
    public static function classUrl()
    {
        // NOTE: This function override compensates for the different way this endpoint is spelled.
        // 'faxs' vs 'faxes'
        // Original function inside ApiResource.php
        return "/v2/telephony_credentials";
    }

    /**
     * Create an Access Token (JWT) for the credential.
     *
     * @param array|null $params
     * @param array|string|null $options
     *
     * @return string
     */
    public function token($params = null, $options = null)
    {
        $url = $this->instanceUrl() . '/token';

        $params = $params ?: [];
        $headers = $options ?: [];

        // This is basically the first half of Telnyx\ApiOperations\Request::_staticRequest() and we don't interpret as json unless there's an error
        $opts = \Telnyx\Util\RequestOptions::parse($options);
        $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
        $requestor = new \Telnyx\ApiRequestor($opts->apiKey, $baseUrl);

        // Instead of calling the neatly packaged request() function, we're calling _requestRaw()
        list($rbody, $rcode, $rheaders, $myApiKey) = $requestor->_requestRaw('post', $url, $params, $headers);

        // Remove headers that don't need to be persistent across other requests
        $opts->discardNonPersistentHeaders();

        if ($rcode < 200 || $rcode >= 300) { // If there is an error then we need to interpret as a json and return the error object
            $json = $requestor->_interpretResponse($rbody, $rcode, $rheaders);
            $resp = new ApiResponse($rbody, $rcode, $rheaders, $json);

            return $resp;
        }
        else { // Default response: raw token as string
            return $rbody;
        }
    }
}