﻿import {EwsServiceXmlWriter} from "../EwsServiceXmlWriter";
import {ExchangeService} from "../ExchangeService";
import {ExchangeVersion} from "../../Enumerations/ExchangeVersion";
import {GetRoomListsResponse} from "../Responses/GetRoomListsResponse";
import {XmlElementNames} from "../XmlElementNames";

import {SimpleServiceRequestBase} from "./SimpleServiceRequestBase";
/** 
 * @internal Represents a GetRoomList request. 
 * 
 * @sealed
 */
export class GetRoomListsRequest extends SimpleServiceRequestBase {
    
    /**
     * @internal Initializes a new instance of the **GetRoomListsRequest** class.
     *
     * @param   {service}   service   The service.
     */
    constructor(service: ExchangeService) {
        super(service);
    }

    /**
     * @internal Executes this request.
     *
     * @return  {Promise<GetRoomListsResponse>}      Service response  :Promise.
     */
    Execute(): Promise<GetRoomListsResponse> {
        return this.InternalExecute().then((serviceResponse: GetRoomListsResponse) => {
            serviceResponse.ThrowIfNecessary();
            return serviceResponse;
        });
    }

    /**
	 * @internal Gets the request version.
	 *
	 * @return  {ExchangeVersion}      Earliest Exchange version in which this request is supported.
	 */
    GetMinimumRequiredServerVersion(): ExchangeVersion {
        return ExchangeVersion.Exchange2010;
    }

    /**
	 * @internal Gets the name of the response XML element.
	 *
	 * @return  {string}      XML element name.
	 */
    GetResponseXmlElementName(): string {
        return XmlElementNames.GetRoomListsResponse;
    }

    /**
	 * @internal Gets the name of the XML element.
	 *
	 * @return  {string}      XML element name.
	 */
    GetXmlElementName(): string {
        return XmlElementNames.GetRoomListsRequest;
    }

    /**
     * @internal Parses the response.
     *
     * @param   {any}   jsonBody   The js object response body.
     * @return  {any}              Response object.
     */
    ParseResponse(jsonBody: any): any {
        let response: GetRoomListsResponse = new GetRoomListsResponse();
        response.LoadFromXmlJsObject(jsonBody, this.Service);
        return response;
    }

    /**
	 * @internal Writes the elements to XML writer.
	 *
	 * @param   {EwsServiceXmlWriter}   writer   The writer.
	 */
    WriteElementsToXml(writer: EwsServiceXmlWriter): void {
        // Don't have parameter in request
    }
}