Class: SimplyAuth::ApiKey
- Defined in:
- app/models/simply_auth/api_key.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#secret ⇒ Object
Returns the value of attribute secret.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Model
#attributes=, collection_path, #collection_path, create, #data, #data=, find, #initialize, instance_path, #instance_path, owner_class, owner_class_name, #owner_id, path_component, #persisted=, #persisted?, #save
Constructor Details
This class inherits a constructor from SimplyAuth::Model
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'app/models/simply_auth/api_key.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'app/models/simply_auth/api_key.rb', line 3 def name @name end |
#secret ⇒ Object
Returns the value of attribute secret.
3 4 5 |
# File 'app/models/simply_auth/api_key.rb', line 3 def secret @secret end |
Class Method Details
.all ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/simply_auth/api_key.rb', line 9 def self.all response = RestClient.get( "https://api.simplyauth.com#{collection_path}", accept: :json ) body = JSON.parse(response.body) body.map do |data| data = data.deep_transform_keys { |key| key.to_s.underscore } new(data) end end |
Instance Method Details
#attributes ⇒ Object
5 6 7 |
# File 'app/models/simply_auth/api_key.rb', line 5 def attributes super.merge(name: name, id: id, secret: secret) end |
#destroy ⇒ Object
21 22 23 24 25 26 |
# File 'app/models/simply_auth/api_key.rb', line 21 def destroy RestClient.delete( "https://api.simplyauth.com#{instance_path}", accept: :json ) end |