/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT License.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is regenerated.
 */

import { FileAssets } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { AppCenterClient } from "../appCenterClient";
import {
  FileAssetsCreateOptionalParams,
  FileAssetsCreateResponse
} from "../models";

/** Class containing FileAssets operations. */
export class FileAssetsImpl implements FileAssets {
  private readonly client: AppCenterClient;

  /**
   * Initialize a new instance of the class FileAssets class.
   * @param client Reference to the service client
   */
  constructor(client: AppCenterClient) {
    this.client = client;
  }

  /**
   * Create a new asset to upload a file
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param options The options parameters.
   */
  create(
    ownerName: string,
    appName: string,
    options?: FileAssetsCreateOptionalParams
  ): Promise<FileAssetsCreateResponse> {
    return this.client.sendOperationRequest(
      { ownerName, appName, options },
      createOperationSpec
    );
  }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);

const createOperationSpec: coreClient.OperationSpec = {
  path: "/v0.1/apps/{owner_name}/{app_name}/file_asset",
  httpMethod: "POST",
  responses: {
    200: {
      bodyMapper:
        Mappers.PathsUd9Bz2V01AppsOwnerNameAppNameFileAssetPostResponses200ContentApplicationJsonSchema
    },
    default: {
      bodyMapper:
        Mappers.Paths1V86Qb5V01AppsOwnerNameAppNameFileAssetPostResponsesDefaultContentApplicationJsonSchema
    }
  },
  requestBody: Parameters.payload,
  urlParameters: [Parameters.$host, Parameters.ownerName, Parameters.appName],
  headerParameters: [Parameters.contentType, Parameters.accept],
  mediaType: "json",
  serializer
};
