Class: Sidemash::Sdk::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/sidemash/sdk/auth.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, secret_key) ⇒ Auth

Returns a new instance of Auth.



25
26
27
28
29
# File 'lib/sidemash/sdk/auth.rb', line 25

def initialize(token, secret_key)
  @_type = 'Auth'
  @token = token
  @secret_key = secret_key
end

Instance Attribute Details

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



23
24
25
# File 'lib/sidemash/sdk/auth.rb', line 23

def secret_key
  @secret_key
end

#tokenObject (readonly)

Returns the value of attribute token.



22
23
24
# File 'lib/sidemash/sdk/auth.rb', line 22

def token
  @token
end

Class Method Details

._typeObject



31
32
33
# File 'lib/sidemash/sdk/auth.rb', line 31

def self._type
  'Auth'
end

.from_hash(h) ⇒ Object



61
62
63
64
# File 'lib/sidemash/sdk/auth.rb', line 61

def self.from_hash(h)
  Auth.new(h['token'],
           h['secret_key'])
end

.from_json(js) ⇒ Object



35
36
37
38
# File 'lib/sidemash/sdk/auth.rb', line 35

def self.from_json(js)
  h = JSON.parse(js)
  Auth.from_hash(h)
end

.from_remote(h) ⇒ Object



56
57
58
59
# File 'lib/sidemash/sdk/auth.rb', line 56

def self.from_remote(h)
  Auth.new(h['token'],
           h['secretKey'])
end

Instance Method Details

#to_hashObject



48
49
50
51
52
53
54
# File 'lib/sidemash/sdk/auth.rb', line 48

def to_hash
  result = {}
  result[:_type] = @_type
  result[:token] = @token
  result[:secret_key] = @secret_key
  result
end

#to_json(*a) ⇒ Object



66
67
68
# File 'lib/sidemash/sdk/auth.rb', line 66

def to_json(*a)
  to_hash.to_json(*a)
end

#to_remoteObject



40
41
42
43
44
45
46
# File 'lib/sidemash/sdk/auth.rb', line 40

def to_remote
  result = {}
  result[:_type] = @_type
  result[:token] = @token
  result[:secretKey] = @secret_key
  result
end

#to_sObject



70
71
72
73
# File 'lib/sidemash/sdk/auth.rb', line 70

def to_s
  ('Auth(token=' + @token +
        ', secret_key=******' +  ')')
end