/*
 * 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 { Commits } 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 {
  CommitsListByShaListOptionalParams,
  CommitsListByShaListResponse
} from "../models";

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

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

  /**
   * Returns commit information for a batch of shas
   * @param hashes A collection of commit SHAs comma-delimited
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param options The options parameters.
   */
  listByShaList(
    hashes: string[],
    ownerName: string,
    appName: string,
    options?: CommitsListByShaListOptionalParams
  ): Promise<CommitsListByShaListResponse> {
    return this.client.sendOperationRequest(
      { hashes, ownerName, appName, options },
      listByShaListOperationSpec
    );
  }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);

const listByShaListOperationSpec: coreClient.OperationSpec = {
  path: "/v0.1/apps/{owner_name}/{app_name}/commits/batch",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: {
        type: {
          name: "Sequence",
          element: {
            type: {
              name: "Composite",
              className:
                "PathsCbr4BhV01AppsOwnerNameAppNameCommitsBatchGetResponses200ContentApplicationJsonSchemaItems"
            }
          }
        }
      }
    }
  },
  queryParameters: [Parameters.hashes],
  urlParameters: [Parameters.$host, Parameters.ownerName, Parameters.appName],
  headerParameters: [Parameters.accept],
  serializer
};
