teleswagger 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -5
  3. data/LICENSE +201 -0
  4. data/README.md +88 -74
  5. data/docs/AnswerCallbackQueryBody.md +12 -0
  6. data/docs/AttachmentsApi.md +166 -3
  7. data/docs/CallbacksApi.md +6 -18
  8. data/docs/Chat.md +2 -0
  9. data/docs/ChatsApi.md +112 -9
  10. data/docs/EditMessageCaptionBody.md +1 -0
  11. data/docs/EditMessageLiveLocationBody.md +13 -0
  12. data/docs/GamesApi.md +5 -5
  13. data/docs/GetUpdatesBody.md +11 -0
  14. data/docs/InlineApi.md +1 -1
  15. data/docs/InlineQueryResultAudio.md +1 -0
  16. data/docs/InlineQueryResultCachedAudio.md +1 -0
  17. data/docs/InlineQueryResultCachedDocument.md +1 -0
  18. data/docs/InlineQueryResultCachedGif.md +1 -0
  19. data/docs/InlineQueryResultCachedMpeg4Gif.md +1 -0
  20. data/docs/InlineQueryResultCachedPhoto.md +1 -0
  21. data/docs/InlineQueryResultCachedVideo.md +1 -0
  22. data/docs/InlineQueryResultCachedVoice.md +1 -0
  23. data/docs/InlineQueryResultDocument.md +1 -0
  24. data/docs/InlineQueryResultGif.md +1 -0
  25. data/docs/InlineQueryResultLocation.md +1 -0
  26. data/docs/InlineQueryResultMpeg4Gif.md +1 -0
  27. data/docs/InlineQueryResultPhoto.md +1 -0
  28. data/docs/InlineQueryResultVideo.md +1 -0
  29. data/docs/InlineQueryResultVoice.md +1 -0
  30. data/docs/InlineResponse200.md +1 -1
  31. data/docs/InlineResponse2001.md +1 -1
  32. data/docs/InlineResponse2002.md +1 -1
  33. data/docs/InlineResponse2003.md +1 -1
  34. data/docs/InlineResponse2004.md +1 -1
  35. data/docs/InlineResponse2005.md +1 -1
  36. data/docs/InlineResponse2006.md +1 -1
  37. data/docs/InlineResponse2007.md +1 -1
  38. data/docs/InlineResponse2008.md +1 -1
  39. data/docs/InlineResponse2009.md +1 -1
  40. data/docs/InputLocationMessageContent.md +1 -0
  41. data/docs/InputMediaPhoto.md +11 -0
  42. data/docs/InputMediaVideo.md +15 -0
  43. data/docs/Message.md +3 -0
  44. data/docs/MessagesApi.md +7 -7
  45. data/docs/PaymentsApi.md +1 -1
  46. data/docs/ReplyKeyboardMarkup.md +1 -1
  47. data/docs/SendInvoiceBody.md +1 -0
  48. data/docs/SendLocationBody.md +1 -0
  49. data/docs/SendMediaGroupLinkBody.md +11 -0
  50. data/docs/StickersApi.md +3 -3
  51. data/docs/StopMessageLiveLocationBody.md +11 -0
  52. data/docs/UpdatesApi.md +4 -8
  53. data/docs/UsersApi.md +5 -5
  54. data/git_push.sh +67 -0
  55. data/lib/teleswagger.rb +20 -2
  56. data/lib/teleswagger/api/attachments_api.rb +367 -158
  57. data/lib/teleswagger/api/callbacks_api.rb +29 -47
  58. data/lib/teleswagger/api/chats_api.rb +316 -192
  59. data/lib/teleswagger/api/games_api.rb +46 -35
  60. data/lib/teleswagger/api/inline_api.rb +21 -8
  61. data/lib/teleswagger/api/messages_api.rb +84 -71
  62. data/lib/teleswagger/api/payments_api.rb +39 -26
  63. data/lib/teleswagger/api/stickers_api.rb +107 -116
  64. data/lib/teleswagger/api/updates_api.rb +50 -39
  65. data/lib/teleswagger/api/users_api.rb +36 -23
  66. data/lib/teleswagger/api_client.rb +45 -55
  67. data/lib/teleswagger/api_error.rb +18 -9
  68. data/lib/teleswagger/configuration.rb +13 -8
  69. data/lib/teleswagger/models/add_sticker_to_set_link_body.rb +16 -21
  70. data/lib/teleswagger/models/allowed_update.rb +15 -2
  71. data/lib/teleswagger/models/animation.rb +16 -9
  72. data/lib/teleswagger/models/answer_callback_query_body.rb +235 -0
  73. data/lib/teleswagger/models/answer_inline_query_body.rb +16 -13
  74. data/lib/teleswagger/models/answer_shipping_query_body.rb +16 -13
  75. data/lib/teleswagger/models/audio.rb +16 -5
  76. data/lib/teleswagger/models/callback_game.rb +16 -5
  77. data/lib/teleswagger/models/callback_query.rb +16 -5
  78. data/lib/teleswagger/models/chat.rb +38 -17
  79. data/lib/teleswagger/models/chat_member.rb +16 -13
  80. data/lib/teleswagger/models/chat_photo.rb +16 -5
  81. data/lib/teleswagger/models/chosen_inline_result.rb +16 -17
  82. data/lib/teleswagger/models/contact.rb +16 -5
  83. data/lib/teleswagger/models/create_new_sticker_set_link_body.rb +16 -25
  84. data/lib/teleswagger/models/document.rb +16 -5
  85. data/lib/teleswagger/models/edit_message_caption_body.rb +26 -6
  86. data/lib/teleswagger/models/edit_message_live_location_body.rb +246 -0
  87. data/lib/teleswagger/models/edit_message_reply_markup_body.rb +16 -5
  88. data/lib/teleswagger/models/edit_message_text_body.rb +16 -9
  89. data/lib/teleswagger/models/error.rb +16 -5
  90. data/lib/teleswagger/models/file.rb +16 -5
  91. data/lib/teleswagger/models/force_reply.rb +16 -5
  92. data/lib/teleswagger/models/game.rb +16 -17
  93. data/lib/teleswagger/models/game_high_score.rb +16 -5
  94. data/lib/teleswagger/models/get_updates_body.rb +228 -0
  95. data/lib/teleswagger/models/inline_keyboard_button.rb +16 -5
  96. data/lib/teleswagger/models/inline_keyboard_markup.rb +16 -5
  97. data/lib/teleswagger/models/inline_query.rb +16 -5
  98. data/lib/teleswagger/models/inline_query_result_article.rb +16 -21
  99. data/lib/teleswagger/models/inline_query_result_audio.rb +26 -22
  100. data/lib/teleswagger/models/inline_query_result_cached_audio.rb +26 -18
  101. data/lib/teleswagger/models/inline_query_result_cached_document.rb +26 -18
  102. data/lib/teleswagger/models/inline_query_result_cached_gif.rb +26 -18
  103. data/lib/teleswagger/models/inline_query_result_cached_mpeg4_gif.rb +26 -18
  104. data/lib/teleswagger/models/inline_query_result_cached_photo.rb +26 -18
  105. data/lib/teleswagger/models/inline_query_result_cached_sticker.rb +16 -17
  106. data/lib/teleswagger/models/inline_query_result_cached_video.rb +26 -18
  107. data/lib/teleswagger/models/inline_query_result_cached_voice.rb +26 -18
  108. data/lib/teleswagger/models/inline_query_result_contact.rb +16 -21
  109. data/lib/teleswagger/models/inline_query_result_document.rb +26 -26
  110. data/lib/teleswagger/models/inline_query_result_game.rb +16 -17
  111. data/lib/teleswagger/models/inline_query_result_gif.rb +26 -22
  112. data/lib/teleswagger/models/inline_query_result_location.rb +50 -24
  113. data/lib/teleswagger/models/inline_query_result_mpeg4_gif.rb +26 -22
  114. data/lib/teleswagger/models/inline_query_result_photo.rb +26 -22
  115. data/lib/teleswagger/models/inline_query_result_venue.rb +16 -29
  116. data/lib/teleswagger/models/inline_query_result_video.rb +26 -30
  117. data/lib/teleswagger/models/inline_query_result_voice.rb +26 -22
  118. data/lib/teleswagger/models/inline_response_200.rb +17 -6
  119. data/lib/teleswagger/models/inline_response_200_1.rb +17 -6
  120. data/lib/teleswagger/models/inline_response_200_2.rb +20 -7
  121. data/lib/teleswagger/models/inline_response_200_3.rb +17 -6
  122. data/lib/teleswagger/models/inline_response_200_4.rb +18 -9
  123. data/lib/teleswagger/models/inline_response_200_5.rb +17 -6
  124. data/lib/teleswagger/models/inline_response_200_6.rb +17 -6
  125. data/lib/teleswagger/models/inline_response_200_7.rb +17 -6
  126. data/lib/teleswagger/models/inline_response_200_8.rb +17 -6
  127. data/lib/teleswagger/models/inline_response_200_9.rb +17 -6
  128. data/lib/teleswagger/models/inline_type.rb +13 -2
  129. data/lib/teleswagger/models/input_contact_message_content.rb +16 -13
  130. data/lib/teleswagger/models/input_location_message_content.rb +51 -13
  131. data/lib/teleswagger/models/input_media_photo.rb +228 -0
  132. data/lib/teleswagger/models/input_media_video.rb +264 -0
  133. data/lib/teleswagger/models/input_text_message_content.rb +16 -9
  134. data/lib/teleswagger/models/input_venue_message_content.rb +16 -21
  135. data/lib/teleswagger/models/invoice.rb +16 -5
  136. data/lib/teleswagger/models/keyboard_button.rb +16 -5
  137. data/lib/teleswagger/models/labeled_price.rb +16 -5
  138. data/lib/teleswagger/models/location.rb +16 -5
  139. data/lib/teleswagger/models/mask_position.rb +16 -5
  140. data/lib/teleswagger/models/message.rb +49 -9
  141. data/lib/teleswagger/models/message_entity.rb +16 -5
  142. data/lib/teleswagger/models/order_info.rb +16 -5
  143. data/lib/teleswagger/models/parse_mode.rb +13 -2
  144. data/lib/teleswagger/models/photo_size.rb +16 -5
  145. data/lib/teleswagger/models/pre_checkout_query.rb +16 -5
  146. data/lib/teleswagger/models/promote_chat_member_body.rb +16 -13
  147. data/lib/teleswagger/models/reply_keyboard_markup.rb +17 -6
  148. data/lib/teleswagger/models/reply_keyboard_remove.rb +16 -5
  149. data/lib/teleswagger/models/response_bool.rb +16 -5
  150. data/lib/teleswagger/models/response_message.rb +16 -5
  151. data/lib/teleswagger/models/response_parameters.rb +16 -5
  152. data/lib/teleswagger/models/response_update.rb +16 -5
  153. data/lib/teleswagger/models/restrict_chat_member_body.rb +16 -13
  154. data/lib/teleswagger/models/send_audio_link_body.rb +16 -13
  155. data/lib/teleswagger/models/send_contact_body.rb +16 -17
  156. data/lib/teleswagger/models/send_document_link_body.rb +16 -13
  157. data/lib/teleswagger/models/send_game_body.rb +16 -13
  158. data/lib/teleswagger/models/send_invoice_body.rb +26 -38
  159. data/lib/teleswagger/models/send_location_body.rb +50 -16
  160. data/lib/teleswagger/models/send_media_group_link_body.rb +230 -0
  161. data/lib/teleswagger/models/send_message_body.rb +16 -13
  162. data/lib/teleswagger/models/send_photo_link_body.rb +16 -13
  163. data/lib/teleswagger/models/send_sticker_link_body.rb +16 -13
  164. data/lib/teleswagger/models/send_venue_body.rb +16 -25
  165. data/lib/teleswagger/models/send_video_link_body.rb +16 -13
  166. data/lib/teleswagger/models/send_video_note_link_body.rb +16 -13
  167. data/lib/teleswagger/models/send_voice_link_body.rb +16 -13
  168. data/lib/teleswagger/models/shipping_address.rb +16 -5
  169. data/lib/teleswagger/models/shipping_option.rb +16 -5
  170. data/lib/teleswagger/models/shipping_query.rb +16 -5
  171. data/lib/teleswagger/models/sticker.rb +16 -5
  172. data/lib/teleswagger/models/sticker_set.rb +16 -5
  173. data/lib/teleswagger/models/stop_message_live_location_body.rb +226 -0
  174. data/lib/teleswagger/models/successful_payment.rb +16 -5
  175. data/lib/teleswagger/models/update.rb +16 -5
  176. data/lib/teleswagger/models/user.rb +16 -5
  177. data/lib/teleswagger/models/user_profile_photos.rb +16 -5
  178. data/lib/teleswagger/models/venue.rb +16 -5
  179. data/lib/teleswagger/models/video.rb +16 -5
  180. data/lib/teleswagger/models/video_note.rb +16 -5
  181. data/lib/teleswagger/models/voice.rb +16 -5
  182. data/lib/teleswagger/models/webhook_info.rb +16 -17
  183. data/lib/teleswagger/version.rb +15 -4
  184. data/spec/models/answer_callback_query_body_spec.rb +77 -0
  185. data/spec/models/edit_message_live_location_body_spec.rb +83 -0
  186. data/spec/models/get_updates_body_spec.rb +71 -0
  187. data/spec/models/input_media_photo_spec.rb +71 -0
  188. data/spec/models/input_media_video_spec.rb +95 -0
  189. data/spec/models/send_media_group_link_body_spec.rb +71 -0
  190. data/spec/models/stop_message_live_location_body_spec.rb +71 -0
  191. data/swagger.yaml +428 -52
  192. data/teleswagger.gemspec +17 -8
  193. metadata +45 -14
