mirror of
https://github.com/liberliber/LINE-KickBot1.git
synced 2024-11-10 08:55:33 +08:00
538 lines
17 KiB
JavaScript
538 lines
17 KiB
JavaScript
//
|
|
// Autogenerated by Thrift Compiler (0.10.0)
|
|
//
|
|
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
//
|
|
"use strict";
|
|
|
|
var thrift = require('thrift');
|
|
var Thrift = thrift.Thrift;
|
|
var Q = thrift.Q;
|
|
|
|
|
|
var ttypes = require('./line_types');
|
|
//HELPER FUNCTIONS AND STRUCTURES
|
|
|
|
var SpotService_lookupByPhoneNumber_args = function(args) {
|
|
this.countryAreaCode = null;
|
|
this.phoneNumber = null;
|
|
if (args) {
|
|
if (args.countryAreaCode !== undefined && args.countryAreaCode !== null) {
|
|
this.countryAreaCode = args.countryAreaCode;
|
|
}
|
|
if (args.phoneNumber !== undefined && args.phoneNumber !== null) {
|
|
this.phoneNumber = args.phoneNumber;
|
|
}
|
|
}
|
|
};
|
|
SpotService_lookupByPhoneNumber_args.prototype = {};
|
|
SpotService_lookupByPhoneNumber_args.prototype.read = function(input) {
|
|
input.readStructBegin();
|
|
while (true)
|
|
{
|
|
var ret = input.readFieldBegin();
|
|
var fname = ret.fname;
|
|
var ftype = ret.ftype;
|
|
var fid = ret.fid;
|
|
if (ftype == Thrift.Type.STOP) {
|
|
break;
|
|
}
|
|
switch (fid)
|
|
{
|
|
case 2:
|
|
if (ftype == Thrift.Type.STRING) {
|
|
this.countryAreaCode = input.readString();
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
case 3:
|
|
if (ftype == Thrift.Type.STRING) {
|
|
this.phoneNumber = input.readString();
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
default:
|
|
input.skip(ftype);
|
|
}
|
|
input.readFieldEnd();
|
|
}
|
|
input.readStructEnd();
|
|
return;
|
|
};
|
|
|
|
SpotService_lookupByPhoneNumber_args.prototype.write = function(output) {
|
|
output.writeStructBegin('SpotService_lookupByPhoneNumber_args');
|
|
if (this.countryAreaCode !== null && this.countryAreaCode !== undefined) {
|
|
output.writeFieldBegin('countryAreaCode', Thrift.Type.STRING, 2);
|
|
output.writeString(this.countryAreaCode);
|
|
output.writeFieldEnd();
|
|
}
|
|
if (this.phoneNumber !== null && this.phoneNumber !== undefined) {
|
|
output.writeFieldBegin('phoneNumber', Thrift.Type.STRING, 3);
|
|
output.writeString(this.phoneNumber);
|
|
output.writeFieldEnd();
|
|
}
|
|
output.writeFieldStop();
|
|
output.writeStructEnd();
|
|
return;
|
|
};
|
|
|
|
var SpotService_lookupByPhoneNumber_result = function(args) {
|
|
this.success = null;
|
|
this.e = null;
|
|
if (args instanceof ttypes.TalkException) {
|
|
this.e = args;
|
|
return;
|
|
}
|
|
if (args) {
|
|
if (args.success !== undefined && args.success !== null) {
|
|
this.success = new ttypes.SpotPhoneNumberResponse(args.success);
|
|
}
|
|
if (args.e !== undefined && args.e !== null) {
|
|
this.e = args.e;
|
|
}
|
|
}
|
|
};
|
|
SpotService_lookupByPhoneNumber_result.prototype = {};
|
|
SpotService_lookupByPhoneNumber_result.prototype.read = function(input) {
|
|
input.readStructBegin();
|
|
while (true)
|
|
{
|
|
var ret = input.readFieldBegin();
|
|
var fname = ret.fname;
|
|
var ftype = ret.ftype;
|
|
var fid = ret.fid;
|
|
if (ftype == Thrift.Type.STOP) {
|
|
break;
|
|
}
|
|
switch (fid)
|
|
{
|
|
case 0:
|
|
if (ftype == Thrift.Type.STRUCT) {
|
|
this.success = new ttypes.SpotPhoneNumberResponse();
|
|
this.success.read(input);
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
case 1:
|
|
if (ftype == Thrift.Type.STRUCT) {
|
|
this.e = new ttypes.TalkException();
|
|
this.e.read(input);
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
default:
|
|
input.skip(ftype);
|
|
}
|
|
input.readFieldEnd();
|
|
}
|
|
input.readStructEnd();
|
|
return;
|
|
};
|
|
|
|
SpotService_lookupByPhoneNumber_result.prototype.write = function(output) {
|
|
output.writeStructBegin('SpotService_lookupByPhoneNumber_result');
|
|
if (this.success !== null && this.success !== undefined) {
|
|
output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
|
|
this.success.write(output);
|
|
output.writeFieldEnd();
|
|
}
|
|
if (this.e !== null && this.e !== undefined) {
|
|
output.writeFieldBegin('e', Thrift.Type.STRUCT, 1);
|
|
this.e.write(output);
|
|
output.writeFieldEnd();
|
|
}
|
|
output.writeFieldStop();
|
|
output.writeStructEnd();
|
|
return;
|
|
};
|
|
|
|
var SpotService_lookupNearby_args = function(args) {
|
|
this.location = null;
|
|
this.category = null;
|
|
this.query = null;
|
|
this.countryAreaCode = null;
|
|
if (args) {
|
|
if (args.location !== undefined && args.location !== null) {
|
|
this.location = new ttypes.Location(args.location);
|
|
}
|
|
if (args.category !== undefined && args.category !== null) {
|
|
this.category = args.category;
|
|
}
|
|
if (args.query !== undefined && args.query !== null) {
|
|
this.query = args.query;
|
|
}
|
|
if (args.countryAreaCode !== undefined && args.countryAreaCode !== null) {
|
|
this.countryAreaCode = args.countryAreaCode;
|
|
}
|
|
}
|
|
};
|
|
SpotService_lookupNearby_args.prototype = {};
|
|
SpotService_lookupNearby_args.prototype.read = function(input) {
|
|
input.readStructBegin();
|
|
while (true)
|
|
{
|
|
var ret = input.readFieldBegin();
|
|
var fname = ret.fname;
|
|
var ftype = ret.ftype;
|
|
var fid = ret.fid;
|
|
if (ftype == Thrift.Type.STOP) {
|
|
break;
|
|
}
|
|
switch (fid)
|
|
{
|
|
case 2:
|
|
if (ftype == Thrift.Type.STRUCT) {
|
|
this.location = new ttypes.Location();
|
|
this.location.read(input);
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
case 3:
|
|
if (ftype == Thrift.Type.I32) {
|
|
this.category = input.readI32();
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
case 4:
|
|
if (ftype == Thrift.Type.STRING) {
|
|
this.query = input.readString();
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
case 5:
|
|
if (ftype == Thrift.Type.STRING) {
|
|
this.countryAreaCode = input.readString();
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
default:
|
|
input.skip(ftype);
|
|
}
|
|
input.readFieldEnd();
|
|
}
|
|
input.readStructEnd();
|
|
return;
|
|
};
|
|
|
|
SpotService_lookupNearby_args.prototype.write = function(output) {
|
|
output.writeStructBegin('SpotService_lookupNearby_args');
|
|
if (this.location !== null && this.location !== undefined) {
|
|
output.writeFieldBegin('location', Thrift.Type.STRUCT, 2);
|
|
this.location.write(output);
|
|
output.writeFieldEnd();
|
|
}
|
|
if (this.category !== null && this.category !== undefined) {
|
|
output.writeFieldBegin('category', Thrift.Type.I32, 3);
|
|
output.writeI32(this.category);
|
|
output.writeFieldEnd();
|
|
}
|
|
if (this.query !== null && this.query !== undefined) {
|
|
output.writeFieldBegin('query', Thrift.Type.STRING, 4);
|
|
output.writeString(this.query);
|
|
output.writeFieldEnd();
|
|
}
|
|
if (this.countryAreaCode !== null && this.countryAreaCode !== undefined) {
|
|
output.writeFieldBegin('countryAreaCode', Thrift.Type.STRING, 5);
|
|
output.writeString(this.countryAreaCode);
|
|
output.writeFieldEnd();
|
|
}
|
|
output.writeFieldStop();
|
|
output.writeStructEnd();
|
|
return;
|
|
};
|
|
|
|
var SpotService_lookupNearby_result = function(args) {
|
|
this.success = null;
|
|
this.e = null;
|
|
if (args instanceof ttypes.TalkException) {
|
|
this.e = args;
|
|
return;
|
|
}
|
|
if (args) {
|
|
if (args.success !== undefined && args.success !== null) {
|
|
this.success = new ttypes.SpotNearbyResponse(args.success);
|
|
}
|
|
if (args.e !== undefined && args.e !== null) {
|
|
this.e = args.e;
|
|
}
|
|
}
|
|
};
|
|
SpotService_lookupNearby_result.prototype = {};
|
|
SpotService_lookupNearby_result.prototype.read = function(input) {
|
|
input.readStructBegin();
|
|
while (true)
|
|
{
|
|
var ret = input.readFieldBegin();
|
|
var fname = ret.fname;
|
|
var ftype = ret.ftype;
|
|
var fid = ret.fid;
|
|
if (ftype == Thrift.Type.STOP) {
|
|
break;
|
|
}
|
|
switch (fid)
|
|
{
|
|
case 0:
|
|
if (ftype == Thrift.Type.STRUCT) {
|
|
this.success = new ttypes.SpotNearbyResponse();
|
|
this.success.read(input);
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
case 1:
|
|
if (ftype == Thrift.Type.STRUCT) {
|
|
this.e = new ttypes.TalkException();
|
|
this.e.read(input);
|
|
} else {
|
|
input.skip(ftype);
|
|
}
|
|
break;
|
|
default:
|
|
input.skip(ftype);
|
|
}
|
|
input.readFieldEnd();
|
|
}
|
|
input.readStructEnd();
|
|
return;
|
|
};
|
|
|
|
SpotService_lookupNearby_result.prototype.write = function(output) {
|
|
output.writeStructBegin('SpotService_lookupNearby_result');
|
|
if (this.success !== null && this.success !== undefined) {
|
|
output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
|
|
this.success.write(output);
|
|
output.writeFieldEnd();
|
|
}
|
|
if (this.e !== null && this.e !== undefined) {
|
|
output.writeFieldBegin('e', Thrift.Type.STRUCT, 1);
|
|
this.e.write(output);
|
|
output.writeFieldEnd();
|
|
}
|
|
output.writeFieldStop();
|
|
output.writeStructEnd();
|
|
return;
|
|
};
|
|
|
|
var SpotServiceClient = exports.Client = function(output, pClass) {
|
|
this.output = output;
|
|
this.pClass = pClass;
|
|
this._seqid = 0;
|
|
this._reqs = {};
|
|
};
|
|
SpotServiceClient.prototype = {};
|
|
SpotServiceClient.prototype.seqid = function() { return this._seqid; };
|
|
SpotServiceClient.prototype.new_seqid = function() { return this._seqid += 1; };
|
|
SpotServiceClient.prototype.lookupByPhoneNumber = function(countryAreaCode, phoneNumber, callback) {
|
|
this._seqid = this.new_seqid();
|
|
if (callback === undefined) {
|
|
var _defer = Q.defer();
|
|
this._reqs[this.seqid()] = function(error, result) {
|
|
if (error) {
|
|
_defer.reject(error);
|
|
} else {
|
|
_defer.resolve(result);
|
|
}
|
|
};
|
|
this.send_lookupByPhoneNumber(countryAreaCode, phoneNumber);
|
|
return _defer.promise;
|
|
} else {
|
|
this._reqs[this.seqid()] = callback;
|
|
this.send_lookupByPhoneNumber(countryAreaCode, phoneNumber);
|
|
}
|
|
};
|
|
|
|
SpotServiceClient.prototype.send_lookupByPhoneNumber = function(countryAreaCode, phoneNumber) {
|
|
var output = new this.pClass(this.output);
|
|
output.writeMessageBegin('lookupByPhoneNumber', Thrift.MessageType.CALL, this.seqid());
|
|
var args = new SpotService_lookupByPhoneNumber_args();
|
|
args.countryAreaCode = countryAreaCode;
|
|
args.phoneNumber = phoneNumber;
|
|
args.write(output);
|
|
output.writeMessageEnd();
|
|
return this.output.flush();
|
|
};
|
|
|
|
SpotServiceClient.prototype.recv_lookupByPhoneNumber = function(input,mtype,rseqid) {
|
|
var callback = this._reqs[rseqid] || function() {};
|
|
delete this._reqs[rseqid];
|
|
if (mtype == Thrift.MessageType.EXCEPTION) {
|
|
var x = new Thrift.TApplicationException();
|
|
x.read(input);
|
|
input.readMessageEnd();
|
|
return callback(x);
|
|
}
|
|
var result = new SpotService_lookupByPhoneNumber_result();
|
|
result.read(input);
|
|
input.readMessageEnd();
|
|
|
|
if (null !== result.e) {
|
|
return callback(result.e);
|
|
}
|
|
if (null !== result.success) {
|
|
return callback(null, result.success);
|
|
}
|
|
return callback('lookupByPhoneNumber failed: unknown result');
|
|
};
|
|
SpotServiceClient.prototype.lookupNearby = function(location, category, query, countryAreaCode, callback) {
|
|
this._seqid = this.new_seqid();
|
|
if (callback === undefined) {
|
|
var _defer = Q.defer();
|
|
this._reqs[this.seqid()] = function(error, result) {
|
|
if (error) {
|
|
_defer.reject(error);
|
|
} else {
|
|
_defer.resolve(result);
|
|
}
|
|
};
|
|
this.send_lookupNearby(location, category, query, countryAreaCode);
|
|
return _defer.promise;
|
|
} else {
|
|
this._reqs[this.seqid()] = callback;
|
|
this.send_lookupNearby(location, category, query, countryAreaCode);
|
|
}
|
|
};
|
|
|
|
SpotServiceClient.prototype.send_lookupNearby = function(location, category, query, countryAreaCode) {
|
|
var output = new this.pClass(this.output);
|
|
output.writeMessageBegin('lookupNearby', Thrift.MessageType.CALL, this.seqid());
|
|
var args = new SpotService_lookupNearby_args();
|
|
args.location = location;
|
|
args.category = category;
|
|
args.query = query;
|
|
args.countryAreaCode = countryAreaCode;
|
|
args.write(output);
|
|
output.writeMessageEnd();
|
|
return this.output.flush();
|
|
};
|
|
|
|
SpotServiceClient.prototype.recv_lookupNearby = function(input,mtype,rseqid) {
|
|
var callback = this._reqs[rseqid] || function() {};
|
|
delete this._reqs[rseqid];
|
|
if (mtype == Thrift.MessageType.EXCEPTION) {
|
|
var x = new Thrift.TApplicationException();
|
|
x.read(input);
|
|
input.readMessageEnd();
|
|
return callback(x);
|
|
}
|
|
var result = new SpotService_lookupNearby_result();
|
|
result.read(input);
|
|
input.readMessageEnd();
|
|
|
|
if (null !== result.e) {
|
|
return callback(result.e);
|
|
}
|
|
if (null !== result.success) {
|
|
return callback(null, result.success);
|
|
}
|
|
return callback('lookupNearby failed: unknown result');
|
|
};
|
|
var SpotServiceProcessor = exports.Processor = function(handler) {
|
|
this._handler = handler;
|
|
}
|
|
;
|
|
SpotServiceProcessor.prototype.process = function(input, output) {
|
|
var r = input.readMessageBegin();
|
|
if (this['process_' + r.fname]) {
|
|
return this['process_' + r.fname].call(this, r.rseqid, input, output);
|
|
} else {
|
|
input.skip(Thrift.Type.STRUCT);
|
|
input.readMessageEnd();
|
|
var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
|
|
output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
|
|
x.write(output);
|
|
output.writeMessageEnd();
|
|
output.flush();
|
|
}
|
|
}
|
|
;
|
|
SpotServiceProcessor.prototype.process_lookupByPhoneNumber = function(seqid, input, output) {
|
|
var args = new SpotService_lookupByPhoneNumber_args();
|
|
args.read(input);
|
|
input.readMessageEnd();
|
|
if (this._handler.lookupByPhoneNumber.length === 2) {
|
|
Q.fcall(this._handler.lookupByPhoneNumber, args.countryAreaCode, args.phoneNumber)
|
|
.then(function(result) {
|
|
var result_obj = new SpotService_lookupByPhoneNumber_result({success: result});
|
|
output.writeMessageBegin("lookupByPhoneNumber", Thrift.MessageType.REPLY, seqid);
|
|
result_obj.write(output);
|
|
output.writeMessageEnd();
|
|
output.flush();
|
|
}, function (err) {
|
|
var result;
|
|
if (err instanceof ttypes.TalkException) {
|
|
result = new SpotService_lookupByPhoneNumber_result(err);
|
|
output.writeMessageBegin("lookupByPhoneNumber", Thrift.MessageType.REPLY, seqid);
|
|
} else {
|
|
result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
|
output.writeMessageBegin("lookupByPhoneNumber", Thrift.MessageType.EXCEPTION, seqid);
|
|
}
|
|
result.write(output);
|
|
output.writeMessageEnd();
|
|
output.flush();
|
|
});
|
|
} else {
|
|
this._handler.lookupByPhoneNumber(args.countryAreaCode, args.phoneNumber, function (err, result) {
|
|
var result_obj;
|
|
if ((err === null || typeof err === 'undefined') || err instanceof ttypes.TalkException) {
|
|
result_obj = new SpotService_lookupByPhoneNumber_result((err !== null || typeof err === 'undefined') ? err : {success: result});
|
|
output.writeMessageBegin("lookupByPhoneNumber", Thrift.MessageType.REPLY, seqid);
|
|
} else {
|
|
result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
|
output.writeMessageBegin("lookupByPhoneNumber", Thrift.MessageType.EXCEPTION, seqid);
|
|
}
|
|
result_obj.write(output);
|
|
output.writeMessageEnd();
|
|
output.flush();
|
|
});
|
|
}
|
|
};
|
|
SpotServiceProcessor.prototype.process_lookupNearby = function(seqid, input, output) {
|
|
var args = new SpotService_lookupNearby_args();
|
|
args.read(input);
|
|
input.readMessageEnd();
|
|
if (this._handler.lookupNearby.length === 4) {
|
|
Q.fcall(this._handler.lookupNearby, args.location, args.category, args.query, args.countryAreaCode)
|
|
.then(function(result) {
|
|
var result_obj = new SpotService_lookupNearby_result({success: result});
|
|
output.writeMessageBegin("lookupNearby", Thrift.MessageType.REPLY, seqid);
|
|
result_obj.write(output);
|
|
output.writeMessageEnd();
|
|
output.flush();
|
|
}, function (err) {
|
|
var result;
|
|
if (err instanceof ttypes.TalkException) {
|
|
result = new SpotService_lookupNearby_result(err);
|
|
output.writeMessageBegin("lookupNearby", Thrift.MessageType.REPLY, seqid);
|
|
} else {
|
|
result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
|
output.writeMessageBegin("lookupNearby", Thrift.MessageType.EXCEPTION, seqid);
|
|
}
|
|
result.write(output);
|
|
output.writeMessageEnd();
|
|
output.flush();
|
|
});
|
|
} else {
|
|
this._handler.lookupNearby(args.location, args.category, args.query, args.countryAreaCode, function (err, result) {
|
|
var result_obj;
|
|
if ((err === null || typeof err === 'undefined') || err instanceof ttypes.TalkException) {
|
|
result_obj = new SpotService_lookupNearby_result((err !== null || typeof err === 'undefined') ? err : {success: result});
|
|
output.writeMessageBegin("lookupNearby", Thrift.MessageType.REPLY, seqid);
|
|
} else {
|
|
result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
|
output.writeMessageBegin("lookupNearby", Thrift.MessageType.EXCEPTION, seqid);
|
|
}
|
|
result_obj.write(output);
|
|
output.writeMessageEnd();
|
|
output.flush();
|
|
});
|
|
}
|
|
};
|