Skip to content

Commit 12c7d43

Browse files
committed
Release 0.0.37
1 parent 8bd6aab commit 12c7d43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+536
-211
lines changed

build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'maven-publish'
4+
id 'com.diffplug.spotless' version '6.11.0'
45
}
56

67
repositories {
@@ -19,6 +20,12 @@ dependencies {
1920
api 'io.github.openfeign:feign-jaxrs2:11.8'
2021
}
2122

23+
spotless {
24+
java {
25+
googleJavaFormat()
26+
}
27+
}
28+
2229
java {
2330
withSourcesJar()
2431
withJavadocJar()
@@ -29,7 +36,7 @@ publishing {
2936
maven(MavenPublication) {
3037
groupId = 'dev.ravenapp'
3138
artifactId = 'raven-java'
32-
version = '0.0.36'
39+
version = '0.0.37'
3340
from components.java
3441
}
3542
}

src/main/java/com/raven/api/client/device/DeviceServiceClient.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,37 @@ public DeviceServiceClient(String url, Authorization auth) {
2929
this.auth = Optional.of(auth);
3030
}
3131

32+
/**
33+
* Add Device for a User.
34+
* If a device_sid is specified, then devices will be merged if one is found.
35+
* If no device_sid is specified, then a new device will be created.
36+
*/
3237
public Device add(Add.Request request) throws AddException {
33-
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required for add")));
38+
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required")));
3439
return this.service.add(authValue, request.getAppId(), request.getUserId(), request.getBody());
3540
}
3641

42+
/**
43+
* Update a Device for a User.
44+
*/
3745
public Device update(Update.Request request) throws UpdateException {
38-
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required for update")));
46+
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required")));
3947
return this.service.update(authValue, request.getAppId(), request.getUserId(), request.getDeviceId(), request.getBody());
4048
}
4149

50+
/**
51+
* Delete a Device for a User
52+
*/
4253
public void delete(Delete.Request request) throws DeleteException {
43-
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required for delete")));
54+
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required")));
4455
this.service.delete(authValue, request.getAppId(), request.getUserId(), request.getDeviceId());
4556
}
4657

58+
/**
59+
* Get a Device for a User
60+
*/
4761
public Device getDevice(GetDevice.Request request) throws GetDeviceException {
48-
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required for getDevice")));
62+
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required")));
4963
return this.service.getDevice(authValue, request.getAppId(), request.getUserId(), request.getDeviceId());
5064
}
5165
}

src/main/java/com/raven/api/client/device/endpoints/Add.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,33 @@ private Add() {
1313
}
1414

1515
public static final class Request {
16-
private final Optional<Authorization> authOverride;
17-
1816
private final String appId;
1917

2018
private final String userId;
2119

2220
private final Device body;
2321

22+
private final Optional<Authorization> authOverride;
23+
2424
private int _cachedHashCode;
2525

26-
Request(Optional<Authorization> authOverride, String appId, String userId, Device body) {
27-
this.authOverride = authOverride;
26+
Request(String appId, String userId, Device body, Optional<Authorization> authOverride) {
2827
this.appId = appId;
2928
this.userId = userId;
3029
this.body = body;
30+
this.authOverride = authOverride;
3131
}
3232

33-
public Optional<Authorization> getAuthOverride() {
34-
return authOverride;
35-
}
36-
33+
/**
34+
* your app identifier
35+
*/
3736
public String getAppId() {
3837
return appId;
3938
}
4039

40+
/**
41+
* your user identifier
42+
*/
4143
public String getUserId() {
4244
return userId;
4345
}
@@ -46,27 +48,31 @@ public Device getBody() {
4648
return body;
4749
}
4850

51+
public Optional<Authorization> getAuthOverride() {
52+
return authOverride;
53+
}
54+
4955
@Override
5056
public boolean equals(Object other) {
5157
if (this == other) return true;
5258
return other instanceof Request && equalTo((Request) other);
5359
}
5460

5561
private boolean equalTo(Request other) {
56-
return authOverride.equals(other.authOverride) && appId.equals(other.appId) && userId.equals(other.userId) && body.equals(other.body);
62+
return appId.equals(other.appId) && userId.equals(other.userId) && body.equals(other.body) && authOverride.equals(other.authOverride);
5763
}
5864

5965
@Override
6066
public int hashCode() {
6167
if (_cachedHashCode == 0) {
62-
_cachedHashCode = Objects.hash(this.authOverride, this.appId, this.userId, this.body);
68+
_cachedHashCode = Objects.hash(this.appId, this.userId, this.body, this.authOverride);
6369
}
6470
return _cachedHashCode;
6571
}
6672

6773
@Override
6874
public String toString() {
69-
return "Add.Request{" + "authOverride: " + authOverride + ", appId: " + appId + ", userId: " + userId + ", body: " + body + "}";
75+
return "Add.Request{" + "appId: " + appId + ", userId: " + userId + ", body: " + body + ", authOverride: " + authOverride + "}";
7076
}
7177

7278
public static AppIdStage builder() {
@@ -95,7 +101,7 @@ public interface _FinalStage {
95101
_FinalStage authOverride(Authorization authOverride);
96102
}
97103

98-
static final class Builder implements AppIdStage, UserIdStage, BodyStage, _FinalStage {
104+
public static final class Builder implements AppIdStage, UserIdStage, BodyStage, _FinalStage {
99105
private String appId;
100106

101107
private String userId;
@@ -109,19 +115,25 @@ private Builder() {
109115

110116
@Override
111117
public Builder from(Request other) {
112-
authOverride(other.getAuthOverride());
113118
appId(other.getAppId());
114119
userId(other.getUserId());
115120
body(other.getBody());
121+
authOverride(other.getAuthOverride());
116122
return this;
117123
}
118124

125+
/**
126+
* your app identifier
127+
*/
119128
@Override
120129
public UserIdStage appId(String appId) {
121130
this.appId = appId;
122131
return this;
123132
}
124133

134+
/**
135+
* your user identifier
136+
*/
125137
@Override
126138
public BodyStage userId(String userId) {
127139
this.userId = userId;
@@ -148,7 +160,7 @@ public _FinalStage authOverride(Optional<Authorization> authOverride) {
148160

149161
@Override
150162
public Request build() {
151-
return new Request(authOverride, appId, userId, body);
163+
return new Request(appId, userId, body, authOverride);
152164
}
153165
}
154166
}

src/main/java/com/raven/api/client/device/endpoints/Delete.java

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,69 @@ private Delete() {
1212
}
1313

1414
public static final class Request {
15-
private final Optional<Authorization> authOverride;
16-
1715
private final String appId;
1816

1917
private final String userId;
2018

2119
private final String deviceId;
2220

21+
private final Optional<Authorization> authOverride;
22+
2323
private int _cachedHashCode;
2424

25-
Request(Optional<Authorization> authOverride, String appId, String userId, String deviceId) {
26-
this.authOverride = authOverride;
25+
Request(String appId, String userId, String deviceId, Optional<Authorization> authOverride) {
2726
this.appId = appId;
2827
this.userId = userId;
2928
this.deviceId = deviceId;
29+
this.authOverride = authOverride;
3030
}
3131

32-
public Optional<Authorization> getAuthOverride() {
33-
return authOverride;
34-
}
35-
32+
/**
33+
* your app identifier
34+
*/
3635
public String getAppId() {
3736
return appId;
3837
}
3938

39+
/**
40+
* your user identifier
41+
*/
4042
public String getUserId() {
4143
return userId;
4244
}
4345

46+
/**
47+
* your device identifier
48+
*/
4449
public String getDeviceId() {
4550
return deviceId;
4651
}
4752

53+
public Optional<Authorization> getAuthOverride() {
54+
return authOverride;
55+
}
56+
4857
@Override
4958
public boolean equals(Object other) {
5059
if (this == other) return true;
5160
return other instanceof Request && equalTo((Request) other);
5261
}
5362

5463
private boolean equalTo(Request other) {
55-
return authOverride.equals(other.authOverride) && appId.equals(other.appId) && userId.equals(other.userId) && deviceId.equals(other.deviceId);
64+
return appId.equals(other.appId) && userId.equals(other.userId) && deviceId.equals(other.deviceId) && authOverride.equals(other.authOverride);
5665
}
5766

5867
@Override
5968
public int hashCode() {
6069
if (_cachedHashCode == 0) {
61-
_cachedHashCode = Objects.hash(this.authOverride, this.appId, this.userId, this.deviceId);
70+
_cachedHashCode = Objects.hash(this.appId, this.userId, this.deviceId, this.authOverride);
6271
}
6372
return _cachedHashCode;
6473
}
6574

6675
@Override
6776
public String toString() {
68-
return "Delete.Request{" + "authOverride: " + authOverride + ", appId: " + appId + ", userId: " + userId + ", deviceId: " + deviceId + "}";
77+
return "Delete.Request{" + "appId: " + appId + ", userId: " + userId + ", deviceId: " + deviceId + ", authOverride: " + authOverride + "}";
6978
}
7079

7180
public static AppIdStage builder() {
@@ -94,7 +103,7 @@ public interface _FinalStage {
94103
_FinalStage authOverride(Authorization authOverride);
95104
}
96105

97-
static final class Builder implements AppIdStage, UserIdStage, DeviceIdStage, _FinalStage {
106+
public static final class Builder implements AppIdStage, UserIdStage, DeviceIdStage, _FinalStage {
98107
private String appId;
99108

100109
private String userId;
@@ -108,25 +117,34 @@ private Builder() {
108117

109118
@Override
110119
public Builder from(Request other) {
111-
authOverride(other.getAuthOverride());
112120
appId(other.getAppId());
113121
userId(other.getUserId());
114122
deviceId(other.getDeviceId());
123+
authOverride(other.getAuthOverride());
115124
return this;
116125
}
117126

127+
/**
128+
* your app identifier
129+
*/
118130
@Override
119131
public UserIdStage appId(String appId) {
120132
this.appId = appId;
121133
return this;
122134
}
123135

136+
/**
137+
* your user identifier
138+
*/
124139
@Override
125140
public DeviceIdStage userId(String userId) {
126141
this.userId = userId;
127142
return this;
128143
}
129144

145+
/**
146+
* your device identifier
147+
*/
130148
@Override
131149
public _FinalStage deviceId(String deviceId) {
132150
this.deviceId = deviceId;
@@ -147,7 +165,7 @@ public _FinalStage authOverride(Optional<Authorization> authOverride) {
147165

148166
@Override
149167
public Request build() {
150-
return new Request(authOverride, appId, userId, deviceId);
168+
return new Request(appId, userId, deviceId, authOverride);
151169
}
152170
}
153171
}

0 commit comments

Comments
 (0)