Completed
Push — master ( 8fbc07...04de59 )
by Armando
03:05 queued 01:27
created

PreCheckoutQuery::answer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Entities\Payments;
12
13
use Longman\TelegramBot\Entities\Entity;
14
use Longman\TelegramBot\Entities\User;
15
use Longman\TelegramBot\Request;
16
17
/**
18
 * Class PreCheckoutQuery
19
 *
20
 * This object contains information about an incoming pre-checkout query.
21
 *
22
 * @link https://core.telegram.org/bots/api#precheckoutquery
23
 *
24
 * @method string    getId()               Unique query identifier
25
 * @method User      getFrom()             User who sent the query
26
 * @method string    getCurrency()         Three-letter ISO 4217 currency code
27
 * @method int       getTotalAmount()      Total price in the smallest units of the currency (integer, not float/double).
28
 * @method string    getInvoicePayload()   Bot specified invoice payload
29
 * @method string    getShippingOptionId() Optional. Identifier of the shipping option chosen by the user
30
 * @method OrderInfo getOrderInfo()        Optional. Order info provided by the user
31
 **/
32
class PreCheckoutQuery extends Entity
33
{
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function subEntities()
38
    {
39
        return [
40
            'user'       => User::class,
41
            'order_info' => OrderInfo::class,
42
        ];
43
    }
44
45
    /**
46
     * Answer this pre-checkout query.
47
     *
48
     * @param bool  $ok
49
     * @param array $data
50
     *
51
     * @return \Longman\TelegramBot\Entities\ServerResponse
52
     */
53
    public function answer($ok, array $data = [])
54
    {
55
        return Request::answerPreCheckoutQuery(array_merge([
56
            'pre_checkout_query_id' => $this->getId(),
57
            'ok'                    => $ok,
58
        ], $data));
59
    }
60
}
61