<?phpuseBraango\braangomodelasmodel;useBraango\braangomodel\RequestHeaderasrhdr;require_once(__DIR__.'/../../vendor/autoload.php');/** * * @author braango * * Sample code showing how to create group for personnel * */// TEST auth token. Please contact// sales@braango.com to have one// created for youBraango\Configuration::getDefaultConfiguration()->setApiKey('auth_token','ISNWF0P30WM0CMK');$api_instance=newBraango\braangoapi\GroupsApi();// string | id of _sub_dealer_$subdealerid="subdealers2002";// string | id of _personnel_$salespersonid="aed72631-c968-4362-a9a4-ebe5bef8310b";// Braango\braangomodel\GroupInput |$groupInput=new\Braango\braangomodel\GroupInput();/* * { "api_key": "ISNGvAzwuy4X7vAqrtV", "id": "any value", * "account_type": "partner" } */$hrd=newrhdr();// 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("group-create-s1002r4");$groupInput->setHeader($hrd);$groupInputBody=newmodel\GroupInputBody();$groupInputBody->setGroup("Test Group");$groupInput->setBody($groupInputBody);try{$result=$api_instance->createGroup($subdealerid,$salespersonid,$groupInput);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");$groupOutputBodyData=$rspBdy->getData();print_r("Group List : ".$groupOutputBodyData);}}}catch(Exception$e){echo'Exception when calling GroupsApi->createGroup: ',$e->getMessage(),PHP_EOL;}?>
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.