@@ -3,10 +3,21 @@
3
3
 
4
4
  #This is a swagger defenition for [Telegram bot API](https://core.telegram.org/bots/api).
5
5
 
6
- OpenAPI spec version: 3.3
6
+ OpenAPI spec version: 3.6
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.2.3
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
10
21
 
11
22
  =end
12
23
 
@@ -38,17 +49,21 @@ module Teleswagger
38
49
  @api_client.config.logger.debug "Calling API: UpdatesApi.delete_webhook ..."
39
50
  end
40
51
  # resource path
41
- local_var_path = "/bot{token}/deleteWebhook"
52
+ local_var_path = "/bot{token}/deleteWebhook".sub('{format}','json')
42
53
 
43
54
  # query parameters
44
55
  query_params = {}
45
56
 
46
57
  # header parameters
47
58
  header_params = {}
59
+
48
60
  # HTTP header 'Accept' (if needed)
49
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
61
+ local_header_accept = ['application/json']
62
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
63
+
50
64
  # HTTP header 'Content-Type'
51
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
65
+ local_header_content_type = ['application/json']
66
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
52
67
 
53
68
  # form parameters
54
69
  form_params = {}
@@ -74,9 +89,7 @@ module Teleswagger
74
89
  # @param token bot's token to authorize the request
