예제 #1
0
        public async Task<IEnumerable<UrlClicked>> GetClickReportAsync(QueryableBaseRequest request, string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/click-details{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                var clickReportResponse = await response.Content.ReadAsAsync<ClickReportResponse>();
                return clickReportResponse.UrlsClicked;
            }
        }
예제 #2
0
        public async Task<CampaignFolderResponse> GetResponseAsync(QueryableBaseRequest request = null)
        {
            using (var client = this.CreateMailClient(BaseUrl))
            {
                var response = await client.GetAsync(request?.ToQueryString()).ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var campaignFolderResponse = await response.Content.ReadAsAsync<CampaignFolderResponse>().ConfigureAwait(false);
                return campaignFolderResponse;
            }
        }
예제 #3
0
        public async Task<MemberResponse> GetMemberResponseAsync(string listId, string segmentId, QueryableBaseRequest request = null)
        {
            using (var client = this.CreateMailClient(string.Format(BaseUrl + "/", listId)))
            {
                var response = await client.GetAsync(segmentId + "/members" + request?.ToQueryString()).ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var memberResponse = await response.Content.ReadAsAsync<MemberResponse>().ConfigureAwait(false);
                return memberResponse;
            }
        }
예제 #4
0
        /// <summary>
        /// The get all async.
        /// </summary>
        /// <param name="listId">
        /// The list Id.
        /// </param>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The <paramref>
        ///         <name>requestUri</name>
        ///     </paramref>
        ///     was null.
        /// </exception>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <exception cref="UriFormatException">In the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, <see cref="T:System.FormatException" />, instead.<paramref name="uriString" /> is empty.-or- The scheme specified in <paramref name="uriString" /> is not correctly formed. See <see cref="M:System.Uri.CheckSchemeName(System.String)" />.-or- <paramref name="uriString" /> contains too many slashes.-or- The password specified in <paramref name="uriString" /> is not valid.-or- The host name specified in <paramref name="uriString" /> is not valid.-or- The file name specified in <paramref name="uriString" /> is not valid. -or- The user name specified in <paramref name="uriString" /> is not valid.-or- The host or authority name specified in <paramref name="uriString" /> cannot be terminated by backslashes.-or- The port number specified in <paramref name="uriString" /> is not valid or cannot be parsed.-or- The length of <paramref name="uriString" /> exceeds 65519 characters.-or- The length of the scheme specified in <paramref name="uriString" /> exceeds 1023 characters.-or- There is an invalid character sequence in <paramref name="uriString" />.-or- The MS-DOS path specified in <paramref name="uriString" /> must start with c:\\.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Enlarging the value of this instance would exceed <see cref="P:System.Text.StringBuilder.MaxCapacity" />. </exception>
        /// <exception cref="MailChimpException">
        /// Custom Mail Chimp Exception
        /// </exception>
        public async Task<IEnumerable<AbuseReport>> GetAllAsync(string listId, QueryableBaseRequest request = null)
        {
            using (var client = this.CreateMailClient("lists/"))
            {
                var response = await client.GetAsync($"{listId}/abuse-reports{request.ToQueryString()}").ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var appResponse = await response.Content.ReadAsAsync<AbuseReportResponse>().ConfigureAwait(false);
                return appResponse.AbuseReports;
            }
        }
예제 #5
0
        public async Task<IEnumerable<Folder>> GetAllAsync(QueryableBaseRequest request)
        {
            using (var client = CreateMailClient("template-folders"))
            {
                var response = await client.GetAsync(request?.ToQueryString());
                await response.EnsureSuccessMailChimpAsync();

                var templateResponse = await response.Content.ReadAsAsync<TemplateFolderResponse>();
                return templateResponse.Folders;
            }
        }
예제 #6
0
 public async Task<IEnumerable<Unsubscribe>> GetUnsubscribesAsync(QueryableBaseRequest request, string campaignId)
 {
     using (var client = CreateMailClient("reports"))
     {
         var response = await client.GetAsync($"{campaignId}/unsubscribed{request.ToQueryString()}");
         await response.EnsureSuccessMailChimpAsync();
         var reportResponse = await response.Content.ReadAsAsync<UnsubscribeReportResponse>();
         return reportResponse.Unsubscribes;
     }
 }
예제 #7
0
        public async Task<SentTo> GetSentToRecipientAsync(QueryableBaseRequest request, string campaignId,
            string emailAddress)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response =
                    await client.GetAsync($"{campaignId}/sent-to/{Hash(emailAddress)}{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<SentTo>();
            }
        }
예제 #8
0
        public async Task<IEnumerable<SentTo>> GetSentToRecipientsAsync(QueryableBaseRequest request, string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/sent-to{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                var sendToResponse = await response.Content.ReadAsAsync<SentToResponse>();
                return sendToResponse.Recipients;
            }
        }
예제 #9
0
        public async Task<IEnumerable<EmailActivity>> GetEmailActivitiesAsync(QueryableBaseRequest request,
            string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/email-activity{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                var emailActivityResponse = await response.Content.ReadAsAsync<EmailResponse>();
                return emailActivityResponse.EmailActivities;
            }
        }
예제 #10
0
 /// <summary>
 /// Gets only the carts from the response object
 /// </summary>
 /// <param name="storeId"></param>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task<IEnumerable<Cart>> GetAllAsync(QueryableBaseRequest request = null)
 {
     return (await GetResponseAsync(request).ConfigureAwait(false))?.Carts;
 }
예제 #11
0
        /// <summary>
        /// The get response async.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task<CartResponse> GetResponseAsync(QueryableBaseRequest request = null)
        {
            var requestUrl = string.Format(BaseUrl, StoreId);
            using (var client = CreateMailClient(requestUrl))
            {
                var response = await client.GetAsync(request?.ToQueryString()).ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var cartResponse = await response.Content.ReadAsAsync<CartResponse>().ConfigureAwait(false);
                return cartResponse;
            }
        }
예제 #12
0
 public async Task<IEnumerable<Member>> GetAllMembersAsync(string listId, string segmentId, QueryableBaseRequest request = null)
 {
     var response = await GetMemberResponseAsync(listId, segmentId, request);
     return response.Members;
 }