Is it ok to use class as an API parameter?

I have these methods

public class ReportService
{
    public DataTable GetCustomerReportDataTable(String dateFrom, String dateTo, String cif, String customerName, String region, String branch, String salesCode);
    public DataTable GetProductReportDataTable(String dateFrom, String dateTo, String cif, String customerName, String product, String region, String branch, String salesCode);
}

And want to refactor it to (below) based on this and this

public class CustomerReportFilter
{

    public String DateFrom { get; set; }
    public String DateTo { get; set; }
    public String CIF { get; set; }
    public String CustomerName { get; set; }
    public String Region { get; set; }
    public String Branch { get; set; }
    public String SalesCode { get; set; }
}

public class ProductReportFilter
{

    public String DateFrom { get; set; }
    public String DateTo { get; set; }
    public String CIF { get; set; }
    public String CustomerName { get; set; }
    public String Product { get; set; }
    public String Region { get; set; }
    public String Branch { get; set; }
    public String SalesCode { get; set; }
}

public class ReportService
{
    public DataTable GetCustomerReportDataTable(CustomerReportFilter filter);
    public DataTable GetProductReportDataTable(ProductReportFilter filter);
}

Question:

What if the API caller is from other language/technology? They'd be tied to CustomerReportFilter and ProductReportFilter class.

Answers


As I implement this API with ASP.Net MVC, it's JSON Binding will automatically convert JSON string into strongly-typed .Net object. So different language can call this API using their REST client then POST a JSON string.

For other language like Java, I've read RESTful Java client with java.net.URL .

I assume being tied to API parameter class is no problem because of the auto-converter.


Need Your Help

Can't open Word doc with COM in PHP

php com ms-word

I'm trying to open and read the contents of a Word document with PHO by using the COM function. But whenever i try to read the contents, then it gives me the following error:

PHP date formatting

php date formatting

I want to transform a date from this format: 01/07/09 to this jan 07,09.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.