Class: Authenticator::Client::Base
- Inherits:
-
Object
- Object
- Authenticator::Client::Base
- Defined in:
- lib/authenticator/client/base.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_password ⇒ Object
readonly
Returns the value of attribute api_password.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #all ⇒ Object
- #authenticate(account) ⇒ Object
- #create(account) ⇒ Object
- #destroy(id) ⇒ Object
-
#initialize(config) ⇒ Base
constructor
A new instance of Base.
- #show(id) ⇒ Object
- #update(id, account) ⇒ Object
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_key ⇒ Object (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_password ⇒ Object (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 |
#host ⇒ Object (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
#all ⇒ Object
15 16 17 18 |
# File 'lib/authenticator/client/base.rb', line 15 def all uri = account_path 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(account) uri = authenticate_path RestClient.post( uri, auth_params.merge(account.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(account) uri = account_path RestClient.post( uri, auth_params.merge(account.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 = account_path(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 = account_path(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, account) uri = account_path(id) RestClient.put( uri, auth_params.merge(account.to_params).to_json, content_type: :json, accept: :json ) end |