Class: Mobile::Version::Thrift::ThriftVersionManageService

Inherits:
Object
  • Object
show all
Defined in:
lib/mobile_version_thrift_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ ThriftVersionManageService

Returns a new instance of ThriftVersionManageService.



34
35
36
37
38
39
40
41
42
43
# File 'lib/mobile_version_thrift_client.rb', line 34

def initialize(config = {})
	if config['servers'].nil?
		raise 'servers must be determined!'
		return
	end
	config = DEFAULT_CONFIG.merge(config)
	config['client_class'] = 'Mobile::Version::Thrift::RemoteVersionManageService::Client'
	@thrift_client = ThriftClient.new(config)
	@@logger = LoggerFactory.getLogger("mobile-version-client")
end

Instance Method Details

#addAppHistory(app_definition = {}, version = nil, apiVersion = 1, downloadUrl = nil) ⇒ Object



73
74
75
76
# File 'lib/mobile_version_thrift_client.rb', line 73

def addAppHistory(app_definition={}, version=nil, apiVersion=1,downloadUrl=nil)
	app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
	return @thrift_client.addAppHistory(app_definition_struct, version, apiVersion, downloadUrl)
end

#addAppProduct(app_definition = {}) ⇒ Object



68
69
70
71
# File 'lib/mobile_version_thrift_client.rb', line 68

def addAppProduct(app_definition={})
	app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
	return @thrift_client.addAppProduct(app_definition_struct)
end

#checkForUpgrade(app_definition = {}, version = nil, device_id = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/mobile_version_thrift_client.rb', line 55

def checkForUpgrade(app_definition={}, version=nil, device_id=nil)
	if app_definition['appId'].nil? || app_definition['appId'].to_i <= 0 || version.nil? || device_id.nil?
		raise 'appId, version, device_id can not be null!'
	end
	app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
	return @thrift_client.checkForUpgrade(app_definition_struct, version, device_id)
end

#destoryObject



45
46
47
48
49
50
51
52
53
# File 'lib/mobile_version_thrift_client.rb', line 45

def destory
	@@logger.error("before version manage thrift service destory!!")
	begin
		@thrift_client.destory
	rescue Exception => e
		@logger.error("version manage thrfit service destory error !#{e.message}" + "\n" + e.backtrace.join("\n"))
	end
	@logger.error("version manage thrift service destroyed!!")
end

#getSecurityToken(app_definition = {}, version = nil) ⇒ Object



63
64
65
66
# File 'lib/mobile_version_thrift_client.rb', line 63

def getSecurityToken(app_definition={}, version=nil)
	app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
	return @thrift_client.getSecurityToken(app_definition_struct, version)
end

#isSpecialVersionOfProductExist(product_id, version) ⇒ Object



83
84
85
# File 'lib/mobile_version_thrift_client.rb', line 83

def isSpecialVersionOfProductExist(product_id, version)
	return @thrift_client.isSpecialVersionOfProductExist(product_id, version)
end

#queryDeterminedAppProduct(app_definition = {}) ⇒ Object



78
79
80
81
# File 'lib/mobile_version_thrift_client.rb', line 78

def queryDeterminedAppProduct(app_definition={})
	app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
	return @thrift_client.queryDeterminedAppProduct(app_definition_struct)
end