/**
  * Shows an endpoint's details
  *
  * @return Response
  */
 public function getEndpoint($alias)
 {
     $endpoint = Endpoint::findByAlias($alias)->first();
     if ($endpoint === null) {
         throw new NotFoundHttpException();
     }
     $baseURL = Setting::byKey('base_api_url');
     $requestParameterTypes = RequestParameterType::all();
     $requestParameters = [];
     foreach ($requestParameterTypes as $requestParameterType) {
         $rp = $endpoint->requestParameters()->where('request_parameter_type_id', '=', $requestParameterType->id)->get();
         $requestParameters[$requestParameterType->id] = ['type' => $requestParameterType, 'parameters' => $rp];
     }
     $data = ['endpoint' => $endpoint, 'requestParameters' => $requestParameters, 'baseURL' => $baseURL];
     return view('layouts.frontend.endpoint', $data);
 }
 public function transform(Endpoint $data)
 {
     return $data->toArray();
 }
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        function hyphenCase($string)
        {
            $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
            $string = strtolower($string);
            return str_replace(' ', '-', $string);
        }
        // ============== Preparation ================ //
        // Get all models
        $models = [new ApiResource(), new Endpoint(), new EndpointExample(), new ObjectModel(), new ObjectModelProperty(), new RequestParameter(), new RequestParameterType(), new Setting(), new Article(), new User()];
        // Truncate all the model tables
        foreach ($models as $model) {
            DB::table($model->getTable())->truncate();
        }
        // ============== Populate tables ================ //
        // Sample user
        $user = User::create(['name' => 'Admin', 'email' => '*****@*****.**', 'password' => Hash::make('admin')]);
        // Object models
        $objectModelsData = ['api_resource' => ['title' => 'api_resource', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the API resource.'], ['key' => 'title', 'value_type' => 'string', 'value_description' => 'The title of the resource.']]], 'endpoint' => ['title' => 'endpoint', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the endpoint.'], ['key' => 'title', 'value_type' => 'string', 'value_description' => 'The title of the endpoint.'], ['key' => 'method', 'value_type' => 'string', 'value_description' => 'The HTTP method used for this endpoint.'], ['key' => 'usage', 'value_type' => 'string', 'value_description' => 'A short description of the usage of this endpoint.'], ['key' => 'secure', 'value_type' => 'bool', 'value_description' => 'Determines whether or not the endpoint requires authentication.'], ['key' => 'description', 'value_type' => 'string', 'value_description' => 'A description of the usage of this endpoint.'], ['key' => 'response_format_description', 'value_type' => 'string', 'value_description' => 'A description of the response format for this endpoint.'], ['key' => 'object_model_id', 'value_type' => 'integer', 'value_description' => 'The ID of the object model this endpoint responds with by default.'], ['key' => 'api_resource_id', 'value_type' => 'integer', 'value_description' => 'The ID of the resource this endpoint belongs to.']]], 'endpoint_example' => ['title' => 'endpoint_example', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the endpoint example.'], ['key' => 'title', 'value_type' => 'string', 'value_description' => 'The title of the endpoint example.'], ['key' => 'curl_example', 'value_type' => 'string', 'value_description' => 'A string that will be parsed in to an CURL command to test this example.'], ['key' => 'response', 'value_type' => 'string', 'value_description' => 'The content of the example response.'], ['key' => 'endpoint_id', 'value_type' => 'integer', 'value_description' => 'The ID of the endpoint this example belongs to.'], ['key' => 'order', 'value_type' => 'integer', 'value_description' => 'An integer that can be used to sort the endpoint examples.']]], 'object_model' => ['title' => 'object_model', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the object model.'], ['key' => 'title', 'value_type' => 'string', 'value_description' => 'The title of the object model.']]], 'object_model_prop' => ['title' => 'object_model_prop', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the object model property.'], ['key' => 'key', 'value_type' => 'string', 'value_description' => 'The name of the object model property.'], ['key' => 'value_type', 'value_type' => 'string', 'value_description' => 'The type of the object model property.'], ['key' => 'value_description', 'value_type' => 'string', 'value_description' => 'A description of the object model property value.'], ['key' => 'object_model_id', 'value_type' => 'integer', 'value_description' => 'The ID of the object model this property belongs to.']]], 'request_parameter' => ['title' => 'request_parameter', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the request parameter.'], ['key' => 'key', 'value_type' => 'string', 'value_description' => 'The name of the request parameter key.'], ['key' => 'value_description', 'value_type' => 'string', 'value_description' => 'The description of request parameter.'], ['key' => 'request_parameter_type_id', 'value_type' => 'integer', 'value_description' => 'The ID of the request parameter type.'], ['key' => 'request_parameter_type', 'value_type' => 'an request_parameter_type object', 'value_description' => 'The type of this request parameter.'], ['key' => 'endpoint_id', 'value_type' => 'integer', 'value_description' => 'The ID of the endpoint this request parameter belongs to.']]], 'request_parameter_type' => ['title' => 'request_parameter_type', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the request parameter type.'], ['key' => 'title', 'value_type' => 'string', 'value_description' => 'The title of the request parameter type.']]], 'setting' => ['title' => 'setting', 'keys' => [['key' => 'id', 'value_type' => 'integer', 'value_description' => 'The unique identifier for the setting.'], ['key' => 'key', 'value_type' => 'string', 'value_description' => 'An unique identifier for the setting.'], ['key' => 'type', 'value_type' => 'string', 'value_description' => 'Identifies what value type the setting is.'], ['key' => 'value', 'value_type' => 'string', 'value_description' => 'The value of the setting.']]]];
        $objectModels = [];
        foreach ($objectModelsData as $key => $objectModelData) {
            $objectModel = ObjectModel::create(['alias' => hyphenCase($objectModelData['title']), 'title' => $objectModelData['title']]);
            $objectModels[$key] = $objectModel;
            $objectModelProps = [];
            foreach ($objectModelData['keys'] as $objectModelPropData) {
                $objectModelProp = new ObjectModelProperty($objectModelPropData);
                array_push($objectModelProps, $objectModelProp);
            }
            $objectModel->props()->saveMany($objectModelProps);
        }
        // Resources and endpoints
        $resourcesData = [['title' => 'Settings', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/settings', 'title' => 'Get all settings', 'usage' => 'Get all settings', 'description' => 'Get a list of all settings.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of setting objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['setting']->id], ['method' => 'POST', 'endpoint' => '/v1/settings', 'title' => 'Create a new setting', 'usage' => 'Create a new setting', 'description' => 'Create a new setting.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a setting object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['setting']->id], ['method' => 'GET', 'endpoint' => '/v1/settings/{id}', 'title' => 'Get a setting', 'usage' => 'Get a setting', 'description' => 'Get information about a single setting.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a setting object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['setting']->id], ['method' => 'PUT', 'endpoint' => '/v1/settings/{id}', 'title' => 'Change setting details', 'usage' => 'Change setting details', 'description' => "Changes a setting's details. Be careful when using this action.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a setting object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['setting']->id], ['method' => 'DELETE', 'endpoint' => '/v1/settings/{id}', 'title' => 'Removes a setting', 'usage' => 'Removes a setting', 'description' => 'Removes the setting completely from the system. Be careful when using this action.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a setting object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['setting']->id]]], ['title' => 'Resources', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/api_resources', 'title' => 'Get all API resources', 'usage' => 'Get all API resources', 'description' => 'Get a list of all the API resources.', 'secure' => 0, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of api_resource objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['api_resource']->id], ['method' => 'POST', 'endpoint' => '/v1/api_resources', 'title' => 'Create a new API resource', 'usage' => 'Create a new API resource', 'description' => 'Create a new API resource.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a api_resource object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['api_resource']->id], ['method' => 'GET', 'endpoint' => '/v1/api_resources/{id}', 'title' => 'Get an API resource', 'usage' => 'Get an API resource', 'description' => 'Get information about a single API resource.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a api_resource object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['api_resource']->id], ['method' => 'PUT', 'endpoint' => '/v1/api_resources/{id}', 'title' => 'Change an API resource details', 'usage' => 'Change an API resource details', 'description' => "Changes a API resource's details.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a api_resource object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['api_resource']->id], ['method' => 'DELETE', 'endpoint' => '/v1/api_resources/{id}', 'title' => 'Removes an API resource', 'usage' => 'Removes an API resource', 'description' => 'Removes the API resource completely from the system.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a api_resource object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['api_resource']->id]]], ['title' => 'Endpoints', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/endpoints', 'title' => 'Get all endpoints', 'usage' => 'Get all endpoints', 'description' => 'Get a list of all the endpoints.', 'secure' => 0, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of endpoint objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint']->id], ['method' => 'POST', 'endpoint' => '/v1/endpoints', 'title' => 'Create a new endpoint', 'usage' => 'Create a new endpoint', 'description' => 'Create a new endpoint.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a endpoint object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint']->id], ['method' => 'GET', 'endpoint' => '/v1/endpoints/{id}', 'title' => 'Get an endpoint', 'usage' => 'Get an endpoint', 'description' => 'Get information about a single endpoint.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a endpoint object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint']->id], ['method' => 'PUT', 'endpoint' => '/v1/endpoints/{id}', 'title' => 'Change an endpoint details', 'usage' => 'Change an endpoint details', 'description' => "Changes a endpoint's details.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a endpoint object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint']->id], ['method' => 'DELETE', 'endpoint' => '/v1/endpoints/{id}', 'title' => 'Removes an endpoint', 'usage' => 'Removes an endpoint', 'description' => 'Removes the endpoint completely from the system.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a endpoint object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint']->id]]], ['title' => 'Endpoint Examples', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/endpoint_examples', 'title' => 'Get all endpoint examples', 'usage' => 'Get all endpoint examples', 'description' => 'Get a list of all the endpoint examples.', 'secure' => 0, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of endpoint_example objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint_example']->id], ['method' => 'POST', 'endpoint' => '/v1/endpoint_examples', 'title' => 'Create a new endpoint example', 'usage' => 'Create a new endpoint example', 'description' => 'Create a new endpoint example.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a endpoint_example object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint_example']->id], ['method' => 'GET', 'endpoint' => '/v1/endpoint_examples/{id}', 'title' => 'Get an endpoint example', 'usage' => 'Get an endpoint example', 'description' => 'Get information about a single endpoint example.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a endpoint_example object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint_example']->id], ['method' => 'PUT', 'endpoint' => '/v1/endpoint_examples/{id}', 'title' => 'Change an endpoint example details', 'usage' => 'Change an endpoint example details', 'description' => "Changes a endpoint example's details.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a endpoint_example object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint_example']->id], ['method' => 'DELETE', 'endpoint' => '/v1/endpoint_examples/{id}', 'title' => 'Removes an endpoint example', 'usage' => 'Removes an endpoint example', 'description' => 'Removes the endpoint example completely from the system.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a endpoint_example object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['endpoint_example']->id]]], ['title' => 'Object Models', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/object_models', 'title' => 'Get all object models', 'usage' => 'Get all object models', 'description' => 'Get a list of all the object models.', 'secure' => 0, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of object_model objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model']->id], ['method' => 'POST', 'endpoint' => '/v1/object_models', 'title' => 'Create a new object model', 'usage' => 'Create a new object model', 'description' => 'Create a new object model.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a object_model object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model']->id], ['method' => 'GET', 'endpoint' => '/v1/object_models/{id}', 'title' => 'Get an object model', 'usage' => 'Get an object model', 'description' => 'Get information about a single object model.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a object_model object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model']->id], ['method' => 'PUT', 'endpoint' => '/v1/object_models/{id}', 'title' => 'Change an object model details', 'usage' => 'Change an object model details', 'description' => "Changes a object model's details.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a object_model object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model']->id], ['method' => 'DELETE', 'endpoint' => '/v1/object_models/{id}', 'title' => 'Removes an object model', 'usage' => 'Removes an object model', 'description' => 'Removes the object model completely from the system.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a object_model object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model']->id]]], ['title' => 'Object Model Property', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/object_model_props', 'title' => 'Get all object model properties', 'usage' => 'Get all object model properties', 'description' => 'Get a list of all the object model properties.', 'secure' => 0, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of object_model_prop objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model_prop']->id], ['method' => 'POST', 'endpoint' => '/v1/object_model_props', 'title' => 'Create a new object model property', 'usage' => 'Create a new object model property', 'description' => 'Create a new object model property.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a object_model_prop object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model_prop']->id], ['method' => 'GET', 'endpoint' => '/v1/object_model_props/{id}', 'title' => 'Get an object model property', 'usage' => 'Get an object model property', 'description' => 'Get information about a single object model property.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a object_model_prop object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model_prop']->id], ['method' => 'PUT', 'endpoint' => '/v1/object_model_props/{id}', 'title' => 'Change an object model property details', 'usage' => 'Change an object model property details', 'description' => "Changes a object model property's details.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a object_model_prop object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model_prop']->id], ['method' => 'DELETE', 'endpoint' => '/v1/object_model_props/{id}', 'title' => 'Removes an object model property', 'usage' => 'Removes an object model property', 'description' => 'Removes the object model property completely from the system.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a object_model_prop object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['object_model_prop']->id]]], ['title' => 'Request Parameter Types', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/request_parameter_types', 'title' => 'Get all request parameter types', 'usage' => 'Get all request parameter types', 'description' => 'Get a list of all the request parameter types.', 'secure' => 0, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of request_parameter_type objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter_type']->id], ['method' => 'POST', 'endpoint' => '/v1/request_parameter_types', 'title' => 'Create a new request parameter type', 'usage' => 'Create a new request parameter type', 'description' => 'Create a new request parameter type.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a request_parameter_type object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter_type']->id], ['method' => 'GET', 'endpoint' => '/v1/request_parameter_types/{id}', 'title' => 'Get a request parameter type', 'usage' => 'Get a request parameter type', 'description' => 'Get information about a single request parameter type.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a request_parameter_type object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter_type']->id], ['method' => 'PUT', 'endpoint' => '/v1/request_parameter_types/{id}', 'title' => 'Change a request parameter type details', 'usage' => 'Change a request parameter type details', 'description' => "Changes a request parameter type's details.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a request_parameter_type object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter_type']->id], ['method' => 'DELETE', 'endpoint' => '/v1/request_parameter_types/{id}', 'title' => 'Removes a request parameter type', 'usage' => 'Removes a request parameter type', 'description' => 'Removes the request parameter type completely from the system.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a request_parameter_type object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter_type']->id]]], ['title' => 'Request Parameters', 'endpoints' => [['method' => 'GET', 'endpoint' => '/v1/request_parameters', 'title' => 'Get all request parameters', 'usage' => 'Get all request parameters', 'description' => 'Get a list of all the request parameters.', 'secure' => 0, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains an array of request_parameter objects in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter']->id], ['method' => 'POST', 'endpoint' => '/v1/request_parameters', 'title' => 'Create a new request parameter', 'usage' => 'Create a new request parameter', 'description' => 'Create a new request parameter.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 201 Created which indicates that the resource has been created. The response body contains the newly created resource as a request_parameter object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter']->id], ['method' => 'GET', 'endpoint' => '/v1/request_parameters/{id}', 'title' => 'Get a request parameter', 'usage' => 'Get a request parameter', 'description' => 'Get information about a single request parameter.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains a request_parameter object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter']->id], ['method' => 'PUT', 'endpoint' => '/v1/request_parameters/{id}', 'title' => 'Change a request parameter details', 'usage' => 'Change a request parameter details', 'description' => "Changes a request parameter's details.", 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK which indicates that the resource has been updated. The response body contains the newly updated resource as a request_parameter object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter']->id], ['method' => 'DELETE', 'endpoint' => '/v1/request_parameters/{id}', 'title' => 'Removes a request parameter', 'usage' => 'Removes a request parameter', 'description' => 'Removes the request parameter completely from the system.', 'secure' => 1, 'response_format_description' => 'On success, the HTTP status code in the response header is 200 OK and the response body contains the deleted resource as a request_parameter object in JSON format. On error, the header status code is an error code and the response body contains an error object.', 'object_model_id' => $objectModels['request_parameter']->id]]]];
        foreach ($resourcesData as $resourceData) {
            $resource = ApiResource::create(['title' => $resourceData['title'], 'alias' => hyphenCase($resourceData['title'])]);
            if (!empty($resourceData['endpoints'])) {
                $endpoints = [];
                foreach ($resourceData['endpoints'] as $endpointData) {
                    $endpointData['alias'] = hyphenCase($endpointData['title']);
                    $endpoint = new Endpoint($endpointData);
                    $endpoint->objectModels()->save($endpoint);
                    array_push($endpoints, $endpoint);
                }
                $resource->endpoints()->saveMany($endpoints);
            }
        }
        $settingsEndpoint = Endpoint::find(3);
        $endpointExample = new EndpointExample();
        $endpointExample->title = 'Get information about a single setting';
        $endpointExample->curl_example = 'curl -X GET "http://api.example.com/v1/settings/1"';
        $endpointExample->response = '{
  "href": "http://aae/api/v1/settings/1",
  "data": {
    "id": 1,
    "key": "base_api_url",
    "type": "string",
    "value": "http://api.example.com",
    "created_at": "2015-08-12 10:07:48",
    "updated_at": "2015-08-12 10:07:48",
    "href": "http://aae/api/v1/settings/1",
    "uri": "aae:settings:1"
  }
}';
        $endpointExample->endpoint()->associate($settingsEndpoint);
        $endpointExample->save();
        // ========== REQUEST PARAMETERS ==========
        $rpt1 = RequestParameterType::create(['title' => 'Path parameter']);
        $rpt2 = RequestParameterType::create(['title' => 'Header field']);
        $rpt3 = RequestParameterType::create(['title' => 'Request body data']);
        $rpt4 = RequestParameterType::create(['title' => 'Query parameter']);
        $requestParameter1 = new RequestParameter();
        $requestParameter1->key = 'id';
        $requestParameter1->value_description = 'The ID for the setting.';
        $requestParameter1->request_parameter_type_id = $rpt1->id;
        $requestParameter1->endpoint_id = 3;
        $requestParameter1->save();
        // ============= SETTINGS =================
        Setting::create(['key' => 'base_api_url', 'type' => 'string', 'value' => 'http://api.example.com']);
        // ============== ARTICLES ================
        $userGuideArticle = new Article();
        $userGuideArticle->alias = "user-guide";
        $userGuideArticle->title = "User Guide";
        $userGuideArticle->content = '<p class=lead">Our Web API provides client applications with fast and reliable access to Spotify data.</p>';
        $userGuideArticle->save();
    }