2
2
3
3
import barista .Endpoints ;
4
4
import barista .HttpMethod ;
5
- import com .fasterxml .jackson .annotation .JsonValue ;
6
5
import com .google .common .base .Strings ;
7
6
import io .allezgo .client .HttpError ;
8
- import io .allezgo .client .Result ;
9
7
import io .allezgo .config .Configuration ;
10
8
import io .allezgo .pipes .PelotonToTcx ;
11
9
import io .allezgo .sink .garmin .GarminActivity ;
@@ -51,17 +49,15 @@ public HttpMethod method() {
51
49
public Response call (Request request ) {
52
50
List <String > failingArgs = checkArgs (request );
53
51
if (!failingArgs .isEmpty ()) {
54
- return new Response (
55
- Result .error ("Some required fields were missing or empty: " + failingArgs ));
52
+ return new Response (null , "Some required fields were missing or empty: " + failingArgs );
56
53
}
57
54
58
55
PelotonClient peloton =
59
56
new PelotonClient (
60
57
new Configuration .Peloton (request .pelotonEmail , request .pelotonPassword ));
61
58
62
59
if (!peloton .validateLogin ()) {
63
- return new Response (
64
- Result .error ("Unable to login to Peloton with the provided credentials" ));
60
+ return new Response (null , "Unable to login to Peloton with the provided credentials" );
65
61
}
66
62
67
63
GarminClient garmin =
@@ -72,11 +68,10 @@ public Response call(Request request) {
72
68
request .garminPelotonGearName ));
73
69
74
70
if (!garmin .validateLogin ()) {
75
- return new Response (
76
- Result .error ("Unable to login to Garmin with the provided credentials" ));
71
+ return new Response (null , "Unable to login to Garmin with the provided credentials" );
77
72
}
78
73
79
- return new Response (Result . ok ( syncLast30Days (peloton , garmin )) );
74
+ return new Response (syncLast30Days (peloton , garmin ), null );
80
75
}
81
76
82
77
private static List <String > checkArgs (Request request ) {
@@ -114,7 +109,7 @@ public record SyncRecord(
114
109
String garminLink ,
115
110
boolean wasCreated ) {}
116
111
117
- public record Response (@ JsonValue Result < List <SyncRecord >, String > response ) {}
112
+ public record Response (List <SyncRecord > result , String error ) {}
118
113
119
114
private static List <SyncRecord > syncLast30Days (PelotonClient peloton , GarminClient garmin ) {
120
115
Instant thirtyDaysAgo = Instant .now ().minus (Period .ofDays (30 ));
0 commit comments