awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
863 stars 474 forks source link

REST API - Stats endpoint: return further data #5402

Open vpratfr opened 7 years ago

vpratfr commented 7 years ago

Hi,

For most store owners, the earnings figure which matters is the one excluding taxes (netto). Earnings provided by the stats API are including taxes only. We do not have any way to access the figures excluding taxes.

Adding a parameter would be a possibility but I think that simply providing both figures including and excluding taxes in the JSON would be better (more manageable on the API client side).

Generally speaking, I think that providing more data in a single API call would be much more useful:

if you look at the dashboard for the iOS application, you require 4 API calls. This is very inefficient on mobile.

If we could have in a single call:

That would reduce our client side work to a single API call

Result could look like:

{
    "today": {  
        "earnings": 3.2,
        "earnings_netto": 2.4,
        "sales": 1
    },
    "current_month": {  
        "earnings": 68,
        "earnings_netto": 63,
        "sales": 1
    },
    "last_month": {  
        "earnings": 57.32,
        "earnings_netto": 55.12,
        "sales": 136
    },
    "totals": {  
        "earnings": 1219.8,
        "earnings_netto": 1123.78,
        "sales": 2465
    },
    "range": {
        "20130201": {  
            "earnings": 0,
            "earnings_netto": 0,
            "sales": 0
        },
        "20130202": {  
            "earnings": 300.34,
            "earnings_netto": 289.89,
            "sales": 12
        },
        "20130203": {  
            "earnings": 0,
            "earnings_netto": 0,
            "sales": 0
        },
        "20130204": {  
            "earnings": 0,
            "earnings_netto": 0,
            "sales": 0
        }
    },
    "request_speed": 0.055752038955688
}
sunnyratilal commented 7 years ago

An issue regarding the option to exclude taxes has been opened at #5444.

Now that we've rewritten our reporting query functions to be more efficient, we could adapt our stats endpoint to include more data.

I'll rename this issue to avoid confusion.