No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.swagger-codegen
docs
lib
test Fix May 3, 2018
.swagger-codegen-ignore
README.md
composer.json
git_push.sh
phpunit.xml.dist

README.md

This helper library is undergoing QA and currently not recommended for production use

karix-php

Overview

Karix API lets you interact with the Karix platform. It allows you to query your account, set up webhooks, send messages and buy phone numbers.

API and Clients Versioning

Karix APIs are versioned using the format vX.Y where X is the major version number and Y is minor. All minor version changes are backwards compatible but major releases are not. Please be careful when upgrading. A new user account is pinned to the latest version at the time of first request. By default every request sent Karix is processed using that version, even if there have been subsequent breaking changes. This is done to prevent existing user applications from breaking. You can change the pinned version for your account using the account dashboard. The default API version can be overridden by specifying the header api-version. Note: Specifying this value will not change your pinned version for other calls. Karix also provides HTTP API clients for all major languages. Release versions of these clients correspond to their API Version supported. Client version vX.Y.Z supports API version vX.Y. HTTP Clients are configured to use api-version header for that client version. When using official Karix HTTP Clients only, you dont need to concern yourself with pinned version. To upgrade your API version simply update the client.

Common Request Structures

All Karix APIs follow a common REST format with the following resources:

  • account
  • message
  • webhook
  • number

Creating a resource

To create a request send a POST request with the desired parameters in a JSON object to /<resource>/ url. A successful response will contain the details of the single resource created with HTTP status code 201 Created. Note: An exception to this is the Create Message API which is a bulk API and returns a list of message records.

Fetching a resource

To fetch a resource by its Unique ID send a GET request to /<resource>/<uid>/ where uid is the Alphanumeric Unique ID of the resource. A successful response will contain the details of the single resource fetched with HTTP status code 200 OK

Editing a resource

To edit certain parameters of a resource send a PATCH request to /<resource>/<uid>/ where uid is the Alphanumeric Unique ID of the resource, with a JSON object containing only the parameters which need to be updated. Edit resource APIs generally have no required parameters. A successful response will contain all the details of the single resource after editing.

Deleting a resource

To delete a resource send a DELETE request to /<resource>/<uid>/ where uid is the Alphanumeric Unique ID of the resource. A successful response will return HTTP status code 204 No Content with no body.

Fetching a list of resources

To fetch a list of resources send a GET request to /<resource>/ with filters as GET parameters. A successful response will contain a list of filtered paginated objects with HTTP status code 200 OK.

Pagination

Pagination for list APIs are controlled using GET parameters:

  • limit: Number of objects to be returned
  • offset: Number of objects to skip before collecting the output list.

Common Response Structures

All Karix APIs follow some common respose structures.

Success Responses

Single Resource Response

Responses returning a single object will have the following keys

Key Child Key Description
meta Meta Details about request and response
request_uuid Unique request identifier
data Details of the object

List Resource Response

Responses returning a list of objects will have the following keys

Key Child Key Description
meta Meta Details about request and response
request_uuid Unique request identifier
previous Link to the previous page of the list
next Link to the next page of the list
count Total number of objects over all pages
limit Limit the API was requested with
offset Page Offset the API was requested with
objects List of objects with details

Error Responses

Validation Error Response

Responses for requests which failed due to validation errors will have the follwing keys:

Key Child Key Description
meta Meta Details about request and response
request_uuid Unique request identifier
error Details for the error
message Error message
param (Optional) parameter this error relates to

Validation error responses will return HTTP Status Code 400 Bad Request

Insufficient Balance Response

Some requests will require to consume account credits. In case of insufficient balance the following keys will be returned:

Key Child Key Description
meta Meta Details about request and response
request_uuid Unique request identifier
error Details for the error
message Insufficient Balance

Insufficient balance response will return HTTP Status Code 402 Payment Required

This PHP package is automatically generated by the Swagger Codegen project:

  • API version: 1.0
  • Build package: io.swagger.codegen.languages.PhpClientCodegen

Requirements

PHP 5.5 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/karixtech/karix-php.git"
    }
  ],
  "require": {
    "karixtech/karix-php": "*@master"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP basic authorization: basicAuth
    $config = new \Swagger\Client\Configuration();
    $config->setUsername('AUTH_ID');
    $config->setPassword('AUTH_TOKEN');
$apiInstance = new Swagger\Client\Api\MessageApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$api_version = "1.0"; // string | API Version. If not specified your pinned verison is used.
$message = new \Swagger\Client\Model\CreateMessage(); // \Swagger\Client\Model\CreateAccount | Subaccount object
date_default_timezone_set('UTC');
$message->setDestination(["+1XXX8323XXX", "+1XXX3234XXX"]);
$message->setSource("+1XXX2321XXX");
$message->setText("Hello Friend");
try {
    $result = $apiInstance->sendMessage($api_version, $message);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MessageApi->createMessage: ', $e->getMessage(), PHP_EOL;
}
?>

Documentation for API Endpoints

All URIs are relative to https://api.karix.io

Class Method HTTP request Description
AccountsApi createSubaccount POST /account/ Create a new subaccount
AccountsApi getSubaccount GET /account/ Get a list of accounts
AccountsApi getSubaccountById GET /account/{uid}/ Get details of an account
AccountsApi patchSubaccount PATCH /account/{uid}/ Edit an account
MessageApi getMessage GET /message/ Get list of messages sent or received
MessageApi getMessageById GET /message/{uid}/ Get message details by id.
MessageApi sendMessage POST /message/ Send a message to a list of phone numbers
NumberApi getNumber GET /number/ Get details of all phone numbers linked to your account.
NumberApi numberNumDelete DELETE /number/{num}/ Unrent number from your account
NumberApi numberNumGet GET /number/{num}/ Get details of a number
NumberApi numberNumPatch PATCH /number/{num}/ Edit phone number belonging to your account
NumberApi rentNumber POST /number/ Rent a phone number
NumberSearchApi numbersearchGet GET /numbersearch/ Query for phone numbers in our inventory.
WebhookApi createWebhook POST /webhook/ Create webhooks to receive Message
WebhookApi deleteWebhookById DELETE /webhook/{uid}/ Delete a webhook by ID
WebhookApi getWebhook GET /webhook/ Get a list of your webhooks
WebhookApi getWebhookById GET /webhook/{uid}/ Get a webhook by ID
WebhookApi patchWebhook PATCH /webhook/{uid}/ Edit a webhook

Documentation For Models

Documentation For Authorization

basicAuth

  • Type: HTTP basic authentication

Author

support@karix.io