Passed
Pull Request — develop (#1077)
by Marco
02:09
created

PreCheckoutQuery   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

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