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

live.radix.gateway.model.TransactionPreviewResponse Maven / Gradle / Ivy

There is a newer version: 1.9.0
Show newest version
/*
 * Radix Gateway API - Babylon
 * This API is exposed by the Babylon Radix Gateway to enable clients to efficiently query current and historic state on the RadixDLT ledger, and intelligently handle transaction submission.  It is designed for use by wallets and explorers, and for light queries from front-end dApps. For exchange/asset integrations, back-end dApp integrations, or simple use cases, you should consider using the Core API on a Node. A Gateway is only needed for reading historic snapshots of ledger states or a more robust set-up.  The Gateway API is implemented by the [Network Gateway](https://github.com/radixdlt/babylon-gateway), which is configured to read from [full node(s)](https://github.com/radixdlt/babylon-node) to extract and index data from the network.  This document is an API reference documentation, visit [User Guide](https://docs.radixdlt.com/) to learn more about how to run a Gateway of your own.  ## Migration guide  Please see [the latest release notes](https://github.com/radixdlt/babylon-gateway/releases).  ## Integration and forward compatibility guarantees  All responses may have additional fields added at any release, so clients are advised to use JSON parsers which ignore unknown fields on JSON objects.  When the Radix protocol is updated, new functionality may be added, and so discriminated unions returned by the API may need to be updated to have new variants added, corresponding to the updated data. Clients may need to update in advance to be able to handle these new variants when a protocol update comes out.  On the very rare occasions we need to make breaking changes to the API, these will be warned in advance with deprecation notices on previous versions. These deprecation notices will include a safe migration path. Deprecation notes or breaking changes will be flagged clearly in release notes for new versions of the Gateway.  The Gateway DB schema is not subject to any compatibility guarantees, and may be changed at any release. DB changes will be flagged in the release notes so clients doing custom DB integrations can prepare. 
 *
 * The version of the OpenAPI document: v1.9.2-L
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package live.radix.gateway.model;

import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import live.radix.gateway.model.TransactionPreviewResponseLogsInner;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.StringJoiner;

/**
 * TransactionPreviewResponse
 */
