Skip to content

avaamo/dashboard_java_sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Avaamo Dashboard SDK

Groups

Users

Broadcasts

Setup

Create a instance of AvaamoDashBoard

AvaamoDashBoard avaamoDashboard = AvaamoDashBoard.create("<Provide your dashborad access token>");

Groups

Create a Group

NewGroup newgroup = new NewGroup();
newgroup.setName("Group Name");
newgroup.setDescription("Group Description");
newgroup.addUser(User.findUserByEmail("<email of the user>").getId());//User to be added to the group
Admin admin = new Admin(User.findUserByEmail("<email of the admin>").getId());
newgroup.setAdmin(admin);
try {
GroupResponse response = avaamoDashboard.getGroupManager().createGroup(newgroup);
} catch (IOException e) {
e.printStackTrace();
}

Add member to group

//Add member to group
ArrayList<Integer> user_ids = new ArrayList<>();
User user1 = User.findUserByEmail("<email of the user>");
user_ids.add(user1.getId());
avaamoDashboard.getGroupManager().addMemberToGroup(<group_id>, user_ids);

Remove member from group

avaamoDashboard.getGroupManager().removeMemberFromGroup(<group_id>, <user_id>);

Change admin of the group

avaamoDashboard.getGroupManager().changeAdmin(<group_id>, <user_id>);

Update group details

