ShippingQuery::answer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the TelegramBot package.
5
 *
6
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Longman\TelegramBot\Entities\Payments;
13
14
use Longman\TelegramBot\Entities\Entity;
15
use Longman\TelegramBot\Entities\ServerResponse;
16
use Longman\TelegramBot\Entities\User;
17
use Longman\TelegramBot\Request;
18
19
/**
20
 * Class ShippingQuery
21
 *
22
 * This object contains information about an incoming shipping query.
23
 *
24
 * @link https://core.telegram.org/bots/api#shippingquery
25
 *
26
 * @method string          getId()              Unique query identifier
27
 * @method User            getFrom()            User who sent the query
28
 * @method string          getInvoicePayload()  Bot specified invoice payload
29
 * @method ShippingAddress getShippingAddress() User specified shipping address
30
 **/
31
class ShippingQuery extends Entity
32
{
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function subEntities(): array
37
    {
38
        return [
39
            'from'             => User::class,
40
            'shipping_address' => ShippingAddress::class,
41
        ];
42
    }
43
44
    /**
45
     * Answer this shipping query.
46
     *
47
     * @param bool  $ok
48
     * @param array $data
49
     *
50
     * @return ServerResponse
51
     */
52
    public function answer(bool $ok, array $data = []): ServerResponse
53
    {
54
        return Request::answerShippingQuery(array_merge([
55
            'shipping_query_id' => $this->getId(),
56
            'ok'                => $ok,
57
        ], $data));
58
    }
59
}
60