Class: SelfSDK::Authenticated

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Authenticated

Returns a new instance of Authenticated.



7
8
9
10
11
12
13
# File 'lib/authenticated.rb', line 7

def initialize(payload)
  return if payload.nil?

  @payload = payload
  @uuid = payload[:cid]
  @selfsdk = payload[:sub]
end

Instance Attribute Details

#payloadObject

Returns the value of attribute payload.



5
6
7
# File 'lib/authenticated.rb', line 5

def payload
  @payload
end

#selfsdkObject

Returns the value of attribute selfsdk.



5
6
7
# File 'lib/authenticated.rb', line 5

def selfsdk
  @selfsdk
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/authenticated.rb', line 5

def status
  @status
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/authenticated.rb', line 5

def uuid
  @uuid
end

Instance Method Details

#accepted?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/authenticated.rb', line 15

def accepted?
  return false if @payload.nil?
  return false if @payload[:auth] != true

  @payload[:status] == "accepted"
end

#to_hashObject



22
23
24
25
26
# File 'lib/authenticated.rb', line 22

def to_hash
  { uuid: @uuid,
    selfsdk: @selfsdk,
    accepted: accepted? }
end