lonnylot/telnyx-php-sdk

dev-master 2019-12-10 11:04 UTC

README

This is an SDK for the Telnyx API v2

NOTE Because the v2 API is still in development some of the v1 endpoints will exist in the \Lonnylot\Telnyx\Legacy namespace.

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require lonnylot/telnyx-php-sdk dev-master

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Dependencies

The library requires the CrudSugar library.

Getting Started

This library was made so you can interact with the Telnyx APIs.

Table of Contents

  1. Setup Client
  2. Available Resources
  3. Available Endpoints
  4. Use Endpoint

Available Resources

The resources are named as follows:

  1. index - Telnyx "List"
  2. show - Telnyx "Retrieve"
  3. update - Telnyx "Update"
  4. delete - Telnyx "Delete"
  5. store - Telnyx "Create"

Available Endpoints

  1. messagingProfile
  2. numberOrder
  3. numberSearch
  4. phoneNumber
  5. phoneNumberMessaging
  6. phoneNumberVoice

Setup Client

Non Laravel

$client = \Lonnylot\Telnyx\Client::getInstance('telnyx');
$client->setApiKey('<your key>');

Laravel

To use with Laravel you need to set your Telnyx API key in app/config/services.php

[
  'telnyx' => [
    'api_key' => env('TELNYX_API_KEY', ''),
  ]
]

Now you can dependency inject \Lonnylot\Telnyx\Client in your Laravel application and it will be ready to use.

Use Endpoint

To use an endpoint you simply call the endpoint from your client followed by the resource you want to use.

NOTE Keep in mind the resource mapping in the Available Resources section

$client->numberSearch->index(['filter' => ['limit' => 3, 'features' => ['sms', 'mms']]]);