Skip to content

Commit 01b797d

Browse files
committed
format
1 parent 330bcca commit 01b797d

File tree

2 files changed

+59
-60
lines changed

2 files changed

+59
-60
lines changed

README.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ PHP Client to Access Agile Functionality
1818
JSON data format should be as shown below. Email is mandatory.
1919

2020
```php
21-
$contact_json = array(
21+
$contact_json = array(
2222
"email" => "[email protected]",
2323
"first_name" => "test",
2424
"last_name" => "contact",
2525
"tags" => "tag1, tag2"
26-
);
26+
);
2727

2828
$contact_json = json_encode($contact_json);
2929
```
@@ -46,9 +46,7 @@ PHP Client to Access Agile Functionality
4646

4747
```php
4848
$contact_json = array(
49-
50-
51-
"email" => "[email protected]",
49+
"email" => "[email protected]",
5250
"first_name" => "test",
5351
"last_name" => "contact",
5452
"tags" => "tag1, tag2",
@@ -57,7 +55,7 @@ $contact_json = array(
5755
"phone" => "+1-541-754-3010",
5856
"website" => "http://www.example.com",
5957
"address" => "{\"city\":\"new delhi\", \"state\":\"delhi\",\"country\":\"india\"}"
60-
);
58+
);
6159

6260
$contact_json = json_encode($contact_json);
6361

@@ -84,11 +82,11 @@ curl_wrap("contact", $json, "DELETE");
8482
###### 1.4 To update a contact
8583

8684
```php
87-
$contact_json = array(
85+
$contact_json = array (
8886
"email" => "[email protected]",
8987
"website" => "http://www.example.com",
9088
"company" => "abc corp"
91-
);
89+
);
9290

9391
$contact_json = json_encode($contact_json);
9492

@@ -100,11 +98,11 @@ curl_wrap("contact", $contact_json, "PUT");
10098
###### 2.1 To add Note
10199

102100
```php
103-
$note_json = array(
101+
$note_json = array(
104102
"email" => "[email protected]",
105103
"subject" => "test",
106104
"description" => "note added"
107-
);
105+
);
108106

109107
$note_json = json_encode($note_json);
110108

@@ -125,10 +123,10 @@ curl_wrap("note", $json, "GET");
125123
###### 3.1 To add score to contact
126124

127125
```php
128-
$score_json = array(
126+
$score_json = array(
129127
"email" => "[email protected]",
130128
"score" => "50"
131-
);
129+
);
132130

133131
$score_json = json_encode($score_json);
134132

@@ -158,11 +156,12 @@ curl_wrap("score", $json, "PUT");
158156

159157
```php
160158
$task_json = array(
161-
"email" => "[email protected]",
162-
"type" => "MEETING",
163-
"priority_type" => "HIGH",
164-
"subject" => "test"
165-
);
159+
"email" => "[email protected]",
160+
"type" => "MEETING",
161+
"priority_type" => "HIGH",
162+
"subject" => "test",
163+
"due" => "1376047332"
164+
);
166165

167166
$task_json = json_encode($task_json);
168167

@@ -183,14 +182,14 @@ curl_wrap("task", $json, "GET");
183182

184183
```php
185184
$deal_json = array(
186-
"email" => "[email protected]",
187-
"name" => "Test Deal",
188-
"description" => "testing deal",
189-
"expected_value" => "100",
190-
"milestone" => "won",
191-
"probability" => "5",
192-
"close_date" => "1376047332"
193-
);
185+
"email" => "[email protected]",
186+
"name" => "Test Deal",
187+
"description" => "testing deal",
188+
"expected_value" => "100",
189+
"milestone" => "won",
190+
"probability" => "5",
191+
"close_date" => "1376047332"
192+
);
194193

195194
$deal_json = json_encode($deal_json);
196195

@@ -213,9 +212,9 @@ curl_wrap("deal", $json, "GET");
213212

214213
```php
215214
$tag_json = array(
216-
"email" => "[email protected]",
217-
"tags" => "tag1, tag2, tag3, tag4, tag5"
218-
);
215+
"email" => "[email protected]",
216+
"tags" => "tag1, tag2, tag3, tag4, tag5"
217+
);
219218

220219
$tag_json = json_encode($tag_json);
221220

@@ -234,9 +233,9 @@ curl_wrap("tags", $json, "GET");
234233

235234
```php
236235
$rm_tags_json = array(
237-
"email" => "[email protected]",
238-
"tags" => "tag3, tag4"
239-
);
236+
"email" => "[email protected]",
237+
"tags" => "tag3, tag4"
238+
);
240239

241240
$rm_tags_json = json_encode($rm_tags_json);
242241

sample.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* Fuction to make an HTTP call using curl
99
*
1010
* @param String $subject Entity to perform action on
11-
* @param String $json JSON data to send on HTTP call
12-
* @param String $action The HTTP method to use
11+
* @param String $json JSON data to send on HTTP call
12+
* @param String $action The HTTP method to use
1313
* @return String
1414
*/
1515
function curl_wrap ($subject, $json, $action)
@@ -19,31 +19,31 @@ function curl_wrap ($subject, $json, $action)
1919
CURLOPT_FOLLOWLOCATION=>true,
2020
CURLOPT_MAXREDIRS=>10,
2121
));
22-
switch($action)
23-
{
24-
case "POST":
25-
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey);
26-
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"POST");
27-
curl_setopt($ch,CURLOPT_POSTFIELDS,$json);
28-
break;
29-
case "GET":
30-
$json = json_decode($json);
31-
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"GET");
32-
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey.'&email='.$json->{'email'});
33-
break;
34-
case "PUT":
35-
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey);
36-
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"PUT");
37-
curl_setopt($ch,CURLOPT_POSTFIELDS,$json);
38-
break;
39-
case "DELETE":
40-
$json = json_decode($json);
41-
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey.'&email='.$json->{'email'});
42-
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"DELETE");
43-
break;
44-
default:
45-
break;
46-
}
22+
switch($action)
23+
{
24+
case "POST":
25+
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey);
26+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"POST");
27+
curl_setopt($ch,CURLOPT_POSTFIELDS,$json);
28+
break;
29+
case "GET":
30+
$json = json_decode($json);
31+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"GET");
32+
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey.'&email='.$json->{'email'});
33+
break;
34+
case "PUT":
35+
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey);
36+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"PUT");
37+
curl_setopt($ch,CURLOPT_POSTFIELDS,$json);
38+
break;
39+
case "DELETE":
40+
$json = json_decode($json);
41+
curl_setopt($ch,CURLOPT_URL,'https://'.domain.'.agilecrm.com/core/php/api/'.$subject.'?id='.apikey.'&email='.$json->{'email'});
42+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"DELETE");
43+
break;
44+
default:
45+
break;
46+
}
4747
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
4848
curl_setopt_array($ch, array(
4949
CURLOPT_RETURNTRANSFER=>true,
@@ -111,8 +111,8 @@ function curl_wrap ($subject, $json, $action)
111111

112112
# To add a deal to contact
113113
$deal_json = array("name"=>"Test Deal", "description"=>"testing deal", "expected_value"=>"100", "milestone"=>"won",
114-
"probability"=>"5", "close_date"=>"1376047332", "email"=>"[email protected]");
115-
# close date in epoch time
114+
"probability"=>"5", "close_date"=>"1376047332", "email"=>"[email protected]");
115+
# close date in epoch time
116116
$deal_json = json_encode($deal_json);
117117
curl_wrap("deal", $deal_json, "POST");
118118

0 commit comments

Comments
 (0)