Module: XLiveServices
- Defined in:
- lib/xlive_services/utils.rb,
lib/xlive_services/xlive.rb,
lib/xlive_services/hresult.rb,
lib/xlive_services/version.rb,
lib/xlive_services/xlive_services.rb,
lib/xlive_services/marketplace_public.rb
Defined Under Namespace
Modules: Utils, WGX, XOnline
Classes: MarketplacePublic, XLive, XLiveServicesError
Constant Summary
collapse
- VERSION =
'0.0.2'
Class Method Summary
collapse
Class Method Details
.DoAuth(identity, serviceName, policy) ⇒ Object
26
27
28
|
# File 'lib/xlive_services/xlive_services.rb', line 26
def self.DoAuth(identity, serviceName, policy)
identity.GetService(serviceName, policy)
end
|
.GetLcwConfig(locale = 'en-US') ⇒ Object
8
9
10
11
12
13
|
# File 'lib/xlive_services/xlive_services.rb', line 8
def self.GetLcwConfig(locale = 'en-US')
raise XLiveServicesError.new('Invalid Locale!') if locale.nil? or locale.empty?
response = HTTPI.get(HTTPI::Request.new("https://live.xbox.com/#{locale}/GetLcwConfig.ashx"))
raise "Error! HTTP Status Code: #{response.code}" if response.error?
XLiveServices.ParseConfig(MultiXml.parse(response.body))
end
|
.GetUserAuthorization(url, userAuthService) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/xlive_services/xlive_services.rb', line 40
def self.GetUserAuthorization(url, userAuthService)
raise XLiveServicesError.new('Invalid AuthService Token!') if userAuthService.Token.nil? or userAuthService.Token.empty?
request = HTTPI::Request.new(url)
request.body = { :serviceType => 1, :titleId => 0 }
request.['Authorization'] = "WLID1.0 #{userAuthService.Token}"
request.['X-ClientType'] = 'panorama'
response = HTTPI.post(request)
raise "Error! HTTP Status Code: #{response.code} #{response.body}" if response.error?
MultiXml.parse(response.body)
end
|
.GetUserAuthService(identity, config) ⇒ Object
30
31
32
33
|
# File 'lib/xlive_services/xlive_services.rb', line 30
def self.GetUserAuthService(identity, config)
configData = config[:Auth][config[:URL][:GetUserAuth].last]
DoAuth(identity, configData[:ServiceName], configData[:Policy])
end
|
.GetWgxService(identity, config) ⇒ Object
35
36
37
38
|
# File 'lib/xlive_services/xlive_services.rb', line 35
def self.GetWgxService(identity, config)
configData = config[:Auth][config[:URL][:WgxService].last]
DoAuth(identity, configData[:ServiceName], configData[:Policy])
end
|
.ParseConfig(config) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/xlive_services/xlive_services.rb', line 15
def self.ParseConfig(config)
parsed = { :Auth => {}, :URL => {} }
config['Environment']['Authentication']['AuthSetting'].each do |setting|
parsed[:Auth][setting['name'].to_sym] = { ServiceName: setting['serviceName'], Policy: setting['policy'].to_sym }
end
config['Environment']['UrlSettings']['UrlSetting'].each do |setting|
parsed[:URL][setting['name'].to_sym] = [ setting['url'], setting['authKey'].empty? ? nil : setting['authKey'].to_sym ]
end
parsed
end
|
.UserLogout(config) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/xlive_services/xlive_services.rb', line 51
def self.UserLogout(config)
request = HTTPI::Request.new(config[:URL][:Logout].first)
response = HTTPI.get(request)
raise XLiveServicesError.new("Error! HTTP Status Code: #{response.code} #{response.body}") if response.error?
response.body
end
|