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 | /**
*
*/
package com.braango.virtualdealer.personnel.voice;
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.VoiceApi;
import com.braango.client.braangomodel.RequestHeader;
import com.braango.client.braangomodel.VoiceInput;
import com.braango.client.braangomodel.VoiceInputBody;
import com.braango.client.braangomodel.VoiceOutput;
import com.braango.client.braangomodel.VoiceOutputBodyDataVoiceList;
/**
* @author braango
*
* Sample code showing how to create add VOICE number for personnel
*
*/
public class CreateVoice {
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 personnel api. Personnel is hosted by subDealer
VoiceApi voiceApi = new VoiceApi(braangoApiClient);
ApiCallback<VoiceOutput> callBack = new ApiCallback<VoiceOutput>() {
@Override
public void onUploadProgress(long bytesWritten,
long contentLength,
boolean done) {
System.out
.println("Place holder for tracking"
+ " request progress");
}
@Override
public void onSuccess(VoiceOutput result, int statusCode,
Map<String, List<String>> responseHeaders) {
List<VoiceOutputBodyDataVoiceList> voiceList = result.getBody()
.getData().getVoiceList();
System.out.println("VOICE LIST : " + voiceList);
}
@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) {
}
};
// PersonnelRequestInput wraps RequestHeader and personnelRequestBody
VoiceInput voiceInput = new VoiceInput();
/*
* { "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("voice-create-s1002r2");
voiceInput.setHeader(hdr);
VoiceInputBody body = new VoiceInputBody();
// Create new SMS number for this personnel
body.setPhoneNumber("4088723444");
voiceInput.setBody(body);
try {
String subDealerId = "subdealers1002";
String salesPersonId = "0550c168-6117-45d5-a95f-e66593e6336b";
voiceApi.createVoiceAsync(subDealerId, salesPersonId, voiceInput,
callBack);
} catch (ApiException e1) {
e1.printStackTrace();
}
}
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.