forked from intercom/intercom-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompaniesClient.java
More file actions
323 lines (292 loc) · 18.8 KB
/
Copy pathCompaniesClient.java
File metadata and controls
323 lines (292 loc) · 18.8 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.intercom.api.resources.companies;
import com.intercom.api.core.ClientOptions;
import com.intercom.api.core.RequestOptions;
import com.intercom.api.core.pagination.SyncPagingIterable;
import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest;
import com.intercom.api.resources.companies.requests.DeleteCompanyRequest;
import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest;
import com.intercom.api.resources.companies.requests.FindCompanyRequest;
import com.intercom.api.resources.companies.requests.ListAttachedContactsRequest;
import com.intercom.api.resources.companies.requests.ListCompaniesRequest;
import com.intercom.api.resources.companies.requests.ListSegmentsAttachedToCompanyRequest;
import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest;
import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest;
import com.intercom.api.resources.companies.requests.UpdateCompanyRequest;
import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse;
import com.intercom.api.resources.companies.types.Company;
import com.intercom.api.types.CompanyAttachedContacts;
import com.intercom.api.types.CompanyAttachedSegments;
import com.intercom.api.types.CreateOrUpdateCompanyRequest;
import com.intercom.api.types.DeletedCompanyObject;
import java.util.Optional;
public class CompaniesClient {
protected final ClientOptions clientOptions;
private final RawCompaniesClient rawClient;
public CompaniesClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawCompaniesClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public RawCompaniesClient withRawResponse() {
return this.rawClient;
}
/**
* You can fetch a single company by passing in <code>company_id</code> or <code>name</code>.
* <p><code>https://api.intercom.io/companies?name={name}</code></p>
* <p><code>https://api.intercom.io/companies?company_id={company_id}</code></p>
* <p>You can fetch all companies and filter by <code>segment_id</code> or <code>tag_id</code> as a query parameter.</p>
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
*/
public CompaniesRetrieveResponse retrieve() {
return this.rawClient.retrieve().body();
}
/**
* You can fetch a single company by passing in <code>company_id</code> or <code>name</code>.
* <p><code>https://api.intercom.io/companies?name={name}</code></p>
* <p><code>https://api.intercom.io/companies?company_id={company_id}</code></p>
* <p>You can fetch all companies and filter by <code>segment_id</code> or <code>tag_id</code> as a query parameter.</p>
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
*/
public CompaniesRetrieveResponse retrieve(RetrieveCompanyRequest request) {
return this.rawClient.retrieve(request).body();
}
/**
* You can fetch a single company by passing in <code>company_id</code> or <code>name</code>.
* <p><code>https://api.intercom.io/companies?name={name}</code></p>
* <p><code>https://api.intercom.io/companies?company_id={company_id}</code></p>
* <p>You can fetch all companies and filter by <code>segment_id</code> or <code>tag_id</code> as a query parameter.</p>
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
*/
public CompaniesRetrieveResponse retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) {
return this.rawClient.retrieve(request, requestOptions).body();
}
/**
* You can create or update a company.
* <p>Companies will be only visible in Intercom when there is at least one associated user.</p>
* <p>Companies are looked up via <code>company_id</code> in a <code>POST</code> request, if not found via <code>company_id</code>, the new company will be created, if found, that company will be updated.</p>
* <p>{% admonition type="warning" name="Using <code>company_id</code>" %}
* You can set a unique <code>company_id</code> value when creating a company. However, it is not possible to update <code>company_id</code>. Be sure to set a unique value once upon creation of the company.
* {% /admonition %}</p>
*/
public Company createOrUpdate() {
return this.rawClient.createOrUpdate().body();
}
/**
* You can create or update a company.
* <p>Companies will be only visible in Intercom when there is at least one associated user.</p>
* <p>Companies are looked up via <code>company_id</code> in a <code>POST</code> request, if not found via <code>company_id</code>, the new company will be created, if found, that company will be updated.</p>
* <p>{% admonition type="warning" name="Using <code>company_id</code>" %}
* You can set a unique <code>company_id</code> value when creating a company. However, it is not possible to update <code>company_id</code>. Be sure to set a unique value once upon creation of the company.
* {% /admonition %}</p>
*/
public Company createOrUpdate(Optional<CreateOrUpdateCompanyRequest> request) {
return this.rawClient.createOrUpdate(request).body();
}
/**
* You can create or update a company.
* <p>Companies will be only visible in Intercom when there is at least one associated user.</p>
* <p>Companies are looked up via <code>company_id</code> in a <code>POST</code> request, if not found via <code>company_id</code>, the new company will be created, if found, that company will be updated.</p>
* <p>{% admonition type="warning" name="Using <code>company_id</code>" %}
* You can set a unique <code>company_id</code> value when creating a company. However, it is not possible to update <code>company_id</code>. Be sure to set a unique value once upon creation of the company.
* {% /admonition %}</p>
*/
public Company createOrUpdate(Optional<CreateOrUpdateCompanyRequest> request, RequestOptions requestOptions) {
return this.rawClient.createOrUpdate(request, requestOptions).body();
}
/**
* You can fetch a single company.
*/
public Company find(FindCompanyRequest request) {
return this.rawClient.find(request).body();
}
/**
* You can fetch a single company.
*/
public Company find(FindCompanyRequest request, RequestOptions requestOptions) {
return this.rawClient.find(request, requestOptions).body();
}
/**
* You can update a single company using the Intercom provisioned <code>id</code>.
* <p>{% admonition type="warning" name="Using <code>company_id</code>" %}
* When updating a company it is not possible to update <code>company_id</code>. This can only be set once upon creation of the company.
* {% /admonition %}</p>
*/
public Company update(UpdateCompanyRequest request) {
return this.rawClient.update(request).body();
}
/**
* You can update a single company using the Intercom provisioned <code>id</code>.
* <p>{% admonition type="warning" name="Using <code>company_id</code>" %}
* When updating a company it is not possible to update <code>company_id</code>. This can only be set once upon creation of the company.
* {% /admonition %}</p>
*/
public Company update(UpdateCompanyRequest request, RequestOptions requestOptions) {
return this.rawClient.update(request, requestOptions).body();
}
/**
* You can delete a single company.
*/
public DeletedCompanyObject delete(DeleteCompanyRequest request) {
return this.rawClient.delete(request).body();
}
/**
* You can delete a single company.
*/
public DeletedCompanyObject delete(DeleteCompanyRequest request, RequestOptions requestOptions) {
return this.rawClient.delete(request, requestOptions).body();
}
/**
* You can fetch a list of all contacts that belong to a company.
*/
public CompanyAttachedContacts listAttachedContacts(ListAttachedContactsRequest request) {
return this.rawClient.listAttachedContacts(request).body();
}
/**
* You can fetch a list of all contacts that belong to a company.
*/
public CompanyAttachedContacts listAttachedContacts(
ListAttachedContactsRequest request, RequestOptions requestOptions) {
return this.rawClient.listAttachedContacts(request, requestOptions).body();
}
/**
* You can fetch a list of all segments that belong to a company.
*/
public CompanyAttachedSegments listAttachedSegments(ListSegmentsAttachedToCompanyRequest request) {
return this.rawClient.listAttachedSegments(request).body();
}
/**
* You can fetch a list of all segments that belong to a company.
*/
public CompanyAttachedSegments listAttachedSegments(
ListSegmentsAttachedToCompanyRequest request, RequestOptions requestOptions) {
return this.rawClient.listAttachedSegments(request, requestOptions).body();
}
/**
* You can list companies. The company list is sorted by the <code>last_request_at</code> field and by default is ordered descending, most recently requested first.
* <p>Note that the API does not include companies who have no associated users in list responses.</p>
* <p>When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the <a href="https://developers.intercom.com/reference#iterating-over-all-companies">Scroll API</a>.
* {% admonition type="warning" name="Pagination" %}
* You can use pagination to limit the number of results returned. The default is <code>20</code> results per page.
* See the <a href="https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis">pagination section</a> for more details on how to use the <code>starting_after</code> param.
* {% /admonition %}</p>
*/
public SyncPagingIterable<Company> list() {
return this.rawClient.list().body();
}
/**
* You can list companies. The company list is sorted by the <code>last_request_at</code> field and by default is ordered descending, most recently requested first.
* <p>Note that the API does not include companies who have no associated users in list responses.</p>
* <p>When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the <a href="https://developers.intercom.com/reference#iterating-over-all-companies">Scroll API</a>.
* {% admonition type="warning" name="Pagination" %}
* You can use pagination to limit the number of results returned. The default is <code>20</code> results per page.
* See the <a href="https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis">pagination section</a> for more details on how to use the <code>starting_after</code> param.
* {% /admonition %}</p>
*/
public SyncPagingIterable<Company> list(ListCompaniesRequest request) {
return this.rawClient.list(request).body();
}
/**
* You can list companies. The company list is sorted by the <code>last_request_at</code> field and by default is ordered descending, most recently requested first.
* <p>Note that the API does not include companies who have no associated users in list responses.</p>
* <p>When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the <a href="https://developers.intercom.com/reference#iterating-over-all-companies">Scroll API</a>.
* {% admonition type="warning" name="Pagination" %}
* You can use pagination to limit the number of results returned. The default is <code>20</code> results per page.
* See the <a href="https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis">pagination section</a> for more details on how to use the <code>starting_after</code> param.
* {% /admonition %}</p>
*/
public SyncPagingIterable<Company> list(ListCompaniesRequest request, RequestOptions requestOptions) {
return this.rawClient.list(request, requestOptions).body();
}
/**
* The <code>list all companies</code> functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset.
* <ul>
* <li>Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.</li>
* <li>If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail</li>
* <li>If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire</li>
* </ul>
* <p>{% admonition type="info" name="Scroll Parameter" %}
* You can get the first page of companies by simply sending a GET request to the scroll endpoint.
* For subsequent requests you will need to use the scroll parameter from the response.
* {% /admonition %}
* {% admonition type="danger" name="Scroll network timeouts" %}
* Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message:
* "Request failed due to an internal network error. Please restart the scroll operation."
* If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll.
* {% /admonition %}</p>
*/
public SyncPagingIterable<Company> scroll() {
return this.rawClient.scroll().body();
}
/**
* The <code>list all companies</code> functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset.
* <ul>
* <li>Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.</li>
* <li>If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail</li>
* <li>If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire</li>
* </ul>
* <p>{% admonition type="info" name="Scroll Parameter" %}
* You can get the first page of companies by simply sending a GET request to the scroll endpoint.
* For subsequent requests you will need to use the scroll parameter from the response.
* {% /admonition %}
* {% admonition type="danger" name="Scroll network timeouts" %}
* Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message:
* "Request failed due to an internal network error. Please restart the scroll operation."
* If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll.
* {% /admonition %}</p>
*/
public SyncPagingIterable<Company> scroll(ScrollCompaniesRequest request) {
return this.rawClient.scroll(request).body();
}
/**
* The <code>list all companies</code> functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset.
* <ul>
* <li>Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.</li>
* <li>If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail</li>
* <li>If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire</li>
* </ul>
* <p>{% admonition type="info" name="Scroll Parameter" %}
* You can get the first page of companies by simply sending a GET request to the scroll endpoint.
* For subsequent requests you will need to use the scroll parameter from the response.
* {% /admonition %}
* {% admonition type="danger" name="Scroll network timeouts" %}
* Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message:
* "Request failed due to an internal network error. Please restart the scroll operation."
* If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll.
* {% /admonition %}</p>
*/
public SyncPagingIterable<Company> scroll(ScrollCompaniesRequest request, RequestOptions requestOptions) {
return this.rawClient.scroll(request, requestOptions).body();
}
/**
* You can attach a company to a single contact.
*/
public Company attachContact(AttachContactToCompanyRequest request) {
return this.rawClient.attachContact(request).body();
}
/**
* You can attach a company to a single contact.
*/
public Company attachContact(AttachContactToCompanyRequest request, RequestOptions requestOptions) {
return this.rawClient.attachContact(request, requestOptions).body();
}
/**
* You can detach a company from a single contact.
*/
public Company detachContact(DetachContactFromCompanyRequest request) {
return this.rawClient.detachContact(request).body();
}
/**
* You can detach a company from a single contact.
*/
public Company detachContact(DetachContactFromCompanyRequest request, RequestOptions requestOptions) {
return this.rawClient.detachContact(request, requestOptions).body();
}
}