@JsonPropertyOrder({
  TransactionPreviewResponse.JSON_PROPERTY_ENCODED_RECEIPT,
  TransactionPreviewResponse.JSON_PROPERTY_RADIX_ENGINE_TOOLKIT_RECEIPT,
  TransactionPreviewResponse.JSON_PROPERTY_RECEIPT,
  TransactionPreviewResponse.JSON_PROPERTY_RESOURCE_CHANGES,
  TransactionPreviewResponse.JSON_PROPERTY_LOGS
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-12-12T19:38:04.213407200+02:00[Europe/Kiev]", comments = "Generator version: 7.7.0")
public class TransactionPreviewResponse {
  public static final String JSON_PROPERTY_ENCODED_RECEIPT = "encoded_receipt";
  private String encodedReceipt;

  public static final String JSON_PROPERTY_RADIX_ENGINE_TOOLKIT_RECEIPT = "radix_engine_toolkit_receipt";
  private Object radixEngineToolkitReceipt;

  public static final String JSON_PROPERTY_RECEIPT = "receipt";
  private Object receipt;

  public static final String JSON_PROPERTY_RESOURCE_CHANGES = "resource_changes";
  private List resourceChanges = new ArrayList<>();

  public static final String JSON_PROPERTY_LOGS = "logs";
  private List logs = new ArrayList<>();

  public TransactionPreviewResponse() {
  }

  public TransactionPreviewResponse encodedReceipt(String encodedReceipt) {
    
    this.encodedReceipt = encodedReceipt;
    return this;
  }

  /**
   * Hex-encoded binary blob.
   * @return encodedReceipt
   */
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_ENCODED_RECEIPT)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public String getEncodedReceipt() {
    return encodedReceipt;
  }


  @JsonProperty(JSON_PROPERTY_ENCODED_RECEIPT)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setEncodedReceipt(String encodedReceipt) {
    this.encodedReceipt = encodedReceipt;
  }

  public TransactionPreviewResponse radixEngineToolkitReceipt(Object radixEngineToolkitReceipt) {
    
    this.radixEngineToolkitReceipt = radixEngineToolkitReceipt;
    return this;
  }

  /**
   * An optional field which is only provided if the `radix_engine_toolkit_receipt` flag is set to true when requesting a transaction preview from the API.  This receipt is primarily intended for use with the toolkit and may contain information that is already available in the receipt provided in the `receipt` field of this response.  A typical client of this API is not expected to use this receipt. The primary clients this receipt is intended for is the Radix wallet or any client that needs to perform execution summaries on their transactions. 
   * @return radixEngineToolkitReceipt
   */
  @javax.annotation.Nullable
  @JsonProperty(JSON_PROPERTY_RADIX_ENGINE_TOOLKIT_RECEIPT)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public Object getRadixEngineToolkitReceipt() {
    return radixEngineToolkitReceipt;
  }


  @JsonProperty(JSON_PROPERTY_RADIX_ENGINE_TOOLKIT_RECEIPT)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public void setRadixEngineToolkitReceipt(Object radixEngineToolkitReceipt) {
    this.radixEngineToolkitReceipt = radixEngineToolkitReceipt;
  }

  public TransactionPreviewResponse receipt(Object receipt) {
    
    this.receipt = receipt;
    return this;
  }

  /**
   * This type is defined in the Core API as `TransactionReceipt`. See the Core API documentation for more details. 
   * @return receipt
   */
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_RECEIPT)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public Object getReceipt() {
    return receipt;
  }


  @JsonProperty(JSON_PROPERTY_RECEIPT)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setReceipt(Object receipt) {
    this.receipt = receipt;
  }

  public TransactionPreviewResponse resourceChanges(List resourceChanges) {
    
    this.resourceChanges = resourceChanges;
    return this;
  }

  public TransactionPreviewResponse addResourceChangesItem(Object resourceChangesItem) {
    if (this.resourceChanges == null) {
      this.resourceChanges = new ArrayList<>();
    }
    this.resourceChanges.add(resourceChangesItem);
    return this;
  }

  /**
   * Get resourceChanges
   * @return resourceChanges
   */
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_RESOURCE_CHANGES)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public List getResourceChanges() {
    return resourceChanges;
  }


  @JsonProperty(JSON_PROPERTY_RESOURCE_CHANGES)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setResourceChanges(List resourceChanges) {
    this.resourceChanges = resourceChanges;
  }

  public TransactionPreviewResponse logs(List logs) {
    
    this.logs = logs;
    return this;
  }

  public TransactionPreviewResponse addLogsItem(TransactionPreviewResponseLogsInner logsItem) {
    if (this.logs == null) {
      this.logs = new ArrayList<>();
    }
    this.logs.add(logsItem);
    return this;
  }

  /**
   * Get logs
   * @return logs
   */
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_LOGS)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public List getLogs() {
    return logs;
  }


  @JsonProperty(JSON_PROPERTY_LOGS)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setLogs(List logs) {
    this.logs = logs;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    TransactionPreviewResponse transactionPreviewResponse = (TransactionPreviewResponse) o;
    return Objects.equals(this.encodedReceipt, transactionPreviewResponse.encodedReceipt) &&
        Objects.equals(this.radixEngineToolkitReceipt, transactionPreviewResponse.radixEngineToolkitReceipt) &&
        Objects.equals(this.receipt, transactionPreviewResponse.receipt) &&
        Objects.equals(this.resourceChanges, transactionPreviewResponse.resourceChanges) &&
        Objects.equals(this.logs, transactionPreviewResponse.logs);
  }

  @Override
  public int hashCode() {
    return Objects.hash(encodedReceipt, radixEngineToolkitReceipt, receipt, resourceChanges, logs);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class TransactionPreviewResponse {\n");
    sb.append("    encodedReceipt: ").append(toIndentedString(encodedReceipt)).append("\n");
    sb.append("    radixEngineToolkitReceipt: ").append(toIndentedString(radixEngineToolkitReceipt)).append("\n");
    sb.append("    receipt: ").append(toIndentedString(receipt)).append("\n");
    sb.append("    resourceChanges: ").append(toIndentedString(resourceChanges)).append("\n");
    sb.append("    logs: ").append(toIndentedString(logs)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

  /**
   * Convert the instance into URL query string.
   *
   * @return URL query string
   */
  public String toUrlQueryString() {
    return toUrlQueryString(null);
  }

  /**
   * Convert the instance into URL query string.
   *
   * @param prefix prefix of the query string
   * @return URL query string
   */
  public String toUrlQueryString(String prefix) {
    String suffix = "";
    String containerSuffix = "";
    String containerPrefix = "";
    if (prefix == null) {
      // style=form, explode=true, e.g. /pet?name=cat&type=manx
      prefix = "";
    } else {
      // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
      prefix = prefix + "[";
      suffix = "]";
      containerSuffix = "]";
      containerPrefix = "[";
    }

    StringJoiner joiner = new StringJoiner("&");

    // add `encoded_receipt` to the URL query string
    if (getEncodedReceipt() != null) {
      try {
        joiner.add(String.format("%sencoded_receipt%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEncodedReceipt()), "UTF-8").replaceAll("\\+", "%20")));
      } catch (UnsupportedEncodingException e) {
        // Should never happen, UTF-8 is always supported
        throw new RuntimeException(e);
      }
    }

    // add `radix_engine_toolkit_receipt` to the URL query string
    if (getRadixEngineToolkitReceipt() != null) {
      try {
        joiner.add(String.format("%sradix_engine_toolkit_receipt%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getRadixEngineToolkitReceipt()), "UTF-8").replaceAll("\\+", "%20")));
      } catch (UnsupportedEncodingException e) {
        // Should never happen, UTF-8 is always supported
        throw new RuntimeException(e);
      }
    }

    // add `receipt` to the URL query string
    if (getReceipt() != null) {
      try {
        joiner.add(String.format("%sreceipt%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getReceipt()), "UTF-8").replaceAll("\\+", "%20")));
      } catch (UnsupportedEncodingException e) {
        // Should never happen, UTF-8 is always supported
        throw new RuntimeException(e);
      }
    }

    // add `resource_changes` to the URL query string
    if (getResourceChanges() != null) {
      for (int i = 0; i < getResourceChanges().size(); i++) {
        try {
          joiner.add(String.format("%sresource_changes%s%s=%s", prefix, suffix,
              "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
              URLEncoder.encode(String.valueOf(getResourceChanges().get(i)), "UTF-8").replaceAll("\\+", "%20")));
        } catch (UnsupportedEncodingException e) {
          // Should never happen, UTF-8 is always supported
          throw new RuntimeException(e);
        }
      }
    }

    // add `logs` to the URL query string
    if (getLogs() != null) {
      for (int i = 0; i < getLogs().size(); i++) {
        if (getLogs().get(i) != null) {
          joiner.add(getLogs().get(i).toUrlQueryString(String.format("%slogs%s%s", prefix, suffix,
              "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix))));
        }
      }
    }

    return joiner.toString();
  }

}