Compare commits

..

3 Commits

Author SHA1 Message Date
Alex 4516db5ffd Refactoring base url #38 2026-07-26 12:56:32 +03:00
Alex a35e1a22ad Merge pull request #40 from alexeipanov/fix/permissions
Add new chat admin permission constants
2026-07-25 22:46:21 +03:00
Alexei Panov caecb3f444 add new chat admin permission constants 2026-07-22 23:08:31 +04:00
8 changed files with 38 additions and 11 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ $client = new \BushlanovDev\MaxMessengerBot\Client(
httpClient: $guzzle, httpClient: $guzzle,
requestFactory: $httpFactory, requestFactory: $httpFactory,
streamFactory: $httpFactory, streamFactory: $httpFactory,
baseUrl: 'https://platform-api2.max.ru', baseUrl: BushlanovDev\MaxMessengerBot\Api::API_BASE_URL,
); );
$api = new BushlanovDev\MaxMessengerBot\Api( $api = new BushlanovDev\MaxMessengerBot\Api(
+1 -1
View File
@@ -99,7 +99,7 @@ $client = new \BushlanovDev\MaxMessengerBot\Client(
httpClient: $guzzle, httpClient: $guzzle,
requestFactory: $httpFactory, requestFactory: $httpFactory,
streamFactory: $httpFactory, streamFactory: $httpFactory,
baseUrl: 'https://platform-api2.max.ru', baseUrl: BushlanovDev\MaxMessengerBot\Api::API_BASE_URL,
); );
$api = new BushlanovDev\MaxMessengerBot\Api( $api = new BushlanovDev\MaxMessengerBot\Api(
+3 -3
View File
@@ -48,12 +48,12 @@ use RuntimeException;
*/ */
class Api 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'; 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_GET = 'GET';
private const string METHOD_POST = 'POST'; private const string METHOD_POST = 'POST';
private const string METHOD_DELETE = 'DELETE'; private const string METHOD_DELETE = 'DELETE';
+5 -2
View File
@@ -17,7 +17,10 @@ enum ChatAdminPermission: string
case Write = 'write'; case Write = 'write';
case CanCall = 'can_call'; case CanCall = 'can_call';
case EditLink = 'edit_link'; case EditLink = 'edit_link';
case PostEditDeleteMessage = 'post_edit_delete_message'; case PostEditDeleteMessage = 'post_edit_delete_message'; // @deprecated use write
case EditMessage = 'edit_message'; case EditMessage = 'edit_message'; // @deprecated use edit
case DeleteMessage = 'delete_message'; case DeleteMessage = 'delete_message';
case Delete = 'delete';
case Edit = 'edit';
case ViewStats = 'view_stats';
} }
+1 -1
View File
@@ -76,7 +76,7 @@ class MaxBotServiceProvider extends ServiceProvider
$guzzle, $guzzle,
$httpFactory, $httpFactory,
$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'), $config->get('maxbot.api_version'),
$logger, $logger,
); );
+1 -1
View File
@@ -36,7 +36,7 @@ return [
| Configuration for the Max Bot API connection. | 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'), 'api_version' => env('MAXBOT_API_VERSION'),
/* /*
+2 -2
View File
@@ -37,8 +37,8 @@ use Psr\Log\LoggerInterface;
final class ClientTest extends TestCase final class ClientTest extends TestCase
{ {
private const string FAKE_TOKEN = '12345:abcdef'; private const string FAKE_TOKEN = '12345:abcdef';
private const string API_VERSION = '0.0.6'; private const string API_VERSION = '1.2.5';
private const string API_BASE_URL = 'https://platform-api.max.ru'; private const string API_BASE_URL = 'https://platform-api2.max.ru';
private MockObject&ClientInterface $httpClientMock; private MockObject&ClientInterface $httpClientMock;
private MockObject&RequestFactoryInterface $requestFactoryMock; private MockObject&RequestFactoryInterface $requestFactoryMock;
@@ -182,6 +182,30 @@ final class MaxBotServiceProviderTest extends TestCase
$this->assertSame('test-version', $apiVersionProp->getValue($client)); $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] #[Test]
public function clientIsConfiguredWithApplicationLoggerWhenLoggingIsEnabled(): void public function clientIsConfiguredWithApplicationLoggerWhenLoggingIsEnabled(): void
{ {