+package com.braango.virtualdealer;
+import java.util.ArrayList;
+import com.braango.client.ApiCallback;
+import com.braango.client.ApiClient;
+import com.braango.client.ApiException;
+import com.braango.client.braangoapi.PersonnelsApi;
+import com.braango.client.braangomodel.HeaderResponse;
+import com.braango.client.braangomodel.PersonnelOutputWrapper;
+import com.braango.client.braangomodel.PersonnelRequest;
+import com.braango.client.braangomodel.PersonnelRequestInput;
+import com.braango.client.braangomodel.RequestHeader;
+import com.braango.client.braangomodel.SubDealerBody;
+import com.braango.client.braangomodel.SubDealerRequestInput;
+ * Sample code showing how to create subDealer
+public class CreatePersonnel {
+ static String basePath = "https://testapi2.braango.com/v2/braango";
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ ApiClient braangoApiClient = new ApiClient();
+ String authToken = "ISNWF0P30WM0CMK"; // TEST auth token. Please contact
+ // sales@braango.com to have one
+ braangoApiClient.setBasePath(basePath);
+ // Set the auth_token for api client to
+ // interact with Braango system
+ braangoApiClient.setApiKey(authToken);
+ // Api key is authorization to to access
+ // resources within braango system
+ // This key is different than auth_token
+ // that is used to validate the master account
+ String apiKey = "ISNfTMNOumV3xYNDd2g";
+ // Create personnel api. Personnel is hosted by subDealer
+ PersonnelsApi personnelsApi = new PersonnelsApi(braangoApiClient);
+ ApiCallback<PersonnelOutputWrapper> callBack = new ApiCallback<PersonnelOutputWrapper>() {
+ public void onUploadProgress(long bytesWritten, long contentLength,
+ .println("Place holder for tracking request progress");
+ public void onSuccess(PersonnelOutputWrapper result,
+ int statusCode, Map<String, List<String>> responseHeaders) {
+ UUID salesPersonId = result.getBody().getData().getSalesPersonId();
+ System.out.println("SUCCESS : SalespersonID = " + salesPersonId.toString());
+ public void onFailure(ApiException e, int statusCode,
+ Map<String, List<String>> responseHeaders) {
+ System.out.println("Error is " + statusCode + " "
+ + e.getResponseBody());
+ public void onDownloadProgress(long bytesRead, long contentLength,
+ // PersonnelRequestInput wraps RequestHeader and personnelRequestBody
+ PersonnelRequestInput personnelRequestInput = new PersonnelRequestInput();
+ * { "api_key": "ISNGvAzwuy4X7vAqrtV", "id": "any value",
+ * "account_type": "partner" }
+ RequestHeader hdr = new RequestHeader();
+ // Set the account type to partner for
+ // virtual dealer and partner hosted
+ hdr.setAccountType("partner");
+ // dealer_api_key returned
+ // when partner_dealer was created
+ // ID that will be reflected back
+ hdr.setId("create-personnel-s1002r3");
+ personnelRequestInput.setHeader(hdr);
+ PersonnelRequest body = new PersonnelRequest();
+ // 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
+ body.setSmsLogin(false);
+ body.setPersonnelName("personnel rep3");
+ * 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.
+ body.setUserName("subdealers1002r3");
+ * 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
+ body.setPassword("test1T$");
+ // List of banners. Braango will
+ // randomly choose one when sending
+ // message to dealer via SMS
+ List<String> dealerBanners = new ArrayList<String>();
+ dealerBanners.add("s1002r3db1");
+ body.setDealerBanners(dealerBanners);
+ // List of client banners. Braango
+ // will randomly choose one when
+ // sending dealer messages to client
+ List<String> clientBanners = new ArrayList<String>();
+ clientBanners.add("s1002r3cb1");
+ body.setClientBanners(clientBanners);
+ // List of supervisor banners. Braango
+ // will randomly choose one when
+ // sending messages to supervisor
+ List<String> supervisorBanners = new ArrayList<String>();
+ supervisorBanners.add("s1002r3sb1");
+ body.setSupervisorBanners(supervisorBanners);
+ // List of dealer footers. Braango will
+ // randomly choose one when sending
+ // message to dealer via SMS
+ List<String> dealerFooters = new ArrayList<String>();
+ dealerFooters.add("s1002r3df1");
+ body.setDealerFooters(dealerFooters);
+ // List of client footers. Braango
+ // will randomly choose one when
+ // sending dealer messages to client
+ List<String> clientFooters = new ArrayList<String>();
+ clientFooters.add("s1002r3cf1");
+ body.setClientFooters(clientFooters);
+ // List of supervisor footers. Braango
+ // will randomly choose one when
+ // sending messages to supervisor
+ List<String> supervisorFooters = new ArrayList<String>();
+ supervisorBanners.add("s1002r3sf1");
+ body.setSupervisorFooters(supervisorFooters);
+ String email = "s1002r3@subdealer1002.com";
+ // If email specified is that for
+ // CRM email (ADF XML compliant)
+ Boolean typeAdfCRMEmail = false;
+ body.setTypeAdfCrm(typeAdfCRMEmail);
+ * Number where personnel can be reached via SMS
+ * pattern:^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$
+ String smsNumber = "4089763435";
+ body.setSmsNumber(smsNumber);
+ * Number where personnel can be reached via voice
+ * pattern:^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$
+ String phoneNumber = "4089763435";
+ body.setPhoneNumber(phoneNumber);
+ //Subscribe to the group
+ String group = "s1002grp";
+ personnelRequestInput.setBody(body);
+ String subDealerId = "subdealers1002";
+ personnelsApi.createPersonnelAsync(subDealerId,personnelRequestInput, callBack);
+ } catch (ApiException e1) {