@@ -150,80 +150,25 @@ function curl_wrap($entity, $data, $method)
150
150
151
151
/*================================================= update contact ================================================*/
152
152
153
- $ address1 = array (
154
- "address " =>"Avenida Álvares Cabral 1777 " ,
155
- "city " =>"Belo Horizonte " ,
153
+ $ contact =
curl_wrap (
"contacts/search/email/[email protected] " ,
null ,
"GET " );
154
+ //Get contact by email and update it.
155
+ $ result = json_decode ($ contact , false , 512 , JSON_BIGINT_AS_STRING );
156
+
157
+ $ result ->lead_score = "150 " ;
158
+ $ address = array (
159
+ "address " =>"MIG-107 " ,
160
+ "city " =>"Belo Horizonto " ,
156
161
"state " =>"Minas Gerais " ,
157
162
"country " =>"Brazil "
158
163
);
159
-
160
- $ contact_email1 =
"[email protected] " ;
161
-
162
-
163
-
164
- $ new_contact_json1 = array (
165
- "id " =>
"5706163895140352 " ,
// This contact id is related to [email protected] .
166
- //And it is mandatory. Example contact id :http://snag.gy/M6S3A.jpg
167
- //You can get contact id of email which is described below.
168
- "lead_score " =>"24 " ,
169
- "star_value " =>"4 " ,
170
- "tags " =>array ("test1 " ,"test2 " ),
171
- "properties " =>array (
172
- array (
173
- "name " =>"first_name " ,
174
- "value " =>"ArnoldUpdated " ,
175
- "type " =>"SYSTEM "
176
- ),
177
- array (
178
- "name " =>"last_name " ,
179
- "value " =>"hello " ,
180
- "type " =>"SYSTEM "
181
- ),
182
- array (
183
- "name " =>"email " ,
184
- "value " =>$ contact_email1 ,
185
- "type " =>"SYSTEM "
186
- ),
187
- array (
188
- "name " =>"title " ,
189
- "value " =>"the phenomenon " ,
190
- "type " =>"SYSTEM "
191
- ),
192
- array (
193
- "name " =>"company " ,
194
- "value " =>"ibm " ,
195
- "type " =>"SYSTEM "
196
- ),
197
- array (
198
- "name " =>"address " ,
199
- "value " =>json_encode ($ address1 ),
200
- "type " =>"SYSTEM "
201
- ),
202
- array (
203
- "name " =>"phone " ,
204
- "value " =>"+1-541-754-3030 " ,
205
- "type " =>"SYSTEM "
206
- ),
207
- array (
208
- "name " =>"website " ,
209
- "value " =>"http://www.google.com " ,
210
- "type " =>"SYSTEM "
211
- ),
212
- array (
213
- "name " =>"experience in field " ,
214
- "value " =>"5 " ,
215
- "type " =>"CUSTOM "
216
- ),
217
- array (
218
- "name " =>"Date Of Joining " ,
219
- "value " =>"1438951923 " , // This is epoch time in seconds.
220
- "type " =>"CUSTOM "
221
- )
222
- )
223
- );
224
- $ new_contact_json1 = json_encode ($ new_contact_json1 );
164
+ $ address1 =json_encode ($ address );
165
+ setContactField ("address " ,$ address1 ,$ result ); // Set contact address with new data
166
+ setContactField ("last_name " ,"de lama2 " ,$ result );
167
+ setContactField ("DOP " ,"1444718961 " ,$ result ); // Set DOP custom data of date type.
168
+ setContactField ("text sample test " ,"hello text sample test " ,$ result ); // Set text sample test custom data of textfiled type
225
169
226
170
171
+ $ new_contact_json1 = json_encode ($ result );
227
172
echo "<li>contact updated with following data</li><br> " ;
228
173
echo "<li> " . $ new_contact_json1 . "</li><br> " ;
229
174
$ result = curl_wrap ("contacts " , $ new_contact_json1 , "PUT " );
@@ -306,30 +251,28 @@ function curl_wrap($entity, $data, $method)
306
251
307
252
/*===================================================== update deal================================================*/
308
253
309
- $ opportunity_json = array (
310
- "id " =>"5675214360805376 " , // Deal ID. Example : http://snag.gy/SqMqF.jpg
311
- "name " =>"test deal1 updated " ,
312
- "description " =>"this is a test deal " ,
313
- "expected_value " =>1000 ,
314
- "milestone " =>"Won " , // Changed milestone type from New to Won for existing deal.
315
- "custom_data " =>array (
316
- array (
317
- "name " =>"dataone " ,
318
- "value " =>"xyz updated "
319
- ),
320
- array (
321
- "name " =>"datatwo " ,
322
- "value " =>"abc updated "
323
- )
324
- ),
325
- "probability " =>50 ,
326
- "close_date " =>1438949981 ,
327
- "contact_ids " =>array ("5706163895140352 " ) // Contact ID to which deal going to added.
328
- );
329
- $ opportunity_json = json_encode ($ opportunity_json );
254
+ $ deal = curl_wrap ("opportunity/5649648836411392 " , null , "GET " );//Get deal by deal id to update.
255
+ $ result = json_decode ($ deal , false , 512 , JSON_BIGINT_AS_STRING );
256
+
257
+ $ result ->name ="helo test " ;
258
+ $ result ->expected_value ="1000 " ; // Should not be null;
259
+ $ result ->milestone ="Proposal " ; // Milestone name should be exactly as in agilecrm website. http://snag.gy/xjAbc.jpg
260
+ $ result ->pipeline_id ="5767790501822464 " ;
261
+
262
+ // If you are updating milestone then pipeline_id is mandatory field. pipeline_id is the id of track,
263
+ // Otherwise comment milestone and pipeline_id to just change other field.
264
+
265
+ setDealCustom ("Message " ,"this is text custom data " ,$ result ); // Setting custom message of text type.
266
+ setDealCustom ("DOJ " ,"11/30/2015 " ,$ result );// Setting custom message of date type.
267
+
268
+ if (sizeof ($ result ->notes ) > 0 ) { // This code checking deal has any notes or not, don't remove this if-condition.
269
+ $ result ->notes =$ result ->note_ids ;
270
+ }
271
+
272
+ $ opportunity_json = json_encode ($ result );
330
273
echo "<li>update deal with below data</li><br> " ;
331
274
echo "<li> " . $ opportunity_json . "</li><br> " ;
332
- $ result = curl_wrap ("opportunity " , $ opportunity_json , "POST " );
275
+ $ result = curl_wrap ("opportunity " , $ opportunity_json , "PUT " );
333
276
echo "<li>updated deal data is ...</li><br> " ;
334
277
echo "<li> " . $ result . "</li> " ;
335
278
echo "<br><hr><br> " ;
0 commit comments