Laragear/ApiManager

View on GitHub
stubs/api.stub

Summary

Maintainability
Test Coverage
<?php

namespace {{ namespace }};

use Laragear\ApiManager\ApiServer;

class DummyClass extends ApiServer
{
    /**
     * The headers to include in each request.
     *
     * @var array|array{string:string}
     */
    public array $headers = [
        // ...
    ];

    /**
     * The list of simple actions for this API.
     *
     * @var array|string[]
     */
    public array $actions = [
        'latest' => '/',
        'create' => 'post:new',
    ];

    /**
     * Returns the API base URL.
     *
     * @return string
     */
    abstract public function getBaseUrl(): string
    {
        return app()->isProduction()
            ? 'https://dummyClass.com/api/v1'
            : 'https://dev.dummyClass.com/api/v1';
    }

    /**
     * Returns the Bearer Token used for authentication.
     *
     * @return string
     */
    protected function authToken(): string
    {
        return config('services.dummyClass.secret');
    }
}