Class: XLiveServices::XLive
- Inherits:
-
Object
- Object
- XLiveServices::XLive
- Defined in:
- lib/xlive_services/xlive.rb
Constant Summary collapse
- LiveIdGUID =
'{D34F9E47-A73B-44E5-AE67-5D0D8B8CFA76}'
- LiveIdVersion =
1
Instance Attribute Summary collapse
-
#Config ⇒ Object
readonly
Returns the value of attribute Config.
-
#Identity ⇒ Object
readonly
Returns the value of attribute Identity.
-
#Live ⇒ Object
readonly
Returns the value of attribute Live.
-
#Locale ⇒ Object
readonly
Returns the value of attribute Locale.
-
#Username ⇒ Object
readonly
Returns the value of attribute Username.
Instance Method Summary collapse
- #Authenticate ⇒ Object
- #GetMarketplace ⇒ Object
- #GetUserAuthorizationInfo ⇒ Object
- #GetUserAuthService ⇒ Object
- #GetWgxService ⇒ Object
-
#initialize(username = nil, password = nil, locale = nil) ⇒ XLive
constructor
A new instance of XLive.
- #IsAuthenticated? ⇒ Boolean
- #PersistCredentials ⇒ Object
- #RemovePersistedCredentials ⇒ Object
Constructor Details
#initialize(username = nil, password = nil, locale = nil) ⇒ XLive
Returns a new instance of XLive.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/xlive_services/xlive.rb', line 10 def initialize(username = nil, password = nil, locale = nil) @Locale = 'en-US' @Locale = locale if locale @Config = XLiveServices.GetLcwConfig(@Locale) @Live = LiveIdentity.new(LiveIdGUID, LiveIdVersion, :NO_UI, { :IDCRL_OPTION_ENVIRONMENT => 'Production' }) if username.nil? identities = @Live.GetIdentities(LiveIdentity::PPCRL_CREDTYPE_PASSWORD) @Username = identities.GetNextIdentityName if !@Username identities = @Live.GetIdentities(LiveIdentity::PPCRL_CREDTYPE_MEMBERNAMEONLY) @Username = identities.GetNextIdentityName end raise XLiveServicesError.new('No Username!') unless @Username else @Username = username end @Identity = @Live.GetIdentity(@Username, :IDENTITY_SHARE_ALL) if !@Identity.HasPersistedCredential?(LiveIdentity::PPCRL_CREDTYPE_MEMBERNAMEONLY) @Identity.SetCredential(LiveIdentity::PPCRL_CREDTYPE_MEMBERNAMEONLY, @Username) end if password @Identity.SetCredential(LiveIdentity::PPCRL_CREDTYPE_PASSWORD, password) elsif !@Identity.HasPersistedCredential?(LiveIdentity::PPCRL_CREDTYPE_PASSWORD) raise XLiveServicesError.new("No Password for #{@Username}!") end end |
Instance Attribute Details
#Config ⇒ Object (readonly)
Returns the value of attribute Config.
6 7 8 |
# File 'lib/xlive_services/xlive.rb', line 6 def Config @Config end |
#Identity ⇒ Object (readonly)
Returns the value of attribute Identity.
8 9 10 |
# File 'lib/xlive_services/xlive.rb', line 8 def Identity @Identity end |
#Live ⇒ Object (readonly)
Returns the value of attribute Live.
7 8 9 |
# File 'lib/xlive_services/xlive.rb', line 7 def Live @Live end |
#Locale ⇒ Object (readonly)
Returns the value of attribute Locale.
5 6 7 |
# File 'lib/xlive_services/xlive.rb', line 5 def Locale @Locale end |
#Username ⇒ Object (readonly)
Returns the value of attribute Username.
9 10 11 |
# File 'lib/xlive_services/xlive.rb', line 9 def Username @Username end |
Instance Method Details
#Authenticate ⇒ Object
54 55 56 57 |
# File 'lib/xlive_services/xlive.rb', line 54 def Authenticate return if IsAuthenticated?() @Identity.Authenticate(nil, :LOGONIDENTITY_ALLOW_PERSISTENT_COOKIES) end |
#GetMarketplace ⇒ Object
72 73 74 75 |
# File 'lib/xlive_services/xlive.rb', line 72 def GetMarketplace # Alternative service url https://services.gamesforwindows.com/SecurePublic/MarketplaceRestSecure.svc XLiveServices::MarketplacePublic.new(@Config[:URL][:WgxService].first, GetWgxService()) end |
#GetUserAuthorizationInfo ⇒ Object
63 64 65 66 |
# File 'lib/xlive_services/xlive.rb', line 63 def GetUserAuthorizationInfo userAuthorization = XLiveServices.GetUserAuthorization(@Config[:URL][:GetUserAuth].first, GetUserAuthService()) userAuthorization['GetUserAuthorizationInfo'] end |
#GetUserAuthService ⇒ Object
59 60 61 |
# File 'lib/xlive_services/xlive.rb', line 59 def GetUserAuthService @GetUserAuthService ||= XLiveServices.GetUserAuthService(@Identity, @Config) end |
#GetWgxService ⇒ Object
68 69 70 |
# File 'lib/xlive_services/xlive.rb', line 68 def GetWgxService @WgxService ||= XLiveServices.GetWgxService(@Identity, @Config) end |
#IsAuthenticated? ⇒ Boolean
50 51 52 |
# File 'lib/xlive_services/xlive.rb', line 50 def IsAuthenticated? @Identity.IsAuthenticated? end |
#PersistCredentials ⇒ Object
40 41 42 43 |
# File 'lib/xlive_services/xlive.rb', line 40 def PersistCredentials @Identity.PersistCredential(LiveIdentity::PPCRL_CREDTYPE_MEMBERNAMEONLY) @Identity.PersistCredential(LiveIdentity::PPCRL_CREDTYPE_PASSWORD) end |
#RemovePersistedCredentials ⇒ Object
45 46 47 48 |
# File 'lib/xlive_services/xlive.rb', line 45 def RemovePersistedCredentials @Identity.RemovePersistedCredential(LiveIdentity::PPCRL_CREDTYPE_PASSWORD) @Identity.RemovePersistedCredential(LiveIdentity::PPCRL_CREDTYPE_MEMBERNAMEONLY) end |