OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library user_service; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:protobuf/protobuf.dart'; |
| 10 |
| 11 import '../../api/errors.dart'; |
| 12 import '../protobuf_api/internal/user_service.pb.dart' as pb; |
| 13 import 'rpc/rpc_service.dart'; |
| 14 |
| 15 class UserServiceClientRPCStub { |
| 16 final RPCService _rpcService; |
| 17 final String _ticket; |
| 18 |
| 19 UserServiceClientRPCStub(this._rpcService, this._ticket); |
| 20 |
| 21 Future<pb.CreateLoginURLResponse> |
| 22 CreateLoginURL(pb.CreateLoginURLRequest request) { |
| 23 return _rpcService.call( |
| 24 'user', 'CreateLoginURL', request.writeToBuffer(), ticket: _ticket) |
| 25 .then((List<int> response) { |
| 26 try { |
| 27 return new pb.CreateLoginURLResponse.fromBuffer(response); |
| 28 } on InvalidProtocolBufferException catch (error) { |
| 29 throw ProtocolError.INVALID_RESPONSE; |
| 30 } |
| 31 }); |
| 32 } |
| 33 |
| 34 Future<pb.CreateLogoutURLResponse> |
| 35 CreateLogoutURL(pb.CreateLogoutURLRequest request) { |
| 36 return _rpcService.call( |
| 37 'user', 'CreateLogoutURL', request.writeToBuffer(), ticket: _ticket) |
| 38 .then((List<int> response) { |
| 39 try { |
| 40 return new pb.CreateLogoutURLResponse.fromBuffer(response); |
| 41 } on InvalidProtocolBufferException catch (error) { |
| 42 throw ProtocolError.INVALID_RESPONSE; |
| 43 } |
| 44 }); |
| 45 } |
| 46 |
| 47 Future<pb.GetOAuthUserResponse> |
| 48 GetOAuthUser(pb.GetOAuthUserRequest request) { |
| 49 return _rpcService.call( |
| 50 'user', 'GetOAuthUser', request.writeToBuffer(), ticket: _ticket) |
| 51 .then((List<int> response) { |
| 52 try { |
| 53 return new pb.GetOAuthUserResponse.fromBuffer(response); |
| 54 } on InvalidProtocolBufferException catch (error) { |
| 55 throw ProtocolError.INVALID_RESPONSE; |
| 56 } |
| 57 }); |
| 58 } |
| 59 |
| 60 Future<pb.CheckOAuthSignatureResponse> |
| 61 CheckOAuthSignature(pb.CheckOAuthSignatureRequest request) { |
| 62 return _rpcService.call( |
| 63 'user', 'CheckOAuthSignature', request.writeToBuffer(), ticket: _ticket) |
| 64 .then((List<int> response) { |
| 65 try { |
| 66 return new pb.CheckOAuthSignatureResponse.fromBuffer(response); |
| 67 } on InvalidProtocolBufferException catch (error) { |
| 68 throw ProtocolError.INVALID_RESPONSE; |
| 69 } |
| 70 }); |
| 71 } |
| 72 } |
OLD | NEW |