// Path: app/src/main/java/com/steevsapps/idledaddy/handlers/callbacks/PurchaseResponseCallback.java
// public class PurchaseResponseCallback extends CallbackMsg {
//     private final EResult result;
//     private final EPurchaseResultDetail purchaseResultDetails;
//     private final KeyValue purchaseReceiptInfo;
// 
//     public PurchaseResponseCallback(JobID jobID, SteammessagesClientserver2.CMsgClientPurchaseResponse.Builder msg) {
//         setJobID(jobID);
// 
//         result = EResult.from(msg.getEresult());
//         purchaseResultDetails = EPurchaseResultDetail.from(msg.getPurchaseResultDetails());
//         purchaseReceiptInfo = new KeyValue();
//         try {
//             purchaseReceiptInfo.tryReadAsBinary(new ByteArrayInputStream(msg.getPurchaseReceiptInfo().toByteArray()));
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public EResult getResult() {
//         return result;
//     }
// 
//     public EPurchaseResultDetail getPurchaseResultDetails() {
//         return purchaseResultDetails;
//     }
// 
//     public KeyValue getPurchaseReceiptInfo() {
//         return purchaseReceiptInfo;
//     }
// }


import com.steevsapps.idledaddy.handlers.callbacks.PurchaseResponseCallback;
import in.dragonbra.javasteam.base.ClientMsgProtobuf;
import in.dragonbra.javasteam.base.IPacketMsg;
import in.dragonbra.javasteam.handlers.ClientMsgHandler;
import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2;
package com.steevsapps.idledaddy.handlers;



public class PurchaseResponse extends ClientMsgHandler {
    @Override
    public void handleMsg(IPacketMsg packetMsg) {
        if (packetMsg == null) {
            throw new IllegalArgumentException("packetMsg is null");
        }

        switch (packetMsg.getMsgType()) {
            case ClientPurchaseResponse:
                handlePurchaseResponse(packetMsg);
                break;
        }
    }

    private void handlePurchaseResponse(IPacketMsg packetMsg) {
        final ClientMsgProtobuf<SteammessagesClientserver2.CMsgClientPurchaseResponse.Builder> purchaseResponse;
        purchaseResponse = new ClientMsgProtobuf<>(SteammessagesClientserver2.CMsgClientPurchaseResponse.class, packetMsg);
// Path: app/src/main/java/com/steevsapps/idledaddy/handlers/callbacks/PurchaseResponseCallback.java
// public class PurchaseResponseCallback extends CallbackMsg {
//     private final EResult result;
//     private final EPurchaseResultDetail purchaseResultDetails;
//     private final KeyValue purchaseReceiptInfo;
// 
//     public PurchaseResponseCallback(JobID jobID, SteammessagesClientserver2.CMsgClientPurchaseResponse.Builder msg) {
//         setJobID(jobID);
// 
//         result = EResult.from(msg.getEresult());
//         purchaseResultDetails = EPurchaseResultDetail.from(msg.getPurchaseResultDetails());
//         purchaseReceiptInfo = new KeyValue();
//         try {
//             purchaseReceiptInfo.tryReadAsBinary(new ByteArrayInputStream(msg.getPurchaseReceiptInfo().toByteArray()));
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public EResult getResult() {
//         return result;
//     }
// 
//     public EPurchaseResultDetail getPurchaseResultDetails() {
//         return purchaseResultDetails;
//     }
// 
//     public KeyValue getPurchaseReceiptInfo() {
//         return purchaseReceiptInfo;
//     }
// }


// Path: app/src/main/java/com/steevsapps/idledaddy/handlers/PurchaseResponse.java
import com.steevsapps.idledaddy.handlers.callbacks.PurchaseResponseCallback;
import in.dragonbra.javasteam.base.ClientMsgProtobuf;
import in.dragonbra.javasteam.base.IPacketMsg;
import in.dragonbra.javasteam.handlers.ClientMsgHandler;
import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2;

package com.steevsapps.idledaddy.handlers;



public class PurchaseResponse extends ClientMsgHandler {
    @Override
    public void handleMsg(IPacketMsg packetMsg) {
        if (packetMsg == null) {
            throw new IllegalArgumentException("packetMsg is null");
        }

        switch (packetMsg.getMsgType()) {
            case ClientPurchaseResponse:
                handlePurchaseResponse(packetMsg);
                break;
        }
    }

    private void handlePurchaseResponse(IPacketMsg packetMsg) {
        final ClientMsgProtobuf<SteammessagesClientserver2.CMsgClientPurchaseResponse.Builder> purchaseResponse;
        purchaseResponse = new ClientMsgProtobuf<>(SteammessagesClientserver2.CMsgClientPurchaseResponse.class, packetMsg);
        getClient().postCallback(new PurchaseResponseCallback(purchaseResponse.getTargetJobID(), purchaseResponse.getBody()));