|
1 | 1 | package com.raven.api; |
2 | 2 |
|
3 | 3 | import com.raven.api.client.Authorization; |
4 | | -import com.raven.api.client.device.DeviceServiceClient; |
5 | | -import com.raven.api.client.event.EventServiceClient; |
6 | | -import com.raven.api.client.event.endpoints.Send; |
7 | | -import com.raven.api.client.event.endpoints.SendBulk; |
8 | | -import com.raven.api.client.event.exceptions.SendBulkException; |
9 | | -import com.raven.api.client.event.exceptions.SendException; |
10 | | -import com.raven.api.client.event.types.SendEventResponse; |
11 | | -import com.raven.api.client.user.UserServiceClient; |
| 4 | +import com.raven.api.client.ServiceClient; |
| 5 | +import com.raven.api.client.device.deviceServiceClient; |
| 6 | +import com.raven.api.client.user.userServiceClient; |
12 | 7 | import com.raven.api.core.Environment; |
13 | | -import java.lang.String; |
14 | 8 | import java.util.Objects; |
15 | 9 | import java.util.concurrent.atomic.AtomicReference; |
16 | 10 | import java.util.function.Supplier; |
17 | 11 |
|
18 | 12 | public final class RavenApiClient { |
19 | | - private final Supplier<DeviceServiceClient> deviceServiceClient; |
| 13 | + private final Supplier<ServiceClient> serviceClient; |
20 | 14 |
|
21 | | - private final Supplier<EventServiceClient> eventServiceClient; |
| 15 | + private final Supplier<deviceServiceClient> deviceServiceClient; |
22 | 16 |
|
23 | | - private final Supplier<UserServiceClient> userServiceClient; |
| 17 | + private final Supplier<userServiceClient> userServiceClient; |
24 | 18 |
|
25 | 19 | public RavenApiClient(Authorization auth) { |
26 | 20 | this(Environment.PROD, auth); |
27 | 21 | } |
28 | 22 |
|
29 | 23 | public RavenApiClient(Environment environment, Authorization auth) { |
30 | | - this.userServiceClient = memoize(() -> new UserServiceClient(environment.getUrl(), auth)); |
31 | | - this.eventServiceClient = memoize(() -> new EventServiceClient(environment.getUrl(), auth)); |
32 | | - this.deviceServiceClient = memoize(() -> new DeviceServiceClient(environment.getUrl(), auth)); |
| 24 | + this.userServiceClient = memoize(() -> new userServiceClient(environment.getUrl(), auth)); |
| 25 | + this.serviceClient = memoize(() -> new ServiceClient(environment.getUrl(), auth)); |
| 26 | + this.deviceServiceClient = memoize(() -> new deviceServiceClient(environment.getUrl(), auth)); |
33 | 27 | } |
34 | 28 |
|
35 | | - public final DeviceServiceClient device() { |
36 | | - return this.deviceServiceClient.get(); |
| 29 | + public final ServiceClient service() { |
| 30 | + return this.serviceClient.get(); |
37 | 31 | } |
38 | 32 |
|
39 | | - public final EventServiceClient event() { |
40 | | - return this.eventServiceClient.get(); |
| 33 | + public final deviceServiceClient device() { |
| 34 | + return this.deviceServiceClient.get(); |
41 | 35 | } |
42 | 36 |
|
43 | | - public final UserServiceClient user() { |
| 37 | + public final userServiceClient user() { |
44 | 38 | return this.userServiceClient.get(); |
45 | 39 | } |
46 | 40 |
|
47 | | - public SendEventResponse send(Send.Request request) throws SendException { |
48 | | - return event().send(request); |
49 | | - } |
50 | | - |
51 | | - public SendEventResponse sendBulk(SendBulk.Request request) throws SendBulkException { |
52 | | - return event().sendBulk(request); |
53 | | - } |
54 | | - |
55 | 41 | private static <T> Supplier<T> memoize(Supplier<T> delegate) { |
56 | 42 | AtomicReference<T> value = new AtomicReference<>(); |
57 | 43 | return () -> { |
|
0 commit comments