File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
main/java/com/pengrad/telegrambot/request
test/java/com/pengrad/telegrambot Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 11package com .pengrad .telegrambot .request ;
22
3+ import com .google .gson .Gson ;
34import com .pengrad .telegrambot .response .GetUpdatesResponse ;
45
56/**
89 */
910public class GetUpdates extends BaseRequest <GetUpdates , GetUpdatesResponse > {
1011
12+ // todo remove gson
13+ private static Gson gson = new Gson ();
14+
1115 private int timeout = 0 ;
1216 private int limit = 100 ;
1317
@@ -29,6 +33,10 @@ public GetUpdates timeout(int timeout) {
2933 return add ("timeout" , timeout );
3034 }
3135
36+ public GetUpdates allowedUpdates (String ... allowedUpdates ) {
37+ return add ("allowed_updates" , gson .toJson (allowedUpdates ));
38+ }
39+
3240 @ Override
3341 public int getTimeoutSeconds () {
3442 return timeout ;
Original file line number Diff line number Diff line change 11package com .pengrad .telegrambot .request ;
22
3+ import com .google .gson .Gson ;
34import com .pengrad .telegrambot .response .BaseResponse ;
45
56import java .io .File ;
1011 */
1112public class SetWebhook extends BaseRequest <SetWebhook , BaseResponse > {
1213
14+ // todo remove gson
15+ private static Gson gson = new Gson ();
16+
1317 private boolean isMultipart = false ;
1418
1519 public SetWebhook () {
@@ -34,6 +38,10 @@ public SetWebhook maxConnections(int maxConnections) {
3438 return add ("max_connections" , maxConnections );
3539 }
3640
41+ public SetWebhook allowedUpdates (String ... allowedUpdates ) {
42+ return add ("allowed_updates" , gson .toJson (allowedUpdates ));
43+ }
44+
3745 @ Override
3846 public boolean isMultipart () {
3947 return isMultipart ;
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public void getMe() {
6464
6565 @ Test
6666 public void getUpdates () {
67- GetUpdatesResponse response = bot .execute (new GetUpdates ().offset (279823304 ). timeout ( 25 ));
67+ GetUpdatesResponse response = bot .execute (new GetUpdates ().offset (279824711 ). allowedUpdates ( "callback_query" ));
6868 System .out .println (response );
6969 }
7070
@@ -235,7 +235,12 @@ public void getWebhookInfo() {
235235
236236 @ Test
237237 public void setWebhook () {
238- BaseResponse response = bot .execute (new SetWebhook ().url ("https://google.com" ).maxConnections (100 ));
238+ BaseResponse response = bot .execute (
239+ new SetWebhook ()
240+ .url ("https://google.com" )
241+ .maxConnections (100 )
242+ .allowedUpdates ("message" , "callback_query" )
243+ );
239244 assertTrue (response .isOk ());
240245 }
241246
You can’t perform that action at this time.
0 commit comments