/// <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")); }
/// <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")); }
/// <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)); }
/// <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)); }
/// <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)); } }
/// <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)); } }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }