forked from agilecrm/java-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestNote.java
More file actions
72 lines (54 loc) · 1.79 KB
/
TestNote.java
File metadata and controls
72 lines (54 loc) · 1.79 KB
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
package com.test;
import java.util.ArrayList;
import java.util.List;
import com.agilecrm.api.APIManager;
import com.agilecrm.api.NoteAPI;
import com.agilecrm.stubs.Note;
/**
* <code>TestNote</code> class contains main method to test the methods in
* <code>NoteAPI</code> class.
*
* @author Ghanshyam
* @since October 2015
* @see NoteAPI
*/
public class TestNote
{
public static void main(String[] args)
{
try
{
String baseUrl = "https://ghanshyam.agilecrm.com/dev";
String userEmail = "ghanshyam.raut@agilecrm.com";
String restAPIKey = "***************************";
// Create a connection to Agile CRM
APIManager apiManager = new APIManager(baseUrl, userEmail, restAPIKey);
// Get the Note API with configured resource
NoteAPI noteApi = apiManager.getNoteAPI();
// List of contact id's to which notes are added
List<String> contactIds = new ArrayList<String>();
contactIds.add("5648063825707008");
contactIds.add("5692387351330816");
contactIds.add("5645452888244224");
// Adding note
Note note1 = new Note();
note1.setSubject("Test Note1");
note1.setDescription("Testing to add note1");
note1 = noteApi.addNoteToContactIds(note1, contactIds);
System.out.println("Added note..." + note1);
// Get notes of a contact
List<Note> notes = noteApi.getNotesByContactId(contactIds.get(0));
System.out.println("All notes of contact.. " + notes);
// Delete note of a contact by note id
String noteId = String.valueOf(notes.get(0).getId());
noteApi.deleteNoteByContactId(contactIds.get(0), noteId);
System.out.println("Deleted note.. " + noteId + " "
+ contactIds.get(0));
}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}