PHP code example of mralston / quake-sdk

1. Go to this page and download the library: Download mralston/quake-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mralston / quake-sdk example snippets



use Mralston\Quake\Client;
use Mralston\Quake\Contact;
use Mralston\Quake\Flow;

// Log in
$client = new Client(
    $username,
    $password,
    $companyId,
    $apiEndpoint
);

// Create contact
$contact = $client->createContact(
    $firstName,
    $lastName,
    $mobileNumber
)

// Delete contact
$client->deleteContact($contact);

// Create flow instance
$flowInstance = $client->createFlowInstance(
    $flow,
    $contact,
    $parameters
);

// Fetch flow instance by ID
$flowInstance = $client->showFlowInstance($id);

// Invite a flow instance (trigger the flow)
$client->inviteFlowInstance($flowInstance);

// Fetch all flow instances
foreach ($client->listFlowInstances() as $flowInstance) {
    dump($flowInstance);
}

// Fetch all flows
foreach ($client->listFlows() as $flow) {
    dump($flow);
}

// Fetch all entities
foreach ($client->listEntities() as $entity) {
    dump($entity);
}

$client->createContact(
    $firstName,
    $lastName,
    $mobileNumber
)->createFlowInstance(
    Flow::make(['id' => $flowId])
)->invite();

$client = new Client(
    $username,
    $password,
    $companyId,
    $apiEndpoint,
    $webhookSecret
);

$crcToken = $_GET['crc_token'];
$response = $client->resolveWebhookChallenge($crcToken);

echo $response;

return [
    'username' => env('QUAKE_USERNAME'),
    'password' => env('QUAKE_PASSWORD'),
    'company_id' => env('QUAKE_COMPANY_ID'),
    'api_endpoint' => env('QUAKE_API_ENDPOINT'),
    'webhook_secret' => env('QUAKE_WEBHOOK_SECRET')
];

use Illuminate\Http\Request;
use Mralston\Quake\Client;

class MyController
{
    public function create(Request $request, Client $client)
    {
        // Create new contact using POST data
        $contact = $client->createContact(
            $request->input('first_name'),
            $request->input('last_name'),
            $request->input('mobile'),
        )
    }
}

use Mralston\Quake\Client;

$client = app(Client::class);

use Mralston\Quake\Facades\Quake;
use Mralston\Quake\Flow;

Quake::createContact(
    $firstName,
    $lastName,
    $mobileNumber
)->createFlowInstance(
    Flow::make(['id' => $flowId])
)->invite();
bash
php artisan vendor:publish --provider="Mralston\Quake\QuakeServiceProvider" --tag="config"