Skip to content

Commit

Permalink
More work on API stability
Browse files Browse the repository at this point in the history
  • Loading branch information
Auties00 committed Oct 6, 2023
1 parent 78f8418 commit 53b9b5b
Show file tree
Hide file tree
Showing 82 changed files with 2,146 additions and 1,642 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
</executions>
</plugin>

<!-- Deploy the result-->
<!-- Deploy the newsletters-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* A builder to specify the type of connection to use
*
* @param <T> the type of the result
* @param <T> the type of the newsletters
*/
@SuppressWarnings("unused")
public final class ConnectionBuilder<T extends OptionsBuilder<T>> {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/it/auties/whatsapp/api/ErrorHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface ErrorHandler {
* @param type the type of client experiencing the error
* @param location the location where the error occurred
* @param throwable a stacktrace of the error, if available
* @return a result determining what should be done
* @return a newsletters determining what should be done
*/
Result handleError(ClientType type, Location location, Throwable throwable);

Expand Down Expand Up @@ -127,7 +127,7 @@ enum Location {

/**
* The constants of this enumerated type describe the various types of actions that can be
* performed by an error handler in response to a throwable
* performed by an error handler in newsletters to a throwable
*/
enum Result {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public T verificationCodeSupplier(@NonNull Supplier<String> verificationCodeSupp
}

/**
* Sets the handler that provides the captcha result when verifying an account
* Sets the handler that provides the captcha newsletters when verifying an account
* Happens only on business devices
*
* @param verificationCaptchaSupplier the non-null supplier
Expand All @@ -72,7 +72,7 @@ public T verificationCodeSupplier(@NonNull AsyncVerificationCodeSupplier verific
}

/**
* Sets the handler that provides the captcha result when verifying an account
* Sets the handler that provides the captcha newsletters when verifying an account
* Happens only on business devices
*
* @param verificationCaptchaSupplier the non-null supplier
Expand Down
270 changes: 215 additions & 55 deletions src/main/java/it/auties/whatsapp/api/Whatsapp.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/it/auties/whatsapp/binary/BinaryDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public final class BinaryDecoder {
private ByteBuf buffer;

public synchronized Node decode(byte[] input) {
public Node decode(byte[] input) {
var buffer = BytesHelper.newBuffer(input);
var token = buffer.readByte() & 2;
allocateBuffer(token, buffer);
Expand Down
35 changes: 14 additions & 21 deletions src/main/java/it/auties/whatsapp/binary/BinaryEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public BinaryEncoder(List<String> singleByteTokens, List<String> doubleByteToken
this.doubleByteTokens = doubleByteTokens;
}

public synchronized byte[] encode(Node node) {
public byte[] encode(Node node) {
buffer.clear();
var encoded = writeNode(node);
var result = new byte[1 + encoded.length];
Expand Down Expand Up @@ -205,26 +205,19 @@ private void writeInt(int size) {
}

private void write(Object input) {
if (input == null) {
buffer.writeByte(LIST_EMPTY.data());
} else if (input instanceof String str) {
writeString(str);
} else if (input instanceof Boolean bool) {
writeString(Boolean.toString(bool));
} else if (input instanceof Number number) {
writeString(number.toString());
} else if (input instanceof byte[] bytes) {
writeBytes(bytes);
} else if (input instanceof Jid jid) {
writeJid(jid);
} else if (input instanceof Collection<?> collection) {
writeList(collection);
} else if (input instanceof Enum<?> serializable) {
writeString(Objects.toString(serializable));
} else if (input instanceof Node) {
throw new IllegalArgumentException("Invalid payload type(nodes should be wrapped by a collection): %s".formatted(input));
} else {
throw new IllegalArgumentException("Invalid payload type(%s): %s".formatted(input.getClass().getName(), input));
switch (input) {
case null -> buffer.writeByte(LIST_EMPTY.data());
case String str -> writeString(str);
case Boolean bool -> writeString(Boolean.toString(bool));
case Number number -> writeString(number.toString());
case byte[] bytes -> writeBytes(bytes);
case Jid jid -> writeJid(jid);
case Collection<?> collection -> writeList(collection);
case Enum<?> serializable -> writeString(Objects.toString(serializable));
case Node node ->
throw new IllegalArgumentException("Invalid payload type(nodes should be wrapped by a collection): %s".formatted(input));
default ->
throw new IllegalArgumentException("Invalid payload type(%s): %s".formatted(input.getClass().getName(), input));
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/main/java/it/auties/whatsapp/binary/BinaryProperty.java

This file was deleted.

Loading

0 comments on commit 53b9b5b

Please sign in to comment.