Permalink
Browse files

Working call that should fail according to question.

  • Loading branch information...
1 parent 452dd06 commit 3379df39e4dade254e89b50331a83023199b3989 @dhermes committed Mar 18, 2013
Showing with 30 additions and 1 deletion.
  1. +12 −1 static/js/base.js
  2. +7 −0 tictactoe_api.py
  3. +11 −0 tictactoe_api_messages.py
View
@@ -347,6 +347,7 @@ google.devrel.samples.ttt.getStringsAtPositions = function(boardString, first,
* Initializes the application.
* @param {string} apiRoot Root of the API's path.
*/
+google.devrel.samples.ttt.globalVar;
google.devrel.samples.ttt.init = function(apiRoot) {
// Loads the OAuth and Tic Tac Toe APIs asynchronously, and triggers login
// when they have completed.
@@ -357,9 +358,19 @@ google.devrel.samples.ttt.init = function(apiRoot) {
google.devrel.samples.ttt.userAuthed);
}
}
+ var callbackAlt = function() {
+ var payload = {g:"Test", u:0, l:{x:4,y:4}};
+ gapi.client.tictactoe.total.total(payload).execute(function(resp) {
+ google.devrel.samples.ttt.globalVar = resp;
+ });
+ if (--apisToLoad == 0) {
+ google.devrel.samples.ttt.signin(true,
+ google.devrel.samples.ttt.userAuthed);
+ }
+ }
apisToLoad = 2; // must match number of calls to gapi.client.load()
- gapi.client.load('tictactoe', 'v1', callback, apiRoot);
+ gapi.client.load('tictactoe', 'v1', callbackAlt, apiRoot);
gapi.client.load('oauth2', 'v2', callback);
var buttons = document.querySelectorAll('td');
View
@@ -29,6 +29,7 @@
from tictactoe_api_messages import ScoresListResponse
from tictactoe_api_messages import ScoreRequestMessage
from tictactoe_api_messages import ScoreResponseMessage
+from tictactoe_api_messages import Total
CLIENT_ID = 'YOUR-CLIENT-ID'
@@ -120,6 +121,12 @@ def scores_insert(self, request):
entity = Score.put_from_message(request)
return entity.to_message()
+ @endpoints.method(Total, Total,
+ path='total', http_method='POST',
+ name='total.total')
+ def total(self, request):
+ return request
+
APPLICATION = endpoints.api_server([TicTacToeApi],
restricted=False)
View
@@ -49,3 +49,14 @@ class ScoreResponseMessage(messages.Message):
class ScoresListResponse(messages.Message):
"""ProtoRPC message definition to represent a list of stored scores."""
items = messages.MessageField(ScoreResponseMessage, 1, repeated=True)
+
+
+class LeftRight(messages.Message):
+ x = messages.IntegerField(1)
+ y = messages.IntegerField(2)
+
+
+class Total(messages.Message):
+ g = messages.StringField(1)
+ u = messages.IntegerField(2)
+ l = messages.MessageField(LeftRight, 3)

0 comments on commit 3379df3

Please sign in to comment.