Easy-digital-downloads: Return null for all empty data returned from the API

Created on 21 Aug 2016  路  7Comments  路  Source: easydigitaldownloads/easy-digital-downloads

Currently, we return an empty array if keys like discount or fees has no data. This is poor design in standard APIs and causes confusion when parsing JSON in Swift because it's not seen as nil.

We should run a simple conditional check like so: ( ! empty( $payment->fees ) ? $payment->fees : null );

component-api type-bug

All 7 comments

Technically this is a breaking change in data returned so would normally require a version bump to the API, but it's small enough that I propose we go ahead and put it in as is.

Yeah I think most developers will be using an empty check here anyway...which null will bass just fine. I'm a :+1: for this.

PR merged into master bug leaving open for the meantime to allow visibility and testing.

Everything that was adjusted returns null when it should for me. :+1:

I am not getting NULL for fees when empty. But I'm not totally sure I'm testing the correct thing. Is this is master right now?

screen shot 2016-08-31 at 3 44 45 pm

@mintplugins make sure you're using v2 of the api, for force it just use /edd-api/v2/<endpoint>. Do you still see that empty fees array?

馃憤 Forcing v2 brings it back NULL:

screen shot 2016-09-01 at 9 45 30 am

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikeyhoward1977 picture mikeyhoward1977  路  5Comments

amdrew picture amdrew  路  5Comments

mindctrl picture mindctrl  路  4Comments

davidsherlock picture davidsherlock  路  4Comments

scottbuscemi picture scottbuscemi  路  5Comments