Class: EasyLlama::Client::Learners
Overview
This class provides methods for interacting with the Easy Llama API for learners.
Constant Summary
Constants inherited from Api
Api::DEFAULT_API_VERSION, Api::DEFAULT_URI_BASE
Instance Method Summary collapse
-
#all(page: 1) ⇒ Array
Sends a GET request to retrieve all learners.
-
#archive(id) ⇒ Object
Sends a DELETE request to archive a learner by ID.
-
#assign_training_to_learner(training_id:, learner_id:) ⇒ Object
Sends a POST request to assign a training to a learner.
-
#create(learner_attributes = {}) ⇒ Object
Sends a POST request to create a learner.
-
#find(id) ⇒ Object
Sends a GET request to retrieve a learner by ID.
-
#unassign_training_from_learner(learner_training_id:, learner_id:) ⇒ Object
Sends a DELETE request to unassign a training from a learner.
-
#update(id, learner_attributes = {}) ⇒ Object
Sends a PATCH request to update a learner by ID.
Methods inherited from Api
#initialize, #parse_response!, #send_request
Constructor Details
This class inherits a constructor from EasyLlama::Client::Api
Instance Method Details
#all(page: 1) ⇒ Array
Sends a GET request to retrieve all learners.
11 12 13 14 15 |
# File 'lib/easyllama/learners.rb', line 11 def all(page: 1) response = send_request(path: '/learners', body: { page: }) parse_response!(response, 'learners') end |
#archive(id) ⇒ Object
Sends a DELETE request to archive a learner by ID.
82 83 84 85 86 |
# File 'lib/easyllama/learners.rb', line 82 def archive(id) response = send_request(path: "/learners/#{id}", method: :delete) parse_response!(response) end |
#assign_training_to_learner(training_id:, learner_id:) ⇒ Object
Sends a POST request to assign a training to a learner.
53 54 55 56 57 58 59 60 61 |
# File 'lib/easyllama/learners.rb', line 53 def assign_training_to_learner(training_id:, learner_id:) response = send_request( path: "/learners/#{learner_id}/learner_trainings", method: :post, body: { learner_id:, training_id: } ) parse_response!(response, 'learner_training') end |
#create(learner_attributes = {}) ⇒ Object
Sends a POST request to create a learner.
31 32 33 34 35 |
# File 'lib/easyllama/learners.rb', line 31 def create(learner_attributes = {}) response = send_request(path: '/learners', method: :post, body: learner_attributes) parse_response!(response, 'learner') end |
#find(id) ⇒ Object
Sends a GET request to retrieve a learner by ID.
21 22 23 24 25 |
# File 'lib/easyllama/learners.rb', line 21 def find(id) response = send_request(path: "/learners/#{id}") parse_response!(response, 'learner') end |
#unassign_training_from_learner(learner_training_id:, learner_id:) ⇒ Object
Sends a DELETE request to unassign a training from a learner.
68 69 70 71 72 73 74 75 76 |
# File 'lib/easyllama/learners.rb', line 68 def unassign_training_from_learner(learner_training_id:, learner_id:) response = send_request( path: "/learners/#{learner_id}/learner_trainings/#{learner_training_id}", method: :delete, body: { learner_id:, learner_training_id: } ) parse_response!(response) end |
#update(id, learner_attributes = {}) ⇒ Object
Sends a PATCH request to update a learner by ID.
42 43 44 45 46 |
# File 'lib/easyllama/learners.rb', line 42 def update(id, learner_attributes = {}) response = send_request(path: "/learners/#{id}", method: :patch, body: learner_attributes) parse_response!(response, 'learner') end |