vonec
vonec

Reputation: 701

ServiceStack Stripe get all invoices with date filter

I'm trying to get all Stripe invoices with a date filter. At the moment the ServiceStack.Stripe package only allows for Date equality:

[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; }
}

There are no options for "lt", "lte", "gt" and "gte".

In order to add these the request needs to look something like:

?date%5Blt%5D=1337923293

We can't use these special characters in a C# attribute name, so is there another way to override the class so that it serializes to match the request parameters required for date filters?

Upvotes: 2

Views: 450

Answers (1)

mythz
mythz

Reputation: 143339

I've just added support for Stripe DateOptions in this commit where you can use use the new DateOptions property to specify a custom date, e.g you can specify a lt date with:

var response = gateway.Get(new GetStripeInvoices
{
    DateOptions = new StripeDateOptions {
        Before = DateTime.UtcNow
    }
});

The different Date Options available include:

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
}

This change is available from v4.0.55 that's now available on MyGet.

Upvotes: 2

Related Questions