ServiceStack Stripe 使用日期过滤器获取所有发票
ServiceStack Stripe get all invoices with date filter
我正在尝试获取所有带日期过滤器的 Stripe 发票。目前 ServiceStack.Stripe 包只允许 Date 相等:
[Route("/invoices")]
public class GetStripeInvoices : IGet, IReturn<StripeCollection<StripeInvoice>>
{
public string Customer { get; set; }
public DateTime? Date { get; set; }
public int? Count { get; set; }
public int? Offset { get; set; }
}
"lt"、"lte"、"gt" 和 "gte" 没有选项。
为了添加这些,请求需要类似于:
?date%5Blt%5D=1337923293
我们不能在 C# 属性名称中使用这些特殊字符,那么是否有另一种方法可以覆盖 class 以便它序列化以匹配日期过滤器所需的请求参数?
我刚刚添加了对 Stripe DateOptions in this commit 的支持,您可以在其中使用新的 DateOptions
属性 来指定自定义日期,例如,您可以指定 lt
日期:
var response = gateway.Get(new GetStripeInvoices
{
DateOptions = new StripeDateOptions {
Before = DateTime.UtcNow
}
});
可用的不同日期选项包括:
public class StripeDateOptions
{
public DateTime? After { get; set; } //gt
public DateTime? OnOrAfter { get; set; } //gte
public DateTime? Before { get; set; } //lt
public DateTime? OnOrBefore { get; set; } //lte
}
此更改适用于现在 available on MyGet 的 v4.0.55。
我正在尝试获取所有带日期过滤器的 Stripe 发票。目前 ServiceStack.Stripe 包只允许 Date 相等:
[Route("/invoices")]
public class GetStripeInvoices : IGet, IReturn<StripeCollection<StripeInvoice>>
{
public string Customer { get; set; }
public DateTime? Date { get; set; }
public int? Count { get; set; }
public int? Offset { get; set; }
}
"lt"、"lte"、"gt" 和 "gte" 没有选项。
为了添加这些,请求需要类似于:
?date%5Blt%5D=1337923293
我们不能在 C# 属性名称中使用这些特殊字符,那么是否有另一种方法可以覆盖 class 以便它序列化以匹配日期过滤器所需的请求参数?
我刚刚添加了对 Stripe DateOptions in this commit 的支持,您可以在其中使用新的 DateOptions
属性 来指定自定义日期,例如,您可以指定 lt
日期:
var response = gateway.Get(new GetStripeInvoices
{
DateOptions = new StripeDateOptions {
Before = DateTime.UtcNow
}
});
可用的不同日期选项包括:
public class StripeDateOptions
{
public DateTime? After { get; set; } //gt
public DateTime? OnOrAfter { get; set; } //gte
public DateTime? Before { get; set; } //lt
public DateTime? OnOrBefore { get; set; } //lte
}
此更改适用于现在 available on MyGet 的 v4.0.55。