예제 #1
0
 /// <summary>
 /// PatchRequest.
 /// </summary>
 /// <typeparam name="T">Request for {EntityReturned}.</typeparam>
 /// <param name="url">url.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <returns>{EntityReturned}.</returns>
 protected T PutRequest <T>(string url, BaseOptions options, RequestOptions requestOptions)
 {
     return(Mapper <T> .MapFromJson(
                Requestor.PutString(
                    this.ApplyAllParameters(options, url),
                    this.SetupRequestOptions(requestOptions)), "data"));
 }
예제 #2
0
 /// <summary>
 /// PatchRequestAsync.
 /// </summary>
 /// <typeparam name="T">Request for {EntityReturned}.</typeparam>
 /// <param name="url">url.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <param name="cancellationToken">cancellationToken.</param>
 /// <returns>{EntityReturned}.</returns>
 protected async Task <T> PutRequestAsync <T>(string url, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(Mapper <T> .MapFromJson(
                await Requestor.PutStringAsync(
                    this.ApplyAllParameters(options, url),
                    this.SetupRequestOptions(requestOptions),
                    cancellationToken).ConfigureAwait(false), "data"));
 }
예제 #3
0
        /// <summary>
        /// GetRequest.
        /// </summary>
        /// <typeparam name="T">Request for {EntityReturned}.</typeparam>
        /// <param name="url">url.</param>
        /// <param name="options">options.</param>
        /// <param name="requestOptions">requestOptions.</param>
        /// <param name="isListMethod">isListMethod.</param>
        /// <returns>{EntityReturned}.</returns>
        protected T GetRequest <T>(string url, BaseOptions options, RequestOptions requestOptions, bool isListMethod)
        {
            var parentToken = (typeof(T) == typeof(TelnyxList <EntityReturned>)) ? null : "data";

            return(Mapper <T> .MapFromJson(
                       Requestor.GetString(
                           this.ApplyAllParameters(options, url, isListMethod),
                           this.SetupRequestOptions(requestOptions)), parentToken));
        }
예제 #4
0
        /// <summary>
        /// GetRequestAsync.
        /// </summary>
        /// <typeparam name="T">Request for {EntityReturned}.</typeparam>
        /// <param name="url">url.</param>
        /// <param name="options">options.</param>
        /// <param name="requestOptions">requestOptions.</param>
        /// <param name="isListMethod">isListMethod.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>{EntityReturned}.</returns>
        protected async Task <T> GetRequestAsync <T>(string url, BaseOptions options, RequestOptions requestOptions, bool isListMethod, CancellationToken cancellationToken)
        {
            var parentToken = (typeof(T) == typeof(TelnyxList <EntityReturned>)) ? null : "data";

            return(Mapper <T> .MapFromJson(
                       await Requestor.GetStringAsync(
                           this.ApplyAllParameters(options, url, isListMethod),
                           this.SetupRequestOptions(requestOptions),
                           cancellationToken).ConfigureAwait(false), parentToken));
        }
예제 #5
0
 /// <summary>
 /// PostRequest.
 /// </summary>
 /// <typeparam name="T">Request for {EntityReturned}.</typeparam>
 /// <param name="url">url.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <returns>{EntityReturned}.</returns>
 protected T PostRequest <T>(string url, BaseOptions options, RequestOptions requestOptions, bool isJsonResponse = true)
 {
     if (isJsonResponse)
     {
         return(Mapper <T> .MapFromJson(
                    Requestor.PostString(
                        this.ApplyAllParameters(options, url),
                        this.SetupRequestOptions(requestOptions)), "data"));
     }
     else
     {
         return(Mapper <T> .MapFromPlainText(Requestor.PostString(
                                                 this.ApplyAllParameters(options, url),
                                                 this.SetupRequestOptions(requestOptions)).ResponseJson));
     }
 }
예제 #6
0
        /// <summary>
        /// PostRequestAsync.
        /// </summary>
        /// <typeparam name="T">Request for {EntityReturned}.</typeparam>
        /// <param name="url">url.</param>
        /// <param name="options">options.</param>
        /// <param name="requestOptions">requestOptions.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>{EntityReturned}.</returns>
        protected async Task <T> PostRequestAsync <T>(string url, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, bool isJsonResponse = true)
        {
            if (isJsonResponse)
            {
                return(Mapper <T> .MapFromJson(
                           await Requestor.PostStringAsync(
                               this.ApplyAllParameters(options, url),
                               this.SetupRequestOptions(requestOptions),
                               cancellationToken).ConfigureAwait(false), "data"));
            }
            else
            {
                var response = await Requestor.PostStringAsync(
                    this.ApplyAllParameters(options, url),
                    this.SetupRequestOptions(requestOptions));

                return(Mapper <T> .MapFromPlainText(response.ResponseJson));
            }
        }
