1
+ package com.pengrad.telegrambot.request
2
+
3
+ import com.pengrad.telegrambot.model.request.LabeledPrice
4
+ import com.pengrad.telegrambot.utility.kotlin.checkDeprecatedConstructorParameters
5
+ import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
6
+ import com.pengrad.telegrambot.utility.kotlin.requestParameter
7
+
8
+ class SendInvoice private constructor(
9
+ chatId : Long? = null ,
10
+ channelUsername : String? = null ,
11
+
12
+ title : String ,
13
+ description : String ,
14
+ payload : String ,
15
+ currency : String ,
16
+ prices : List <LabeledPrice >
17
+ ) : KAbstractSendRequest<SendInvoice>(
18
+ chatId = chatId,
19
+ channelUsername = channelUsername,
20
+ ) {
21
+
22
+ constructor (
23
+ chatId: Long ,
24
+ title: String ,
25
+ description: String ,
26
+ payload: String ,
27
+ currency: String ,
28
+ prices: List <LabeledPrice >
29
+ ) : this (
30
+ chatId = chatId,
31
+ channelUsername = null ,
32
+ title = title,
33
+ description = description,
34
+ payload = payload,
35
+ currency = currency,
36
+ prices = prices
37
+ )
38
+
39
+ constructor (
40
+ channelUsername: String ,
41
+ title: String ,
42
+ description: String ,
43
+ payload: String ,
44
+ currency: String ,
45
+ prices: List <LabeledPrice >
46
+ ) : this (
47
+ chatId = null ,
48
+ channelUsername = channelUsername,
49
+ title = title,
50
+ description = description,
51
+ payload = payload,
52
+ currency = currency,
53
+ prices = prices
54
+ )
55
+
56
+ @Deprecated(" Use constructor with chatId or channelUsername instead" , ReplaceWith (" SendInvoice(chatId, title, description, payload, currency, prices.toList())" ))
57
+ constructor (
58
+ chatId: Any ,
59
+ title: String ,
60
+ description: String ,
61
+ payload: String ,
62
+ currency: String ,
63
+ vararg prices: LabeledPrice
64
+ ) : this (
65
+ chatId = (chatId as ? Number )?.toLong(),
66
+ channelUsername = chatId as ? String ,
67
+ title = title,
68
+ description = description,
69
+ payload = payload,
70
+ currency = currency,
71
+ prices = prices.toList()
72
+ ) {
73
+ checkDeprecatedConstructorParameters()
74
+ }
75
+
76
+ val title: String by requestParameter(title)
77
+ val description: String by requestParameter(description)
78
+ val payload: String by requestParameter(payload)
79
+ val currency: String by requestParameter(currency)
80
+ val prices: List <LabeledPrice > by requestParameter(prices)
81
+
82
+ var providerToken: String? by optionalRequestParameter()
83
+ var providerData: String? by optionalRequestParameter()
84
+
85
+ var maxTipAmount: Int? by optionalRequestParameter()
86
+ var suggestedTipAmounts: List <Int >? by optionalRequestParameter()
87
+
88
+ var photoUrl: String? by optionalRequestParameter()
89
+ var photoSize: Int? by optionalRequestParameter()
90
+ var photoWidth: Int? by optionalRequestParameter()
91
+ var photoHeight: Int? by optionalRequestParameter()
92
+
93
+ var needName: Boolean? by optionalRequestParameter()
94
+ var needPhoneNumber: Boolean? by optionalRequestParameter()
95
+ var needEmail: Boolean? by optionalRequestParameter()
96
+ var needShippingAddress: Boolean? by optionalRequestParameter()
97
+
98
+ var sendEmailToProvider: Boolean? by optionalRequestParameter()
99
+ var sendPhoneNumberToProvider: Boolean? by optionalRequestParameter()
100
+
101
+ var isFlexible: Boolean? by optionalRequestParameter()
102
+ var subscriptionPeriod: Int? by optionalRequestParameter()
103
+ var startParameter: String? by optionalRequestParameter()
104
+
105
+ fun providerToken (providerToken : String ) = applySelf { this .providerToken = providerToken }
106
+
107
+ fun providerData (providerData : String ) = applySelf { this .providerData = providerData }
108
+
109
+ fun maxTipAmount (maxTipAmount : Int ) = applySelf { this .maxTipAmount = maxTipAmount }
110
+
111
+ fun suggestedTipAmounts (suggestedTipAmounts : List <Int >) = applySelf { this .suggestedTipAmounts = suggestedTipAmounts }
112
+
113
+ fun suggestedTipAmounts (suggestedTipAmounts : Array <Int >) = suggestedTipAmounts(suggestedTipAmounts.toList())
114
+
115
+ fun suggestedTipAmounts (vararg suggestedTipAmounts : Int ) = suggestedTipAmounts(suggestedTipAmounts.toList())
116
+
117
+ fun photoUrl (photoUrl : String ) = applySelf { this .photoUrl = photoUrl }
118
+
119
+ fun photoSize (photoSize : Int ) = applySelf { this .photoSize = photoSize }
120
+
121
+ fun photoWidth (photoWidth : Int ) = applySelf { this .photoWidth = photoWidth }
122
+
123
+ fun photoHeight (photoHeight : Int ) = applySelf { this .photoHeight = photoHeight }
124
+
125
+ fun needName (needName : Boolean ) = applySelf { this .needName = needName }
126
+
127
+ fun needPhoneNumber (needPhoneNumber : Boolean ) = applySelf { this .needPhoneNumber = needPhoneNumber }
128
+
129
+ fun needEmail (needEmail : Boolean ) = applySelf { this .needEmail = needEmail }
130
+
131
+ fun needShippingAddress (needShippingAddress : Boolean ) = applySelf { this .needShippingAddress = needShippingAddress }
132
+
133
+ fun sendEmailToProvider (sendEmailToProvider : Boolean ) = applySelf { this .sendEmailToProvider = sendEmailToProvider }
134
+
135
+ fun sendPhoneNumberToProvider (sendPhoneNumberToProvider : Boolean ) = applySelf { this .sendPhoneNumberToProvider = sendPhoneNumberToProvider }
136
+
137
+ fun isFlexible (isFlexible : Boolean ) = applySelf { this .isFlexible = isFlexible }
138
+
139
+ fun startParameter (startParameter : String ) = applySelf { this .startParameter = startParameter }
140
+
141
+ }
0 commit comments