forked from intercom/intercom-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncTicketsClient.java
More file actions
260 lines (241 loc) · 20.2 KB
/
Copy pathAsyncTicketsClient.java
File metadata and controls
260 lines (241 loc) · 20.2 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
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.intercom.api.resources.tickets;
import com.intercom.api.core.ClientOptions;
import com.intercom.api.core.RequestOptions;
import com.intercom.api.core.pagination.SyncPagingIterable;
import com.intercom.api.resources.jobs.types.Jobs;
import com.intercom.api.resources.tickets.requests.CreateTicketRequest;
import com.intercom.api.resources.tickets.requests.DeleteTicketRequest;
import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest;
import com.intercom.api.resources.tickets.requests.FindTicketRequest;
import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest;
import com.intercom.api.resources.tickets.requests.UpdateTicketRequest;
import com.intercom.api.resources.tickets.types.DeleteTicketResponse;
import com.intercom.api.resources.tickets.types.Ticket;
import com.intercom.api.types.SearchRequest;
import com.intercom.api.types.TicketReply;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
public class AsyncTicketsClient {
protected final ClientOptions clientOptions;
private final AsyncRawTicketsClient rawClient;
public AsyncTicketsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawTicketsClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawTicketsClient withRawResponse() {
return this.rawClient;
}
/**
* You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins.
*/
public CompletableFuture<TicketReply> reply(ReplyToTicketRequest request) {
return this.rawClient.reply(request).thenApply(response -> response.body());
}
/**
* You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins.
*/
public CompletableFuture<TicketReply> reply(ReplyToTicketRequest request, RequestOptions requestOptions) {
return this.rawClient.reply(request, requestOptions).thenApply(response -> response.body());
}
/**
* You can create a new ticket.
*/
public CompletableFuture<Optional<Ticket>> create(CreateTicketRequest request) {
return this.rawClient.create(request).thenApply(response -> response.body());
}
/**
* You can create a new ticket.
*/
public CompletableFuture<Optional<Ticket>> create(CreateTicketRequest request, RequestOptions requestOptions) {
return this.rawClient.create(request, requestOptions).thenApply(response -> response.body());
}
/**
* Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job.
*/
public CompletableFuture<Jobs> enqueueCreateTicket(EnqueueCreateTicketRequest request) {
return this.rawClient.enqueueCreateTicket(request).thenApply(response -> response.body());
}
/**
* Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job.
*/
public CompletableFuture<Jobs> enqueueCreateTicket(
EnqueueCreateTicketRequest request, RequestOptions requestOptions) {
return this.rawClient.enqueueCreateTicket(request, requestOptions).thenApply(response -> response.body());
}
/**
* You can fetch the details of a single ticket.
*/
public CompletableFuture<Optional<Ticket>> get(FindTicketRequest request) {
return this.rawClient.get(request).thenApply(response -> response.body());
}
/**
* You can fetch the details of a single ticket.
*/
public CompletableFuture<Optional<Ticket>> get(FindTicketRequest request, RequestOptions requestOptions) {
return this.rawClient.get(request, requestOptions).thenApply(response -> response.body());
}
/**
* You can update a ticket.
*/
public CompletableFuture<Optional<Ticket>> update(UpdateTicketRequest request) {
return this.rawClient.update(request).thenApply(response -> response.body());
}
/**
* You can update a ticket.
*/
public CompletableFuture<Optional<Ticket>> update(UpdateTicketRequest request, RequestOptions requestOptions) {
return this.rawClient.update(request, requestOptions).thenApply(response -> response.body());
}
/**
* You can delete a ticket using the Intercom provided ID.
*/
public CompletableFuture<DeleteTicketResponse> deleteTicket(DeleteTicketRequest request) {
return this.rawClient.deleteTicket(request).thenApply(response -> response.body());
}
/**
* You can delete a ticket using the Intercom provided ID.
*/
public CompletableFuture<DeleteTicketResponse> deleteTicket(
DeleteTicketRequest request, RequestOptions requestOptions) {
return this.rawClient.deleteTicket(request, requestOptions).thenApply(response -> response.body());
}
/**
* You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want.
* <p>To search for tickets, you send a <code>POST</code> request to <code>https://api.intercom.io/tickets/search</code>.</p>
* <p>This will accept a query object in the body which will define your filters.
* {% admonition type="warning" name="Optimizing search queries" %}
* Search queries can be complex, so optimizing them can help the performance of your search.
* Use the <code>AND</code> and <code>OR</code> operators to combine multiple filters to get the exact results you need and utilize
* 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/#example-search-conversations-request">pagination section</a> for more details on how to use the <code>starting_after</code> param.
* {% /admonition %}</p>
* <h3>Nesting & Limitations</h3>
* <p>You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
* There are some limitations to the amount of multiples there can be:</p>
* <ul>
* <li>There's a limit of max 2 nested filters</li>
* <li>There's a limit of max 15 filters for each AND or OR group</li>
* </ul>
* <h3>Accepted Fields</h3>
* <p>Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as <code>created_at</code> accepts a date, the <code>value</code> cannot be a string such as <code>"foobar"</code>).
* The <code>source.body</code> field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a <code>"I need support"</code> body - the query should contain a <code>=</code> operator with the value <code>"support"</code> for such conversation to be returned. A query with a <code>=</code> operator and a <code>"need support"</code> value will not yield a result.</p>
* <p>| Field | Type |
* | :---------------------------------------- | :--------------------------------------------------------------------------------------- |
* | id | String |
* | created_at | Date (UNIX timestamp) |
* | updated_at | Date (UNIX timestamp) |
* | title | String |
* | description | String |
* | category | String |
* | ticket_type_id | String |
* | contact_ids | String |
* | teammate_ids | String |
* | admin_assignee_id | String |
* | team_assignee_id | String |
* | open | Boolean |
* | state | String |
* | snoozed_until | Date (UNIX timestamp) |
* | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |</p>
* <p>{% admonition type="info" name="Searching by Category" %}
* When searching for tickets by the <strong><code>category</code></strong> field, specific terms must be used instead of the category names:</p>
* <ul>
* <li>For <strong>Customer</strong> category tickets, use the term <code>request</code>.</li>
* <li>For <strong>Back-office</strong> category tickets, use the term <code>task</code>.</li>
* <li>For <strong>Tracker</strong> category tickets, use the term <code>tracker</code>.
* {% /admonition %}</li>
* </ul>
* <h3>Accepted Operators</h3>
* <p>{% admonition type="info" name="Searching based on <code>created_at</code>" %}
* You may use the <code><=</code> or <code>>=</code> operators to search by <code>created_at</code>.
* {% /admonition %}</p>
* <p>The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (<code>"="</code>). The operator has to be compatible with the field's type (eg. you cannot search with <code>></code> for a given string value as it's only compatible for integer's and dates).</p>
* <p>| Operator | Valid Types | Description |
* | :------- | :----------------------------- | :----------------------------------------------------------- |
* | = | All | Equals |
* | != | All | Doesn't Equal |
* | IN | All | In Shortcut for <code>OR</code> queries Values most be in Array |
* | NIN | All | Not In Shortcut for <code>OR !</code> queries Values must be in Array |
* | > | Integer Date (UNIX Timestamp) | Greater (or equal) than |
* | < | Integer Date (UNIX Timestamp) | Lower (or equal) than |
* | ~ | String | Contains |
* | !~ | String | Doesn't Contain |
* | ^ | String | Starts With |
* | $ | String | Ends With |</p>
*/
public CompletableFuture<SyncPagingIterable<Optional<Ticket>>> search(SearchRequest request) {
return this.rawClient.search(request).thenApply(response -> response.body());
}
/**
* You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want.
* <p>To search for tickets, you send a <code>POST</code> request to <code>https://api.intercom.io/tickets/search</code>.</p>
* <p>This will accept a query object in the body which will define your filters.
* {% admonition type="warning" name="Optimizing search queries" %}
* Search queries can be complex, so optimizing them can help the performance of your search.
* Use the <code>AND</code> and <code>OR</code> operators to combine multiple filters to get the exact results you need and utilize
* 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/#example-search-conversations-request">pagination section</a> for more details on how to use the <code>starting_after</code> param.
* {% /admonition %}</p>
* <h3>Nesting & Limitations</h3>
* <p>You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
* There are some limitations to the amount of multiples there can be:</p>
* <ul>
* <li>There's a limit of max 2 nested filters</li>
* <li>There's a limit of max 15 filters for each AND or OR group</li>
* </ul>
* <h3>Accepted Fields</h3>
* <p>Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as <code>created_at</code> accepts a date, the <code>value</code> cannot be a string such as <code>"foobar"</code>).
* The <code>source.body</code> field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a <code>"I need support"</code> body - the query should contain a <code>=</code> operator with the value <code>"support"</code> for such conversation to be returned. A query with a <code>=</code> operator and a <code>"need support"</code> value will not yield a result.</p>
* <p>| Field | Type |
* | :---------------------------------------- | :--------------------------------------------------------------------------------------- |
* | id | String |
* | created_at | Date (UNIX timestamp) |
* | updated_at | Date (UNIX timestamp) |
* | title | String |
* | description | String |
* | category | String |
* | ticket_type_id | String |
* | contact_ids | String |
* | teammate_ids | String |
* | admin_assignee_id | String |
* | team_assignee_id | String |
* | open | Boolean |
* | state | String |
* | snoozed_until | Date (UNIX timestamp) |
* | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |</p>
* <p>{% admonition type="info" name="Searching by Category" %}
* When searching for tickets by the <strong><code>category</code></strong> field, specific terms must be used instead of the category names:</p>
* <ul>
* <li>For <strong>Customer</strong> category tickets, use the term <code>request</code>.</li>
* <li>For <strong>Back-office</strong> category tickets, use the term <code>task</code>.</li>
* <li>For <strong>Tracker</strong> category tickets, use the term <code>tracker</code>.
* {% /admonition %}</li>
* </ul>
* <h3>Accepted Operators</h3>
* <p>{% admonition type="info" name="Searching based on <code>created_at</code>" %}
* You may use the <code><=</code> or <code>>=</code> operators to search by <code>created_at</code>.
* {% /admonition %}</p>
* <p>The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (<code>"="</code>). The operator has to be compatible with the field's type (eg. you cannot search with <code>></code> for a given string value as it's only compatible for integer's and dates).</p>
* <p>| Operator | Valid Types | Description |
* | :------- | :----------------------------- | :----------------------------------------------------------- |
* | = | All | Equals |
* | != | All | Doesn't Equal |
* | IN | All | In Shortcut for <code>OR</code> queries Values most be in Array |
* | NIN | All | Not In Shortcut for <code>OR !</code> queries Values must be in Array |
* | > | Integer Date (UNIX Timestamp) | Greater (or equal) than |
* | < | Integer Date (UNIX Timestamp) | Lower (or equal) than |
* | ~ | String | Contains |
* | !~ | String | Doesn't Contain |
* | ^ | String | Starts With |
* | $ | String | Ends With |</p>
*/
public CompletableFuture<SyncPagingIterable<Optional<Ticket>>> search(
SearchRequest request, RequestOptions requestOptions) {
return this.rawClient.search(request, requestOptions).thenApply(response -> response.body());
}
}