Skip to content

Commit

Permalink
docs and some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tustin committed Aug 21, 2018
1 parent 6b56742 commit d4a085c
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 67 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
language: php
php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
script: phpunit --configuration phpunit.xml
21 changes: 10 additions & 11 deletions src/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,51 @@ public function __construct(Client $client)

public function get(string $path, array $parameters = [], array $headers = [])
{
return $this->client->getHttpClient()->get($path, $parameters, $headers);
return $this->client->httpClient()->get($path, $parameters, $headers);
}

public function post(string $path, $parameters, array $headers = [])
{
return $this->client->getHttpClient()->post($path, $parameters, HttpClient::FORM, $headers);
return $this->client->httpClient()->post($path, $parameters, HttpClient::FORM, $headers);
}

public function postJson(string $path, $parameters, array $headers = [])
{
return $this->client->getHttpClient()->post($path, $parameters, HttpClient::JSON, $headers);
return $this->client->httpClient()->post($path, $parameters, HttpClient::JSON, $headers);
}

public function postMultiPart(string $path, array $parameters, array $headers = [])
{
return $this->client->getHttpClient()->post($path, $parameters, HttpClient::MULTI, $headers);
return $this->client->httpClient()->post($path, $parameters, HttpClient::MULTI, $headers);
}

public function delete(string $path, array $headers = [])
{
return $this->client->getHttpClient()->delete($path, $headers);
return $this->client->httpClient()->delete($path, $headers);
}

public function patch(string $path, $parameters, array $headers = [])
{
return $this->client->getHttpClient()->patch($path, $parameters, HttpClient::FORM, $headers);
return $this->client->httpClient()->patch($path, $parameters, HttpClient::FORM, $headers);
}

public function patchJson(string $path, $parameters, array $headers = [])
{
return $this->client->getHttpClient()->patch($path, $parameters, HttpClient::JSON, $headers);
return $this->client->httpClient()->patch($path, $parameters, HttpClient::JSON, $headers);
}

public function put(string $path, $parameters, array $headers = [])
{
return $this->client->getHttpClient()->put($path, $parameters, HttpClient::FORM, $headers);
return $this->client->httpClient()->put($path, $parameters, HttpClient::FORM, $headers);
}

public function putJson(string $path, $parameters, array $headers = [])
{
return $this->client->getHttpClient()->put($path, $parameters, HttpClient::JSON, $headers);
return $this->client->httpClient()->put($path, $parameters, HttpClient::JSON, $headers);
}

public function putMultiPart(string $path, array $parameters, array $headers = [])
{
return $this->client->getHttpClient()->put($path, $parameters, HttpClient::MULTI, $headers);
return $this->client->httpClient()->put($path, $parameters, HttpClient::MULTI, $headers);
}

}
2 changes: 1 addition & 1 deletion src/Api/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function commentId() : string
}

/**
* Gets the post date of the Comment.
* Gets the DateTime of the Comment.
*
* @return \DateTime
*/
Expand Down
42 changes: 42 additions & 0 deletions src/Api/Community.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace PlayStation\Api;

use PlayStation\Client;
use PlayStation\Api\User;

class Community extends AbstractApi
{

public const COMMUNITY_ENDPOINT = 'https://communities.api.playstation.com/v1/';

private $community;

public function __construct(Client $client, object $community)
{
parent::__construct($client);

$this->community = $community;
}

public function id() : string
{
return $this->community->id;
}

public function name() : string
{
return $this->community->name;
}

public function description() : string
{
return $this->community->description;
}

public function memberCount() : int
{
return $this->community->members->size;
}

}
2 changes: 1 addition & 1 deletion src/Api/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function trophies() : array
$data['comparedUser'] = $this->user()->onlineId();
}

$trophies = $this->get(sprintf(Trophy::TROPHY_ENDPOINT . 'trophyTitles/%s/trophyGroups/all/trophies', $this->trophySet->game()->communicationId()), $data);
$trophies = $this->get(sprintf(Trophy::TROPHY_ENDPOINT . 'trophyTitles/%s/trophyGroups/all/trophies', $this->communicationId()), $data);

foreach ($trophies->trophies as $trophy) {
$returnTrophies[] = new Trophy($this->client, $trophy, $this);
Expand Down
8 changes: 4 additions & 4 deletions src/Api/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(Client $client, object $message, MessageThread $mess
}

/**
* Get the sender of the message.
* Get the sender of the Message.
*
* @return User
*/
Expand All @@ -29,7 +29,7 @@ public function sender() : User
}

/**
* Get the MessageThread the message is in.
* Get the MessageThread the Message is in.
*
* @return MessageThread
*/
Expand All @@ -39,7 +39,7 @@ public function thread() : MessageThread
}

/**
* Get the message body text.
* Get the Message body text.
*
* @return string
*/
Expand All @@ -49,7 +49,7 @@ public function body() : string
}

/**
* Get the DateTime the message was sent.
* Get the DateTime when the Message was sent.
*
* @return \DateTime
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Api/MessageThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(Client $client, $messageThreadOrId)
}
}

/**
/**
* Get the MessageThread info.
*
* @param integer $count Amount of messages to return.
Expand Down
36 changes: 35 additions & 1 deletion src/Api/TrophyGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,73 @@ public function __construct(Client $client, object $group, Game $game)
$this->game = $game;
}

/**
* Get TrophyGroup ID.
*
* @return void
*/
public function id()
{
return $this->group->trophyGroupId;
}

/**
* Get name.
*
* @return string
*/
public function name() : string
{
return $this->group->trophyGroupName;
}

/**
* Get detail.
*
* @return string
*/
public function detail() : string
{
return $this->group->trophyGroupDetail;
}

/**
* Get the icon URL.
*
* @return string
*/
public function iconUrl() : string
{
return $this->group->trophyGroupIconUrl;
}

/**
* Get amount of Trophies.
*
* @return integer
*/
public function trophyCount() : int
{
return Trophy::calculateTrophies($this->group->definedTrophies);
}

/**
* Get completion progress of TrophyGroup.
*
* @return integer
*/
public function progress() : int
{
return $this->comparing() ?
$this->group->comparedUser->progress :
$this->group->fromUser->progress;
}

/**
* Get Trophy earn date.
*
* @return \DateTime
*/
public function lastEarnedDate() : \DateTime
{
return new \DateTime(
Expand All @@ -60,7 +95,6 @@ public function lastEarnedDate() : \DateTime
);
}


/**
* Get last TrophyGroup earned DateTIme.
*
Expand Down
Loading

0 comments on commit d4a085c

Please sign in to comment.