75
90
  # @param [Hash] opts the optional parameters
76
91
  # @option opts [Integer] :offset
77
- # @option opts [Integer] :limit
78
- # @option opts [Integer] :timeout
79
- # @option opts [Array<String>] :allowed_updates
92
+ # @option opts [GetUpdatesBody] :body
80
93
  # @return [ResponseUpdate]
81
94
  def get_updates(token, opts = {})
82
95
  data, _status_code, _headers = get_updates_with_http_info(token, opts)
@@ -88,45 +101,39 @@ module Teleswagger
88
101
  # @param token bot&#39;s token to authorize the request
89
102
  # @param [Hash] opts the optional parameters
90
103
  # @option opts [Integer] :offset
91
- # @option opts [Integer] :limit
92
- # @option opts [Integer] :timeout
93
- # @option opts [Array<String>] :allowed_updates
104
+ # @option opts [GetUpdatesBody] :body
94
105
  # @return [Array<(ResponseUpdate, Fixnum, Hash)>] ResponseUpdate data, response status code and response headers
95
106
  def get_updates_with_http_info(token, opts = {})
96
107
  if @api_client.config.debugging
97
108
  @api_client.config.logger.debug "Calling API: UpdatesApi.get_updates ..."
98
109
  end
99
110
  # verify the required parameter 'token' is set
100
- if @api_client.config.client_side_validation && token.nil?
101
- fail ArgumentError, "Missing the required parameter 'token' when calling UpdatesApi.get_updates"
102
- end
103
- if @api_client.config.client_side_validation && opts[:'allowed_updates'] && !opts[:'allowed_updates'].all?{|item| ['message', 'edited_message', 'channel_post', 'edited_channel_post', 'inline_query', 'chosen_inline_result', 'callback_query'].include?(item)}
104
- fail ArgumentError, 'invalid value for "allowed_updates", must include one of message, edited_message, channel_post, edited_channel_post, inline_query, chosen_inline_result, callback_query'
105
- end
111
+ fail ArgumentError, "Missing the required parameter 'token' when calling UpdatesApi.get_updates" if token.nil?
106
112
  # resource path
107
- local_var_path = "/bot{token}/getUpdates".sub('{' + 'token' + '}', token.to_s)
113
+ local_var_path = "/bot{token}/getUpdates".sub('{format}','json').sub('{' + 'token' + '}', token.to_s)
108
114
 
109
115
  # query parameters
110
116
  query_params = {}
111
117
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
112
- query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
113
- query_params[:'timeout'] = opts[:'timeout'] if !opts[:'timeout'].nil?
114
- query_params[:'allowed_updates'] = @api_client.build_collection_param(opts[:'allowed_updates'], :multi) if !opts[:'allowed_updates'].nil?
115
118
 
116
119
  # header parameters
117
120
  header_params = {}
121
+
118
122
  # HTTP header 'Accept' (if needed)
119
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
123
+ local_header_accept = ['application/json']
124
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
125
+
120
126
  # HTTP header 'Content-Type'
121
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
127
+ local_header_content_type = ['application/json']
128
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
122
129
 
123
130
  # form parameters
124
131
  form_params = {}
125
132
 
126
133
  # http body (model)
127
- post_body = nil
134
+ post_body = @api_client.object_to_http_body(opts[:'body'])
128
135
  auth_names = []
129
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
136
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
130
137
  :header_params => header_params,
131
138
  :query_params => query_params,
132
139
  :form_params => form_params,
@@ -157,17 +164,21 @@ module Teleswagger
157
164
  @api_client.config.logger.debug "Calling API: UpdatesApi.get_webhook_info ..."
158
165
  end
159
166
  # resource path
160
- local_var_path = "/bot{token}/getWebhookInfo"
167
+ local_var_path = "/bot{token}/getWebhookInfo".sub('{format}','json')
161
168
 
162
169
  # query parameters
163
170
  query_params = {}
164
171
 
165
172
  # header parameters
166
173
  header_params = {}
174
+
167
175
  # HTTP header 'Accept' (if needed)
168
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
176
+ local_header_accept = ['application/json']
177
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
178
+
169
179
  # HTTP header 'Content-Type'
170
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
180
+ local_header_content_type = ['application/json']
181
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
171
182
 
172
183
  # form parameters
173
184
  form_params = {}
@@ -216,28 +227,28 @@ module Teleswagger
216
227
  @api_client.config.logger.debug "Calling API: UpdatesApi.set_webhook ..."
217
228
  end
218
229
  # verify the required parameter 'token' is set
219
- if @api_client.config.client_side_validation && token.nil?
220
- fail ArgumentError, "Missing the required parameter 'token' when calling UpdatesApi.set_webhook"
221
- end
230
+ fail ArgumentError, "Missing the required parameter 'token' when calling UpdatesApi.set_webhook" if token.nil?
222
231
  # verify the required parameter 'url' is set
223
- if @api_client.config.client_side_validation && url.nil?
224
- fail ArgumentError, "Missing the required parameter 'url' when calling UpdatesApi.set_webhook"
225
- end
226
- if @api_client.config.client_side_validation && opts[:'allowed_updates'] && !opts[:'allowed_updates'].all?{|item| ['message', 'edited_message', 'channel_post', 'edited_channel_post', 'inline_query', 'chosen_inline_result', 'callback_query'].include?(item)}
227
- fail ArgumentError, 'invalid value for "allowed_updates", must include one of message, edited_message, channel_post, edited_channel_post, inline_query, chosen_inline_result, callback_query'
232
+ fail ArgumentError, "Missing the required parameter 'url' when calling UpdatesApi.set_webhook" if url.nil?
233
+ if opts[:'allowed_updates'] && !['message', 'edited_message', 'channel_post', 'edited_channel_post', 'inline_query', 'chosen_inline_result', 'callback_query', 'shipping_query', 'pre_checkout_query'].include?(opts[:'allowed_updates'])
234
+ fail ArgumentError, 'invalid value for "allowed_updates", must be one of message, edited_message, channel_post, edited_channel_post, inline_query, chosen_inline_result, callback_query, shipping_query, pre_checkout_query'
228
235
  end
229
236
  # resource path
230
- local_var_path = "/bot{token}/setWebhook".sub('{' + 'token' + '}', token.to_s)
237
+ local_var_path = "/bot{token}/setWebhook".sub('{format}','json').sub('{' + 'token' + '}', token.to_s)
231
238
 
232
239
  # query parameters
233
240
  query_params = {}
234
241
 
235
242
  # header parameters
236
243
  header_params = {}
244
+
237
245
  # HTTP header 'Accept' (if needed)
238
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
246
+ local_header_accept = ['application/json']
247
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
248
+
239
249
  # HTTP header 'Content-Type'
240
- header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
250
+ local_header_content_type = ['multipart/form-data']
251
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
241
252
 
242
253
  # form parameters
243
254
  form_params = {}
@@ -3,10 +3,21 @@
3
3
 
4
4
  #This is a swagger defenition for [Telegram bot API](https://core.telegram.org/bots/api).
5
5
 
6
- OpenAPI spec version: 3.3
6
+ OpenAPI spec version: 3.6
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.2.3
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
10
21
 
11
22
  =end
12
23
 
@@ -24,7 +35,7 @@ module Teleswagger
24
35
  #
25
36
  # @param token bot&#39;s token to authorize the request
26
37
  # @param [Hash] opts the optional parameters
27
- # @return [InlineResponse200]
38
+ # @return [InlineResponse2007]
28
39
  def get_me(token, opts = {})
29
40
  data, _status_code, _headers = get_me_with_http_info(token, opts)
30
41
  return data
@@ -34,27 +45,29 @@ module Teleswagger
34
45
  #
35
46
  # @param token bot&#39;s token to authorize the request
36
47
  # @param [Hash] opts the optional parameters
37
- # @return [Array<(InlineResponse200, Fixnum, Hash)>] InlineResponse200 data, response status code and response headers
48
+ # @return [Array<(InlineResponse2007, Fixnum, Hash)>] InlineResponse2007 data, response status code and response headers
38
49
  def get_me_with_http_info(token, opts = {})
39
50
  if @api_client.config.debugging
40
51
  @api_client.config.logger.debug "Calling API: UsersApi.get_me ..."
41
52
  end
42
53
  # verify the required parameter 'token' is set
43
- if @api_client.config.client_side_validation && token.nil?
44
- fail ArgumentError, "Missing the required parameter 'token' when calling UsersApi.get_me"
45
- end
54
+ fail ArgumentError, "Missing the required parameter 'token' when calling UsersApi.get_me" if token.nil?
46
55
  # resource path
47
- local_var_path = "/bot{token}/getMe".sub('{' + 'token' + '}', token.to_s)
56
+ local_var_path = "/bot{token}/getMe".sub('{format}','json').sub('{' + 'token' + '}', token.to_s)
48
57
 
49
58
  # query parameters
50
59
  query_params = {}
51
60
 
52
61
  # header parameters
53
62
  header_params = {}
63
+
54
64
  # HTTP header 'Accept' (if needed)
55
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
65
+ local_header_accept = ['application/json']
66
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
67
+
56
68
  # HTTP header 'Content-Type'
57
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
69
+ local_header_content_type = ['application/json']
70
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
58
71
 
59
72
  # form parameters
60
73
  form_params = {}
@@ -68,7 +81,7 @@ module Teleswagger
68
81
  :form_params => form_params,
69
82
  :body => post_body,
70
83
  :auth_names => auth_names,
71
- :return_type => 'InlineResponse200')
84
+ :return_type => 'InlineResponse2007')
72
85
  if @api_client.config.debugging
73
86
  @api_client.config.logger.debug "API called: UsersApi#get_me\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
74
87
  end
@@ -82,7 +95,7 @@ module Teleswagger
82
95
  # @param [Hash] opts the optional parameters
83
96
  # @option opts [Integer] :offset
