Snippets

Monil Gandhi Create Footers

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 add Footers for a personnel
 *        
 */

// 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\FootersApi();

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

// string | id of _personnel_
$salespersonid = "d1e5cb9c-def7-4273-85c7-46a1b5e46869";

// Braango\braangomodel\FootersInput |
$footersInput = new \Braango\braangomodel\FootersInput();

/*
 * { "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("Footer-create-s1002");

$footersInput->setHeader($hrd);

$footersInputBody = new model\FootersInputBody();

// Create Banners

$footersInputBody->setClientFooters($clientFooters = array(
    "s2002cf1-client api"
));

$footersInputBody->setDealerFooters($dealerFooters = array(
    "s2002df1-dealer api"
));

$footersInputBody->setSupervisorFooters($supervisorFooters = array(
    "s2002sf1-supervisor api"
));

$footersInput->setBody($footersInputBody);

try {
    $result = $api_instance->createFooters($subdealerid, $salespersonid, $footersInput);
    
    if ($result != null) {
        // Extract out response hdr and bdy
        $rspHdr = $result->getHeader();
        
        if ($requestHdr = ! null) {
            $rspId = $rspHdr->getId();
            $braangoRequestId = $rspHdr->getIsnRequestId();
            print_r("Response ID = " . $rspId . ", API Request Id = " . $braangoRequestId . "\n");
        }
        
        $rspBdy = $result->getBody();
        if ($rspBdy != null) {
            $status = $rspBdy->getStatus();
            
            // Typically this value should be always SUCCESS else exception will be thrown
            // Sometimes, this can be WARNING to indicate if any resource conflicted or not
            // In case of SUCCESS or WARNING, resources are always created (excepting warned sub-resources)
            print_r("Status = " . $status . "\n");
            
            $footersOutPutBodyData = $rspBdy->getData();
            
            $footersDealer = $footersOutPutBodyData->getDealerFooters();
            $footersClient = $footersOutPutBodyData->getClientFooters();
            $footersSupervisor = $footersOutPutBodyData->getSupervisorFooters();
            
            // Prints the Client, Dealer, and Supervisor footers
            
            print "Dealer Footers = ";
            print_r($footersDealer);
            
            print "Client Footers = ";
            print_r($footersClient);
            
            print "Supervisor Footers = ";
            print_r($footersSupervisor);
        }
    }
} catch (Exception $e) {
    echo 'Exception when calling FootersApi->createFooters: ', $e->getMessage(), PHP_EOL;
}
?>

Comments (0)