Class: HumanApi::App
- Inherits:
-
Nestful::Resource
- Object
- Nestful::Resource
- HumanApi::App
- Defined in:
- lib/human_api/app.rb
Class Method Summary collapse
-
.create_human(id) ⇒ Object
Create a new human:.
-
.delete_human(id) ⇒ Object
Delete a new human:.
-
.humans ⇒ Object
Get the humans of your app:.
Class Method Details
.create_human(id) ⇒ Object
Create a new human:
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/human_api/app.rb', line 21 def self.create_human(id) response = post 'users', externalId: id # If the response is true if response.status >= 200 && response.status < 300 # Leave it for now JSON.parse response.body else # Else tell me something went wrong: false # Nothing was created end rescue Nestful::UnauthorizedAccess => e if HumanApi.config.handle_access_error HumanApi.config.handle_access_error.call e, self else raise if HumanApi.config.raise_access_errors false end end |
.delete_human(id) ⇒ Object
Delete a new human:
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/human_api/app.rb', line 41 def self.delete_human(id) response = delete "users/#{id}" response.status >= 200 && response.status < 300 rescue Nestful::UnauthorizedAccess => e if HumanApi.config.handle_access_error HumanApi.config.handle_access_error.call e, self else raise if HumanApi.config.raise_access_errors false end end |
.humans ⇒ Object
Get the humans of your app:
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/human_api/app.rb', line 9 def self.humans get 'users' rescue Nestful::UnauthorizedAccess => e if HumanApi.config.handle_access_error HumanApi.config.handle_access_error.call e, self else raise if HumanApi.config.raise_access_errors [] end end |