+use Braango\braangomodel as model;
+use Braango\braangomodel\RequestHeader as rhdr;
+require_once (__DIR__ . '/../../vendor/autoload.php');
+ * Sample code showing how to create add email for personnel
+// TEST auth token. Please contact
+// sales@braango.com to have one
+Braango\Configuration::getDefaultConfiguration()->setApiKey('auth_token', 'ISNWF0P30WM0CMK');
+$api_instance = new Braango\braangoapi\EmailsApi();
+// string | id of _sub_dealer_
+$subdealerid = "subdealers2002";
+// string | if of _personnel_
+$salespersonid = "aed72631-c968-4362-a9a4-ebe5bef8310b";
+// Braango\braangomodel\EmailInput |
+$emailInput = new \Braango\braangomodel\EmailInput();
+// bool | Specifies to get ADF CRM email records or plain email records.
+// If not specified, default is false i.e. regular email ID accounts
+$typeAdfCrmEmail = FALSE;
+ * { "api_key": "ISNGvAzwuy4X7vAqrtV", "id": "any value",
+ * "account_type": "partner" }
+// dealer_api_key returned
+// when partner_dealer was created
+$hrd->setApiKey("ISNMdzuNiKG7jhl9d9v");
+// Set the account type to partner for
+// virtual dealer and partner hosted
+$hrd->setAccountType("partner");
+$hrd->setId("email-create-s2002r2");
+$emailInput->setHeader($hrd);
+$emailInputBody = new model\EmailInputBody();
+// Create new SMS number for this personnel
+$emailInputBody->setEmail("test7@subdealers2002.com");
+$emailInputBody->setTypeAdfCrm($typeAdfCrmEmail);
+$emailInput->setBody($emailInputBody);
+ $result = $api_instance->createEmail($subdealerid, $salespersonid, $emailInput);
+ // 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();
+ $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");
+ $emailOutPutBodyData = new model\EmailOutputBodyData();
+ $emailOutPutBodyData = $rspBdy->getData();
+ if ($typeAdfCrmEmail) {
+ $emails = $emailOutPutBodyData->getCrmEmailList();
+ $emails = $emailOutPutBodyData->getEmailList();
+ print_r(array_values($emails));
+} catch (Exception $e) {
+ echo 'Exception when calling EmailsApi->createEmail: ', $e->getMessage(), PHP_EOL;