Skip to content

Commit

Permalink
Search api
Browse files Browse the repository at this point in the history
  • Loading branch information
SeniorZhai committed May 7, 2022
1 parent 9de30df commit e5db7d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ interface UserCallService {
fun mixinMainnetRPCCall(
@Body rpcRequest: RpcRequest
): Call<JsonObject>

@GET("search/{query}")
fun searchCall(@Path("query") query: String): Call<MixinResponse<User>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ interface UserCoroutineService {
suspend fun mixinMainnetRPC(
@Body rpcRequest: RpcRequest
): JsonObject

@GET("search/{query}")
suspend fun search(@Path("query") query: String): MixinResponse<User>
}
13 changes: 13 additions & 0 deletions samples/src/main/java/jvmMain/java/Sample.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public static void main(String[] args) {
EdDSAPublicKey publicKey = (EdDSAPublicKey) (sessionKey.getPublic());
String sessionSecret = base64Encode(publicKey.getAbyte());

// searchUser(client);

User user = createUser(client, sessionSecret);
assert user != null;
client.setUserToken(getUserToken(user, sessionKey, false));
Expand Down Expand Up @@ -157,6 +159,17 @@ private static User createUser(HttpClient client, String sessionSecret) throws I
return user;
}

private static void searchUser(HttpClient client) throws IOException {
// Search user
MixinResponse<User> userResponse = client.getUserService().searchCall("26832").execute().body();
assert userResponse != null;
if (userResponse.isSuccess()) {
System.out.printf("User %s: %s%n", Objects.requireNonNull(userResponse.getData()).getFullName(), Objects.requireNonNull(userResponse.getData()).getUserId());
} else {
System.out.println("Search failure");
}
}

private static void createPin(HttpClient client, String userAesKey) throws IOException {
MixinResponse<User> pinResponse = client.getUserService().createPinCall(new PinRequest(Objects.requireNonNull(encryptPin(userAesKey, Sample.userPin)), null)).execute().body();
assert pinResponse != null;
Expand Down

0 comments on commit e5db7d5

Please sign in to comment.