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

com.fireblocks.sdk.model.ContractUploadRequest Maven / Gradle / Ivy

/*
 * Fireblocks API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.6.2
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

package com.fireblocks.sdk.model;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonValue;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

/** ContractUploadRequest */
@JsonPropertyOrder({
    ContractUploadRequest.JSON_PROPERTY_NAME,
    ContractUploadRequest.JSON_PROPERTY_DESCRIPTION,
    ContractUploadRequest.JSON_PROPERTY_LONG_DESCRIPTION,
    ContractUploadRequest.JSON_PROPERTY_BYTECODE,
    ContractUploadRequest.JSON_PROPERTY_SOURCECODE,
    ContractUploadRequest.JSON_PROPERTY_TYPE,
    ContractUploadRequest.JSON_PROPERTY_DOCS,
    ContractUploadRequest.JSON_PROPERTY_ABI,
    ContractUploadRequest.JSON_PROPERTY_ATTRIBUTES
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ContractUploadRequest {
    public static final String JSON_PROPERTY_NAME = "name";
    private String name;

    public static final String JSON_PROPERTY_DESCRIPTION = "description";
    private String description;

    public static final String JSON_PROPERTY_LONG_DESCRIPTION = "longDescription";
    private String longDescription;

    public static final String JSON_PROPERTY_BYTECODE = "bytecode";
    private String bytecode;

    public static final String JSON_PROPERTY_SOURCECODE = "sourcecode";
    private String sourcecode;

    /** The type of the contract template */
    public enum TypeEnum {
        FUNGIBLE_TOKEN("FUNGIBLE_TOKEN"),

        NON_FUNGIBLE_TOKEN("NON_FUNGIBLE_TOKEN"),

        NON_TOKEN("NON_TOKEN"),

        TOKEN_EXTENSION("TOKEN_EXTENSION"),

        TOKEN_UTILITY("TOKEN_UTILITY");

        private String value;

        TypeEnum(String value) {
            this.value = value;
        }

        @JsonValue
        public String getValue() {
            return value;
        }

        @Override
        public String toString() {
            return String.valueOf(value);
        }

        @JsonCreator
        public static TypeEnum fromValue(String value) {
            for (TypeEnum b : TypeEnum.values()) {
                if (b.value.equals(value)) {
                    return b;
                }
            }
            throw new IllegalArgumentException("Unexpected value '" + value + "'");
        }
    }

    public static final String JSON_PROPERTY_TYPE = "type";
    private TypeEnum type;

    public static final String JSON_PROPERTY_DOCS = "docs";
    private ContractDoc docs;

    public static final String JSON_PROPERTY_ABI = "abi";
    private List> abi = new ArrayList<>();

    public static final String JSON_PROPERTY_ATTRIBUTES = "attributes";
    private ContractAttributes attributes;

    public ContractUploadRequest() {}

    public ContractUploadRequest name(String name) {
        this.name = name;
        return this;
    }

    /**
     * The name of the contract template
     *
     * @return name
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_NAME)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public String getName() {
        return name;
    }

    @JsonProperty(JSON_PROPERTY_NAME)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setName(String name) {
        this.name = name;
    }

    public ContractUploadRequest description(String description) {
        this.description = description;
        return this;
    }

    /**
     * A short description of the contract template
     *
     * @return description
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_DESCRIPTION)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public String getDescription() {
        return description;
    }

    @JsonProperty(JSON_PROPERTY_DESCRIPTION)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setDescription(String description) {
        this.description = description;
    }

    public ContractUploadRequest longDescription(String longDescription) {
        this.longDescription = longDescription;
        return this;
    }

    /**
     * A full description of the contract template. May contain to break the lines
     *
     * @return longDescription
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_LONG_DESCRIPTION)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public String getLongDescription() {
        return longDescription;
    }

    @JsonProperty(JSON_PROPERTY_LONG_DESCRIPTION)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setLongDescription(String longDescription) {
        this.longDescription = longDescription;
    }

    public ContractUploadRequest bytecode(String bytecode) {
        this.bytecode = bytecode;
        return this;
    }

    /**
     * The compiled artifact of this smart contract. Used for deployment of this contract template
     *
     * @return bytecode
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_BYTECODE)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public String getBytecode() {
        return bytecode;
    }

    @JsonProperty(JSON_PROPERTY_BYTECODE)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setBytecode(String bytecode) {
        this.bytecode = bytecode;
    }

    public ContractUploadRequest sourcecode(String sourcecode) {
        this.sourcecode = sourcecode;
        return this;
    }

    /**
     * The source code of the contract. Optional.
     *
     * @return sourcecode
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_SOURCECODE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public String getSourcecode() {
        return sourcecode;
    }

    @JsonProperty(JSON_PROPERTY_SOURCECODE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setSourcecode(String sourcecode) {
        this.sourcecode = sourcecode;
    }

    public ContractUploadRequest type(TypeEnum type) {
        this.type = type;
        return this;
    }

    /**
     * The type of the contract template
     *
     * @return type
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_TYPE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public TypeEnum getType() {
        return type;
    }

    @JsonProperty(JSON_PROPERTY_TYPE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setType(TypeEnum type) {
        this.type = type;
    }

    public ContractUploadRequest docs(ContractDoc docs) {
        this.docs = docs;
        return this;
    }

    /**
     * A `natspec` compliant documentation json. Can be retrieved from the output json
     * after compilation
     *
     * @return docs
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_DOCS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public ContractDoc getDocs() {
        return docs;
    }

    @JsonProperty(JSON_PROPERTY_DOCS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setDocs(ContractDoc docs) {
        this.docs = docs;
    }

    public ContractUploadRequest abi(List> abi) {
        this.abi = abi;
        return this;
    }

    public ContractUploadRequest addAbiItem(List abiItem) {
        if (this.abi == null) {
            this.abi = new ArrayList<>();
        }
        this.abi.add(abiItem);
        return this;
    }

    /**
     * Get abi
     *
     * @return abi
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_ABI)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public List> getAbi() {
        return abi;
    }

    @JsonProperty(JSON_PROPERTY_ABI)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setAbi(List> abi) {
        this.abi = abi;
    }

    public ContractUploadRequest attributes(ContractAttributes attributes) {
        this.attributes = attributes;
        return this;
    }

    /**
     * The attributes related to this contract template. It will be displayed in the tokenization
     * page
     *
     * @return attributes
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_ATTRIBUTES)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public ContractAttributes getAttributes() {
        return attributes;
    }

    @JsonProperty(JSON_PROPERTY_ATTRIBUTES)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setAttributes(ContractAttributes attributes) {
        this.attributes = attributes;
    }

    /** Return true if this ContractUploadRequest object is equal to o. */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ContractUploadRequest contractUploadRequest = (ContractUploadRequest) o;
        return Objects.equals(this.name, contractUploadRequest.name)
                && Objects.equals(this.description, contractUploadRequest.description)
                && Objects.equals(this.longDescription, contractUploadRequest.longDescription)
                && Objects.equals(this.bytecode, contractUploadRequest.bytecode)
                && Objects.equals(this.sourcecode, contractUploadRequest.sourcecode)
                && Objects.equals(this.type, contractUploadRequest.type)
                && Objects.equals(this.docs, contractUploadRequest.docs)
                && Objects.equals(this.abi, contractUploadRequest.abi)
                && Objects.equals(this.attributes, contractUploadRequest.attributes);
    }

    @Override
    public int hashCode() {
        return Objects.hash(
                name,
                description,
                longDescription,
                bytecode,
                sourcecode,
                type,
                docs,
                abi,
                attributes);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class ContractUploadRequest {\n");
        sb.append("    name: ").append(toIndentedString(name)).append("\n");
        sb.append("    description: ").append(toIndentedString(description)).append("\n");
        sb.append("    longDescription: ").append(toIndentedString(longDescription)).append("\n");
        sb.append("    bytecode: ").append(toIndentedString(bytecode)).append("\n");
        sb.append("    sourcecode: ").append(toIndentedString(sourcecode)).append("\n");
        sb.append("    type: ").append(toIndentedString(type)).append("\n");
        sb.append("    docs: ").append(toIndentedString(docs)).append("\n");
        sb.append("    abi: ").append(toIndentedString(abi)).append("\n");
        sb.append("    attributes: ").append(toIndentedString(attributes)).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 `name` to the URL query string
        if (getName() != null) {
            joiner.add(
                    String.format(
                            "%sname%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `description` to the URL query string
        if (getDescription() != null) {
            joiner.add(
                    String.format(
                            "%sdescription%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(
                                            String.valueOf(getDescription()),
                                            StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `longDescription` to the URL query string
        if (getLongDescription() != null) {
            joiner.add(
                    String.format(
                            "%slongDescription%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(
                                            String.valueOf(getLongDescription()),
                                            StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `bytecode` to the URL query string
        if (getBytecode() != null) {
            joiner.add(
                    String.format(
                            "%sbytecode%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(String.valueOf(getBytecode()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `sourcecode` to the URL query string
        if (getSourcecode() != null) {
            joiner.add(
                    String.format(
                            "%ssourcecode%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(
                                            String.valueOf(getSourcecode()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `type` to the URL query string
        if (getType() != null) {
            joiner.add(
                    String.format(
                            "%stype%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `docs` to the URL query string
        if (getDocs() != null) {
            joiner.add(getDocs().toUrlQueryString(prefix + "docs" + suffix));
        }

        // add `abi` to the URL query string
        if (getAbi() != null) {
            for (int i = 0; i < getAbi().size(); i++) {
                if (getAbi().get(i) != null) {
                    joiner.add(
                            String.format(
                                    "%sabi%s%s=%s",
                                    prefix,
                                    suffix,
                                    "".equals(suffix)
                                            ? ""
                                            : String.format(
                                                    "%s%d%s", containerPrefix, i, containerSuffix),
                                    URLEncoder.encode(
                                                    String.valueOf(getAbi().get(i)),
                                                    StandardCharsets.UTF_8)
                                            .replaceAll("\\+", "%20")));
                }
            }
        }

        // add `attributes` to the URL query string
        if (getAttributes() != null) {
            joiner.add(getAttributes().toUrlQueryString(prefix + "attributes" + suffix));
        }

        return joiner.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy