/** * */ 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 callBack = new ApiCallback() { @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> responseHeaders) { System.out.println("Add client status " + statusCode); } @Override public void onFailure(ApiException e, int statusCode, Map> 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 message = new ArrayList(); 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(); } } }