Skip to content

Commit

Permalink
Closes #40
Browse files Browse the repository at this point in the history
Closes #41
-Updated ecommerce orders to use order response to filter by customer id
  • Loading branch information
brandonseydel committed Jun 14, 2016
1 parent c1740fa commit 57a6a48
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 5 deletions.
14 changes: 14 additions & 0 deletions MailChimp.Net/Core/Requests/OrderRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MailChimp.Net.Core
{
public class OrderRequest : QueryableBaseRequest
{
[QueryString("customer_id")]
public string CustomerId { get; set; }
}
}
3 changes: 3 additions & 0 deletions MailChimp.Net/Interfaces/IBatchLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ public interface IBatchLogic
Task<BatchResponse> GetResponseAsync(QueryableBaseRequest request = null);

Task<Batch> GetBatchStatus(string batchId);

Task DeleteAsync(string batchId);

}
}
4 changes: 2 additions & 2 deletions MailChimp.Net/Interfaces/IEcommerceOrderLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface IECommerceOrderLogic
/// <param name="storeId"></param>
/// <param name="request"></param>
/// <returns></returns>
Task<IEnumerable<Order>> GetAllAsync(QueryableBaseRequest request = null);
Task<IEnumerable<Order>> GetAllAsync(OrderRequest request = null);

/// <summary>
/// The get async.
Expand All @@ -59,7 +59,7 @@ public interface IECommerceOrderLogic
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
Task<StoreOrderResponse> GetResponseAsync(QueryableBaseRequest request = null);
Task<StoreOrderResponse> GetResponseAsync(OrderRequest request = null);

/// <summary>
/// The update async.
Expand Down
10 changes: 10 additions & 0 deletions MailChimp.Net/Logic/BatchLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public async Task<BatchResponse> GetResponseAsync(QueryableBaseRequest request =
}
}

public async Task DeleteAsync(string batchId)
{
using (var client = this.CreateMailClient("batches/"))
{
var response = await client.DeleteAsync($"{batchId}").ConfigureAwait(false);
await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);
}
}


public async Task<Batch> GetBatchStatus(string batchId)
{
using (var client = this.CreateMailClient($"batches/{batchId}"))
Expand Down
4 changes: 2 additions & 2 deletions MailChimp.Net/Logic/ECommerceOrderLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task DeleteAsync(string orderId)
/// <param name="storeId"></param>
/// <param name="request"></param>
/// <returns></returns>
public async Task<IEnumerable<Order>> GetAllAsync(QueryableBaseRequest request = null)
public async Task<IEnumerable<Order>> GetAllAsync(OrderRequest request = null)
{
return (await GetResponseAsync(request).ConfigureAwait(false))?.Orders;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task<Order> GetAsync(string orderId, BaseRequest request = null)
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
public async Task<StoreOrderResponse> GetResponseAsync(QueryableBaseRequest request = null)
public async Task<StoreOrderResponse> GetResponseAsync(OrderRequest request = null)
{
var requestUrl = string.Format(BaseUrl, StoreId);
using (var client = CreateMailClient(requestUrl))
Expand Down
1 change: 1 addition & 0 deletions MailChimp.Net/MailChimp.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="Core\Requests\InterestCategoryRequest.cs" />
<Compile Include="Core\Batch.cs" />
<Compile Include="Core\Requests\ListSegmentRequest.cs" />
<Compile Include="Core\Requests\OrderRequest.cs" />
<Compile Include="Core\Requests\Segment.cs" />
<Compile Include="Core\Requests\MergeFieldRequest.cs" />
<Compile Include="Core\Responses\BatchResponse.cs" />
Expand Down
13 changes: 13 additions & 0 deletions MailChimp.Net/Models/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,25 @@ public Order()
[JsonProperty("tax_total")]
public double TaxTotal { get; set; }

[JsonProperty("shipping_total")]
public double ShippingTotal { get; set; }

[JsonProperty("tracking_code")]
public string TrackingCode { get; set; }

[JsonProperty("processed_at_foreign")]
public string ProcessedAtForeign { get; set; }

[JsonProperty("cancelled_at_foreign")]
public string CancelledAtForeign { get; set; }

[JsonProperty("shipping_address")]
public Address ShippingAddress { get; set; }

[JsonProperty("billing_address")]
public Address BillingAddress { get; set; }


[JsonProperty("updated_at_foreign")]
public string UpdatedAtForeign { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion MailChimp.Net/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.2")]
[assembly: AssemblyVersion("1.5.3")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit 57a6a48

Please sign in to comment.