Passed
Push — master ( c05883...1d5c29 )
by Nikolay
02:30
created

SendInvoiceMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 198
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 37
dl 0
loc 198
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 25 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\ReplyMarkupVariableTrait;
10
use TgBotApi\BotApiBase\Type\LabeledPriceType;
11
12
/**
13
 * Class SendInvoiceMethod.
14
 *
15
 * @see https://core.telegram.org/bots/api#sendinvoice
16
 */
17
class SendInvoiceMethod
18
{
19
    use FillFromArrayTrait;
20
    use ChatIdVariableTrait;
21
    use ReplyMarkupVariableTrait;
22
23
    /**
24
     * Product name, 1-32 characters.
25
     *
26
     * @var string
27
     */
28
    public $title;
29
30
    /**
31
     * Product description, 1-255 characters.
32
     *
33
     * @var string
34
     */
35
    public $description;
36
37
    /**
38
     * Bot-defined invoice payload, 1-128 bytes.
39
     * This will not be displayed to the user, use for your internal processes.
40
     *
41
     * @var string
42
     */
43
    public $payload;
44
45
    /**
46
     * Payments provider token, obtained via Botfather.
47
     *
48
     * @var string
49
     */
50
    public $providerToken;
51
52
    /**
53
     * Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter.
54
     *
55
     * @var string
56
     */
57
    public $startParameter;
58
59
    /**
60
     * Three-letter ISO 4217 currency code, see more on currencies.
61
     *
62
     * @var string
63
     */
64
    public $currency;
65
66
    /**
67
     * Price breakdown, a list of components
68
     * (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.).
69
     *
70
     * @var LabeledPriceType[]
71
     */
72
    public $prices;
73
74
    /**
75
     * Optional. JSON-encoded data about the invoice, which will be shared with the payment provider.
76
     * A detailed description of required fields should be provided by the payment provider.
77
     *
78
     * @var string|null
79
     */
80
    public $providerData;
81
82
    /**
83
     * Optional. URL of the product photo for the invoice.
84
     * Can be a photo of the goods or a marketing image for a service.
85
     * People like it better when they see what they are paying for.
86
     *
87
     * @var string|null
88
     */
89
    public $photoUrl;
90
91
    /**
92
     * Optional. Photo size.
93
     *
94
     * @var int|null
95
     */
96
    public $photoSize;
97
98
    /**
99
     * Optional. Photo width.
100
     *
101
     * @var int|null
102
     */
103
    public $photoWidth;
104
105
    /**
106
     * Optional. Photo height.
107
     *
108
     * @var int|null
109
     */
110
    public $photoHeight;
111
112
    /**
113
     * Optional. Pass True, if you require the user's full name to complete the order.
114
     *
115
     * @var bool|null
116
     */
117
    public $needName;
118
119
    /**
120
     * Optional. Pass True, if you require the user's phone number to complete the order.
121
     *
122
     * @var bool|null
123
     */
124
    public $needPhoneNumber;
125
126
    /**
127
     * Optional. Pass True, if you require the user's email address to complete the order.
128
     *
129
     * @var bool|null
130
     */
131
    public $needEmail;
132
133
    /**
134
     * Optional. Pass True, if you require the user's shipping address to complete the order.
135
     *
136
     * @var bool|null
137
     */
138
    public $needShippingAddress;
139
140
    /**
141
     * Optional. Pass True, if user's phone number should be sent to provider.
142
     *
143
     * @var bool|null
144
     */
145
    public $sendPhoneNumberToProvider;
146
147
    /**
148
     * Optional. Pass True, if user's email address should be sent to provider.
149
     *
150
     * @var bool|null
151
     */
152
    public $sendEmailToProvider;
153
154
    /**
155
     * Optional. Pass True, if the final price depends on the shipping method.
156
     *
157
     * @var bool|null
158
     */
159
    public $isFlexible;
160
161
    /**
162
     * Optional. Sends the message silently. Users will receive a notification with no sound.
163
     *
164
     * @var bool|null
165
     */
166
    public $disableNotification;
167
168
    /**
169
     * Optional. If the message is a reply, ID of the original message.
170
     *
171
     * @var int|null
172
     */
173
    public $replyToMessageId;
174
175
    /**
176
     * @param int|string $chatId
177
     * @param string     $title
178
     * @param string     $description
179
     * @param string     $payload
180
     * @param string     $providerToken
181
     * @param string     $startParameter
182
     * @param string     $currency
183
     * @param array      $prices
184
     * @param array|null $data
185
     *
186
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
187
     *
188
     * @return SendInvoiceMethod
189
     */
190
    public static function create(
191
        $chatId,
192
        string $title,
193
        string $description,
194
        string $payload,
195
        string $providerToken,
196
        string $startParameter,
197
        string $currency,
198
        array $prices,
199
        array $data = null
200
    ): SendInvoiceMethod {
201
        $instance = new static();
202
        $instance->chatId = $chatId;
203
        $instance->title = $title;
204
        $instance->description = $description;
205
        $instance->payload = $payload;
206
        $instance->providerToken = $providerToken;
207
        $instance->startParameter = $startParameter;
208
        $instance->currency = $currency;
209
        $instance->prices = $prices;
210
        if ($data) {
211
            $instance->fill($data);
212
        }
213
214
        return $instance;
215
    }
216
}
217