Skip to content

Commit

Permalink
add /v2/wvw/matches/{overview,scores,stats}
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Jan 22, 2017
1 parent 446749b commit 7bdbd9b
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/V2/Endpoint/WvW/MatchEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,16 @@ public function url() {
public function world($id) {
return $this->request(['world' => $id])->json();
}

public function overview() {
return new OverviewEndpoint($this->api);
}

public function scores() {
return new ScoreEndpoint($this->api);
}

public function stats() {
return new StatEndpoint($this->api);
}
}
28 changes: 28 additions & 0 deletions src/V2/Endpoint/WvW/OverviewEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\WvW;

use GW2Treasures\GW2Api\V2\Bulk\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Bulk\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;

class OverviewEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

/**
* {@inheritdoc}
*/
public function url() {
return 'v2/wvw/matches/overview';
}

/**
* Get the current match of a world.
*
* @param int $id
* @return mixed
*/
public function world($id) {
return $this->request(['world' => $id])->json();
}
}
28 changes: 28 additions & 0 deletions src/V2/Endpoint/WvW/ScoreEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\WvW;

use GW2Treasures\GW2Api\V2\Bulk\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Bulk\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;

class ScoreEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

/**
* {@inheritdoc}
*/
public function url() {
return 'v2/wvw/matches/scores';
}

/**
* Get the current match of a world.
*
* @param int $id
* @return mixed
*/
public function world($id) {
return $this->request(['world' => $id])->json();
}
}
28 changes: 28 additions & 0 deletions src/V2/Endpoint/WvW/StatEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\WvW;

use GW2Treasures\GW2Api\V2\Bulk\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Bulk\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;

class StatEndpoint extends Endpoint implements IBulkEndpoint {
use BulkEndpoint;

/**
* {@inheritdoc}
*/
public function url() {
return 'v2/wvw/matches/stats';
}

/**
* Get the current match of a world.
*
* @param int $id
* @return mixed
*/
public function world($id) {
return $this->request(['world' => $id])->json();
}
}
30 changes: 30 additions & 0 deletions tests/V2/WvWEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,36 @@ public function testMatchEndpoint() {
$this->assertEquals(169331, $endpoint->world('id')->scores->red);
}

public function testMatchOverviewEndpoint() {
$endpoint = $this->api()->wvw()->matches()->overview();

$this->assertEndpointUrl('v2/wvw/matches/overview', $endpoint);
$this->assertEndpointIsBulk($endpoint);

$this->mockResponse('{"id":"1-1","worlds":{"red":1008,"blue":1019,"green":1005}}');
$this->assertEquals(1008, $endpoint->world(1008)->worlds->red);
}

public function testMatchScoreEndpoint() {
$endpoint = $this->api()->wvw()->matches()->scores();

$this->assertEndpointUrl('v2/wvw/matches/scores', $endpoint);
$this->assertEndpointIsBulk($endpoint);

$this->mockResponse('{"id":"1-1","scores":{"red":169331,"blue":246780,"green":216241}}');
$this->assertEquals(169331, $endpoint->world(1008)->scores->red);
}

public function testMatchStatEndpoint() {
$endpoint = $this->api()->wvw()->matches()->stats();

$this->assertEndpointUrl('v2/wvw/matches/stats', $endpoint);
$this->assertEndpointIsBulk($endpoint);

$this->mockResponse('{"id":"1-1","deaths":{"red":7276,"blue":5922,"green":5767}}');
$this->assertEquals(7276, $endpoint->world(1008)->deaths->red);
}

public function testRankEndpoint() {
$endpoint = $this->api()->wvw()->ranks();

Expand Down

0 comments on commit 7bdbd9b

Please sign in to comment.