// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.media.videoanalyzer.edge.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.serializer.JsonSerializerProviders;
import com.azure.core.util.serializer.ObjectSerializer;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;

/** Base class for direct method calls. */
@Fluent
public class MethodRequest {
    /*
     * Video Analyzer API version.
     */
    @JsonProperty(value = "@apiVersion", required = true)
    private String apiVersion;

    /** Creates an instance of MethodRequest class. */
    public MethodRequest() {
        apiVersion = "1.1";
    }

    /**
     * Get the apiVersion property: Video Analyzer API version.
     *
     * @return the apiVersion value.
     */
    public String getApiVersion() {
        return this.apiVersion;
    }

    /**
     * Get the payload as JSON: the serialized form of the request body
     *
     * @return the payload as JSON
     * @throws UnsupportedEncodingException UnsupportedEncodingException UnsupportedEncodingException
     */
    @JsonIgnore
    public String getPayloadAsJson() throws UnsupportedEncodingException {
        ObjectSerializer serializer = JsonSerializerProviders.createInstance();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        serializer.serialize(outputStream, this);
        String payload = outputStream.toString("UTF-8");
        return payload;
    }
}
