Skip to content

Commit 53e4ea3

Browse files
committed
Rewrite SendVenue to Kotlin
1 parent 99598b0 commit 53e4ea3

File tree

3 files changed

+122
-32
lines changed

3 files changed

+122
-32
lines changed

library/src/main/java/com/pengrad/telegrambot/request/SendVenue.java

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.pengrad.telegrambot.request
2+
3+
import com.pengrad.telegrambot.utility.kotlin.checkDeprecatedConstructorParameters
4+
import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
5+
import com.pengrad.telegrambot.utility.kotlin.requestParameter
6+
7+
class SendVenue private constructor(
8+
chatId: Long? = null,
9+
channelUsername: String? = null,
10+
11+
latitude: Float,
12+
longitude: Float,
13+
title: String,
14+
address: String
15+
) : KAbstractSendRequest<SendVenue>(
16+
chatId = chatId,
17+
channelUsername = channelUsername,
18+
) {
19+
20+
constructor(
21+
chatId: Long,
22+
latitude: Float,
23+
longitude: Float,
24+
title: String,
25+
address: String
26+
) : this(
27+
chatId = chatId,
28+
channelUsername = null,
29+
latitude = latitude,
30+
longitude = longitude,
31+
title = title,
32+
address = address
33+
)
34+
35+
constructor(
36+
channelUsername: String,
37+
latitude: Float,
38+
longitude: Float,
39+
title: String,
40+
address: String
41+
) : this(
42+
chatId = null,
43+
channelUsername = channelUsername,
44+
latitude = latitude,
45+
longitude = longitude,
46+
title = title,
47+
address = address
48+
)
49+
50+
@Deprecated("Use constructor with chatId or channelUsername instead", ReplaceWith("SendVenue(chatId, latitude, longitude, title, address)"))
51+
constructor(
52+
chatId: Any,
53+
latitude: Float,
54+
longitude: Float,
55+
title: String,
56+
address: String
57+
) : this(
58+
chatId = (chatId as? Number)?.toLong(),
59+
channelUsername = chatId as? String,
60+
latitude = latitude,
61+
longitude = longitude,
62+
title = title,
63+
address = address
64+
) {
65+
checkDeprecatedConstructorParameters()
66+
}
67+
68+
val latitude: Float by requestParameter(latitude)
69+
val longitude: Float by requestParameter(longitude)
70+
val title: String by requestParameter(title)
71+
val address: String by requestParameter(address)
72+
73+
var foursquareId: String? by optionalRequestParameter()
74+
var foursquareType: String? by optionalRequestParameter()
75+
76+
var googlePlaceId: String? by optionalRequestParameter()
77+
var googlePlaceType: String? by optionalRequestParameter()
78+
79+
fun foursquareId(foursquareId: String) = applySelf { this.foursquareId = foursquareId }
80+
81+
fun foursquareType(foursquareType: String) = applySelf { this.foursquareType = foursquareType }
82+
83+
fun googlePlaceId(googlePlaceId: String) = applySelf { this.googlePlaceId = googlePlaceId }
84+
85+
fun googlePlaceType(googlePlaceType: String) = applySelf { this.googlePlaceType = googlePlaceType }
86+
87+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.pengrad.telegrambot.utility.kotlin.extension.request
2+
3+
import com.pengrad.telegrambot.TelegramAware
4+
import com.pengrad.telegrambot.request.SendVenue
5+
import com.pengrad.telegrambot.utility.kotlin.extension.execute
6+
7+
inline fun TelegramAware.sendVenue(
8+
chatId: Long,
9+
latitude: Float,
10+
longitude: Float,
11+
title: String,
12+
address: String,
13+
modifier: SendVenue.() -> Unit = {}
14+
) = this.execute(SendVenue(
15+
chatId = chatId,
16+
latitude = latitude,
17+
longitude = longitude,
18+
title = title,
19+
address = address,
20+
), modifier)
21+
22+
inline fun TelegramAware.sendVenue(
23+
channelUsername: String,
24+
latitude: Float,
25+
longitude: Float,
26+
title: String,
27+
address: String,
28+
modifier: SendVenue.() -> Unit = {}
29+
) = this.execute(SendVenue(
30+
channelUsername = channelUsername,
31+
latitude = latitude,
32+
longitude = longitude,
33+
title = title,
34+
address = address,
35+
), modifier)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy