All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.auties.whatsapp.model.companion.CompanionDeviceSpec Maven / Gradle / Ivy

package it.auties.whatsapp.model.companion;

import it.auties.whatsapp.model.companion.CompanionDevice;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;

public class CompanionDeviceSpec {
    public static byte[] encode(CompanionDevice protoInputObject) {
      if(protoInputObject == null) {
         return null;
      }
      var outputStream = new ProtobufOutputStream();
outputStream.writeString(1, protoInputObject.model());
outputStream.writeString(2, protoInputObject.manufacturer());
outputStream.writeInt32(3, it.auties.whatsapp.model.signal.auth.UserAgentPlatformTypeSpec.encode(protoInputObject.platform()));
outputStream.writeString(4, protoInputObject.version());
      return outputStream.toByteArray();
    }

    public static CompanionDevice decode(byte[] input) {
        if(input == null) {
            return null;
        }
        var inputStream = new ProtobufInputStream(input);
        java.lang.String model = null;
        java.lang.String manufacturer = null;
        it.auties.whatsapp.model.signal.auth.UserAgent.PlatformType platform = null;
        java.lang.String version = null;
        while(inputStream.readTag()) {
            switch(inputStream.index()) {
                case 1 -> model = inputStream.readString();
                case 2 -> manufacturer = inputStream.readString();
                case 3 -> platform = it.auties.whatsapp.model.signal.auth.UserAgentPlatformTypeSpec.decode(inputStream.readInt32()).orElse(null);
                case 4 -> version = inputStream.readString();
                default -> inputStream.skipBytes();
            }
        }
        return new it.auties.whatsapp.model.companion.CompanionDevice(model, manufacturer, platform, version);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy