Class: BotUpdates

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_bot_builder/bot_updates.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#limitObject

Returns the value of attribute limit.



3
4
5
# File 'lib/telegram_bot_builder/bot_updates.rb', line 3

def limit
  @limit
end

#offsetObject

Returns the value of attribute offset.



2
3
4
# File 'lib/telegram_bot_builder/bot_updates.rb', line 2

def offset
  @offset
end

#timeoutObject

Returns the value of attribute timeout.



4
5
6
# File 'lib/telegram_bot_builder/bot_updates.rb', line 4

def timeout
  @timeout
end

Instance Method Details

#getObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/telegram_bot_builder/bot_updates.rb', line 6

def get
  method = 'getUpdates'

  params = {}

  if offset != nil
    params[:offset] = offset
  end

  if limit != nil
    params[:limit] = limit
  end

  if timeout != nil
    params[:timeout] = timeout
  end

  uri = URI.parse(BotAPI::URLBUIDER.build(method))
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri)
  request.set_form_data(params)
  result = http.request(request)

  if result.code == "200"
    return BotAPI.parse(method, result.body)
  end
end