001    /*
002     * The MIT License
003     * Copyright (c) 2012 Microsoft Corporation
004     *
005     * Permission is hereby granted, free of charge, to any person obtaining a copy
006     * of this software and associated documentation files (the "Software"), to deal
007     * in the Software without restriction, including without limitation the rights
008     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009     * copies of the Software, and to permit persons to whom the Software is
010     * furnished to do so, subject to the following conditions:
011     *
012     * The above copyright notice and this permission notice shall be included in
013     * all copies or substantial portions of the Software.
014     *
015     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021     * THE SOFTWARE.
022     */
023    
024    package microsoft.exchange.webservices.data.core.request;
025    
026    import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
027    import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;
028    import microsoft.exchange.webservices.data.core.ExchangeService;
029    import microsoft.exchange.webservices.data.core.XmlElementNames;
030    import microsoft.exchange.webservices.data.core.response.PlayOnPhoneResponse;
031    import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
032    import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
033    import microsoft.exchange.webservices.data.property.complex.ItemId;
034    
035    /**
036     * Represents a PlayOnPhone request.
037     */
038    public final class PlayOnPhoneRequest extends SimpleServiceRequestBase<PlayOnPhoneResponse> {
039    
040      /**
041       * The item id.
042       */
043      private ItemId itemId;
044    
045      /**
046       * The dial string.
047       */
048      private String dialString;
049    
050      /**
051       * Initializes a new instance of the PlayOnPhoneRequest class.
052       *
053       * @param service the service
054       * @throws Exception
055       */
056      public PlayOnPhoneRequest(ExchangeService service)
057          throws Exception {
058        super(service);
059      }
060    
061      /**
062       * Gets the name of the XML element.
063       *
064       * @return XML element name.
065       */
066      @Override public String getXmlElementName() {
067        return XmlElementNames.PlayOnPhone;
068      }
069    
070      /**
071       * Writes XML elements.
072       *
073       * @param writer the writer
074       * @throws Exception the exception
075       */
076      @Override
077      protected void writeElementsToXml(EwsServiceXmlWriter writer)
078          throws Exception {
079        this.itemId.writeToXml(writer, XmlNamespace.Messages,
080            XmlElementNames.ItemId);
081        writer.writeElementValue(XmlNamespace.Messages,
082            XmlElementNames.DialString, dialString);
083      }
084    
085      /**
086       * Gets the name of the response XML element.
087       *
088       * @return XML element name,
089       */
090      @Override
091      protected String getResponseXmlElementName() {
092        return XmlElementNames.PlayOnPhoneResponse;
093      }
094    
095      /**
096       * {@inheritDoc}
097       */
098      @Override
099      protected PlayOnPhoneResponse parseResponse(EwsServiceXmlReader reader)
100          throws Exception {
101        PlayOnPhoneResponse serviceResponse = new PlayOnPhoneResponse(this
102            .getService());
103        serviceResponse
104            .loadFromXml(reader, XmlElementNames.PlayOnPhoneResponse);
105        return serviceResponse;
106      }
107    
108      /**
109       * Gets the request version.
110       *
111       * @return Earliest Exchange version in which this request is supported.
112       */
113      @Override
114      protected ExchangeVersion getMinimumRequiredServerVersion() {
115        return ExchangeVersion.Exchange2010;
116      }
117    
118      /**
119       * Executes this request.
120       *
121       * @return Service response.
122       * @throws Exception the exception
123       */
124      public PlayOnPhoneResponse execute() throws Exception {
125        PlayOnPhoneResponse serviceResponse = internalExecute();
126        serviceResponse.throwIfNecessary();
127        return serviceResponse;
128      }
129    
130      /**
131       * Gets the item id of the message to play.
132       *
133       * @return the item id
134       */
135      protected ItemId getItemId() {
136        return this.itemId;
137      }
138    
139      /**
140       * Sets the item id.
141       *
142       * @param itemId the new item id
143       */
144      public void setItemId(ItemId itemId) {
145        this.itemId = itemId;
146      }
147    
148      /**
149       * Gets  the dial string.
150       *
151       * @return the dial string
152       */
153      protected String getDialString() {
154        return this.dialString;
155      }
156    
157      /**
158       * Sets the dial string.
159       *
160       * @param dialString the new dial string
161       */
162      public void setDialString(String dialString) {
163        this.dialString = dialString;
164      }
165    
166    }