|
| 1 | +// ------------------------------------------------------------------------------ |
| 2 | +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. |
| 3 | +// ------------------------------------------------------------------------------ |
| 4 | + |
| 5 | +// **NOTE** This file was generated by a tool and any changes will be overwritten. |
| 6 | +// <auto-generated/> |
| 7 | + |
| 8 | +// Template Source: Templates\CSharp\Requests\EntityWithReferenceRequest.cs.tt |
| 9 | + |
| 10 | +namespace Microsoft.Graph |
| 11 | +{ |
| 12 | + using System; |
| 13 | + using System.Collections.Generic; |
| 14 | + using System.IO; |
| 15 | + using System.Net.Http; |
| 16 | + using System.Threading; |
| 17 | + using System.Linq.Expressions; |
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// The type CallWithReferenceRequest. |
| 21 | + /// </summary> |
| 22 | + public partial class CallWithReferenceRequest : BaseRequest, ICallWithReferenceRequest |
| 23 | + { |
| 24 | + /// <summary> |
| 25 | + /// Constructs a new CallWithReferenceRequest. |
| 26 | + /// </summary> |
| 27 | + /// <param name="requestUrl">The URL for the built request.</param> |
| 28 | + /// <param name="client">The <see cref="IBaseClient"/> for handling requests.</param> |
| 29 | + /// <param name="options">Query and header option name value pairs for the request.</param> |
| 30 | + public CallWithReferenceRequest( |
| 31 | + string requestUrl, |
| 32 | + IBaseClient client, |
| 33 | + IEnumerable<Option> options) |
| 34 | + : base(requestUrl, client, options) |
| 35 | + { |
| 36 | + } |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Gets the specified Call. |
| 40 | + /// </summary> |
| 41 | + /// <returns>The Call.</returns> |
| 42 | + public System.Threading.Tasks.Task<Call> GetAsync() |
| 43 | + { |
| 44 | + return this.GetAsync(CancellationToken.None); |
| 45 | + } |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// Gets the specified Call. |
| 49 | + /// </summary> |
| 50 | + /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> |
| 51 | + /// <returns>The Call.</returns> |
| 52 | + public async System.Threading.Tasks.Task<Call> GetAsync(CancellationToken cancellationToken) |
| 53 | + { |
| 54 | + this.Method = "GET"; |
| 55 | + var retrievedEntity = await this.SendAsync<Call>(null, cancellationToken).ConfigureAwait(false); |
| 56 | + return retrievedEntity; |
| 57 | + } |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Creates the specified Call using POST. |
| 61 | + /// </summary> |
| 62 | + /// <param name="callToCreate">The Call to create.</param> |
| 63 | + /// <returns>The created Call.</returns> |
| 64 | + public System.Threading.Tasks.Task<Call> CreateAsync(Call callToCreate) |
| 65 | + { |
| 66 | + return this.CreateAsync(callToCreate, CancellationToken.None); |
| 67 | + } |
| 68 | + |
| 69 | + /// <summary> |
| 70 | + /// Creates the specified Call using POST. |
| 71 | + /// </summary> |
| 72 | + /// <param name="callToCreate">The Call to create.</param> |
| 73 | + /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> |
| 74 | + /// <returns>The created Call.</returns> |
| 75 | + public async System.Threading.Tasks.Task<Call> CreateAsync(Call callToCreate, CancellationToken cancellationToken) |
| 76 | + { |
| 77 | + this.ContentType = "application/json"; |
| 78 | + this.Method = "POST"; |
| 79 | + var newEntity = await this.SendAsync<Call>(callToCreate, cancellationToken).ConfigureAwait(false); |
| 80 | + return newEntity; |
| 81 | + } |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// Updates the specified Call using PATCH. |
| 85 | + /// </summary> |
| 86 | + /// <param name="callToUpdate">The Call to update.</param> |
| 87 | + /// <returns>The updated Call.</returns> |
| 88 | + public System.Threading.Tasks.Task<Call> UpdateAsync(Call callToUpdate) |
| 89 | + { |
| 90 | + return this.UpdateAsync(callToUpdate, CancellationToken.None); |
| 91 | + } |
| 92 | + |
| 93 | + /// <summary> |
| 94 | + /// Updates the specified Call using PATCH. |
| 95 | + /// </summary> |
| 96 | + /// <param name="callToUpdate">The Call to update.</param> |
| 97 | + /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> |
| 98 | + /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception> |
| 99 | + /// <returns>The updated Call.</returns> |
| 100 | + public async System.Threading.Tasks.Task<Call> UpdateAsync(Call callToUpdate, CancellationToken cancellationToken) |
| 101 | + { |
| 102 | + if (callToUpdate.AdditionalData != null) |
| 103 | + { |
| 104 | + if (callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || |
| 105 | + callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) |
| 106 | + { |
| 107 | + throw new ClientException( |
| 108 | + new Error |
| 109 | + { |
| 110 | + Code = GeneratedErrorConstants.Codes.NotAllowed, |
| 111 | + Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, callToUpdate.GetType().Name) |
| 112 | + }); |
| 113 | + } |
| 114 | + } |
| 115 | + if (callToUpdate.AdditionalData != null) |
| 116 | + { |
| 117 | + if (callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || |
| 118 | + callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) |
| 119 | + { |
| 120 | + throw new ClientException( |
| 121 | + new Error |
| 122 | + { |
| 123 | + Code = GeneratedErrorConstants.Codes.NotAllowed, |
| 124 | + Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, callToUpdate.GetType().Name) |
| 125 | + }); |
| 126 | + } |
| 127 | + } |
| 128 | + this.ContentType = "application/json"; |
| 129 | + this.Method = "PATCH"; |
| 130 | + var updatedEntity = await this.SendAsync<Call>(callToUpdate, cancellationToken).ConfigureAwait(false); |
| 131 | + return updatedEntity; |
| 132 | + } |
| 133 | + |
| 134 | + /// <summary> |
| 135 | + /// Deletes the specified Call. |
| 136 | + /// </summary> |
| 137 | + /// <returns>The task to await.</returns> |
| 138 | + public System.Threading.Tasks.Task DeleteAsync() |
| 139 | + { |
| 140 | + return this.DeleteAsync(CancellationToken.None); |
| 141 | + } |
| 142 | + |
| 143 | + /// <summary> |
| 144 | + /// Deletes the specified Call. |
| 145 | + /// </summary> |
| 146 | + /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> |
| 147 | + /// <returns>The task to await.</returns> |
| 148 | + public async System.Threading.Tasks.Task DeleteAsync(CancellationToken cancellationToken) |
| 149 | + { |
| 150 | + this.Method = "DELETE"; |
| 151 | + await this.SendAsync<Call>(null, cancellationToken).ConfigureAwait(false); |
| 152 | + } |
| 153 | + |
| 154 | + /// <summary> |
| 155 | + /// Adds the specified expand value to the request. |
| 156 | + /// </summary> |
| 157 | + /// <param name="value">The expand value.</param> |
| 158 | + /// <returns>The request object to send.</returns> |
| 159 | + public ICallWithReferenceRequest Expand(string value) |
| 160 | + { |
| 161 | + this.QueryOptions.Add(new QueryOption("$expand", value)); |
| 162 | + return this; |
| 163 | + } |
| 164 | + |
| 165 | + /// <summary> |
| 166 | + /// Adds the specified expand value to the request. |
| 167 | + /// </summary> |
| 168 | + /// <param name="expandExpression">The expression from which to calculate the expand value.</param> |
| 169 | + /// <returns>The request object to send.</returns> |
| 170 | + public ICallWithReferenceRequest Expand(Expression<Func<Call, object>> expandExpression) |
| 171 | + { |
| 172 | + if (expandExpression == null) |
| 173 | + { |
| 174 | + throw new ArgumentNullException(nameof(expandExpression)); |
| 175 | + } |
| 176 | + string error; |
| 177 | + string value = ExpressionExtractHelper.ExtractMembers(expandExpression, out error); |
| 178 | + if (value == null) |
| 179 | + { |
| 180 | + throw new ArgumentException(error, nameof(expandExpression)); |
| 181 | + } |
| 182 | + else |
| 183 | + { |
| 184 | + this.QueryOptions.Add(new QueryOption("$expand", value)); |
| 185 | + } |
| 186 | + return this; |
| 187 | + } |
| 188 | + |
| 189 | + /// <summary> |
| 190 | + /// Adds the specified select value to the request. |
| 191 | + /// </summary> |
| 192 | + /// <param name="value">The select value.</param> |
| 193 | + /// <returns>The request object to send.</returns> |
| 194 | + public ICallWithReferenceRequest Select(string value) |
| 195 | + { |
| 196 | + this.QueryOptions.Add(new QueryOption("$select", value)); |
| 197 | + return this; |
| 198 | + } |
| 199 | + |
| 200 | + /// <summary> |
| 201 | + /// Adds the specified select value to the request. |
| 202 | + /// </summary> |
| 203 | + /// <param name="selectExpression">The expression from which to calculate the select value.</param> |
| 204 | + /// <returns>The request object to send.</returns> |
| 205 | + public ICallWithReferenceRequest Select(Expression<Func<Call, object>> selectExpression) |
| 206 | + { |
| 207 | + if (selectExpression == null) |
| 208 | + { |
| 209 | + throw new ArgumentNullException(nameof(selectExpression)); |
| 210 | + } |
| 211 | + string error; |
| 212 | + string value = ExpressionExtractHelper.ExtractMembers(selectExpression, out error); |
| 213 | + if (value == null) |
| 214 | + { |
| 215 | + throw new ArgumentException(error, nameof(selectExpression)); |
| 216 | + } |
| 217 | + else |
| 218 | + { |
| 219 | + this.QueryOptions.Add(new QueryOption("$select", value)); |
| 220 | + } |
| 221 | + return this; |
| 222 | + } |
| 223 | + |
| 224 | + } |
| 225 | +} |
0 commit comments