mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-28 19:18:02 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4516db5ffd | |||
| a35e1a22ad | |||
| caecb3f444 |
@@ -85,7 +85,7 @@ $client = new \BushlanovDev\MaxMessengerBot\Client(
|
||||
httpClient: $guzzle,
|
||||
requestFactory: $httpFactory,
|
||||
streamFactory: $httpFactory,
|
||||
baseUrl: 'https://platform-api2.max.ru',
|
||||
baseUrl: BushlanovDev\MaxMessengerBot\Api::API_BASE_URL,
|
||||
);
|
||||
|
||||
$api = new BushlanovDev\MaxMessengerBot\Api(
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ $client = new \BushlanovDev\MaxMessengerBot\Client(
|
||||
httpClient: $guzzle,
|
||||
requestFactory: $httpFactory,
|
||||
streamFactory: $httpFactory,
|
||||
baseUrl: 'https://platform-api2.max.ru',
|
||||
baseUrl: BushlanovDev\MaxMessengerBot\Api::API_BASE_URL,
|
||||
);
|
||||
|
||||
$api = new BushlanovDev\MaxMessengerBot\Api(
|
||||
|
||||
+3
-3
@@ -48,12 +48,12 @@ use RuntimeException;
|
||||
*/
|
||||
class Api
|
||||
{
|
||||
public const string LIBRARY_VERSION = '1.6.5';
|
||||
public const string API_BASE_URL = 'https://platform-api2.max.ru';
|
||||
|
||||
public const string LIBRARY_VERSION = '1.6.6';
|
||||
|
||||
public const string API_VERSION = '1.2.5';
|
||||
|
||||
private const string API_BASE_URL = 'https://platform-api2.max.ru';
|
||||
|
||||
private const string METHOD_GET = 'GET';
|
||||
private const string METHOD_POST = 'POST';
|
||||
private const string METHOD_DELETE = 'DELETE';
|
||||
|
||||
@@ -17,7 +17,10 @@ enum ChatAdminPermission: string
|
||||
case Write = 'write';
|
||||
case CanCall = 'can_call';
|
||||
case EditLink = 'edit_link';
|
||||
case PostEditDeleteMessage = 'post_edit_delete_message';
|
||||
case EditMessage = 'edit_message';
|
||||
case PostEditDeleteMessage = 'post_edit_delete_message'; // @deprecated use write
|
||||
case EditMessage = 'edit_message'; // @deprecated use edit
|
||||
case DeleteMessage = 'delete_message';
|
||||
case Delete = 'delete';
|
||||
case Edit = 'edit';
|
||||
case ViewStats = 'view_stats';
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class MaxBotServiceProvider extends ServiceProvider
|
||||
$guzzle,
|
||||
$httpFactory,
|
||||
$httpFactory,
|
||||
$config->get('maxbot.base_url', 'https://platform-api2.max.ru'),
|
||||
empty($config->get('maxbot.base_url')) ? Api::API_BASE_URL : $config->get('maxbot.base_url'),
|
||||
$config->get('maxbot.api_version'),
|
||||
$logger,
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ return [
|
||||
| Configuration for the Max Bot API connection.
|
||||
|
|
||||
*/
|
||||
'base_url' => env('MAXBOT_BASE_URL', 'https://botapi.max.ru'),
|
||||
'base_url' => env('MAXBOT_BASE_URL', \BushlanovDev\MaxMessengerBot\Api::API_BASE_URL),
|
||||
'api_version' => env('MAXBOT_API_VERSION'),
|
||||
|
||||
/*
|
||||
|
||||
@@ -37,8 +37,8 @@ use Psr\Log\LoggerInterface;
|
||||
final class ClientTest extends TestCase
|
||||
{
|
||||
private const string FAKE_TOKEN = '12345:abcdef';
|
||||
private const string API_VERSION = '0.0.6';
|
||||
private const string API_BASE_URL = 'https://platform-api.max.ru';
|
||||
private const string API_VERSION = '1.2.5';
|
||||
private const string API_BASE_URL = 'https://platform-api2.max.ru';
|
||||
|
||||
private MockObject&ClientInterface $httpClientMock;
|
||||
private MockObject&RequestFactoryInterface $requestFactoryMock;
|
||||
|
||||
@@ -182,6 +182,30 @@ final class MaxBotServiceProviderTest extends TestCase
|
||||
$this->assertSame('test-version', $apiVersionProp->getValue($client));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{0: mixed}>
|
||||
*/
|
||||
public static function falsyBaseUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'null (MAXBOT_BASE_URL unset)' => [null],
|
||||
'empty string' => [''],
|
||||
];
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[DataProvider('falsyBaseUrlProvider')]
|
||||
public function clientFallsBackToApiBaseUrlConstantWhenBaseUrlIsFalsy(mixed $falsyBaseUrl): void
|
||||
{
|
||||
$this->app['config']->set('maxbot.base_url', $falsyBaseUrl);
|
||||
|
||||
/** @var Client $client */
|
||||
$client = $this->app->make(ClientApiInterface::class);
|
||||
|
||||
$baseUrlProp = (new ReflectionClass($client))->getProperty('baseUrl');
|
||||
$this->assertSame(Api::API_BASE_URL, $baseUrlProp->getValue($client));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function clientIsConfiguredWithApplicationLoggerWhenLoggingIsEnabled(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user