Snippets
Created by
Monil Gandhi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | <?php
use Braango\braangoapi\BraangonumbersApi;
use Braango\braangomodel as model;
use Braango\braangomodel\RequestHeader as rhdr;
require_once (__DIR__ . '/../../vendor/autoload.php');
/**
*
* @author braango
*
* Sample code showing how to create subDealer
*
*/
// 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\PersonnelsApi();
// Braango\braangomodel\SubDealerRequestInput |
$subDealerRequestInput = new \Braango\braangomodel\SubDealerRequestInput();
$typeAdfCRMEmail = FALSE;
/*
* { "api_key": "ISNGvAzwuy4X7vAqrtV", "id": "any value",
* "account_type": "partner" }
*/
$hdr = new rhdr();
// Set the account type to partner for
// virtual dealer and partner hosted
// accounts
$hdr->setAccountType("partner");
// dealer_api_key returned
// when partner_dealer was created
$hdr->setApiKey("ISNMdzuNiKG7jhl9d9v");
// ID that will be reflected back
$hdr->setId("create-sub-dealer-s2002");
$subDealerRequestInput->setHeader($hdr);
// Subdealer request body
$subDealerBody = new model\SubDealerBody();
// REQUIRED FIELDS
// Required field . Used for
// SMS login in to the UI
// For Braango Enterprise, this is don't care
// unless partner implements UI with SMS login
$subDealerBody->setSmsLogin(FALSE);
$subDealerBody->setDealerName("test dealer s2002");
// Create SubDealer creates full functional
// braango personnel with added capability
// Provide personnel name that is typical
// contact point
$subDealerBody->setPersonnelName("name of manager");
/*
* This is a user name created while signing this personnel up.
* Typically this user name can be used to log into the braango UI.
* However for whitelabel product, it is expected that this will be used
* for single signon with respect to dealer account on partner system.
* i.e. it is expected that partner will pass on the same user name that
* dealer has on its system to give seamless integration experience.
*/
$subDealerBody->setUserName("subdealer2002r1");
/*
* Password will be encrypted with SHA-25 and base64 encoded and stored
* internally within the braango system. pattern:
* ^(?=^.{6,10}$)(?=.*\d)(
* ?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+}{"
* ;:;'?/>.<,])(?!.*\s).*$
*
* Used for single sign on. needs to 6-10 characters with one capital,
* one numberal and one special character
*/
$subDealerBody->setPassword("test1T$");
/*
* pattern: ^(?:Starter|Small Business|Rooftop|Franchise)$
*
* Every sub_dealer needs to have braango package
*/
$subDealerBody->setPackage("Small Business");
// Required field. Indicates the
// ID for this business
// All internal resources, leads, personnel,
// braango number are associated with this id
// Needs to be unique within Braango system
//
// Will return error if there is clash
//
// Recommended to use unique naming convention
// or UUID string
$subDealerBody->setSubDealerId("subdealers2002");
$subDealerBody->setEmail("s2002r1@subdealer2002.com");
// If email specified is that for
// CRM email (ADF XML compliant)
$subDealerBody->setTypeAdfCrm($typeAdfCRMEmail);
/*
* Number where dealer's root account can be reached via SMS
* for leads
*
* pattern:^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$
*/
$subDealerBody->setPhoneNumber('4089763433');
/*
* Number where dealer's root account can be reached via SMS
* for leads
*
* pattern:^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$
*/
$subDealerBody->setSmsNumber('4089763433');
// List of dealer banners. Braango will
// randomly choose one when sending
// message to dealer via SMS
//
$dealerBanners = array(
"s2002db1"
);
$subDealerBody->setDealerBanners($dealerBanners);
// List of client banners. Braango
// will randomly choose one when
// sending dealer messages to client
$clientBanners = array(
's2002cb1'
);
$subDealerBody->setClientBanners($clientBanners);
// List of dealer footers. Braango will
// randomly choose one when sending
// message to dealer via SMS
//
$dealerFooters = array(
's2002df1'
);
$subDealerBody->setDealerFooters($dealerFooters);
// List of client footers. Braango
// will randomly choose one when
// sending dealer messages to client
$clientFooters = array(
's2002cf1'
);
$subDealerBody->setClientFooters($clientFooters);
// List of supervisor banners. Braango
// will randomly choose one when
// sending messages to supervisor
$supervisorBanners = array(
's2002sb1'
);
$subDealerBody->setSupervisorBanners($supervisorBanners);
// List of supervisor footers. Braango
// will randomly choose one when
// sending messages to supervisor
$supervisorFooters = array(
's2002sf1'
);
$subDealerBody->setSupervisorFooters($supervisorFooters);
// SubDealer's can create unique groups
// that personnel can subscribe to
$subDealerBody->setGroup('s2002g');
$subDealerRequestInput->setBody($subDealerBody);
try {
$result = $api_instance->createSubDealer($subDealerRequestInput);
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");
$salesPersonId = $rspBdy->getData()->getSalesPersonId();
print_r("SUCCESS : SalespersonID = " . $salesPersonId);
}
}
} catch (Exception $e) {
echo 'Exception when calling PersonnelsApi->createSubDealer: ', $e->getMessage(), PHP_EOL;
}
?>
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.