2023-02-12 17:56:31 -05:00
|
|
|
<?php
|
|
|
|
|
2024-10-02 00:18:12 -04:00
|
|
|
namespace TgBotLib\Objects;
|
2023-02-12 17:56:31 -05:00
|
|
|
|
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
|
|
|
|
|
|
|
class Venue implements ObjectTypeInterface
|
|
|
|
{
|
2024-10-06 15:58:00 -04:00
|
|
|
private Location $location;
|
|
|
|
private string $title;
|
|
|
|
private string $address;
|
|
|
|
private ?string $foursquare_id;
|
|
|
|
private ?string $foursquare_type;
|
|
|
|
private ?string $google_place_id;
|
|
|
|
private ?string $google_place_type;
|
2023-02-12 17:56:31 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Venue location. Can't be a live location
|
|
|
|
*
|
|
|
|
* @return Location
|
|
|
|
*/
|
|
|
|
public function getLocation(): Location
|
|
|
|
{
|
|
|
|
return $this->location;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Name of the venue
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTitle(): string
|
|
|
|
{
|
|
|
|
return $this->title;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Address of the venue
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getAddress(): string
|
|
|
|
{
|
|
|
|
return $this->address;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional. Foursquare identifier of the venue
|
|
|
|
*
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getFoursquareId(): ?string
|
|
|
|
{
|
|
|
|
return $this->foursquare_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional. Foursquare type of the venue.
|
|
|
|
* (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
|
|
|
|
*
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getFoursquareType(): ?string
|
|
|
|
{
|
|
|
|
return $this->foursquare_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional. Google Places identifier of the venue
|
|
|
|
*
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getGooglePlaceId(): ?string
|
|
|
|
{
|
|
|
|
return $this->google_place_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional. Google Places type of the venue. (See supported types.)
|
|
|
|
*
|
|
|
|
* @see https://developers.google.com/places/web-service/supported_types
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getGooglePlaceType(): ?string
|
|
|
|
{
|
|
|
|
return $this->google_place_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-06 15:58:00 -04:00
|
|
|
* @inheritDoc
|
2023-02-12 17:56:31 -05:00
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
2024-11-03 18:07:06 -05:00
|
|
|
'location' => $this->location->toArray(),
|
2023-02-12 17:56:31 -05:00
|
|
|
'title' => $this->title,
|
|
|
|
'address' => $this->address,
|
|
|
|
'foursquare_id' => $this->foursquare_id,
|
|
|
|
'foursquare_type' => $this->foursquare_type,
|
|
|
|
'google_place_id' => $this->google_place_id,
|
|
|
|
'google_place_type' => $this->google_place_type,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-06 15:58:00 -04:00
|
|
|
* @inheritDoc
|
2023-02-12 17:56:31 -05:00
|
|
|
*/
|
2024-10-06 15:58:00 -04:00
|
|
|
public static function fromArray(?array $data): ?Venue
|
2023-02-12 17:56:31 -05:00
|
|
|
{
|
2024-10-06 15:58:00 -04:00
|
|
|
if($data === null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2023-02-12 17:56:31 -05:00
|
|
|
|
2024-10-06 15:58:00 -04:00
|
|
|
$object = new self();
|
2023-02-12 17:56:31 -05:00
|
|
|
$object->location = isset($data['location']) ? Location::fromArray($data['location']) : null;
|
2023-02-14 17:35:16 -05:00
|
|
|
$object->title = $data['title'];
|
|
|
|
$object->address = $data['address'];
|
|
|
|
$object->foursquare_id = $data['foursquare_id'] ?? null;
|
|
|
|
$object->foursquare_type = $data['foursquare_type'] ?? null;
|
|
|
|
$object->google_place_id = $data['google_place_id'] ?? null;
|
|
|
|
$object->google_place_type = $data['google_place_type'] ?? null;
|
2023-02-12 17:56:31 -05:00
|
|
|
|
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|