Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
146 lines (123 loc) · 4.13 KB

File metadata and controls

146 lines (123 loc) · 4.13 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package com.agilecrm.api;
import java.util.List;
import com.agilecrm.stubs.Contact;
import com.agilecrm.stubs.Note;
import com.agilecrm.stubs.NoteCollection;
import com.agilecrm.utils.StringUtils;
import com.sun.jersey.api.client.WebResource;
/**
* <code>NoteAPI</code> contains methods to add, get and delete notes from Agile
* CRM
*
* @author Tejaswi
* @since March 2013
* @see APIManager
*/
public class NoteAPI
{
/**
* Holds a {@link WebResource} object
*/
private final WebResource resource;
/**
* Initializes the field resource with the configured resource from
* {@link APIManager}
*
* @param resource
* {@link WebResource}
*/
NoteAPI(WebResource resource)
{
this.resource = resource;
}
/**
* Adds note to the list of contact id's in the Agile CRM based on the given
* parameters
*
* @param subject
* {@link String} subject of the {@link Note}
* @param description
* {@link String} description of the {@link Note}
* @param contactIds
* {@link List} of {@link String} id's of the {@link Contact} to
* which note is added
* @return Added {@link Note}
* @throws Exception
*/
public Note addNoteToContactIds(String subject, String description,
List<String> contactIds) throws Exception
{
System.out.println("Adding note ---------------------------------");
if (StringUtils.isNullOrEmpty(new String[] { subject, description }))
throw new Exception("subject or description of note is empty");
if (StringUtils.isNullOrEmpty(contactIds))
throw new Exception("Please specify contacts ids to add note");
Note note = new Note();
note.setSubject(subject);
note.setDescription(description);
note.setContact_ids(contactIds);
note = resource.path("/api/notes").post(Note.class, note);
return note;
}
/**
* Adds a note to Agile CRM with the given {@link Note} object
*
* @param note
* {@link Note} object to be added
* @param contactIds
* {@link List} of {@link String} id's of the {@link Contact}
* @return Added {@link Note}
* @throws Exception
*/
public Note addNoteToContactIds(Note note, List<String> contactIds)
throws Exception
{
System.out.println("Adding note ---------------------------------");
if (note == null)
throw new Exception("Cannot add a note without note object");
if (StringUtils.isNullOrEmpty(contactIds))
throw new Exception("Please specify contacts ids to add note");
note.setContact_ids(contactIds);
note = resource.path("/api/notes").post(Note.class, note);
return note;
}
/**
* Retrieves a {@link Note} from Agile CRM based on the id of the
* {@link Contact} to which note is related.
*
* @param contactId
* {@link String} id of the {@link Contact}
* @return {@link Note}
* @throws Exception
*/
public List<Note> getNotesByContactId(String contactId) throws Exception
{
System.out.println("Getting notes by contact id --------------------");
if (StringUtils.isNullOrEmpty(new String[] { contactId }))
throw new Exception("Please specify contact Id to get the notes");
NoteCollection notecollection = resource.path(
"/api/contacts/" + contactId + "/notes").get(
NoteCollection.class);
return notecollection.getNotes();
}
/**
* Deletes a {@link Note} in Agile CRM based on its id and id of the
* {@link Contact} to which it is related.
*
* @param contactId
* {@link String} id of the {@link Contact}
* @param noteId
* {@link String} id of the {@link Note}
* @throws Exception
*/
public void deleteNoteByContactId(String contactId, String noteId)
throws Exception
{
System.out.println("Deleting note --------------------------------");
if (StringUtils.isNullOrEmpty(new String[] { contactId, noteId }))
throw new Exception(
"Please specify contact id and note id to delete the notes");
resource.path("/api/contacts/" + contactId + "/notes/" + noteId)
.delete();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.