Repository: defstudio/telegraph (php)

Issue:
Implement `contact` method
implement https://core.telegram.org/bots/api#sendcontact

to allow:

```php
Telegraph::contact($phoneNumber, $firstName, $lastName, $vcard)
```

Pull request description:
[feat] SendContact Method
close #187 implemented sendContact method with relative test, doc and snapshot

Patch:
diff --git a/docs/content/en/features/attachments.md b/docs/content/en/features/attachments.md
index 72143f03..b6e8688a 100644
--- a/docs/content/en/features/attachments.md
+++ b/docs/content/en/features/attachments.md
@@ -82,6 +82,14 @@ A location attachment can be sent through Telegraph `->location()` method:
 Telegraph::location(12.345, -54.321)->send();
 ```
 
+### Contact
+
+A contact attachment can be sent through Telegraph `->contact()` method:
+
+```php
+Telegraph::contact('3331122111', 'firstName')->send();
+```
+
 ### Dice
 
 An animated emoji attachment that will display a random value can be sent through Telegraph `->dice()` method:
diff --git a/docs/content/en/features/telegram-api-calls.md b/docs/content/en/features/telegram-api-calls.md
index d27d276b..afea082e 100644
--- a/docs/content/en/features/telegram-api-calls.md
+++ b/docs/content/en/features/telegram-api-calls.md
@@ -165,6 +165,14 @@ sends a location attachment
 Telegraph::location(12.345, -54.321)->send();
 ```
 
+### Contact
+
+sens a contact attachment
+
+```php
+Telegraph::contact('3331122111', 'firstName')->send();
+```
+
 ## markdown
 
 compose a new telegram message (parsed as markdown)
diff --git a/src/Concerns/SendsAttachments.php b/src/Concerns/SendsAttachments.php
index af67f03b..47a3a1c2 100644
--- a/src/Concerns/SendsAttachments.php
+++ b/src/Concerns/SendsAttachments.php
@@ -77,6 +77,18 @@ trait SendsAttachments
         return $telegraph;
     }
 
+    public function contact(string $phoneNumber, string $firstName): self
+    {
+        $telegraph = clone $this;
+
+        $telegraph->endpoint = self::ENDPOINT_SEND_CONTACT  ;
+        $telegraph->data['chat_id'] = $telegraph->getChatId();
+        $telegraph->data['phone_number'] = $phoneNumber;
+        $telegraph->data['first_name'] = $firstName;
+
+        return $telegraph;
+    }
+
     public function voice(string $path, string $filename = null): self
     {
         $telegraph = clone $this;
diff --git a/src/Facades/Telegraph.php b/src/Facades/Telegraph.php
index dd896f2d..00ebc225 100644
--- a/src/Facades/Telegraph.php
+++ b/src/Facades/Telegraph.php
@@ -42,6 +42,7 @@ use Illuminate\Support\Facades\Facade;
  * @method static \DefStudio\Telegraph\Telegraph  animation(string $path, string $filename = null)
  * @method static \DefStudio\Telegraph\Telegraph  voice(string $path, string $filename = null)
  * @method static \DefStudio\Telegraph\Telegraph  location(float $latitude, float $longitude)
+ * @method static \DefStudio\Telegraph\Telegraph  contact(string $phoneNumber, string $firstName)
  * @method static \DefStudio\Telegraph\Telegraph  video(string $path, string $filename = null)
  * @method static \DefStudio\Telegraph\Telegraph  dice()
  * @method static \DefStudio\Telegraph\Telegraph  botUpdates()
diff --git a/src/Models/TelegraphChat.php b/src/Models/TelegraphChat.php
index 227e81f7..9749d81d 100644
--- a/src/Models/TelegraphChat.php
+++ b/src/Models/TelegraphChat.php
@@ -206,6 +206,11 @@ class TelegraphChat extends Model implements Storable
         return TelegraphFacade::chat($this)->voice($path, $filename);
     }
 
+    public function contact(string $phoneNumber, string $firstName): Telegraph
+    {
+        return TelegraphFacade::chat($this)->contact($phoneNumber, $firstName);
+    }
+
     public function setBaseUrl(string|null $url): Telegraph
     {
         return TelegraphFacade::chat($this)->setBaseUrl($url);
diff --git a/src/Telegraph.php b/src/Telegraph.php
index de9d39cf..42a12443 100755
--- a/src/Telegraph.php
+++ b/src/Telegraph.php
@@ -80,6 +80,7 @@ class Telegraph
     public const ENDPOINT_SEND_DOCUMENT = 'sendDocument';
     public const ENDPOINT_SEND_PHOTO = 'sendPhoto';
     public const ENDPOINT_SEND_VIDEO = 'sendVideo';
+    public const ENDPOINT_SEND_CONTACT = 'sendContact';
     public const ENDPOINT_GET_FILE = 'getFile';
     public const ENDPOINT_ANSWER_INLINE_QUERY = 'answerInlineQuery';
     public const ENDPOINT_SET_CHAT_TITLE = 'setChatTitle';


Test patch:
diff --git a/tests/Unit/Concerns/SendsAttachmentsTest.php b/tests/Unit/Concerns/SendsAttachmentsTest.php
index 5d294e48..04605fa7 100644
--- a/tests/Unit/Concerns/SendsAttachmentsTest.php
+++ b/tests/Unit/Concerns/SendsAttachmentsTest.php
@@ -156,6 +156,11 @@ it('can send a location message', function () {
         ->toMatchTelegramSnapshot();
 });
 
+it('can send a contact', function () {
+    expect(fn (Telegraph $telegraph) => $telegraph->contact('3331122333', 'testFirstName'))
+        ->toMatchTelegramSnapshot();
+});
+
 it('can send a photo', function () {
     expect(fn (Telegraph $telegraph) => $telegraph->photo(Storage::path('photo.jpg')))
         ->toMatchTelegramSnapshot();
diff --git a/tests/Unit/Models/TelegraphChatTest.php b/tests/Unit/Models/TelegraphChatTest.php
index ab914047..a0aa8833 100644
--- a/tests/Unit/Models/TelegraphChatTest.php
+++ b/tests/Unit/Models/TelegraphChatTest.php
@@ -185,6 +185,18 @@ it('can send an animation', function () {
     ]);
 });
 
+it('can send a contact', function () {
+    Telegraph::fake();
+    $chat = make_chat();
+
+    $chat->contact('3331122333', 'testFirstName')->send();
+
+    Telegraph::assertSentData(\DefStudio\Telegraph\Telegraph::ENDPOINT_SEND_CONTACT, [
+        'phone_number' => '3331122333',
+        'first_name' => 'testFirstName',
+    ], false);
+});
+
 it('can send a animation from remote url', function () {
     Telegraph::fake();
     $chat = make_chat();
diff --git a/tests/__snapshots__/SendsAttachmentsTest__it_can_send_a_contact__1.yml b/tests/__snapshots__/SendsAttachmentsTest__it_can_send_a_contact__1.yml
new file mode 100644
index 00000000..1b016841
--- /dev/null
+++ b/tests/__snapshots__/SendsAttachmentsTest__it_can_send_a_contact__1.yml
@@ -0,0 +1,6 @@
+url: 'https://api.telegram.org/bot3f3814e1-5836-3d77-904e-60f64b15df36/sendContact'
+payload:
+    chat_id: '-123456789'
+    phone_number: '3331122333'
+    first_name: testFirstName
+files: {  }