Class: Authenticator::Client::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/authenticator/client/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
# File 'lib/authenticator/client/base.rb', line 8

def initialize(config)
  @api_key = config[:api_key]
  @api_password = config[:api_password]
  @host = config[:host]
  validate_variables
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



6
7
8
# File 'lib/authenticator/client/base.rb', line 6

def api_key
  @api_key
end

#api_passwordObject (readonly)

Returns the value of attribute api_password.



6
7
8
# File 'lib/authenticator/client/base.rb', line 6

def api_password
  @api_password
end

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/authenticator/client/base.rb', line 6

def host
  @host
end

Instance Method Details

#allObject



15
16
17
18
# File 'lib/authenticator/client/base.rb', line 15

def all
  uri = 
  RestClient.get uri, params: auth_params
end

#authenticate(account) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/authenticator/client/base.rb', line 35

def authenticate()
  uri = authenticate_path
  RestClient.post(
    uri,
    auth_params.merge(.to_params).to_json,
    content_type: :json,
    accept: :json
  )
end

#create(account) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/authenticator/client/base.rb', line 25

def create()
  uri = 
  RestClient.post(
    uri,
    auth_params.merge(.to_params).to_json,
    content_type: :json,
    accept: :json
  )
end

#destroy(id) ⇒ Object



55
56
57
58
59
60
# File 'lib/authenticator/client/base.rb', line 55

def destroy(id)
  uri = (id)
  RestClient.delete(
    uri, params: auth_params
  )
end

#show(id) ⇒ Object



20
21
22
23
# File 'lib/authenticator/client/base.rb', line 20

def show(id)
  uri = (id)
  RestClient.get uri, params: auth_params
end

#update(id, account) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/authenticator/client/base.rb', line 45

def update(id, )
  uri = (id)
  RestClient.put(
    uri,
    auth_params.merge(.to_params).to_json,
    content_type: :json,
    accept: :json
  )
end