Class: RSynology::Client::Auth

Inherits:
API
  • Object
show all
Defined in:
lib/rsynology/client/auth.rb

Defined Under Namespace

Classes: AccountDisabledOrGuest, AccountNotSpecified, AuthenticationFailed, InvalidPassword

Instance Attribute Summary collapse

Attributes inherited from API

#minVersion, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from API

#api_name, #initialize, #request

Constructor Details

This class inherits a constructor from RSynology::Client::API

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/rsynology/client/auth.rb', line 4

def client
  @client
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



4
5
6
# File 'lib/rsynology/client/auth.rb', line 4

def endpoint
  @endpoint
end

#maxVersionObject (readonly)

Returns the value of attribute maxVersion.



4
5
6
# File 'lib/rsynology/client/auth.rb', line 4

def maxVersion
  @maxVersion
end

Class Method Details

.api_nameObject



8
9
10
# File 'lib/rsynology/client/auth.rb', line 8

def self.api_name
  'SYNO.API.Auth'
end

Instance Method Details

#login(account, password, session = nil, format = 'sid') ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rsynology/client/auth.rb', line 12

def (, password, session = nil, format = 'sid')
  params = {
    account: ,
    passwd: password,
    format: format,
  }
  params.merge!(session: session) if session

  response = request("Login", params)

  raise AuthenticationFailed if !response['success']

  client.session_id = response['data']['sid']
end

#logout(session) ⇒ Object



27
28
29
# File 'lib/rsynology/client/auth.rb', line 27

def logout(session)
  client.request(endpoint, {session: session})
end