-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathIntercomCompanies.php
More file actions
149 lines (135 loc) · 3.71 KB
/
IntercomCompanies.php
File metadata and controls
149 lines (135 loc) · 3.71 KB
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
147
148
149
<?php
namespace Intercom;
use Http\Client\Exception;
use stdClass;
class IntercomCompanies extends IntercomResource
{
/**
* Creates a Company.
*
* @see https://developers.intercom.io/reference#create-or-update-company
* @param array $options
* @return stdClass
* @throws Exception
*/
public function create($options)
{
return $this->client->post("companies", $options);
}
/**
* Updates a Company.
*
* @see https://developers.intercom.io/reference#create-or-update-company
* @param array $options
* @return stdClass
* @throws Exception
*/
public function update($options)
{
return $this->create($options);
}
/**
* Attaches a Contact to a Company.
*
* @see https://developers.intercom.io/reference#attach-contact-to-company
* @param string $contactId
* @param string $companyId
* @param array $options
* @return stdClass
* @throws Exception
*/
public function attachContact(string $contactId, string $companyId, array $options = [])
{
$path = $this->companyAttachPath($contactId);
$options = array_merge($options, ["id" => $companyId]);
return $this->client->post($path, $options);
}
/**
* Detaches a Contact from a Company.
*
* @see https://developers.intercom.io/reference#detach-contact-from-company
* @param string $contactId
* @param string $companyId
* @param array $options
* @return stdClass
* @throws Exception
*/
public function detachContact(string $contactId, string $companyId, array $options = [])
{
$path = $this->companyDetachPath($contactId, $companyId);
return $this->client->delete($path, $options);
}
/**
* Returns list of Companies.
*
* @see https://developers.intercom.io/reference#list-companies
* @param array $options
* @return stdClass
* @throws Exception
*/
public function getCompanies($options = [])
{
return $this->client->get("companies", $options);
}
/**
* Gets a single Company based on the Intercom ID.
*
* @see https://developers.intercom.com/reference#view-a-company
* @param string $id
* @param array $options
* @return stdClass
* @throws Exception
*/
public function getCompany($id, $options = [])
{
$path = $this->companyPath($id);
return $this->client->get($path, $options);
}
/**
* Returns a list of Users belonging to a single Company based on the Intercom ID.
*
* @see https://developers.intercom.com/reference#list-company-users
* @param string $id
* @param array $options
* @return stdClass
* @throws Exception
*/
public function getCompanyUsers($id, $options = [])
{
$path = $this->companyUsersPath($id);
return $this->client->get($path, $options);
}
/**
* @param string $id
* @return string
*/
public function companyPath($id)
{
return 'companies/' . $id;
}
/**
* @param string $id
* @return string
*/
public function companyUsersPath($id)
{
return 'companies/' . $id . '/users';
}
/**
* @param string $contactId
* @return string
*/
public function companyAttachPath(string $contactId)
{
return 'contacts/' . $contactId . '/companies';
}
/**
* @param string $contactId
* @param string $companyId
* @return string
*/
public function companyDetachPath(string $contactId, string $companyId)
{
return 'contacts/' . $contactId . '/companies/' . $companyId;
}
}