84
97
  # @option opts [Integer] :limit
85
- # @return [InlineResponse2001]
98
+ # @return [InlineResponse2009]
86
99
  def get_user_profile_photos(token, user_id, opts = {})
87
100
  data, _status_code, _headers = get_user_profile_photos_with_http_info(token, user_id, opts)
88
101
  return data
@@ -95,21 +108,17 @@ module Teleswagger
95
108
  # @param [Hash] opts the optional parameters
96
109
  # @option opts [Integer] :offset
97
110
  # @option opts [Integer] :limit
98
- # @return [Array<(InlineResponse2001, Fixnum, Hash)>] InlineResponse2001 data, response status code and response headers
111
+ # @return [Array<(InlineResponse2009, Fixnum, Hash)>] InlineResponse2009 data, response status code and response headers
99
112
  def get_user_profile_photos_with_http_info(token, user_id, opts = {})
100
113
  if @api_client.config.debugging
101
114
  @api_client.config.logger.debug "Calling API: UsersApi.get_user_profile_photos ..."
102
115
  end
103
116
  # verify the required parameter 'token' is set
104
- if @api_client.config.client_side_validation && token.nil?
105
- fail ArgumentError, "Missing the required parameter 'token' when calling UsersApi.get_user_profile_photos"
106
- end
117
+ fail ArgumentError, "Missing the required parameter 'token' when calling UsersApi.get_user_profile_photos" if token.nil?
107
118
  # verify the required parameter 'user_id' is set
108
- if @api_client.config.client_side_validation && user_id.nil?
109
- fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.get_user_profile_photos"
110
- end
119
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.get_user_profile_photos" if user_id.nil?
111
120
  # resource path
112
- local_var_path = "/bot{token}/getUserProfilePhotos".sub('{' + 'token' + '}', token.to_s)
121
+ local_var_path = "/bot{token}/getUserProfilePhotos".sub('{format}','json').sub('{' + 'token' + '}', token.to_s)
113
122
 
114
123
  # query parameters
115
124
  query_params = {}
@@ -119,10 +128,14 @@ module Teleswagger
119
128
 
120
129
  # header parameters
121
130
  header_params = {}
131
+
122
132
  # HTTP header 'Accept' (if needed)
123
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
133
+ local_header_accept = ['application/json']
134
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
135
+
124
136
  # HTTP header 'Content-Type'
125
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
137
+ local_header_content_type = ['application/json']
138
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
126
139
 
127
140
  # form parameters
128
141
  form_params = {}
@@ -136,7 +149,7 @@ module Teleswagger
136
149
  :form_params => form_params,
137
150
  :body => post_body,
138
151
  :auth_names => auth_names,
139
- :return_type => 'InlineResponse2001')
152
+ :return_type => 'InlineResponse2009')
140
153
  if @api_client.config.debugging
141
154
  @api_client.config.logger.debug "API called: UsersApi#get_user_profile_photos\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
142
155
  end
@@ -3,10 +3,21 @@
3
3
 
4
4
  #This is a swagger defenition for [Telegram bot API](https://core.telegram.org/bots/api).
5
5
 
6
- OpenAPI spec version: 3.3
6
+ OpenAPI spec version: 3.6
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.2.3
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
10
21
 
11
22
  =end
12
23
 
@@ -55,18 +66,10 @@ module Teleswagger
55
66
  end
56
67
 
57
68
  unless response.success?
58
- if response.timed_out?
59
- fail ApiError.new('Connection timed out')
60
- elsif response.code == 0
61
- # Errors from libcurl will be made visible here
62
- fail ApiError.new(:code => 0,
63
- :message => response.return_message)
64
- else
65
- fail ApiError.new(:code => response.code,
66
- :response_headers => response.headers,
67
- :response_body => response.body),
68
- response.status_message
69
- end
69
+ fail ApiError.new(:code => response.code,
70
+ :response_headers => response.headers,
71
+ :response_body => response.body),
72
+ response.status_message
70
73
  end
71
74
 
72
75
  if opts[:return_type]
@@ -122,9 +125,7 @@ module Teleswagger
122
125
  end
123
126
  end
124
127
 
125
- request = Typhoeus::Request.new(url, req_opts)
126
- download_file(request) if opts[:return_type] == 'File'
127
- request
128
+ Typhoeus::Request.new(url, req_opts)
128
129
  end
