Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4aeeadf
Create EventType model
iDiegoNL Nov 10, 2021
aa1284c
Create EventServer model
iDiegoNL Nov 10, 2021
e3a1b7f
Create EventLocation model
iDiegoNL Nov 10, 2021
eee6a7d
Create EventCompany model
iDiegoNL Nov 10, 2021
ab9fc49
Create EventOrganizer model
iDiegoNL Nov 10, 2021
f02bf15
Create EventAttendance model
iDiegoNL Nov 10, 2021
370cce7
Create Event model
iDiegoNL Nov 10, 2021
1bc82ad
Create EventCollection
iDiegoNL Nov 10, 2021
8e45d39
Create EventIndex model
iDiegoNL Nov 10, 2021
6f476ab
Create EventIndexRequest
iDiegoNL Nov 10, 2021
5297ab6
Create EventRequest
iDiegoNL Nov 10, 2021
1857eca
Correct some Docblocks & type declarations with nullable fields
iDiegoNL Nov 10, 2021
093c18e
Add events and event method to client
iDiegoNL Nov 10, 2021
68094d1
Add confirmed & unsure user collection to Event model
iDiegoNL Nov 10, 2021
75e0652
Correct EventAttendance getUnsure return type
iDiegoNL Nov 10, 2021
4e75b6e
Correct EventCollection foreach var name
iDiegoNL Nov 10, 2021
7806c37
Implement Company Events
iDiegoNL Nov 10, 2021
5ee9356
Add DLCs to Event model
iDiegoNL Nov 10, 2021
b6501c8
Add events and event methods to TestCase
iDiegoNL Nov 10, 2021
d6083ce
Fix code to be PSR12 compliant
iDiegoNL Nov 10, 2021
c0a162d
Create event tests
iDiegoNL Nov 10, 2021
4df53c9
Use camelCase instead of snake_case
iDiegoNL Nov 10, 2021
1d862c3
Update some Docblocks
iDiegoNL Nov 10, 2021
56d717a
Merge branch 'TruckersMP:develop' into develop
iDiegoNL Nov 10, 2021
1e6fce7
Update EventAttendee following description & property name
iDiegoNL Nov 10, 2021
dffa680
Apply suggestions from code review
iDiegoNL Nov 10, 2021
bb5f8c0
Fix companyEvent cache name in TestCase
iDiegoNL Nov 11, 2021
97957c6
Fix EventAttendee following property
iDiegoNL Nov 11, 2021
6a64e01
Merge branch 'develop' of github.com:iDiegoNL/API-Client into develop
iDiegoNL Nov 11, 2021
1afce3f
Fix EventIndexRequest get method DocBlock return type
iDiegoNL Nov 11, 2021
873ff9d
Return an empty collection instead of null in EventIndex
iDiegoNL Nov 11, 2021
c3f3987
Remove null from EventLocation city property return type
iDiegoNL Nov 11, 2021
7016c51
Update src/Models/EventAttendee.php
iDiegoNL Nov 12, 2021
62fc308
Add myself as a contributor in the composer.json
iDiegoNL Nov 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"email": "shawnczek@truckersmp.com",
"homepage": "https://github.com/shawnczek",
"role": "Maintainer"
},
{
"name": "Diego Relyveld",
"email": "me@diegor.nl",
"homepage": "https://github.com/iDiegoNL",
"role": "Contributor"
}
],
"require": {
Expand Down
27 changes: 27 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace TruckersMP\APIClient;

use TruckersMP\APIClient\Requests\BanRequest;
use TruckersMP\APIClient\Requests\EventIndexRequest;
use TruckersMP\APIClient\Requests\EventRequest;
use TruckersMP\APIClient\Requests\CompanyIndexRequest;
use TruckersMP\APIClient\Requests\CompanyRequest;
use TruckersMP\APIClient\Requests\GameTimeRequest;
Expand Down Expand Up @@ -130,6 +132,31 @@ public function rules(): RuleRequest
return new RuleRequest();
}

/**
* Get the featured, today's and upcoming events.
*
* https://stats.truckersmp.com/api#events_index
*
* @return EventIndexRequest
*/
public function events(): EventIndexRequest
{
return new EventIndexRequest();
}

/**
* Get the information for the event with the specified ID.
*
* https://stats.truckersmp.com/api#events_info
*
* @param int $id
* @return EventRequest
*/
public function event(int $id): EventRequest
{
return new EventRequest($id);
}

/**
* Get the configuration to use for Guzzle.
*
Expand Down
23 changes: 23 additions & 0 deletions src/Collections/DlcCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TruckersMP\APIClient\Collections;

use TruckersMP\APIClient\Models\Dlc;

class DlcCollection extends Collection
{
/**
* Create a new DlcCollection instance.
*
* @param array $response
* @return void
*/
public function __construct(array $response)
{
parent::__construct();

foreach ($response as $key => $dlc) {
$this->items[$key] = new Dlc($key, $dlc);
}
}
}
23 changes: 23 additions & 0 deletions src/Collections/EventAttendeeCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TruckersMP\APIClient\Collections;

use TruckersMP\APIClient\Models\EventAttendee;

class EventAttendeeCollection extends Collection
{
/**
* Create a new EventAttendeeCollection instance.
*
* @param array $response
* @return void
*/
public function __construct(array $response)
{
parent::__construct();

foreach ($response as $key => $attendee) {
$this->items[$key] = new EventAttendee($attendee);
}
}
}
23 changes: 23 additions & 0 deletions src/Collections/EventCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TruckersMP\APIClient\Collections;

use TruckersMP\APIClient\Models\Event;

class EventCollection extends Collection
{
/**
* Create a new EventCollection instance.
*
* @param array $response
* @return void
*/
public function __construct(array $response)
{
parent::__construct();

foreach ($response as $key => $event) {
$this->items[$key] = new Event($event);
}
}
}
36 changes: 36 additions & 0 deletions src/Models/CompanyEventIndex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace TruckersMP\APIClient\Models;

use TruckersMP\APIClient\Collections\EventCollection;

class CompanyEventIndex
{
/**
* The company events.
*
* @var EventCollection
*/
protected $events;

/**
* Create a new CompanyEventIndex instance.
*
* @param array $response
* @return void
*/
public function __construct(array $response)
{
$this->events = new EventCollection($response);
}

/**
* Get the collection of company events.
*
* @return EventCollection
*/
public function getEvents(): EventCollection
{
return $this->events;
}
}
55 changes: 55 additions & 0 deletions src/Models/Dlc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace TruckersMP\APIClient\Models;

class Dlc
{
/**
* The DLC ID.
*
* @var int
*/
protected $id;

/**
* The DLC name.
*
* @var string
*/
protected $name;

/**
* Create a new Dlc instance.
*
* @param int $id
* @param string $name
* @return void
*/
public function __construct(
int $id,
string $name
) {
$this->id = $id;
$this->name = $name;
}

/**
* Get the DLC ID.
*
* @return int
*/
public function getId(): int
{
return $this->id;
}

/**
* Get the DLC name.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
}
Loading