Group group = new Group(853);
group.setDescription("Description”);
group.setAvatarImage(new File("test_image.jpg"));
GroupResponse groupResponse = avaamoDashboard.getGroupManager().updateGroup(group);

Get list of members in the group

GroupMembersResponse membersResponse= new GroupMembersResponse(<group_id>);
do{	
    ArrayList<GroupMember> group_members = membersResponse.getEntries();
}while(membersResponse.hasEntries());

Get list of groups

GroupListResponse listResponse= new GroupListResponse();
do{	
	ArrayList<Group> users = listResponse.getEntries();
}while(listResponse.hasEntries());

Get messages of the group

AttachedFile file = null;
GroupMessagesResponse messagesResponse= new GroupMessagesResponse(<group_id>);
do{	
	ArrayList<Message> group_messages = messagesResponse.getEntries();
	for (Iterator<Message> iterator = group_messages.iterator(); iterator.hasNext();) {
		Message message = (Message) iterator.next();
		System.out.println(""+message);
		if(message.hasAttachments()){
			List<AttachedFile> files = message.getAttachments().get(0).files;
			for (ListIterator<AttachedFile> iterator2 = files.listIterator(); iterator2.hasNext();) {
                file = (AttachedFile) iterator2.next();
				System.out.println(""+file);
			}
		}
	}
}while(messagesResponse.hasEntries());

//Provide folder name to which the file should be downloaded
boolean fileDownloaded = AvaamoDashBoard.getInstance().getAttachmentUtil().downloadAttachment(file, "downloads");

boolean fileDownloaded2 = AvaamoDashBoard.getInstance().getAttachmentUtil().downloadAttachment("68488",
"Temp_file.jpeg", "downloads");

Users

Create user

NewUser newuser = new NewUser();
newuser.setEmail("<email of the user>");
newuser.setPhoneNo("<phone no>");
newuser.setFirstName("<first name");
newuser.setLastName("<last name>");
try {
    int user_id = avaamoDashboard.getUserManager().createUser(newuser);
} catch (IOException e) {
e.printStackTrace();
}

Get User Details

User user = avaamoDashboard.getUserManager().getUser(user_id);

Update user details

User updatedUser = avaamoDashboard.getUserManager().updateUser(user);

Invite the user

InviteUserTemplate template = new InviteUserTemplate();
template.setFromName("<Name>");
template.setSmsBody("sms body goes here");
template.setSubject("Invite from sdk dashboard");
template.setTemplate("Template of the invite message");
avaamoDashboard.getUserManager().inviteUser(user_id, template);

Get all users

UserListResponse response= new UserListResponse();
do{	
ArrayList<User> users = response.getEntries();
}while(response.hasEntries());

Delete a user

avaamoDashboard.getUserManager().deleteUser(user_id);

Broadcasts

Send AnnouncementCard

image

AnnouncementCard ac = new AnnouncementCard();

// set header line
ac.setHeadline("Annoucement Heading: Check this out@@@");
ac.setShowcaseImage(new File("test_image.jpg"));
ac.setBody("This is the test body. It can be minimal rich text too. " + "Like <b>Bold</b> <i>Italic</i>.");

// set sender name and avatar
ac.setSender(new Sender(1, "Sender Name", "Display name"));

//Received User can reply to these users
ac.addReplyTo(35545);//Passing user ids here.
ac.addReplyTo(36284);

//Add attachemnts like simple link, video link and files 
ArrayList<BroadcastAttachment> attachments = new ArrayList<>();
attachments.add(new BroadcastAttachment(Type.LINK,"Attachment 1","https://www.google.com"));
ac.setAttachments(attachments);

ac.addTargetUsersList(createSampleBroadcastList().getId());

// send the broadcast
avaamoDashboard.sendBroadcast(ac);

Send CustomCard

![image](screenshots/Multi-field Card.png)

CustomCard customCard = new CustomCard();

customCard.setHeadline("MultiField Card");
customCard.setSender(new Sender(1196,"SDK Sender", null));

// Add Questions
customCard.addQuestion(new Signature("Sign here for sdk"));

// Add a poll
Poll poll = new Poll("Is sdk usefull for you?");
poll.addOption(0, "Yes");
poll.addOption(0, "No");
customCard.addQuestion(poll);

// Add a rating question
Rating rating = new Rating("Rate this sdk");
rating.setStarCount(5);
rating.setStartCount(2);// These values don't reflect
customCard.addQuestion(rating);


// single line text field
customCard.addQuestion(new SingleLineText("Single line text field"));

// multiline text field
customCard.addQuestion(new DataCapture("Data capture field"));

// Display only label. This can take minimal HTML as well
customCard.addQuestion(new LabelField("Label  field"));

// yes or no question
customCard.addQuestion(new Approval("Yes/No  field"));

// Number field
customCard.addQuestion(new Aggregate("Aggregate  field"));

// To Do items field
Checklist checklist = new Checklist("CheckList  field");
checklist.addOption(0, "Option 1");
checklist.addOption(0, "Option 2");
customCard.addQuestion(checklist);

//File attachment field
File file = new File("test_image.jpg");
customCard.addQuestion(new FileLabel("File sending..", file));

//Set expiry in hours(Without expiry also servers accepts the card..should we allow that?)
customCard.setExpiresIn(2);

customCard.addTargetUsersList(245);//Target user list id. If you don't have one create using "createSampleBroadcastList()"
try {
  avaamoDashboard.sendBroadcast(customCard);
} catch (IOException e) {
  e.printStackTrace();
}

Send Poll

![image](screenshots/Poll Card.png)

CustomCard customCard = new CustomCard();
customCard.setHeadline("Simple Poll");
customCard.setSender(new Sender(1196,"Dashboard SDK Sender", null));

// Add a poll
Poll poll = new Poll(" What is your preference?");
poll.addOption(0, "Yes");
poll.addOption(1, "No");
poll.addOption(2, "May Be");
customCar.addQuestion(poll);

		
BroadcastList bl = new BroadcastList("Simple User List");
bl.addUser(User.findUserByEmail("<User email>"));
		
// set target users
customCard.addTargetUsersList(BroadcastListUtil.createBroadcastList(bl).getId());
		
// set poll expiration - in hours
customCard.setExpiresIn(2);
		
BroadcastCardResponse res = avaamoDashboard.sendBroadcast(customCard);

Send Data Capture

![image](screenshots/Data Capture.png)

CustomCard customCard = new CustomCard();
customCard.setHeadline("Only Data capture Card");
customCard.setSender(new Sender(1196,"SDK Sender", null));//1196 is sender id. To create a new sender pass 0

// multiline text field
customCard.addQuestion(new DataCapture("Data capture field"));

BroadcastCardResponse res = avaamoDashboard.sendBroadcast(customCard);

Send ToDo List

![image](screenshots/ToDo List.png)

CustomCard customCard = new CustomCard();
customCard.setHeadline("Simple ToDo");
customCard.setSender(new Sender(1196,"Dashboard SDK Sender", null));

// To Do items field
Checklist checklist = new Checklist("CheckList  field");
checklist.addOption(0, "Option 1");
checklist.addOption(1, "Option 2");
customCard.addQuestion(checklist);

BroadcastList bl = new BroadcastList("Simple User List");
bl.addUser(User.findUserByEmail("<User email>"));
		
// set target users
customCard.addTargetUsersList(BroadcastListUtil.createBroadcastList(bl).getId());
		
// set expiration - in hours
customCard.setExpiresIn(2);
		
BroadcastCardResponse res = avaamoDashboard.sendBroadcast(customCard);

Send Rating Card

![image](screenshots/Rating Card.png)

CustomCard customCard = new CustomCard();
customCard.setHeadline("Simple Rating Card");
customCard.setSender(new Sender(1196,"Dashboard SDK Sender", null));

// Add a rating question
Rating rating = new Rating("Rate this sdk");
rating.setStarCount(5);
rating.setStartCount(2);
customCard.addQuestion(rating);
		
BroadcastList bl = new BroadcastList("Simple User List");
bl.addUser(User.findUserByEmail("<User email>"));
		
// set target users
customCard.addTargetUsersList(BroadcastListUtil.createBroadcastList(bl).getId());
		
// set expiration - in hours
customCard.setExpiresIn(2);
		
BroadcastCardResponse res = avaamoDashboard.sendBroadcast(customCard);

Send Location Card

image

CustomCard customCard = new CustomCard();
customCard.setHeadline("Simple Location Card");
customCard.setSender(new Sender(1196,"Dashboard SDK Sender", null));

// Add a location question
customCard.addQuestion(new Location("Please share your location"));
		
BroadcastList bl = new BroadcastList("Simple User List");
bl.addUser(User.findUserByEmail("<User email>"));
		
// set target users
customCard.addTargetUsersList(BroadcastListUtil.createBroadcastList(bl).getId());
		
// set expiration - in hours
customCard.setExpiresIn(2);
		
BroadcastCardResponse res = avaamoDashboard.sendBroadcast(customCard);

Send Approval Card

![image](screenshots/Approval Card.png)

CustomCard customCard = new CustomCard();
customCard.setHeadline("Simple Approval Card");
customCard.setSender(new Sender(1196,"Dashboard SDK Sender", null));

// yes or no question
customCard.addQuestion(new Approval("Yes/No  field"));
		
BroadcastList bl = new BroadcastList("Simple User List");
bl.addUser(User.findUserByEmail("<User email>"));
		
// set target users
customCard.addTargetUsersList(BroadcastListUtil.createBroadcastList(bl).getId());
		
// set expiration - in hours
customCard.setExpiresIn(2);
		
BroadcastCardResponse res = avaamoDashboard.sendBroadcast(customCard);

Send Data Aggregation Card

![image](screenshots/Data Aggregation.png)

CustomCard customCard = new CustomCard();
customCard.setHeadline("Simple Data Aggregation Card");
customCard.setSender(new Sender(1196,"Dashboard SDK Sender", null));

// Number field
customCard.addQuestion(new Aggregate("Enter the sales forecast this month?"));
		
BroadcastList bl = new BroadcastList("Simple User List");
bl.addUser(User.findUserByEmail("<User email>"));
		
// set target users
customCard.addTargetUsersList(BroadcastListUtil.createBroadcastList(bl).getId());
		
// set expiration - in hours
customCard.setExpiresIn(2);
		
BroadcastCardResponse res = avaamoDashboard.sendBroadcast(customCard);

Get Broadcast audience

//Provides list of audience of the given broadcast_card_id
BroadcastAudienceResponse audienceResponse = new BroadcastAudienceResponse(<broadcast_card_id>);
do{	
	ArrayList<User> audiences = audienceResponse.getEntries();
}while(audienceResponse.hasEntries());

Get All Broadcast cards

DashboardUser dashboardUser = avaamoDashboard.getDashboardUser();
/*dashboard_user_id can be used to fetch all broadcast cards sent by that user*/
int dashboard_user_id = dashboardUser.getId();
			
AllBroadcastCardsResponse allCardsResponse = new AllBroadcastCardsResponse(dashboard_user_id);
do{	
	ArrayList<BroadcastCardResponse> broadcast_cards = allCardsResponse.getEntries();
}while(allCardsResponse.hasEntries());

Fetch Poll Response

//Check the replies from the users for the given <broadcast_card_id>
BroadcastReplyManager replyManager = new BroadcastReplyManager(<broadcast_card_id>);
ArrayList<Question> questions = replyManager.getBroadcastReply().getQuestions();

for (Question question : questions) {
	System.out.print(" "+question);
}
System.out.println();

ArrayList<BroadcastReplyElement> replyElements = replyManager.getBroadcastReply().getResponses();
for (BroadcastReplyElement broadcastReplyElement : replyElements) {
	System.out.println("----------------");
	System.out.println(""+broadcastReplyElement.getUser());
	ArrayList<Reply> replies  = broadcastReplyElement.getReplies();
	for(Reply reply:replies){
		System.out.print(" "+reply);
	}
	System.out.println();
	System.out.println("----------------");
}

About

SDK to access the Avaamo Premium features

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors