Skip to content

Rules Request

Ben Sherred edited this page Nov 5, 2021 · 6 revisions

To get the current TruckersMP rules as shown here, you can call the rules() method on the Client instance:

<?php

require_once('vendor/autoload.php');

$client = new TruckersMP\APIClient\Client();

$rules = $client->rules()->get();

This will return an instance of the Rule model.

The Model

To get the data from the model, a couple of helpful getters have been created as shown below.

Method Type Description
getRules() string The rules in a markdown format
getRevision() int The version of the rules

Example

Below is an example of how you would get the markdown rules:

<?php

require_once('vendor/autoload.php');

$client = new TruckersMP\APIClient\Client();

$rules = $client->rules()->get();

echo $rules->getRules();

To get the revision number, you can use the following snippet:

<?php

require_once('vendor/autoload.php');

$client = new TruckersMP\APIClient\Client();

$rules = $client->rules()->get();
$revision = $rules->getRevision();

echo "This is revision {$revision} of the rules";