Class: Bot
- Inherits:
-
Object
- Object
- Bot
- Defined in:
- lib/mebots.rb
Constant Summary collapse
- @@HOST =
"https://mebotsco.herokuapp.com"- @@API_ROOT =
"/api/"
Instance Method Summary collapse
- #get(endpoint) ⇒ Object
-
#initialize(slug, token) ⇒ Bot
constructor
A new instance of Bot.
- #instance(group_id) ⇒ Object
Constructor Details
#initialize(slug, token) ⇒ Bot
Returns a new instance of Bot.
17 18 19 20 |
# File 'lib/mebots.rb', line 17 def initialize(slug, token) @slug = slug @token = token end |
Instance Method Details
#get(endpoint) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mebots.rb', line 22 def get(endpoint) uri = URI(@@HOST + @@API_ROOT + endpoint + "?token=#{@token}") Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == "https") do |http| req = Net::HTTP::Get.new(uri) return JSON.parse(http.request(req).body) end end |
#instance(group_id) ⇒ Object
33 34 35 |
# File 'lib/mebots.rb', line 33 def instance(group_id) return Instance.new(get("bot/#{@slug}/instance/#{group_id}")) end |