예제 #7
0
 /// <summary>
 /// GetEntity
 /// </summary>
 /// <param name="id">id</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <param name="postPath">postPath</param>
 /// <returns>{EntityReturned}</returns>
 protected EntityReturned GetEntity(string id, BaseOptions options, RequestOptions requestOptions, string postPath = null)
 {
     return(this.GetRequest <EntityReturned>(this.CallUrl(id, postPath), options, requestOptions, false));
 }
예제 #8
0
 /// <summary>
 /// ListEntitiesAsync.
 /// </summary>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <param name="cancellationToken">cancellationToken.</param>
 /// <returns>TelnyxList {EntityReturned}.</returns>
 protected async Task <TelnyxList <EntityReturned> > ListEntitiesAsync(BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(await this.GetRequestAsync <TelnyxList <EntityReturned> >(this.ClassUrl(), options, requestOptions, true, cancellationToken));
 }
예제 #9
0
 /// <summary>
 /// CreateEntityAsync.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="postFix">postFix.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <param name="cancellationToken">cancellationToken.</param>
 /// <returns>{EntityReturned}.</returns>
 protected async Task <EntityReturned> CreateEntityAsync(string id, string postFix, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(await this.PostRequestAsync <EntityReturned>(this.CallUrl(id, postFix), options, requestOptions, cancellationToken));
 }
예제 #10
0
 /// <summary>
 /// UpdateEntity
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <returns>{EntityReturned}.</returns>
 protected EntityReturned UpdateEntity(string id, BaseOptions options, RequestOptions requestOptions)
 {
     return(this.PatchRequest <EntityReturned>(this.InstanceUrl(id), options, requestOptions));
 }
예제 #11
0
 /// <summary>
 /// DeleteNestedEntityAsync
 /// </summary>
 /// <param name="parentId">parentId</param>
 /// <param name="id">id</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <param name="cancellationToken">cancellationToken</param>
 /// <returns>{EntityReturned}</returns>
 protected async Task <EntityReturned> DeleteNestedEntityAsync(string parentId, string id, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(await this.DeleteRequestAsync <EntityReturned>(this.InstanceUrl(parentId, id), options, requestOptions, cancellationToken));
 }
예제 #12
0
 /// <summary>
 /// CreateNestedEntityAsync
 /// </summary>
 /// <param name="parentId">parentId</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <param name="cancellationToken">cancellationToken</param>
 /// <returns>{EntityReturned}</returns>
 protected async Task <EntityReturned> CreateNestedEntityAsync(string parentId, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(await this.PostRequestAsync <EntityReturned>(this.ClassUrl(parentId), options, requestOptions, cancellationToken));
 }
예제 #13
0
 /// <summary>
 /// BulkUpdateEntity.
 /// </summary>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <param name="postPath">postPath</param>
 /// <returns>{EntityReturned}</returns>
 protected EntityReturned BulkUpdateEntity(BaseOptions options, RequestOptions requestOptions, string postPath = null)
 {
     return(this.PutRequest <EntityReturned>(this.ClassUrl(), options, requestOptions));
 }
예제 #14
0
 /// <summary>
 /// BulkUpdateEntity.
 /// </summary>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <param name="cancellationToken">cancellationToken</param>
 /// <param name="postPath">postPath</param>
 /// <returns>{EntityReturned}</returns>
 protected async Task <EntityReturned> BulkUpdateEntityAsync(BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, string postPath = null)
 {
     return(await this.PutRequestAsync <EntityReturned>(this.ClassUrl(), options, requestOptions, cancellationToken));
 }
예제 #15
0
 /// <summary>
 /// UpgradeEntityAsync.
 /// </summary>
 /// <param name="id">id</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <param name="cancellationToken">cancellationToken</param>
 /// <param name="postPath">postPath</param>
 /// <returns>{EntityReturned}</returns>
 protected async Task <EntityReturned> UpgradeEntityAsync(string id, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, string postPath = null)
 {
     return(await this.PutRequestAsync <EntityReturned>(this.CallUrl(id, postPath), options, requestOptions, cancellationToken));
 }
