forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTime.java
More file actions
65 lines (49 loc) · 1.72 KB
/
Copy pathTime.java
File metadata and controls
65 lines (49 loc) · 1.72 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
package com.pubnub.api.endpoints;
import com.pubnub.api.PubNub;
import com.pubnub.api.PubNubException;
import com.pubnub.api.builder.PubNubErrorBuilder;
import com.pubnub.api.enums.PNOperationType;
import com.pubnub.api.managers.RetrofitManager;
import com.pubnub.api.managers.TelemetryManager;
import com.pubnub.api.models.consumer.PNTimeResult;
import retrofit2.Call;
import retrofit2.Response;
import java.util.List;
import java.util.Map;
public class Time extends Endpoint<List<Long>, PNTimeResult> {
public Time(PubNub pubnub, TelemetryManager telemetryManager, RetrofitManager retrofit) {
super(pubnub, telemetryManager, retrofit);
}
@Override
protected List<String> getAffectedChannels() {
return null;
}
@Override
protected List<String> getAffectedChannelGroups() {
return null;
}
@Override
protected void validateParams() throws PubNubException {
}
@Override
protected Call<List<Long>> doWork(Map<String, String> params) {
return this.getRetrofit().getTimeService().fetchTime(params);
}
@Override
protected PNTimeResult createResponse(Response<List<Long>> input) throws PubNubException {
PNTimeResult.PNTimeResultBuilder timeData = PNTimeResult.builder();
if (input.body() == null || input.body().size() == 0) {
throw PubNubException.builder().pubnubError(PubNubErrorBuilder.PNERROBJ_PARSING_ERROR).build();
}
timeData.timetoken(input.body().get(0));
return timeData.build();
}
@Override
protected PNOperationType getOperationType() {
return PNOperationType.PNTimeOperation;
}
@Override
protected boolean isAuthRequired() {
return false;
}
}