wetcat-studios / fortie

Laravel 5 package for Fortnox API
Apache License 2.0
19 stars 20 forks source link

Parameters addons #43

Closed bagendahl closed 5 years ago

bagendahl commented 5 years ago

Hi again,

Could you change in fortieRequest.php from this:

270    // Add the optional filter to params
271    if (!is_null($this->optionalFilter)) {
272     $this->params['filter'] = $this->optionalFilter;
273    }

to

270    // Add the optional filter to params
271    if (!is_null($this->optionalFilter)) {
272        if (is_array($this->optionalFilter)) {
273            $this->params = $this->optionalFilter;
274        } else {
275            $this->params['filter'] = $this->optionalFilter;
276        }
278    }

Without [filter]in params if sending array. In this case you can send in multiple parameters, example:

$orders = $this->fortie->orders()->all(['sortby' => 'customernumber', 'sortorder' => 'descending', 'limit' => 1]);

All params are enabled from documentation https://developer.fortnox.se/documentation/general/parameters/

Thanks, Patrick

agoransson commented 5 years ago

I can see why you need this - I must've completely missed this use-case somehow. I think for now it's a good fix to handle that use-case, but in the long run I'll want to add more args to the functions instead so that "filter" actually means filter, and nothing else. Probably adding a "sort" as well, at a "limit".

Thanks!

bagendahl commented 5 years ago

I can understand that would be more user friendly to have filter, sort, limit etc. But a suggestion could be to refactor "filter" to params (parameters), in that case if fortnox add more features you do not need to add any more params.