Module: Ocelots
Defined Under Namespace
Instance Method Summary collapse
- #base_url ⇒ Object
- #get(command, params) ⇒ Object
- #post(command, params) ⇒ Object
- #post_antechamber(team_slug, content) ⇒ Object
- #request_antechamber(team_slug, from) ⇒ Object
- #request_profile(email) ⇒ Object
- #url_for(command, params = {}) ⇒ Object
Instance Method Details
#base_url ⇒ Object
30 31 32 |
# File 'lib/ocelots.rb', line 30 def base_url ENV['OCELOTS_URL'] || 'http://ocelots.herokuapp.com' end |
#get(command, params) ⇒ Object
17 18 19 |
# File 'lib/ocelots.rb', line 17 def get command, params HTTParty.get url_for command, params end |
#post(command, params) ⇒ Object
21 22 23 |
# File 'lib/ocelots.rb', line 21 def post command, params HTTParty.post url_for(command), params end |
#post_antechamber(team_slug, content) ⇒ Object
13 14 15 |
# File 'lib/ocelots.rb', line 13 def post_antechamber team_slug, content post "antechamber/#{team_slug}", body: {content: content}, headers: {'ContentType' => 'application/json'} end |
#request_antechamber(team_slug, from) ⇒ Object
9 10 11 |
# File 'lib/ocelots.rb', line 9 def request_antechamber team_slug, from get "antechamber/#{team_slug}", from: from end |
#request_profile(email) ⇒ Object
5 6 7 |
# File 'lib/ocelots.rb', line 5 def request_profile email get "profiles/#{Digest::MD5.hexdigest email}" end |
#url_for(command, params = {}) ⇒ Object
25 26 27 28 |
# File 'lib/ocelots.rb', line 25 def url_for command, params={} params[:auth_token] = ENV['OCELOTS_AUTH_TOKEN'] "#{base_url}/api/#{command}?#{params.map{ |k,v| "#{k}=#{CGI.escape v.to_s}" }.join('&')}" end |