Skip to content

Commit ed46ee1

Browse files
committed
Create README.md
1 parent aef5b66 commit ed46ee1

File tree

1 file changed

+392
-0
lines changed

1 file changed

+392
-0
lines changed

README.md

Lines changed: 392 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,392 @@
1+
#PHP API
2+
PHP Client to access Agile functionality
3+
4+
#Intro
5+
6+
1. Fill in your **AGILE_DOMAIN**, **AGILE_USER_EMAIL**, **AGILE_REST_API_KEY** in **curlwrapper.php**.
7+
8+
2. Copy and paste the source / include the **curlwrapper.php** in your php code.
9+
10+
3. You need to provide 3 paramaters to the curl_wrap function. They are **$entity**, **$data**, **$method**.
11+
12+
- **$entity** should be one of *"contacts/{id}", "contacts", "opportunity/{id}", "opportunity", "notes", "contacts/{contact_id}/notes", "contacts/{contact_id}/notes/{note_id}", "tasks/{id}", "tasks", "events", "events/{id}", "milestone/pipelines", "milestone/pipelines/{id}"* depending on requirement.
13+
14+
- **$data** must be stringified JSON.
15+
16+
```javascript
17+
$data = array(
18+
"properties"=>array(
19+
array(
20+
"name"=>"first_name",
21+
"value"=>"phprest",
22+
"type"=>"SYSTEM"
23+
),
24+
array(
25+
"name"=>"last_name",
26+
"value"=>"contact",
27+
"type"=>"SYSTEM"
28+
),
29+
array(
30+
"name"=>"email",
31+
"value"=>"[email protected]",
32+
"type"=>"SYSTEM"
33+
)
34+
)
35+
);
36+
37+
$data = json_encode($data);
38+
```
39+
40+
- **$method** can be set to
41+
42+
POST to create an entity (contact, deal, task, event).
43+
44+
GET to fetch an entity.
45+
46+
PUT to update entity.
47+
48+
DELETE to remove an entity.
49+
50+
#Usage
51+
52+
## 1. Contact
53+
54+
#### 1.1 To create a contact
55+
56+
```javascript
57+
$contact_json = array(
58+
"properties"=>array(
59+
array(
60+
"name"=>"first_name",
61+
"value"=>"phprest",
62+
"type"=>"SYSTEM"
63+
),
64+
array(
65+
"name"=>"last_name",
66+
"value"=>"contact",
67+
"type"=>"SYSTEM"
68+
),
69+
array(
70+
"name"=>"email",
71+
"value"=>"[email protected]",
72+
"type"=>"SYSTEM"
73+
)
74+
)
75+
);
76+
77+
$contact_json = json_encode($contact_json);
78+
curl_wrap("contacts", $contact_json, "POST");
79+
```
80+
81+
#### 1.2 To fetch contact data
82+
83+
```javascript
84+
curl_wrap("contacts/5722721933590528", null, "GET");
85+
```
86+
87+
#### 1.3 To delete a contact
88+
89+
```javascript
90+
curl_wrap("contacts/5722721933590528", null, "DELETE");
91+
```
92+
93+
#### 1.4 To update a contact
94+
95+
```javascript
96+
$contact_json = array(
97+
"id"=>5722721933590528,
98+
"properties"=>array(
99+
array(
100+
"name"=>"first_name",
101+
"value"=>"php",
102+
"type"=>"SYSTEM"
103+
),
104+
array(
105+
"name"=>"last_name",
106+
"value"=>"contact",
107+
"type"=>"SYSTEM"
108+
),
109+
array(
110+
"name"=>"email",
111+
"value"=>"[email protected]",
112+
"type"=>"SYSTEM"
113+
)
114+
)
115+
);
116+
117+
$contact_json = json_encode($contact_json);
118+
curl_wrap("contacts", $contact_json, "PUT");
119+
```
120+
121+
## 2. Company
122+
123+
#### 2.1 To create a company
124+
125+
```javascript
126+
$company_json = array(
127+
"type"=>"COMPANY",
128+
"properties"=>array(
129+
array(
130+
"name"=>"name",
131+
"value"=>"test company",
132+
"type"=>"SYSTEM"
133+
),
134+
array(
135+
"name"=>"url",
136+
"value"=>"https://www.testcompany.org",
137+
"type"=>"SYSTEM"
138+
)
139+
)
140+
);
141+
142+
$company_json = json_encode($company_json);
143+
curl_wrap("contacts", $company_json, "POST");
144+
```
145+
146+
#### 2.2 To get a company
147+
148+
```javascript
149+
curl_wrap("contacts/5695414665740288", null, "GET");
150+
```
151+
152+
#### 2.3 To delete a company
153+
154+
```javascript
155+
curl_wrap("contacts/5695414665740288", null, "DELETE")
156+
```
157+
#### 2.4 To update a company
158+
159+
```javascript
160+
$company_json = array(
161+
"id"=>5695414665740288,
162+
"type"=>"COMPANY",
163+
"properties"=>array(
164+
array(
165+
"name"=>"name",
166+
"value"=>"test company",
167+
"type"=>"SYSTEM"
168+
),
169+
array(
170+
"name"=>"url",
171+
"value"=>"https://www.test-company.org",
172+
"type"=>"SYSTEM"
173+
)
174+
)
175+
);
176+
177+
$company_json = json_encode($company_json);
178+
curl_wrap("contacts", $company_json, "PUT");
179+
```
180+
181+
# 3. Deal (Opportunity)
182+
183+
#### 3.1 To create a deal
184+
185+
```javascript
186+
$opportunity_json = array(
187+
"name"=>"test deal",
188+
"description"=>"this is a test deal",
189+
"expected_value"=>1000,
190+
"milestone"=>"Open",
191+
"probability"=>50,
192+
"close_date"=>1414317504,
193+
"contact_ids"=>array(5722721933590528)
194+
);
195+
196+
$opportunity_json = json_encode($opportunity_json);
197+
curl_wrap("opportunity", $opportunity_json, "POST");
198+
```
199+
#### 3.2 To get a deal
200+
201+
```javascript
202+
curl_wrap("opportunity/5739083074633728", null, "GET");
203+
```
204+
205+
#### 3.3 To delete a deal
206+
207+
```javascript
208+
curl_wrap("opportunity/5739083074633728", null, "DELETE");
209+
```
210+
211+
#### 3.4 To update deal
212+
213+
```javascript
214+
$opportunity_json = array(
215+
"id"=>5739083074633728,
216+
"name"=>"test",
217+
"description"=>"this is a test deal",
218+
"expected_value"=>1000,
219+
"milestone"=>"Open",
220+
"probability"=>50,
221+
"close_date"=>1414317504,
222+
"contact_ids"=>array(5722721933590528)
223+
);
224+
225+
$opportunity_json = json_encode($opportunity_json);
226+
curl_wrap("opportunity", $opportunity_json, "PUT");
227+
```
228+
229+
# 4. Note
230+
231+
#### 4.1 To create a note
232+
233+
```javascript
234+
$note_json = array(
235+
"subject"=>"test note",
236+
"description"=>"this is a test note",
237+
"contact_ids"=>array(5722721933590528),
238+
"owner_id"=>3103059
239+
);
240+
241+
$note_json = json_encode($note_json);
242+
curl_wrap("notes", $note_json, POST);
243+
```
244+
245+
#### 4.2 To get all notes *related to specific contact*
246+
247+
```javascript
248+
curl_wrap("contacts/5722721933590528/notes", null, "GET");
249+
```
250+
251+
#### 4.3 To update a note
252+
253+
```javascript
254+
$note_json = array(
255+
"id"=>1414322285,
256+
"subject"=>"note",
257+
"description"=>"this is a test note",
258+
"contact_ids"=>array(5722721933590528),
259+
"owner_id"=>3103059
260+
);
261+
262+
$note_json = json_encode($note_json);
263+
curl_wrap("notes", $note_json, "PUT");
264+
```
265+
266+
267+
# 5. Task
268+
269+
#### 5.1 To create a task
270+
271+
```javascript
272+
$task_json = array(
273+
"type"=>"MILESTONE",
274+
"priority_type"=>"HIGH",
275+
"due"=>1414671165,
276+
"contacts"=>array(5722721933590528),
277+
"subject"=>"this is a test task",
278+
"status"=>"YET_TO_START",
279+
"owner_id"=>3103059
280+
);
281+
282+
$task_json = json_encode($task_json);
283+
curl_wrap("tasks", $task_json, "POST");
284+
```
285+
286+
#### 5.2 To get a task
287+
288+
```javascript
289+
curl_wrap("tasks/5752207420948480", null, "GET");
290+
```
291+
292+
#### 5.3 To delete a task
293+
294+
```javascript
295+
curl_wrap("tasks/5752207420948480", null, "DELETE");
296+
```
297+
298+
#### 5.4 To update a task
299+
300+
```javascript
301+
$task_json = array(
302+
"id"=>5752207420948480,
303+
"type"=>"MILESTONE",
304+
"priority_type"=>"LOW",
305+
"due"=>1414671165,
306+
"contacts"=>array(5722721933590528),
307+
"subject"=>"this is a test task",
308+
"status"=>"YET_TO_START",
309+
"owner_id"=>3103059
310+
);
311+
312+
$task_json = json_encode($task_json);
313+
curl_wrap("tasks", $task_json, "PUT");
314+
```
315+
316+
# 6. Event
317+
#### 6.1 To create a event
318+
319+
```javascript
320+
$event_json = array(
321+
"start"=>1414155679,
322+
"end"=>1414328479,
323+
"title"=>"this is a test event",
324+
"contacts"=>array(5722721933590528),
325+
"allDay"=>true
326+
);
327+
328+
$event_json = json_encode($event_json);
329+
curl_wrap("events", $event_json, "POST");
330+
```
331+
332+
#### 6.2 To delete a event
333+
334+
```javascript
335+
curl_wrap("events/5703789046661120", null, "DELETE");
336+
```
337+
338+
#### 6.3 To update a event
339+
340+
```javascript
341+
$event_json = array(
342+
"id"=>5703789046661120,
343+
"start"=>1414155679,
344+
"end"=>1414328479,
345+
"title"=>"this is a test event",
346+
"contacts"=>array(5722721933590528),
347+
"allDay"=>false
348+
);
349+
350+
$event_json = json_encode($event_json);
351+
curl_wrap("events", $event_json, "PUT");
352+
```
353+
354+
# 7. Deal Tracks and Milestones
355+
356+
#### 7.1 To create a track
357+
358+
```javascript
359+
$milestone_json = array(
360+
"name"=>"new",
361+
"milestones"=>"one, two, three"
362+
);
363+
364+
$milestone_json = json_encode($milestone_json);
365+
curl_wrap("milestone/pipelines", $milestone_json, "POST")
366+
```
367+
368+
#### 7.2 To get all tracks
369+
370+
```javascript
371+
curl_wrap("milestone/pipelines", null, "GET");
372+
```
373+
374+
#### 7.3 To update track
375+
376+
```javascript
377+
$milestone_json = array(
378+
"id"=>5659711005261824,
379+
"name"=>"latest",
380+
"milestones"=>"one, two, three, four"
381+
);
382+
383+
$milestone_json = json_encode($milestone_json);
384+
curl_wrap("milestone/pipelines", $milestone_json, "PUT");
385+
```
386+
387+
388+
#### 7.4 To delete a track
389+
390+
```javascript
391+
curl_wrap("milestone/pipelines/5659711005261824", null, "DELETE");
392+
```

0 commit comments

Comments
 (0)