예제 #16
0
 /// <summary>
 /// UpgradeEntity.
 /// </summary>
 /// <param name="id">id</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <param name="postPath">postPath</param>
 /// <returns>{EntityReturned}</returns>
 protected EntityReturned UpgradeEntity(string id, BaseOptions options, RequestOptions requestOptions, string postPath = null)
 {
     return(this.PutRequest <EntityReturned>(this.CallUrl(id, postPath), options, requestOptions));
 }
예제 #17
0
 /// <summary>
 /// UpdateEntityAsync.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <param name="cancellationToken">cancellationToken.</param>
 /// <returns>{EntityReturned}.</returns>
 protected async Task <EntityReturned> UpdateEntityAsync(string id, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(await this.PatchRequestAsync <EntityReturned>(this.InstanceUrl(id), options, requestOptions, cancellationToken));
 }
예제 #18
0
 /// <summary>
 /// CreateEntity for PlainText response.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="postFix">postFix.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <returns>{EntityReturned}.</returns>
 protected string CreateEntity(string id, string postFix, BaseOptions options, RequestOptions requestOptions, bool isJsonResponse = true)
 {
     return(this.PostRequest <string>(this.CallUrl(id, postFix), options, requestOptions, isJsonResponse));
 }
예제 #19
0
 /// <summary>
 /// CreateEntity.
 /// </summary>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <returns>{EntityReturned}.</returns>
 protected EntityReturned CreateEntity(BaseOptions options, RequestOptions requestOptions)
 {
     return(this.PostRequest <EntityReturned>(this.ClassUrl(), options, requestOptions));
 }
예제 #20
0
 /// <summary>
 /// CreateNestedEntity
 /// </summary>
 /// <param name="parentId">parentId</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <returns>{EntityReturned}</returns>
 protected EntityReturned CreateNestedEntity(string parentId, BaseOptions options, RequestOptions requestOptions)
 {
     return(this.PostRequest <EntityReturned>(this.ClassUrl(parentId), options, requestOptions));
 }
예제 #21
0
 /// <summary>
 /// CreateEntity.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="postFix">postFix.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <returns>{EntityReturned}.</returns>
 protected EntityReturned CreateEntity(string id, string postFix, BaseOptions options, RequestOptions requestOptions)
 {
     return(this.PostRequest <EntityReturned>(this.CallUrl(id, postFix), options, requestOptions));
 }
예제 #22
0
 /// <summary>
 /// DeleteNestedEntity
 /// </summary>
 /// <param name="parentId">parentId</param>
 /// <param name="id">id</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <returns>{EntityReturned}</returns>
 protected EntityReturned DeleteNestedEntity(string parentId, string id, BaseOptions options, RequestOptions requestOptions)
 {
     return(this.DeleteRequest <EntityReturned>(this.InstanceUrl(parentId, id), options, requestOptions));
 }
예제 #23
0
 /// <summary>
 /// ListEntities.
 /// </summary>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <returns>TelnyxList {EntityReturned}.</returns>
 protected TelnyxList <EntityReturned> ListEntities(BaseOptions options, RequestOptions requestOptions)
 {
     return(this.GetRequest <TelnyxList <EntityReturned> >(this.ClassUrl(), options, requestOptions, true));
 }
예제 #24
0
 /// <summary>
 /// GetNestedEntity
 /// </summary>
 /// <param name="parentId">parentId</param>
 /// <param name="id">id</param>
 /// <param name="options">options</param>
 /// <param name="requestOptions">requestOptions</param>
 /// <returns>{EntityReturned}</returns>
 protected EntityReturned GetNestedEntity(string parentId, string id, BaseOptions options, RequestOptions requestOptions)
 {
     return(this.GetRequest <EntityReturned>(this.InstanceUrl(parentId, id), options, requestOptions, false));
 }
예제 #25
0
 /// <summary>
 /// CreateEntityAsync for PlainText response.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="postFix">postFix.</param>
 /// <param name="options">options.</param>
 /// <param name="requestOptions">requestOptions.</param>
 /// <param name="cancellationToken">cancellationToken.</param>
 /// <returns>{EntityReturned}.</returns>
 protected async Task <string> CreateEntityAsync(string id, string postFix, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, bool isJsonResponse = true)
 {
     return(await this.PostRequestAsync <string>(this.CallUrl(id, postFix), options, requestOptions, cancellationToken, isJsonResponse));
 }