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 | /**
*
*/
package com.braango.virtualdealer.communications.connects;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.braango.client.ApiCallback;
import com.braango.client.ApiClient;
import com.braango.client.ApiException;
import com.braango.client.braangoapi.BraangonumbersApi;
import com.braango.client.braangoapi.ConnectsApi;
import com.braango.client.braangoapi.EmailsApi;
import com.braango.client.braangoapi.GroupsApi;
import com.braango.client.braangoapi.MessagingApi;
import com.braango.client.braangoapi.WebhooksApi;
import com.braango.client.braangomodel.AddClient;
import com.braango.client.braangomodel.AddClientRequestInput;
import com.braango.client.braangomodel.BraangoNumberCreateInput;
import com.braango.client.braangomodel.BraangoNumberCreateInputBody;
import com.braango.client.braangomodel.BraangoNumberInput;
import com.braango.client.braangomodel.BraangoNumberOutput;
import com.braango.client.braangomodel.BraangoNumberOutputBodyData;
import com.braango.client.braangomodel.EmailOutputBodyData;
import com.braango.client.braangomodel.GroupOutput;
import com.braango.client.braangomodel.GroupOutputBodyData;
import com.braango.client.braangomodel.MessageBlast;
import com.braango.client.braangomodel.MessageBlastNumbers;
import com.braango.client.braangomodel.MessageBlastOutputWrapper;
import com.braango.client.braangomodel.MessageBlastOutputWrapperBodyData;
import com.braango.client.braangomodel.MessageBlastRequestInput;
import com.braango.client.braangomodel.RequestHeader;
import com.braango.client.braangomodel.EmailInput;
import com.braango.client.braangomodel.EmailInputBody;
import com.braango.client.braangomodel.EmailOutput;
import com.braango.client.braangomodel.WebhookOutput;
import com.braango.client.braangomodel.WebhookOutputBodyData;
/**
* @author braango
*
* Sample code showing how to use
* addClient api to add new
* client to a sub-dealer
*
* The api is very flexible with
* lots of options
*
* Please refer to api docs
* to see how to use all options
*
* Intent here is to show
* the relevant api and
* call needed
*
*
*/
public class AddClientCall {
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();
// TEST auth token. Please contact
// sales@braango.com to have one
// created for you
String authToken = "ISNWF0P30WM0CMK";
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 connects api.
ConnectsApi connectsApi = new ConnectsApi(braangoApiClient);
ApiCallback<Void> callBack = new ApiCallback<Void>() {
@Override
public void onUploadProgress(long bytesWritten,
long contentLength,
boolean done) {
System.out
.println("Place holder for tracking"
+ " request progress");
}
@Override
public void onSuccess(Void result, int statusCode,
Map<String, List<String>> responseHeaders) {
System.out.println("Add client status " + statusCode);
}
@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) {
}
};
// Wraps hdr and body
AddClientRequestInput addClientInput
= new AddClientRequestInput();
RequestHeader hdr = new RequestHeader();
hdr.setAccountType("partner");
hdr.setApiKey(apiKey);
hdr.setId("add-client-01");
addClientInput.setHeader(hdr);
// This is where the action happens
AddClient body = new AddClient();
// This is the client that is going
// to be seeded into the
// braango system for this subdealer and/or
// given personnel
//
// If the client already exists, it simply
// becomes upsert operation
body.setClientNumber("4089874333");
// Specifies if the added client
// is to be connected with
// the dealer. Default is
// true. If false
// then, to enable connection
// either call this api or dealerconnect
// api and specify enable = true
body.setConnectEnable(false);
// specify the braango number
// to be used. System will
// verify if the braango number
// is valid for given sub_dealer and/or personnel
//
// If not specified, partner's blast number will be
// used
//
// As a fallback Braango's general number will be used
// if everything fails
body.setBraangoNumber("555-555-5555");
// Allows to send initial seeding message
// to the client if this flag is true
body.setSendMessage(true);
// If this flag is true, seeding will not
// happen. This should be used after
// seeding has happened and
// api caller wants programmatic
// control of sending message to the
// client
body.setSendMessageOnly(false);
List<String> message = new ArrayList<String>();
message.add("Line 1 \n");
body.setMessage(message);
addClientInput.setBody(body);
try {
String subDealerId = "subdealers1002";
// Group for which the braango number is being created
String group = "DEFAULT";
String salesPersonId = "0550c168-6117-45d5-a95f-e66593e6336b";
; connectsApi.addClientAsync(subDealerId, salesPersonId, addClientInput, callBack);
} catch (ApiException e1) {
e1.printStackTrace();
}
}
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.