Snippets
Created by
Purvesh Khona
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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | /**
*
*/
package com.braango.virtualdealer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
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.PersonnelUpdate;
import com.braango.client.braangomodel.PersonnelUpdateRequestInput;
import com.braango.client.braangomodel.RequestHeader;
import com.braango.client.braangomodel.SubDealerBody;
import com.braango.client.braangomodel.SubDealerRequestInput;
/**
* @author braango
*
* Sample code showing how to create subDealer
*
*/
public class UpdatePersonnel {
static String basePath = "https://testapi2.braango.com/v2/braango";
/**
* @param args
*/
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
// created for you
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>() {
@Override
public void onUploadProgress(long bytesWritten, long contentLength,
boolean done) {
System.out
.println("Place holder for tracking request progress");
}
@Override
public void onSuccess(PersonnelOutputWrapper result,
int statusCode, Map<String, List<String>> responseHeaders) {
UUID salesPersonId = result.getBody().getData().getSalesPersonId();
System.out.println("SUCCESS : Updated SalespersonID = " + salesPersonId.toString());
}
@Override
public void onFailure(ApiException e, int statusCode,
Map<String, List<String>> responseHeaders) {
System.out.println("Error is " + statusCode + " "
+ e.getResponseBody());
}
@Override
public void onDownloadProgress(long bytesRead, long contentLength,
boolean done) {
}
};
// PersonnelUpdateInput wraps RequestHeader and personnelUpdate
PersonnelUpdateRequestInput personnelRequestInput = new PersonnelUpdateRequestInput();
/*
* { "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
// accounts
hdr.setAccountType("partner");
// dealer_api_key returned
// when partner_dealer was created
hdr.setApiKey(apiKey);
// ID that will be reflected back
hdr.setId("create-personnel-s1002r2");
personnelRequestInput.setHeader(hdr);
PersonnelUpdate body = new PersonnelUpdate();
// 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
body.setSmsLogin(false);
/*
* 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
*
* Chaning the password for the update call
*
*/
body.setPassword("test2T$");
// OPTIONAL FIELDS
// List of banners. Braango will
// randomly choose one when sending
// message to dealer via SMS
//
List<String> dealerBanners = new ArrayList<String>();
dealerBanners.add("s1002r2db1updated");
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("s1002r2cb1updated");
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("s1002r2sb1updated");
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("s1002r2df1updated");
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("s1002r2cf1updated");
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("s1002r2sf1updated");
body.setSupervisorFooters(supervisorFooters);
String email = "s1002r2@subdealer1002.com";
body.setEmail(email);
// 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
* for leads
*
* pattern:^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$
*/
String smsNumber = "4089763434";
body.setSmsNumber(smsNumber);
/*
* Number where personnel can be reached via voice
* for leads
*
* pattern:^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$
*
*/
String phoneNumber = "4089763434";
body.setPhoneNumber(phoneNumber);
//Subscribe to the group
String group = "s1002grp";
body.setGroup(group);
personnelRequestInput.setBody(body);
try {
String subDealerId = "subdealers1002";
// Existing salesperson
String salesPersonId = "c8e7f607-24b7-4805-a007-7482e9938d1e";
personnelsApi.updatePersonnelAsync(subDealerId,salesPersonId,personnelRequestInput, callBack);
} catch (ApiException e1) {
e1.printStackTrace();
}
}
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.