protected virtual async Task <TResponse> ExecuteAsync <TResponse>(IRestRequest request, CancellationToken cancellationToken) where TResponse : DripResponse, new() { var resp = await Client.ExecuteTaskAsync <TResponse>(request, cancellationToken); return(DripResponse.FromRequestResponse <TResponse>(request, resp)); }
protected virtual TResponse Execute <TResponse>(IRestRequest request) where TResponse : DripResponse, new() { var resp = Client.Execute <TResponse>(request); return(DripResponse.FromRequestResponse <TResponse>(request, resp)); }
/// <summary> /// Apply a tag to a subscriber. /// See: https://www.getdrip.com/docs/rest-api#apply_tag /// </summary> /// <param name="email">The subscriber's email address.</param> /// <param name="tag">The tag to apply. E.g. "Customer"</param> /// <param name="cancellationToken">The CancellationToken to be used to cancel the request.</param> /// <returns>A Task that, when completed successfully, will contain a StatusCode of NoContent.</returns> public async Task <DripResponse> ApplyTagToSubscriberAsync(string email, string tag, CancellationToken cancellationToken = default(CancellationToken)) { //This doesn't use a PostResource overload because specifying a return type causes an error var req = CreatePostRequest(ApplyTagToSubscriberResource, TagsRequestBodyKey, new DripTag[] { new DripTag { Email = email, Tag = tag } }); var resp = await Client.ExecuteTaskAsync(req, cancellationToken); return(DripResponse.FromRequestResponse(req, resp)); }
/// <summary> /// Apply a tag to a subscriber. /// See: https://www.getdrip.com/docs/rest-api#apply_tag /// </summary> /// <param name="email">The subscriber's email address.</param> /// <param name="tag">The tag to apply. E.g. "Customer"</param> /// <returns>On success, a DripResponse with StatusCode of Created.</returns> public DripResponse ApplyTagToSubscriber(string email, string tag) { //This doesn't use a PostResource overload because specifying a return type causes an error var req = CreatePostRequest(ApplyTagToSubscriberResource, TagsRequestBodyKey, new DripTag[] { new DripTag { Email = email, Tag = tag } }); var resp = Client.Execute(req); return(DripResponse.FromRequestResponse(req, resp)); }
protected async virtual Task <DripResponse> PostBatchResourceAsync <TData>(string resourceUrl, string key, TData data, CancellationToken cancellationToken) { var body = new Dictionary <string, TData>[] { new Dictionary <string, TData> { { key, data } } }; var req = CreatePostRequest(resourceUrl, BatchRequestBodyKey, body); var resp = await Client.ExecuteTaskAsync(req, cancellationToken); return(DripResponse.FromRequestResponse(req, resp)); }
protected virtual DripResponse PostBatchResource <TData>(string resourceUrl, string key, TData data) { var body = new Dictionary <string, TData>[] { new Dictionary <string, TData> { { key, data } } }; var req = CreatePostRequest(resourceUrl, BatchRequestBodyKey, body); var resp = Client.Execute(req); return(DripResponse.FromRequestResponse(req, resp)); }