-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApideck.java
More file actions
323 lines (253 loc) · 8.87 KB
/
Copy pathApideck.java
File metadata and controls
323 lines (253 loc) · 8.87 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
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
package com.apideck.unify;
import com.apideck.unify.utils.HTTPClient;
import com.apideck.unify.utils.Headers;
import com.apideck.unify.utils.Hook.SdkInitData;
import com.apideck.unify.utils.RetryConfig;
import com.apideck.unify.utils.SpeakeasyHTTPClient;
import com.apideck.unify.utils.Utils;
import java.lang.String;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
/**
* Apideck: The Apideck OpenAPI Spec: SDK Optimized
*
* <p><a href="https://developers.apideck.com">Apideck Developer Docs</a>
*/
public class Apideck {
private static final Headers _headers = Headers.EMPTY;
/**
* SERVERS contains the list of server urls available to the SDK.
*/
public static final String[] SERVERS = {
"https://unify.apideck.com",
};
private final Accounting accounting;
private final Ats ats;
private final Crm crm;
private final Ecommerce ecommerce;
private final FileStorage fileStorage;
private final Hris hris;
private final Sms sms;
private final IssueTracking issueTracking;
private final Connector connector;
private final Vault vault;
private final Webhook webhook;
public Accounting accounting() {
return accounting;
}
public Ats ats() {
return ats;
}
public Crm crm() {
return crm;
}
public Ecommerce ecommerce() {
return ecommerce;
}
public FileStorage fileStorage() {
return fileStorage;
}
public Hris hris() {
return hris;
}
public Sms sms() {
return sms;
}
public IssueTracking issueTracking() {
return issueTracking;
}
public Connector connector() {
return connector;
}
public Vault vault() {
return vault;
}
public Webhook webhook() {
return webhook;
}
private final AsyncApideck asyncSDK;
/**
* The Builder class allows the configuration of a new instance of the SDK.
*/
public static class Builder {
private final SDKConfiguration sdkConfiguration = new SDKConfiguration();
private String serverUrl;
private String server;
private Builder() {
}
/**
* Allows the default HTTP client to be overridden with a custom implementation.
*
* @param client The HTTP client to use for all requests.
* @return The builder instance.
*/
public Builder client(HTTPClient client) {
this.sdkConfiguration.setClient(client);
return this;
}
/**
* Configures the SDK security to use the provided secret.
*
* @param apiKey The secret to use for all requests.
* @return The builder instance.
*/
public Builder apiKey(String apiKey) {
this.sdkConfiguration.setSecuritySource(SecuritySource.of(com.apideck.unify.models.components.Security.builder()
.apiKey(apiKey)
.build()));
return this;
}
/**
* Configures the SDK to use a custom security source.
*
* @param securitySource The security source to use for all requests.
* @return The builder instance.
*/
public Builder securitySource(SecuritySource securitySource) {
Utils.checkNotNull(securitySource, "securitySource");
this.sdkConfiguration.setSecuritySource(securitySource);
return this;
}
/**
* Overrides the default server URL.
*
* @param serverUrl The server URL to use for all requests.
* @return The builder instance.
*/
public Builder serverURL(String serverUrl) {
this.serverUrl = serverUrl;
return this;
}
/**
* Overrides the default server URL with a templated URL populated with the provided parameters.
*
* @param serverUrl The server URL to use for all requests.
* @param params The parameters to use when templating the URL.
* @return The builder instance.
*/
public Builder serverURL(String serverUrl, Map<String, String> params) {
this.serverUrl = Utils.templateUrl(serverUrl, params);
return this;
}
/**
* Overrides the default server by index.
*
* @param serverIdx The server to use for all requests.
* @return The builder instance.
*/
public Builder serverIndex(int serverIdx) {
this.sdkConfiguration.setServerIdx(serverIdx);
this.serverUrl= SERVERS[serverIdx];
return this;
}
/**
* Overrides the default configuration for retries
*
* @param retryConfig The retry configuration to use for all requests.
* @return The builder instance.
*/
public Builder retryConfig(RetryConfig retryConfig) {
this.sdkConfiguration.setRetryConfig(Optional.of(retryConfig));
return this;
}
/**
* Enables debug logging for HTTP requests and responses, including JSON body content.
* <p>
* Convenience method that calls {@link HTTPClient#enableDebugLogging(boolean)}.
* {@link SpeakeasyHTTPClient} honors this setting. If you are using a custom HTTP client,
* it is up to the custom client to honor this setting.
* </p>
*
* @param enabled Whether to enable debug logging.
* @return The builder instance.
*/
public Builder enableHTTPDebugLogging(boolean enabled) {
this.sdkConfiguration.client().enableDebugLogging(enabled);
return this;
}
/**
* Allows setting the consumerId parameter for all supported operations.
*
* @param consumerId The value to set.
* @return The builder instance.
*/
public Builder consumerId(String consumerId) {
this.sdkConfiguration.globals.putParam("header", "x-apideck-consumer-id", consumerId);
return this;
}
/**
* Allows setting the appId parameter for all supported operations.
*
* @param appId The value to set.
* @return The builder instance.
*/
public Builder appId(String appId) {
this.sdkConfiguration.globals.putParam("header", "x-apideck-app-id", appId);
return this;
}
// Visible for testing, may be accessed via reflection in tests
Builder _hooks(com.apideck.unify.utils.Hooks hooks) {
sdkConfiguration.setHooks(hooks);
return this;
}
// Visible for testing, may be accessed via reflection in tests
Builder _hooks(Consumer<? super com.apideck.unify.utils.Hooks> consumer) {
consumer.accept(sdkConfiguration.hooks());
return this;
}
/**
* Builds a new instance of the SDK.
*
* @return The SDK instance.
*/
public Apideck build() {
if (serverUrl == null || serverUrl.isBlank()) {
serverUrl = SERVERS[0];
sdkConfiguration.setServerIdx(0);
}
sdkConfiguration.setServerUrl(serverUrl);
return new Apideck(sdkConfiguration);
}
}
/**
* Get a new instance of the SDK builder to configure a new instance of the SDK.
*
* @return The SDK builder instance.
*/
public static Builder builder() {
return new Builder();
}
public Apideck(SDKConfiguration sdkConfiguration) {
sdkConfiguration.initialize();
this.accounting = new Accounting(sdkConfiguration);
this.ats = new Ats(sdkConfiguration);
this.crm = new Crm(sdkConfiguration);
this.ecommerce = new Ecommerce(sdkConfiguration);
this.fileStorage = new FileStorage(sdkConfiguration);
this.hris = new Hris(sdkConfiguration);
this.sms = new Sms(sdkConfiguration);
this.issueTracking = new IssueTracking(sdkConfiguration);
this.connector = new Connector(sdkConfiguration);
this.vault = new Vault(sdkConfiguration);
this.webhook = new Webhook(sdkConfiguration);
SdkInitData data = sdkConfiguration.hooks().sdkInit(
new SdkInitData(
sdkConfiguration.resolvedServerUrl(),
sdkConfiguration.client()));
sdkConfiguration.setServerUrl(data.baseUrl());
sdkConfiguration.setClient(data.client());
this.asyncSDK = new AsyncApideck(this, sdkConfiguration);
}
/**
* Switches to the async SDK.
*
* @return The async SDK
*/
public AsyncApideck async() {
return asyncSDK;
}
}