Skip to content

Commit

Permalink
Rename Commands to Request
Browse files Browse the repository at this point in the history
  • Loading branch information
pavarnos committed Aug 14, 2018
1 parent 535b2e3 commit 17acbf5
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 63 deletions.
20 changes: 10 additions & 10 deletions src/Threema/MsgApi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

namespace Threema\MsgApi;

use Threema\MsgApi\Commands\Capability;
use Threema\MsgApi\Commands\Credits;
use Threema\MsgApi\Commands\DownloadFile;
use Threema\MsgApi\Commands\FetchPublicKey;
use Threema\MsgApi\Commands\LookupBulk;
use Threema\MsgApi\Commands\LookupEmail;
use Threema\MsgApi\Commands\LookupPhone;
use Threema\MsgApi\Commands\SendE2E;
use Threema\MsgApi\Commands\SendSimple;
use Threema\MsgApi\Commands\UploadFile;
use Threema\MsgApi\Request\Capability;
use Threema\MsgApi\Request\Credits;
use Threema\MsgApi\Request\DownloadFile;
use Threema\MsgApi\Request\FetchPublicKey;
use Threema\MsgApi\Request\LookupBulk;
use Threema\MsgApi\Request\LookupEmail;
use Threema\MsgApi\Request\LookupPhone;
use Threema\MsgApi\Request\SendE2E;
use Threema\MsgApi\Request\SendSimple;
use Threema\MsgApi\Request\UploadFile;
use Threema\MsgApi\Encryptor\AbstractEncryptor;
use Threema\MsgApi\Helpers\E2EHelper;
use Threema\MsgApi\Helpers\ReceiveMessageResult;
Expand Down
26 changes: 13 additions & 13 deletions src/Threema/MsgApi/HttpDriver/CurlHttpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace Threema\MsgApi\HttpDriver;

use Threema\MsgApi\Commands\CommandInterface;
use Threema\MsgApi\Commands\JsonCommandInterface;
use Threema\MsgApi\Commands\MultiPartCommandInterface;
use Threema\MsgApi\Request\RequestInterface;
use Threema\MsgApi\Request\JsonRequestInterface;
use Threema\MsgApi\Request\MultiPartRequestInterface;
use Threema\MsgApi\Constants;
use Threema\MsgApi\Exceptions\HttpException;
use Threema\MsgApi\Helpers\Url;
Expand Down Expand Up @@ -52,21 +52,21 @@ public function __construct(string $threemaID, string $apiSecret, array $tlsOpti
}

/**
* @param CommandInterface $command
* @param RequestInterface $command
* @param \Closure $progress
* @return Response
*/
public function get(CommandInterface $command, \Closure $progress = null): Response
public function get(RequestInterface $command, \Closure $progress = null): Response
{
return $this->call($command, $this->createDefaultOptions($progress),
$this->buildRequestParams($command->getParams()));
}

/**
* @param CommandInterface $command
* @param RequestInterface $command
* @return Response
*/
public function postForm(CommandInterface $command): Response
public function postForm(RequestInterface $command): Response
{
$options = $this->createDefaultOptions();
$params = $this->buildRequestParams($command->getParams());
Expand All @@ -79,10 +79,10 @@ public function postForm(CommandInterface $command): Response
}

/**
* @param MultiPartCommandInterface $command
* @param MultiPartRequestInterface $command
* @return Response
*/
public function postMultiPart(MultiPartCommandInterface $command): Response
public function postMultiPart(MultiPartRequestInterface $command): Response
{
$options = $this->createDefaultOptions();
$params = $this->buildRequestParams($command->getParams());
Expand All @@ -96,10 +96,10 @@ public function postMultiPart(MultiPartCommandInterface $command): Response
}

/**
* @param JsonCommandInterface $command
* @param JsonRequestInterface $command
* @return Response
*/
public function postJson(JsonCommandInterface $command): Response
public function postJson(JsonRequestInterface $command): Response
{
$options = $this->createDefaultOptions();
$params = $this->buildRequestParams($command->getParams());
Expand Down Expand Up @@ -181,13 +181,13 @@ private function buildRequestParams(array $params): array
}

