-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnutshell_create_account.php
115 lines (105 loc) · 2.28 KB
/
nutshell_create_account.php
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
<?php
// Configuration:
$apiKey = 'YOUR_API_KEY';
$username = 'Your_Registered_Email';
// End of configuration
require_once('../NutshellApi.php');
$api = new NutshellApi($username, $apiKey);
/**
* Example: creating an account, contact, and lead
*
* We will create a new contact, then add a new account associated with that contact,
* then finally create a new lead involving that account/contact.
*
* Relevant documentation:
* http://www.nutshell.com/api/detail/class_nut___api___core.html
*/
// Create a new contact and save its ID to $newContactId
$params = array(
'contact' => array(
'name' => 'Joan Smith',
'phone' => array(
'734-555-9090',
'cell' => '734-555-6711',
),
'email' => array(
'jsmith@example.infit',
),
),
);
try
{
$newContact = $api->call('newContact', $params);
if($newContact){
$newContactId = $newContact->id;
// Create a new account that includes the contact we just added
$params = array(
'account' => array(
'name' => 'Arbor Medical LLC',
'industryId' => 1,
'url' => array(
'http://example.com',
'http://suppliers.example.com',
),
'phone' => array(
'734-234-9990',
),
'contacts' => array(
array(
'id' => $newContactId,
'relationship' => 'Purchasing Manager'
),
),
'address' => array(
'office' => array(
'address_1' => '220 Depot St',
'city' => 'Ann Arbor',
'state' => 'MI',
'postalCode' => '48104',
),
),
),
);
$newAccount = $api->newAccount($params);
$newAccountId = $newAccount->id;
// Finally, create a lead that includes the account we just added
$params = array(
'lead' => array(
'primaryAccount' => array('id' => $newAccountId),
'confidence' => 70,
'market' => array('id' => 1),
'contacts' => array(
array(
'relationship' => 'First Contact',
'id' => $newContactId,
),
),
'products' => array(
array(
'relationship' => '',
'quantity' => 15,
'price' => array(
'currency_shortname' => 'USD',
'amount' => 1000,
),
'id' => 1,
),
),
'sources' => array(
array('id' => 2),
),
'assignee' => array(
'entityType' => 'Teams',
'id' => 1000,
),
),
);
$result = $api->newLead($params);
var_dump($result);
echo "\n";
}
}
catch (Exception $e)
{
echo "Exception:".$e;
}