from nameko.web.handlers import http

from pokebattle.scores import ScoreService


class GameService(object):

    score_service = RpcProxy('score_service')

    @http('POST', '/signup')
    def signup(self):
        pass

    @http('POST', '/login')
    def login(self):
        pass

    @http('POST', '/battle')
    def new_game(self):
        pass

    @http('GET', '/leaderboard')
    def leaderboard(self):
        pass

    @http('GET', '/user/<int:id>')
    def user(self):
        pass

    @http('GET', '/user/<int:id>/pokemons')
    def user_pokemons(self):
        pass

import json

from nameko.web.handlers import http
from nameko.rpc import RpcProxy

from pokebattle.scores import ScoreService


class GameService(object):
    name = 'game_service'
    score_rpc = RpcProxy('score_service')

    @http('POST', '/signup')
    def signup(self, request):
        pass

    @http('POST', '/login')
    def login(self, request):
        pass

    @http('POST', '/battle')
    def new_game(self, request):
        pass

    @http('GET', '/leaderboard')
    def leaderboard(self, request):
        return json.dumps(self.score_rpc.leaderboard())

    @http('GET', '/user/<int:id>')
    def user(self, request):
        pass

    @http('GET', '/user/<int:id>/pokemons')
    def user_pokemons(self, request):
        pass

Add leaderbord rpc call and add request arg to all methods
Add leaderbord rpc call and add request arg to all methods

+ import json
+ 
  from nameko.web.handlers import http
+ from nameko.rpc import RpcProxy
  
  from pokebattle.scores import ScoreService
  
  
  class GameService(object):
- 
+     name = 'game_service'
-     score_service = RpcProxy('score_service')
+     score_rpc = RpcProxy('score_service')
  
      @http('POST', '/signup')
-     def signup(self):
+     def signup(self, request):
          pass
  
      @http('POST', '/login')
-     def login(self):
+     def login(self, request):
          pass
  
      @http('POST', '/battle')
-     def new_game(self):
+     def new_game(self, request):
          pass
  
      @http('GET', '/leaderboard')
-     def leaderboard(self):
+     def leaderboard(self, request):
-         pass
+         return json.dumps(self.score_rpc.leaderboard())
  
      @http('GET', '/user/<int:id>')
-     def user(self):
+     def user(self, request):
          pass
  
      @http('GET', '/user/<int:id>/pokemons')
-     def user_pokemons(self):
+     def user_pokemons(self, request):
          pass
  
Add leaderbord rpc call and add request arg to all methods
## Code Before:
from nameko.web.handlers import http

from pokebattle.scores import ScoreService


class GameService(object):

    score_service = RpcProxy('score_service')

    @http('POST', '/signup')
    def signup(self):
        pass

    @http('POST', '/login')
    def login(self):
        pass

    @http('POST', '/battle')
    def new_game(self):
        pass

    @http('GET', '/leaderboard')
    def leaderboard(self):
        pass

    @http('GET', '/user/<int:id>')
    def user(self):
        pass

    @http('GET', '/user/<int:id>/pokemons')
    def user_pokemons(self):
        pass

## Instruction:
Add leaderbord rpc call and add request arg to all methods
## Code After:
import json

from nameko.web.handlers import http
from nameko.rpc import RpcProxy

from pokebattle.scores import ScoreService


class GameService(object):
    name = 'game_service'
    score_rpc = RpcProxy('score_service')

    @http('POST', '/signup')
    def signup(self, request):
        pass

    @http('POST', '/login')
    def login(self, request):
        pass

    @http('POST', '/battle')
    def new_game(self, request):
        pass

    @http('GET', '/leaderboard')
    def leaderboard(self, request):
        return json.dumps(self.score_rpc.leaderboard())

    @http('GET', '/user/<int:id>')
    def user(self, request):
        pass

    @http('GET', '/user/<int:id>/pokemons')
    def user_pokemons(self, request):
        pass