/**
* @param CommandInterface $command
* @param RequestInterface $command
* @param array $curlOptions
* @param array $queryParameters
* @return Response
* @throws \Threema\MsgApi\Exceptions\HttpException
*/
private function call(CommandInterface $command, array $curlOptions, array $queryParameters): Response
private function call(RequestInterface $command, array $curlOptions, array $queryParameters): Response
{
$path = $command->getPath();
$fullPath = new Url('', $this->host);
Expand Down
22 changes: 11 additions & 11 deletions src/Threema/MsgApi/HttpDriver/HttpDriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@

namespace Threema\MsgApi\HttpDriver;

use Threema\MsgApi\Commands\CommandInterface;
use Threema\MsgApi\Commands\JsonCommandInterface;
use Threema\MsgApi\Commands\MultiPartCommandInterface;
use Threema\MsgApi\Request\RequestInterface;
use Threema\MsgApi\Request\JsonRequestInterface;
use Threema\MsgApi\Request\MultiPartRequestInterface;
use Threema\MsgApi\Response\Response;

/**
*/
interface HttpDriverInterface
{
/**
* @param CommandInterface $command
* @param RequestInterface $command
* @param \Closure $progress
* @return Response
*/
public function get(CommandInterface $command, \Closure $progress = null): Response;
public function get(RequestInterface $command, \Closure $progress = null): Response;

/**
* @param CommandInterface $command
* @param RequestInterface $command
* @return Response
*/
public function postForm(CommandInterface $command): Response;
public function postForm(RequestInterface $command): Response;

/**
* @param MultiPartCommandInterface $command
* @param MultiPartRequestInterface $command
* @return Response
*/
public function postMultiPart(MultiPartCommandInterface $command): Response;
public function postMultiPart(MultiPartRequestInterface $command): Response;

/**
* @param JsonCommandInterface $command
* @param JsonRequestInterface $command
* @return Response
*/
public function postJson(JsonCommandInterface $command): Response;
public function postJson(JsonRequestInterface $command): Response;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\CapabilityResponse;
use Threema\MsgApi\Response\Response;

class Capability implements CommandInterface
class Capability implements RequestInterface
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\CreditsResponse;
use Threema\MsgApi\Response\Response;

class Credits implements CommandInterface
class Credits implements RequestInterface
{
/**
* @return array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\DownloadFileResponse;
use Threema\MsgApi\Response\Response;

class DownloadFile implements CommandInterface
class DownloadFile implements RequestInterface
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\FetchPublicKeyResponse;

class FetchPublicKey implements CommandInterface
class FetchPublicKey implements RequestInterface
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

interface JsonCommandInterface extends CommandInterface
interface JsonRequestInterface extends RequestInterface
{
public function getJson(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Encryptor\AbstractEncryptor;
use Threema\MsgApi\Response\LookupBulkResponse;
Expand All @@ -22,7 +22,7 @@
* BulkLookupIdentity helper class. The original key of the email or phone is returned to you in the match result, which
* is helpful if it is linked to a user.id or person.id for example.
*/
class LookupBulk implements JsonCommandInterface
class LookupBulk implements JsonRequestInterface
{
/** @var string[] */
private $email = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\LookupIdResponse;
use Threema\MsgApi\Response\Response;

class LookupEmail implements CommandInterface
class LookupEmail implements RequestInterface
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\LookupIdResponse;
use Threema\MsgApi\Response\Response;

class LookupPhone implements CommandInterface
class LookupPhone implements RequestInterface
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

interface MultiPartCommandInterface extends CommandInterface
interface MultiPartRequestInterface extends RequestInterface
{
public function getData(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\Response;

interface CommandInterface
interface RequestInterface
{
/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\Response;
use Threema\MsgApi\Response\SendE2EResponse;

class SendE2E implements CommandInterface
class SendE2E implements RequestInterface
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\SendSimpleResponse;

class SendSimple implements CommandInterface
class SendSimple implements RequestInterface
{
/** @var string */
private $text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

declare(strict_types=1);

namespace Threema\MsgApi\Commands;
namespace Threema\MsgApi\Request;

use Threema\MsgApi\Response\Response;
use Threema\MsgApi\Response\UploadFileResponse;

class UploadFile implements MultiPartCommandInterface
class UploadFile implements MultiPartRequestInterface
{
/**
* @var string
Expand Down
4 changes: 2 additions & 2 deletions src/Threema/MsgApi/Response/LookupBulkResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

namespace Threema\MsgApi\Response;

use Threema\MsgApi\Commands\LookupBulk;
use Threema\MsgApi\Request\LookupBulk;
use Threema\MsgApi\Helpers\BulkLookupIdentity;

class LookupBulkResponse extends Response
{
/** @var \Threema\MsgApi\Commands\LookupBulk */
/** @var \Threema\MsgApi\Request\LookupBulk */
private $request;

/** @var BulkLookupIdentity[] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Threema\MsgApi\Response;

use PHPUnit\Framework\TestCase;
use Threema\MsgApi\Commands\LookupBulk;
use Threema\MsgApi\Request\LookupBulk;
use Threema\MsgApi\ConnectionFactory;

class LookupBulkResultTest extends TestCase
Expand Down

0 comments on commit 17acbf5

Please sign in to comment.