summaryrefslogtreecommitdiff
path: root/app/controllers/users_controller.rb
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-23 20:41:03 -0400
committernfoy <nfoy@purdue.edu>2014-04-23 20:41:03 -0400
commit9afd5a4f7a86eeaab3fa8a0c25609ac7977e0489 (patch)
tree8d47adc08a58a8936e2026f30852f877ee47cf64 /app/controllers/users_controller.rb
parent422a7b39a06e2fe54415f2be08548021a981e8a8 (diff)
parent7ff82b901705475f97e277a9f3f31756bd3ce948 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r--app/controllers/users_controller.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c3261b8..cfa5d67 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,5 +1,8 @@
class UsersController < ApplicationController
+ require 'httparty'
+ require 'json'
+
# GET /users
# GET /users.json
@@ -74,6 +77,20 @@ class UsersController < ApplicationController
end
end
+ def set_remote
+ game = Game.find_by_name("League of Legends")
+
+ remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{@name.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
+
+ remote = @user.find_remote_username(game)
+ if remote.nil?
+ @user.remote_username.create(game: game, value: remote_username)
+ else
+ remote.value = remote_username
+ remote.save
+ end
+ end
+
private
# Use callbacks to share common setup or constraints between actions.
def set_user