generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from defstudio/fix_issue_#202
added InlineQueryResultLocation + test + snapshots + fix other inline…
- Loading branch information
Showing
18 changed files
with
197 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
/** @noinspection PhpUnused */ | ||
|
||
namespace DefStudio\Telegraph\DTO; | ||
|
||
class InlineQueryResultLocation extends InlineQueryResult | ||
{ | ||
protected string $type = 'location'; | ||
protected string $id; | ||
protected string $title; | ||
protected float $latitude; | ||
protected float $longitude; | ||
protected string|null $thumbUrl = null; | ||
protected int|null $livePeriod = null; | ||
protected int|null $heading = null; | ||
protected int|null $proximityAlertRadius = null; | ||
protected int|null $thumbWidth = null; | ||
protected int|null $thumbHeight = null; | ||
protected float|null $horizontalAccuracy = null; | ||
|
||
public static function make(string $id, string $title, float $latitude, float $longitude): InlineQueryResultLocation | ||
{ | ||
$result = new InlineQueryResultLocation(); | ||
$result->id = $id; | ||
$result->title = $title; | ||
$result->latitude = $latitude; | ||
$result->longitude = $longitude; | ||
|
||
return $result; | ||
} | ||
|
||
public function thumbUrl(string|null $thumbUrl): InlineQueryResultLocation | ||
{ | ||
$this->thumbUrl = $thumbUrl; | ||
|
||
return $this; | ||
} | ||
|
||
public function livePeriod(int|null $livePeriod): InlineQueryResultLocation | ||
{ | ||
$this->livePeriod = $livePeriod; | ||
|
||
return $this; | ||
} | ||
|
||
public function heading(int|null $heading): InlineQueryResultLocation | ||
{ | ||
$this->heading = $heading; | ||
|
||
return $this; | ||
} | ||
|
||
public function proximityAlertRadius(int|null $proximityAlertRadius): InlineQueryResultLocation | ||
{ | ||
$this->proximityAlertRadius = $proximityAlertRadius; | ||
|
||
return $this; | ||
} | ||
|
||
public function thumbWidth(int|null $thumbWidth): InlineQueryResultLocation | ||
{ | ||
$this->thumbWidth = $thumbWidth; | ||
|
||
return $this; | ||
} | ||
|
||
public function thumbHeight(int|null $thumbHeight): InlineQueryResultLocation | ||
{ | ||
$this->thumbHeight = $thumbHeight; | ||
|
||
return $this; | ||
} | ||
|
||
public function horizontalAccuracy(float|null $horizontalAccuracy): InlineQueryResultLocation | ||
{ | ||
$this->horizontalAccuracy = $horizontalAccuracy; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function data(): array | ||
{ | ||
return [ | ||
'title' => $this->title, | ||
'latitude' => $this->latitude, | ||
'longitude' => $this->longitude, | ||
'thumb_url' => $this->thumbUrl, | ||
'live_period' => $this->livePeriod, | ||
'heading' => $this->heading, | ||
'proximity_alert_radius' => $this->proximityAlertRadius, | ||
'thumb_width' => $this->thumbWidth, | ||
'thumb_height' => $this->thumbHeight, | ||
'horizontal_accuracy' => $this->horizontalAccuracy, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use DefStudio\Telegraph\DTO\InlineQueryResultLocation; | ||
|
||
it('can export to array', function () { | ||
expect( | ||
InlineQueryResultLocation::make('a45', 'testTitle', 10.5, 10.5) | ||
->thumbUrl('testThumbUrl') | ||
->livePeriod(10) | ||
->heading(10) | ||
->proximityAlertRadius(5) | ||
->thumbWidth(200) | ||
->thumbHeight(100) | ||
->horizontalAccuracy(10.5) | ||
->toArray() | ||
)-> | ||
toBe([ | ||
'title' => 'testTitle', | ||
'latitude' => 10.5, | ||
'longitude' => 10.5, | ||
'thumb_url' => 'testThumbUrl', | ||
'live_period' => 10, | ||
'heading' => 10, | ||
'proximity_alert_radius' => 5, | ||
'thumb_width' => 200, | ||
'thumb_height' => 100, | ||
'horizontal_accuracy' => 10.5, | ||
'id' => "a45", | ||
'type' => "location", | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/__snapshots__/AnswersInlineQueriesTest__it_can_answer_an_inline_query__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
url: 'https://api.telegram.org/bot3f3814e1-5836-3d77-904e-60f64b15df36/answerInlineQuery' | ||
payload: | ||
inline_query_id: '99' | ||
results: [{ gif_url: 'https://gif.dev', thumb_url: 'https://gif-thumb.dev', id: '42', type: gif }, { photo_url: 'https://photo.dev', thumb_url: 'https://photo-thumb.dev', id: '42', type: photo }, { phone_number: '399999999', first_name: testFirstName, id: '42', type: contact }, { title: testTitle, input_message_content: { message: testMessage, parse_mode: html }, id: '42', type: article }, { mpeg4_url: testMpeg4Url, thumb_url: testThumbUrl, id: '42', type: mpeg4_gif }, { title: testTitle, $video_url: testVideoUrl, $mime_type: testMimeType, $thumb_url: testThumbUrl, $title: testTitle, id: '42', type: video }, { $audio_url: testAudioUrl, $title: testTitle, id: '42', type: audio }, { $voice_url: testVoiceUrl, $title: testTitle, id: '42', type: voice }, { $title: testDocumentTitle, $document_url: testDocumentUrl, $mime_type: testDocumentMimeType, id: '42', type: document }] | ||
results: [{ gif_url: 'https://gif.dev', thumb_url: 'https://gif-thumb.dev', id: '42', type: gif }, { photo_url: 'https://photo.dev', thumb_url: 'https://photo-thumb.dev', id: '42', type: photo }, { phone_number: '399999999', first_name: testFirstName, id: '42', type: contact }, { title: testTitle, input_message_content: { message: testMessage, parse_mode: html }, id: '42', type: article }, { mpeg4_url: testMpeg4Url, thumb_url: testThumbUrl, id: '42', type: mpeg4_gif }, { video_url: testVideoUrl, mime_type: testMimeType, thumb_url: testThumbUrl, title: testTitle, id: '42', type: video }, { audio_url: testAudioUrl, title: testTitle, id: '42', type: audio }, { voice_url: testVoiceUrl, title: testTitle, id: '42', type: voice }, { title: testDocumentTitle, document_url: testDocumentUrl, mime_type: testDocumentMimeType, id: '42', type: document }, { title: testLocationTitle, latitude: 10.5, longitude: 10.5, id: '42', type: location }] | ||
files: { } |
2 changes: 1 addition & 1 deletion
2
.../__snapshots__/AnswersInlineQueriesTest__it_can_offer_to_switch_to_private_message__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
url: 'https://api.telegram.org/bot3f3814e1-5836-3d77-904e-60f64b15df36/answerInlineQuery' | ||
payload: | ||
inline_query_id: '99' | ||
results: [{ gif_url: 'https://gif.dev', thumb_url: 'https://gif-thumb.dev', id: '42', type: gif }, { photo_url: 'https://photo.dev', thumb_url: 'https://photo-thumb.dev', id: '42', type: photo }, { phone_number: '399999999', first_name: testFirstName, id: '42', type: contact }, { title: testTitle, input_message_content: { message: testMessage, parse_mode: html }, id: '42', type: article }, { mpeg4_url: testMpeg4Url, thumb_url: testThumbUrl, id: '42', type: mpeg4_gif }, { title: testTitle, $video_url: testVideoUrl, $mime_type: testMimeType, $thumb_url: testThumbUrl, $title: testTitle, id: '42', type: video }, { $audio_url: testAudioUrl, $title: testTitle, id: '42', type: audio }, { $voice_url: testVoiceUrl, $title: testTitle, id: '42', type: voice }, { $title: testDocumentTitle, $document_url: testDocumentUrl, $mime_type: testDocumentMimeType, id: '42', type: document }] | ||
results: [{ gif_url: 'https://gif.dev', thumb_url: 'https://gif-thumb.dev', id: '42', type: gif }, { photo_url: 'https://photo.dev', thumb_url: 'https://photo-thumb.dev', id: '42', type: photo }, { phone_number: '399999999', first_name: testFirstName, id: '42', type: contact }, { title: testTitle, input_message_content: { message: testMessage, parse_mode: html }, id: '42', type: article }, { mpeg4_url: testMpeg4Url, thumb_url: testThumbUrl, id: '42', type: mpeg4_gif }, { video_url: testVideoUrl, mime_type: testMimeType, thumb_url: testThumbUrl, title: testTitle, id: '42', type: video }, { audio_url: testAudioUrl, title: testTitle, id: '42', type: audio }, { voice_url: testVoiceUrl, title: testTitle, id: '42', type: voice }, { title: testDocumentTitle, document_url: testDocumentUrl, mime_type: testDocumentMimeType, id: '42', type: document }, { title: testLocationTitle, latitude: 10.5, longitude: 10.5, id: '42', type: location }] | ||
switch_pm_text: configure | ||
switch_pm_parameter: '123456' | ||
files: { } |
2 changes: 1 addition & 1 deletion
2
tests/__snapshots__/AnswersInlineQueriesTest__it_can_set_cache_duration__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
url: 'https://api.telegram.org/bot3f3814e1-5836-3d77-904e-60f64b15df36/answerInlineQuery' | ||
payload: | ||
inline_query_id: '99' | ||
results: [{ gif_url: 'https://gif.dev', thumb_url: 'https://gif-thumb.dev', id: '42', type: gif }, { photo_url: 'https://photo.dev', thumb_url: 'https://photo-thumb.dev', id: '42', type: photo }, { phone_number: '399999999', first_name: testFirstName, id: '42', type: contact }, { title: testTitle, input_message_content: { message: testMessage, parse_mode: html }, id: '42', type: article }, { mpeg4_url: testMpeg4Url, thumb_url: testThumbUrl, id: '42', type: mpeg4_gif }, { title: testTitle, $video_url: testVideoUrl, $mime_type: testMimeType, $thumb_url: testThumbUrl, $title: testTitle, id: '42', type: video }, { $audio_url: testAudioUrl, $title: testTitle, id: '42', type: audio }, { $voice_url: testVoiceUrl, $title: testTitle, id: '42', type: voice }, { $title: testDocumentTitle, $document_url: testDocumentUrl, $mime_type: testDocumentMimeType, id: '42', type: document }] | ||
results: [{ gif_url: 'https://gif.dev', thumb_url: 'https://gif-thumb.dev', id: '42', type: gif }, { photo_url: 'https://photo.dev', thumb_url: 'https://photo-thumb.dev', id: '42', type: photo }, { phone_number: '399999999', first_name: testFirstName, id: '42', type: contact }, { title: testTitle, input_message_content: { message: testMessage, parse_mode: html }, id: '42', type: article }, { mpeg4_url: testMpeg4Url, thumb_url: testThumbUrl, id: '42', type: mpeg4_gif }, { video_url: testVideoUrl, mime_type: testMimeType, thumb_url: testThumbUrl, title: testTitle, id: '42', type: video }, { audio_url: testAudioUrl, title: testTitle, id: '42', type: audio }, { voice_url: testVoiceUrl, title: testTitle, id: '42', type: voice }, { title: testDocumentTitle, document_url: testDocumentUrl, mime_type: testDocumentMimeType, id: '42', type: document }, { title: testLocationTitle, latitude: 10.5, longitude: 10.5, id: '42', type: location }] | ||
cache_time: 600 | ||
files: { } |
Oops, something went wrong.