Exemplo n.º 1
0
        public async Task<App> GetAsync(string appId, BaseRequest request = null)
        {
            using (var client = CreateMailClient("authorized-apps/"))
            {
                var response = await client.GetAsync($"{appId}{request?.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<App>();
            }
        }
Exemplo n.º 2
0
        public async Task<object> GetDefaultContentAsync(string templateId, BaseRequest request = null)
        {
            using (var client = this.CreateMailClient("templates/"))
            {
                var response = await client.GetAsync($"{templateId}/default-content{request?.ToQueryString()}").ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);
                return await response.Content.ReadAsStringAsync().ConfigureAwait(false);
            }

        }
Exemplo n.º 3
0
 /// <summary>
 /// The get all async.
 /// </summary>
 /// <param name="request">
 /// The request.
 /// </param>
 /// <returns>
 /// The <see cref="Task"/>.
 /// </returns>
 /// <exception cref="ArgumentNullException"><paramref>
 ///         <name>uriString</name>
 ///     </paramref>
 ///     is null. </exception>
 /// <exception cref="ArgumentOutOfRangeException">Enlarging the value of this instance would exceed <see cref="P:System.Text.StringBuilder.MaxCapacity" />. </exception>
 /// <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="NotSupportedException"><paramref name="element" /> is not a constructor, method, property, event, type, or field. </exception>
 /// <exception cref="MailChimpException">
 /// Custom Mail Chimp Exception
 /// </exception>
 /// <exception cref="TypeLoadException">A custom attribute type cannot be loaded. </exception>
 public async Task<IEnumerable<Automation>> GetAllAsync(BaseRequest request = null)
 {
     using (var client = this.CreateMailClient("automations"))
     {
         var response = await client.GetAsync(request?.ToQueryString()).ConfigureAwait(false);
         await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);
         var automationResponse = await response.Content.ReadAsAsync<AutomationResponse>().ConfigureAwait(false);
         return automationResponse.Automations;
     }
 }
Exemplo n.º 4
0
        public async Task<Folder> GetAsync(string folderId, BaseRequest request)
        {
            using (var client = CreateMailClient("templates-folders/"))
            {
                var response = await client.GetAsync($"{folderId}{request?.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<Folder>();
            }
        }
Exemplo n.º 5
0
        public async Task<UrlClicked> GetClickReportDetailsAsync(BaseRequest request, string campaignId, string linkId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/click-details/{linkId}{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<UrlClicked>();
            }
        }
Exemplo n.º 6
0
        public async Task<Report> GetReportAsync(BaseRequest request, string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync(campaignId + request.ToQueryString());
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<Report>();
            }
        }
Exemplo n.º 7
0
        public async Task<IEnumerable<Advice>> GetCampaignAdviceAsync(BaseRequest request, string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/advice{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                var campaignAdviceReport = await response.Content.ReadAsAsync<CampaignAdviceReport>();
                return campaignAdviceReport.Advice;
            }
        }
Exemplo n.º 8
0
        public async Task<Folder> GetAsync(string folderId, BaseRequest request = null)
        {
            using (var client = this.CreateMailClient($"{BaseUrl}/"))
            {
                var response = await client.GetAsync(folderId).ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var folder = await response.Content.ReadAsAsync<Folder>().ConfigureAwait(false);
                return folder;
            }
        }
Exemplo n.º 9
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"/> was null.
        /// </exception>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task<ActivityResponse> GetResponseAsync(string listId, BaseRequest request = null)
        {
            using (var client = this.CreateMailClient("lists/"))
            {
                var response = await client.GetAsync($"{listId}/activity{request?.ToQueryString()}").ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var appResponse = await response.Content.ReadAsAsync<ActivityResponse>().ConfigureAwait(false);
                return appResponse;
            }
        }
        /// <summary>
        /// The get async.
        /// </summary>
        /// <param name="storeId">
        /// The store id.
        /// </param>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task<Variant> GetAsync(string variantId, BaseRequest request = null)
        {

            using (var client = CreateMailClient(BaseUrl + "/"))
            {
                var response = await client.GetAsync(variantId + request?.ToQueryString()).ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var variantResponse = await response.Content.ReadAsAsync<Variant>().ConfigureAwait(false);
                return variantResponse;
            }
        }
Exemplo n.º 11
0
        public async Task<EmailActivity> GetEmailActivityAsync(BaseRequest request, string campaignId,
            string emailAddress)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response =
                    await client.GetAsync($"{campaignId}/email-activity/{Hash(emailAddress)}{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<EmailActivity>();
            }
        }
Exemplo n.º 12
0
        public async Task<ClickMember> GetClickReportMemberAsync(BaseRequest request, string campaignId, string linkId,
            string emailAddress)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response =
                    await
                        client.GetAsync(
                            $"{campaignId}/click-details/{linkId}/members/{Hash(emailAddress)}{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<ClickMember>();
            }
        }
Exemplo n.º 13
0
 public async Task<Unsubscribe> GetUnsubscriberAsync(BaseRequest request, string campaignId, string emailAddress)
 {
     using (var client = CreateMailClient("reports"))
     {
         var response =
             await client.GetAsync($"{campaignId}/unsubscribed/{Hash(emailAddress)}{request.ToQueryString()}");
         await response.EnsureSuccessMailChimpAsync();
         return await response.Content.ReadAsAsync<Unsubscribe>();
     }
 }
Exemplo n.º 14
0
 public async Task<IEnumerable<Report>> GetSubReportAsync(BaseRequest request, string campaignId)
 {
     using (var client = CreateMailClient("reports"))
     {
         var response = await client.GetAsync($"{campaignId}/sub-reports{request.ToQueryString()}");
         await response.EnsureSuccessMailChimpAsync();
         var reportResponse = await response.Content.ReadAsAsync<ReportResponse>();
         return reportResponse.Reports;
     }
 }
Exemplo n.º 15
0
        public async Task<IEnumerable<OpenLocation>> GetLocationsAsync(BaseRequest request, string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/locations{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                var openLocationResponse = await response.Content.ReadAsAsync<OpenLocationResponse>();
                return openLocationResponse.Locations;
            }
        }
Exemplo n.º 16
0
        public async Task<EepUrlActivity> GetEepUrlReportAsync(BaseRequest request, string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/click-details/eepurl{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                return await response.Content.ReadAsAsync<EepUrlActivity>();
            }
        }
Exemplo n.º 17
0
        public async Task<IEnumerable<Domain>> GetDomainPerformanceAsync(BaseRequest request, string campaignId)
        {
            using (var client = CreateMailClient("reports/"))
            {
                var response = await client.GetAsync($"{campaignId}/domain-performance{request.ToQueryString()}");
                await response.EnsureSuccessMailChimpAsync();

                var domainPerformanceResponse = await response.Content.ReadAsAsync<DomainPerformanceResponse>();
                return domainPerformanceResponse.Domains;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// The get async.
        /// </summary>
        /// <param name="storeId">
        /// The store id.
        /// </param>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task<Cart> GetAsync(string cartId, BaseRequest request = null)
        {
            var requestUrl = string.Format(BaseUrl, StoreId);

            using (var client = CreateMailClient(requestUrl + "/"))
            {
                var response = await client.GetAsync(cartId + request?.ToQueryString()).ConfigureAwait(false);
                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                var cartResponse = await response.Content.ReadAsAsync<Cart>().ConfigureAwait(false);
                return cartResponse;
            }
        }