PreCheckoutQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 27
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A answer() 0 6 1
A subEntities() 0 5 1
1
<?php
2
3
namespace TelegramBot\Entities\Payments;
4
5
use TelegramBot\Entities\Response;
6
use TelegramBot\Entities\User;
7
use TelegramBot\Entity;
8
use TelegramBot\Request;
9
10
/**
11
 * Class PreCheckoutQuery
12
 *
13
 * This object contains information about an incoming pre-checkout query.
14
 *
15
 * @link https://core.telegram.org/bots/api#precheckoutquery
16
 *
17
 * @method string    getId()                Unique query identifier
18
 * @method User      getFrom()              User who sent the query
19
 * @method string    getCurrency()          Three-letter ISO 4217 currency code
20
 * @method int       getTotalAmount()       Total price in the smallest units of the currency (integer, not float/double).
21
 * @method string    getInvoicePayload()    Bot specified invoice payload
22
 * @method string    getShippingOptionId()  Optional. Identifier of the shipping option chosen by the user
23
 * @method OrderInfo getOrderInfo()         Optional. Order info provided by the user
24
 **/
25
class PreCheckoutQuery extends Entity
26
{
27
28
    /**
29
     * Answer this pre-checkout query.
30
     *
31
     * @param bool $ok
32
     * @param array $data
33
     *
34
     * @return Response
35
     */
36
    public function answer(bool $ok, array $data = []): Response
37
    {
38
        return Request::answerPreCheckoutQuery(array_merge([
39
            'pre_checkout_query_id' => $this->getId(),
40
            'ok' => $ok,
41
        ], $data));
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function subEntities(): array
48
    {
49
        return [
50
            'from' => User::class,
51
            'order_info' => OrderInfo::class,
52
        ];
53
    }
54
55
}
56