129
130
 
130
131
  # Check if the given MIME is a JSON MIME.
@@ -132,11 +133,10 @@ module Teleswagger
132
133
  # application/json
133
134
  # application/json; charset=UTF8
134
135
  # APPLICATION/JSON
135
- # */*
136
136
  # @param [String] mime MIME
137
- # @return [Boolean] True if the MIME is application/json
137
+ # @return [Boolean] True if the MIME is applicaton/json
138
138
  def json_mime?(mime)
139
- (mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
139
+ !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
140
140
  end
141
141
 
142
142
  # Deserialize the response to the given return type.
@@ -145,16 +145,14 @@ module Teleswagger
145
145
  # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
146
146
  def deserialize(response, return_type)
147
147
  body = response.body
148
-
149
- # handle file downloading - return the File instance processed in request callbacks
150
- # note that response body is empty when the file is written in chunks in request on_body callback
151
- return @tempfile if return_type == 'File'
152
-
153
148
  return nil if body.nil? || body.empty?
154
149
 
155
150
  # return response body directly for String return type
156
151
  return body if return_type == 'String'
157
152
 
153
+ # handle file downloading - save response body into a tmp file and return the File instance
154
+ return download_file(response) if return_type == 'File'
155
+
158
156
  # ensuring a default content type
159
157
  content_type = response.headers['Content-Type'] || 'application/json'
160
158
 
@@ -217,38 +215,30 @@ module Teleswagger
217
215
 
218
216
  # Save response body into a file in (the defined) temporary folder, using the filename
219
217
  # from the "Content-Disposition" header if provided, otherwise a random filename.
220
- # The response body is written to the file in chunks in order to handle files which
221
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
222
- # process can use.
223
218
  #
224
219
  # @see Configuration#temp_folder_path
225
- def download_file(request)
226
- tempfile = nil
227
- encoding = nil
228
- request.on_headers do |response|
229
- content_disposition = response.headers['Content-Disposition']
230
- if content_disposition and content_disposition =~ /filename=/i
231
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
232
- prefix = sanitize_filename(filename)
233
- else
234
- prefix = 'download-'
235
- end
236
- prefix = prefix + '-' unless prefix.end_with?('-')
237
- encoding = response.body.encoding
238
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
239
- @tempfile = tempfile
240
- end
241
- request.on_body do |chunk|
242
- chunk.force_encoding(encoding)
243
- tempfile.write(chunk)
220
+ # @return [Tempfile] the file downloaded
221
+ def download_file(response)
222
+ content_disposition = response.headers['Content-Disposition']
223
+ if content_disposition and content_disposition =~ /filename=/i
224
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
225
+ prefix = sanitize_filename(filename)
226
+ else
227
+ prefix = 'download-'
244
228
  end
245
- request.on_complete do |response|
246
- tempfile.close
247
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
248
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
249
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
250
- "explicitly with `tempfile.delete`"
229
+ prefix = prefix + '-' unless prefix.end_with?('-')
230
+
231
+ tempfile = nil
232
+ encoding = response.body.encoding
233
+ Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
234
+ file.write(response.body)
235
+ tempfile = file
251
236
  end
237
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
238
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
239
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
240
+ "explicitly with `tempfile.delete`"
241
+ tempfile
252
242
  end
253
243
 
254
244
  # Sanitize filename by removing path.
@@ -279,7 +269,7 @@ module Teleswagger
279
269
  data = {}
280
270
  form_params.each do |key, value|
281
271
  case value
282
- when ::File, ::Array, nil
272
+ when File, Array, nil
283
273
  # let typhoeus handle File, Array and nil parameters
284
274
  data[key] = value
285
275
  else
@@ -297,7 +287,7 @@ module Teleswagger
297
287
  # Update hearder and query params based on authentication settings.
298
288
  #
299
289
  # @param [Hash] header_params Header parameters
300
- # @param [Hash] query_params Query parameters
290
+ # @param [Hash] form_params Query parameters
301
291
  # @param [String] auth_names Authentication scheme name
302
292
  def update_params_for_auth!(header_params, query_params, auth_names)
303
293
  Array(auth_names).each do |auth_name|