Skip to content

Commit

Permalink
Merge pull request #251 from defstudio/implement_getUserProfilePhotos
Browse files Browse the repository at this point in the history
Implement get user profile photos
  • Loading branch information
fabio-ivona authored Nov 10, 2022
2 parents ccd5f86 + a543697 commit 1438b69
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/content/en/features/telegram-api-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ retrieves Chat member count
Telegraph::chatMemberCount()->send();
```

## userProfilePhotos

retrieves the User's profile photos

```php
Telegraph::userProfilePhotos($userId)->send();
```

## generateChatPrimaryInviteLink

generates a new primary invite link for a chat. Any previously generated primary link is revoked. For more info, see telegram [bot documentation](https://core.telegram.org/bots/api#exportchatinvitelink)
Expand Down
25 changes: 25 additions & 0 deletions src/Concerns/InteractWithUsers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php


/** @noinspection PhpUnhandledExceptionInspection */

namespace DefStudio\Telegraph\Concerns;

use DefStudio\Telegraph\Telegraph;

/**
* @mixin Telegraph
*/

trait InteractWithUsers
{
public function userProfilePhotos(string $userId): Telegraph
{
$telegraph = clone $this;

$telegraph->endpoint = self::ENDPOINT_GET_USER_PROFILE_PHOTOS;
$telegraph->data['user_id'] = $userId;

return $telegraph;
}
}
1 change: 1 addition & 0 deletions src/Facades/Telegraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
* @method static \DefStudio\Telegraph\Telegraph restrictChatMember(string $userId, array $permissions)
* @method static \DefStudio\Telegraph\Telegraph promoteChatMember(string $userId, array $permissions)
* @method static \DefStudio\Telegraph\Telegraph demoteChatMember(string $userId)
* @method static \DefStudio\Telegraph\Telegraph userProfilePhotos(string $userId)
* @method static TelegraphPollPayload poll(string $question)
* @method static TelegraphQuizPayload quiz(string $question)
* @method static string store(Downloadable $attachment, string $path, string $filename = null)
Expand Down
3 changes: 3 additions & 0 deletions src/Telegraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use DefStudio\Telegraph\Concerns\HasBotsAndChats;
use DefStudio\Telegraph\Concerns\InteractsWithTelegram;
use DefStudio\Telegraph\Concerns\InteractsWithWebhooks;
use DefStudio\Telegraph\Concerns\InteractWithUsers;
use DefStudio\Telegraph\Concerns\ManagesKeyboards;
use DefStudio\Telegraph\Concerns\SendsAttachments;
use DefStudio\Telegraph\Concerns\StoresFiles;
Expand All @@ -34,6 +35,7 @@ class Telegraph
use StoresFiles;
use AnswersInlineQueries;
use CreatesScopedPayloads;
use InteractWithUsers;

public const MAX_DOCUMENT_SIZE_IN_MB = 50;
public const MAX_PHOTO_SIZE_IN_MB = 10;
Expand Down Expand Up @@ -92,6 +94,7 @@ class Telegraph
public const ENDPOINT_PROMOTE_CHAT_MEMBER = 'promoteChatMember';
public const ENDPOINT_SEND_POLL = 'sendPoll';
public const ENDPOINT_FORWARD_MESSAGE = 'forwardMessage';
public const ENDPOINT_GET_USER_PROFILE_PHOTOS = 'getUserProfilePhotos';


/** @var array<string, mixed> */
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/Concerns/InteractsWithUsersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

/** @noinspection PhpUnhandledExceptionInspection */

/** @noinspection LaravelFunctionsInspection */

it('can retrieve user profile photos', function () {
expect(function (\DefStudio\Telegraph\Telegraph $telegraph) {
return $telegraph->chat(make_chat())->userProfilePhotos(123456);
})->toMatchTelegramSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: 'https://api.telegram.org/bot3f3814e1-5836-3d77-904e-60f64b15df36/getUserProfilePhotos'
payload:
user_id: '123456'
files: { }

0 comments on commit 1438b69

Please sign in to comment.