easyllama-client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/easyllama/client/version.rb +1 -1
- data/lib/easyllama/client.rb +4 -8
- data/lib/easyllama/learners.rb +55 -0
- data/lib/easyllama/locations.rb +26 -0
- data/lib/easyllama/trainings.rb +17 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b275fa080c57dc300bb5d804413e54a90b69b04d58732db4e72286a03bc009f4
|
4
|
+
data.tar.gz: 23255762cc3409dfd092ef45ec3e089b455ed6f43097ad0faa5b24749c8bee91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b59d2271d6987a6676cd7603dff54391d5dfbdd2793d7bf0133d2bec6950ba07ab19584f8289ca93fb6a491b6c7c5cb813b055d2f8d1750eaf827ad6da08af91
|
7
|
+
data.tar.gz: 946e1fa2c7ddfbb15a588841e8114eb714fb94a3a89d433c7201cd4972a4be1d889be3f0b0548cb9aee23835474bbf01ab5a956596522cbe3cf22169ccf46799
|
data/lib/easyllama/client.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
require 'net/http'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
+
require_relative 'locations'
|
7
|
+
require_relative 'learners'
|
8
|
+
require_relative 'trainings'
|
9
|
+
|
6
10
|
module EasyLlama
|
7
11
|
# This class provides methods for interacting with the Easy Llama API.
|
8
12
|
class Client
|
@@ -36,14 +40,6 @@ module EasyLlama
|
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
|
-
# Sends a GET request to retrieve locations.
|
40
|
-
#
|
41
|
-
# @return [Object] The locations or an error message.
|
42
|
-
def locations
|
43
|
-
response = send_request(path: '/locations')
|
44
|
-
response_body(response, 'locations')
|
45
|
-
end
|
46
|
-
|
47
43
|
private
|
48
44
|
|
49
45
|
def build_uri(path)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EasyLlama
|
4
|
+
class Client
|
5
|
+
class Learners
|
6
|
+
class << self
|
7
|
+
# Sends a GET request to retrieve all learners.
|
8
|
+
#
|
9
|
+
# @return [Object] The learners or an error message.
|
10
|
+
def all
|
11
|
+
response = EasyLlama::Client.send_request(path: '/learners')
|
12
|
+
EasyLlama::Client.response_body(response, 'learners')
|
13
|
+
end
|
14
|
+
|
15
|
+
# Sends a GET request to retrieve a learner by ID.
|
16
|
+
#
|
17
|
+
# @param id [Integer] The ID of the learner.
|
18
|
+
# @return [Object] The learner or an error message.
|
19
|
+
def find(id)
|
20
|
+
response = EasyLlama::Client.send_request(path: "/learners/#{id}")
|
21
|
+
EasyLlama::Client.response_body(response, 'learner')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Sends a POST request to create a learner.
|
25
|
+
#
|
26
|
+
# @param learner_attributes [Hash] The attributes of the learner.
|
27
|
+
# @return [Object] The created learner or an error message.
|
28
|
+
def create(learner_attributes = {})
|
29
|
+
response = EasyLlama::Client.send_request(path: '/learners', method: :post, body: learner_attributes)
|
30
|
+
EasyLlama::Client.response_body(response, 'learner')
|
31
|
+
end
|
32
|
+
|
33
|
+
# Sends a PATCH request to update a learner by ID.
|
34
|
+
#
|
35
|
+
# @param id [Integer] The ID of the learner.
|
36
|
+
# @param learner_attributes [Hash] The attributes to update.
|
37
|
+
# @return [Object] The updated learner or an error message.
|
38
|
+
def update(id, learner_attributes = {})
|
39
|
+
response = EasyLlama::Client.send_request(path: "/learners/#{id}", method: :patch, body: learner_attributes)
|
40
|
+
EasyLlama::Client.response_body(response, 'learner')
|
41
|
+
end
|
42
|
+
|
43
|
+
# Sends a POST request to assign a training to a learner.
|
44
|
+
#
|
45
|
+
# @param training_id [Integer] The ID of the training.
|
46
|
+
# @param learner_id [Integer] The ID of the learner.
|
47
|
+
# @return [Object] The assignment details or an error message.
|
48
|
+
def assign_training_to_learner(training_id:, learner_id:)
|
49
|
+
response = EasyLlama::Client.send_request(path: "/learners/#{learner_id}/learner_trainings", method: :post, body: { learner_id:, training_id: })
|
50
|
+
EasyLlama::Client.response_body(response, 'assignment')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EasyLlama
|
4
|
+
class Client
|
5
|
+
class Locations
|
6
|
+
class << self
|
7
|
+
# Sends a GET request to retrieve all locations.
|
8
|
+
#
|
9
|
+
# @return [Object] The locations or an error message.
|
10
|
+
def all
|
11
|
+
response = EasyLlama::Client.send_request(path: '/locations')
|
12
|
+
EasyLlama::Client.response_body(response, 'locations')
|
13
|
+
end
|
14
|
+
|
15
|
+
# Sends a POST request to create a location.
|
16
|
+
#
|
17
|
+
# @param location_attributes [Hash] The attributes of the location.
|
18
|
+
# @return [Object] The created location or an error message.
|
19
|
+
def create(location_attributes = {})
|
20
|
+
response = EasyLlama::Client.send_request(path: '/locations', method: :post, body: location_attributes)
|
21
|
+
EasyLlama::Client.response_body(response, 'location')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EasyLlama
|
4
|
+
class Client
|
5
|
+
class Trainings
|
6
|
+
class << self
|
7
|
+
# Sends a GET request to retrieve all trainings.
|
8
|
+
#
|
9
|
+
# @return [Object] The trainings or an error message.
|
10
|
+
def all
|
11
|
+
response = EasyLlama::Client.send_request(path: '/trainings')
|
12
|
+
EasyLlama::Client.response_body(response, 'trainings')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easyllama-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitalii Kashoid
|
@@ -47,6 +47,9 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- lib/easyllama/client.rb
|
49
49
|
- lib/easyllama/client/version.rb
|
50
|
+
- lib/easyllama/learners.rb
|
51
|
+
- lib/easyllama/locations.rb
|
52
|
+
- lib/easyllama/trainings.rb
|
50
53
|
homepage: https://rubygems.org/gems/easyllama-client
|
51
54
|
licenses:
|
52
55
|
- MIT
|