linkmobility-php-client/src/Request/RequestInterface.php

129 lines
3.4 KiB
PHP
Raw Normal View History

2022-06-20 14:47:33 +02:00
<?php
/**
2022-07-13 10:50:45 +02:00
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
2022-06-20 14:47:33 +02:00
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
2022-07-13 10:50:45 +02:00
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link https://www.oxidmodule.com
2022-06-20 14:47:33 +02:00
*/
declare(strict_types=1);
namespace D3\LinkmobilityClient\Request;
2023-02-02 00:07:12 +01:00
use Assert\InvalidArgumentException;
use D3\LinkmobilityClient\Client;
2022-07-27 09:31:46 +02:00
use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface;
use D3\LinkmobilityClient\ValueObject\SmsMessageInterface;
2022-06-24 16:00:56 +02:00
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
use D3\LinkmobilityClient\Response\ResponseInterface as LMResponseInterface;
2022-06-20 14:47:33 +02:00
interface RequestInterface
{
// @codeCoverageIgnoreStart
2022-07-13 10:41:23 +02:00
public const METHOD_GET = 'GET';
public const METHOD_POST = 'POST';
public const METHOD_PUT = 'PUT';
public const METHOD_PATCH = 'PATCH';
public const METHOD_DELETE = 'DELETE';
2022-06-20 14:47:33 +02:00
2022-07-13 10:41:23 +02:00
public const CONTENTTYPE_JSON = 'application/json';
2022-06-20 14:47:33 +02:00
2022-07-13 10:41:23 +02:00
public const CONTENTCATEGORY_INFORMATIONAL = 'informational';
public const CONTENTCATEGORY_ADVERTISEMENT = 'advertisement';
2022-06-20 14:47:33 +02:00
2022-07-13 10:41:23 +02:00
public const MESSAGETYPE_DEFAULT = 'default';
public const MESSAGETYPE_VOICE = 'voice';
2022-06-20 14:47:33 +02:00
2022-07-13 10:41:23 +02:00
public const SENDERADDRESSTYPE_NATIONAL = 'national';
public const SENDERADDRESSTYPE_INTERNATIONAL = 'international';
public const SENDERADDRESSTYPE_ALPHANUMERIC = 'alphanumeric';
public const SENDERADDRESSTYPE_SHORTCODE = 'shortcode';
// @codeCoverageIgnoreEnd
2022-06-20 14:47:33 +02:00
2022-07-27 09:31:46 +02:00
/**
* @param SmsMessageInterface $message
* @param Client $client
*/
public function __construct(SmsMessageInterface $message, Client $client);
2022-07-27 09:31:46 +02:00
/**
* @param string $method
*
* @return Request
*/
public function setMethod(string $method): Request;
2022-06-20 14:47:33 +02:00
/**
* Must return the HTTP verb for this request, i.e. GET, POST, PUT
*
* @return string
*/
2022-07-13 10:41:23 +02:00
public function getMethod(): string;
2022-06-20 14:47:33 +02:00
2022-07-27 09:31:46 +02:00
/**
* @param bool $test
*
* @return Request
*/
public function setTestMode(bool $test): Request;
/**
* @return bool
*/
public function getTestMode(): bool;
2022-06-20 14:47:33 +02:00
/**
* Must return the URI for the request with a leading slash, i.e. /messages.json
*
* @return string
*/
2022-07-13 10:41:23 +02:00
public function getUri(): string;
2022-06-20 14:47:33 +02:00
/**
* Must return the body which is being sent as json
*
* @return array
*/
2022-07-13 10:41:23 +02:00
public function getBody(): array;
2022-06-20 14:47:33 +02:00
/**
* Must return the class to where the response is handed over. It must implement the ResponseInterface
*
* @return string
*/
2022-07-13 10:41:23 +02:00
public function getResponseClass(): string;
2022-06-20 14:47:33 +02:00
/**
2022-06-24 16:00:56 +02:00
* @param PsrResponseInterface $rawResponse
2022-06-20 14:47:33 +02:00
*
2022-06-24 16:00:56 +02:00
* @return LMResponseInterface
2022-06-20 14:47:33 +02:00
*/
2022-06-24 16:00:56 +02:00
public function getResponseInstance(PsrResponseInterface $rawResponse): LMResponseInterface;
2022-06-20 14:47:33 +02:00
2022-07-27 09:31:46 +02:00
/**
* @return RecipientsListInterface
*/
public function getRecipientsList(): RecipientsListInterface;
2022-06-20 14:47:33 +02:00
/**
* Must return the options for this request. If there are none, return [] (empty array)
*
* @return array
*/
2022-07-13 10:41:23 +02:00
public function getOptions(): array;
2022-06-20 14:47:33 +02:00
/**
* Must validate the input of the request
* This is called before sending the request
* Must throw an exception if the validation fails
*
* @throws InvalidArgumentException
2022-06-20 14:47:33 +02:00
*/
2022-06-24 16:00:56 +02:00
public function validate();
2022-07-13 10:41:23 +02:00
}