Skip to content

Request for documentation #33

@eltjor

Description

@eltjor

Guys,
I've been struggling with a generic implementation of Trucker in my app.
I want an implementation where I can configure the end-point in a ModelResource since we're using multiple external resources.

App/Resources/ProfileResource

<?php

    namespace App\Resources;

    use App\CoreConfig;
    use Trucker\Facades\Config as TruckerConfig;
    use Trucker\Resource\Model;

    class ProfileResource extends Model
    {

        var $request = [
            'base_uri' => 'https://profiler.local',
            'driver' => 'rest',
            'http_method_param' => null,
            ];

        public function __construct()
        {
            TruckerConfig::set('auth.basic.username', CoreConfig::getConfig('api:Profiler:username'));
            TruckerConfig::set('auth.basic.password', CoreConfig::getConfig('api:Profiler:password'));
        }

    }

App/Model/Profile

<?php

namespace App;

use \App\Resources\ProfileResource;

class Profile extends ProfileResource
{
    //
}

To test:

# php artisan tinker
>>> $test = new \App\Profile;
=> App\Profile {#878
     +request: [
       "base_uri" => "https://profiler.local",
       "driver" => "rest",
       "http_method_param" => null,
     ],
     +nestedUnder: null,
   }
>>> $test->all();
Guzzle\Common\Exception\RuntimeException with message 'Unable to parse response body into JSON: 4'
>>> $test->errors();
=> []
>>> 

How can I debug? see what is happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions