Snippets

Monil Gandhi Dealer Connect

Created by Monil Gandhi
<?php
use Braango\braangomodel as model;
use Braango\braangomodel\RequestHeader as rhdr;
require_once (__DIR__ . '/../../vendor/autoload.php');
/**
 *
 * @author braango
 *        
 *         Sample code showing how to use
 *         dealerConnect api to enable
 *         bridge between seeded client
 *         and the sub-dealer
 */

// TEST auth token. Please contact
// sales@braango.com to have one
// created for you
Braango\Configuration::getDefaultConfiguration()->setApiKey('auth_token', 'ISNWF0P30WM0CMK');

$api_instance = new Braango\braangoapi\ConnectsApi();

// string | id of _sub_dealer_
$subdealerid = "subdealers2002";

// string | id of _personnel_
$salespersonid = "aed72631-c968-4362-a9a4-ebe5bef8310b";

// Braango\braangomodel\DealerConnectRequestInput |
$dealerConnectRequestInput = new \Braango\braangomodel\DealerConnectRequestInput();

/*
 * { "api_key": "ISNGvAzwuy4X7vAqrtV", "id": "any value",
 * "account_type": "partner" }
 */
$hrd = new rhdr();

// dealer_api_key returned
// when partner_dealer was created
$hrd->setApiKey("ISNMdzuNiKG7jhl9d9v");

// Set the account type to partner for
// virtual dealer and partner hosted
// accounts
$hrd->setAccountType("partner");

// ID that will be reflected back

$hrd->setId("add-dealer-01");

$dealerConnectRequestInput->setHeader($hrd);

// This is where the action happens
$dealerConnectBody = new model\DealerConnect();

// This is the client that is going
// to be seeded into the
// braango system for this subdealer and/or
// given personnel
//
// If the client already exists, it simply
// becomes upsert operation
//
// This also informs braango
// which client to use for connecting
// to the subDealer personnel

$dealerConnectBody->setClientNumber("4089874333");

// Specifies if the client
// is to be connected with
// the dealer.

$dealerConnectBody->setConnectEnable(TRUE);

// specify the braango number
// to be used. System will
// verify if the braango number
// is valid for given sub_dealer and/or personnel
//
// If not specified, partner's blast number will be
// used
//
// As a fallback Braango's general number will be used
// if everything fails

$dealerConnectBody->setBraangoNumber("555-555-5555");

$message = array(
    "Line 1"
);

$dealerConnectBody->setMessage($message);

$dealerConnectRequestInput->setBody($dealerConnectBody);

try {
    $api_instance->dealerConnect($subdealerid, $salespersonid, $dealerConnectRequestInput);
    // status code
} catch (Exception $e) {
    echo 'Exception when calling ConnectsApi->dealerConnect: ', $e->getMessage(), PHP_EOL;
}
?>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.