exlo89 / laravel-sevdesk-api

Helpfull Laravel package to work with the Sevdesk API.
MIT License
7 stars 11 forks source link

Return values as collections #3

Closed ghost closed 1 year ago

ghost commented 1 year ago

My Idea is that the return values of some functions should be Collections instead of regular arrays. This adds some more functionality to them and integrates it better into Laravel.

Example:

// In Class Exlo89\LaravelSevdeskApi\Api\Contact;
    public function all(int $depth = 0)
    {
        // Only difference is the Collection::make()
        return Collection::make($this->_get(Routes::CONTACT, ['depth' => $depth]));
    }
$sevdeskapi = Sevdesk::make();
$contacts = $sevdeskApi->contact()->all()
$contacts->first() // now possible since it is a collection

Maybe there is a smoother way to achive this.

exlo89 commented 1 year ago

@sebitwo that is a good idea. give me some time to implement it. :)

ghost commented 1 year ago

I opened a pull request that implements it the way i suggested ^^ But as i said: this may not be the best way to do it /s

exlo89 commented 1 year ago

nice work :)