easyllama-client 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90e02be82a179df253b9307fe743895d2a0cb506d9ca9c860437b915c4d2125a
4
- data.tar.gz: ade84697ba0a443078331fa59f6a537968047bcd9bd2a68e66f6687f8da56146
3
+ metadata.gz: 903c7bae3a844f73ab2d96243015e7a738a385878308fd1bb20e8061c807aec4
4
+ data.tar.gz: de4509cfc6fb7cf02e6d20cb8631d0cd83251c5a35a7ff0639d50c463c96e133
5
5
  SHA512:
6
- metadata.gz: 0f253b970ad0ee4bf658f238186ecddb693853cf07400ea750a4af1ffb7ff149547b1e9a049be3f0465ca72324918583e31a64d4bfc13b44e8ac95ae8630eff1
7
- data.tar.gz: 893b1c44a5ab43c4fc290040c7abe51d1253c3729a0571b803ba0af7948864254d8f2bfe72dfff040a6396c5a4b1959347376bbff7a1159218882c50598bc834
6
+ metadata.gz: fa7f902ba1ce705fecde58e46ffc011ac4426cacd10597fa82124b57f33127a6b24bb72effb0e69c5810dd5c193210682d4a3a01552f5697789226538bf04c88
7
+ data.tar.gz: db0620a5e4995a3a36a9f834f1ec0f15526c2ae02bff243c97ee8e50e75a800293e64a821eee3ef62d7e522f0317f4fe26da37d41dabda8a9ecd85e23dd61b2a
data/lib/easyllama/api.rb CHANGED
@@ -60,7 +60,7 @@ module EasyLlama
60
60
  request['content-type'] = 'application/json'
61
61
  request['accept'] = 'application/json'
62
62
  request['authorization'] = "Bearer #{@token}"
63
- request.body = body if body.present?
63
+ request.body = body.to_json if body.present?
64
64
  request
65
65
  end
66
66
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module EasyLlama
4
4
  module Client
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.3'
6
6
  end
7
7
  end
@@ -8,6 +8,7 @@ require_relative 'oauth'
8
8
  require_relative 'locations'
9
9
  require_relative 'learners'
10
10
  require_relative 'trainings'
11
+ require_relative 'learner_trainings'
11
12
 
12
13
  module EasyLlama
13
14
  # This class provides methods for interacting with the Easy Llama API interface.
@@ -26,6 +27,10 @@ module EasyLlama
26
27
  def trainings
27
28
  Trainings.new(api_token)
28
29
  end
30
+
31
+ def learner_trainings
32
+ LearnerTrainings.new(api_token)
33
+ end
29
34
  end
30
35
  end
31
36
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EasyLlama
4
+ class Client
5
+ # This class provides methods for interacting with the Easy Llama API for learner trainings.
6
+ class LearnerTrainings < Api
7
+ # Sends a GET request to retrieve all learner trainings.
8
+ #
9
+ # @param page [Integer] The page number.
10
+ # @return [Array] The learner trainings or an error message.
11
+ def where(page: 1, learner_id: nil, training_id: nil, status: nil, sort: nil)
12
+ response = send_request(path: '/learner_trainings', body: { page:, learner_id:, training_id:, status:, sort: })
13
+
14
+ parse_response!(response, 'learner_trainings')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -6,9 +6,10 @@ module EasyLlama
6
6
  class Learners < Api
7
7
  # Sends a GET request to retrieve all learners.
8
8
  #
9
- # @return [Object] The learners or an error message.
10
- def all
11
- response = send_request(path: '/learners')
9
+ # @param page [Integer] The page number.
10
+ # @return [Array] The learners or an error message.
11
+ def all(page: 1)
12
+ response = send_request(path: '/learners', body: { page: })
12
13
 
13
14
  parse_response!(response, 'learners')
14
15
  end
@@ -48,7 +49,7 @@ module EasyLlama
48
49
  #
49
50
  # @param training_id [Integer] The ID of the training.
50
51
  # @param learner_id [Integer] The ID of the learner.
51
- # @return [Object] The training assignment details or an error message.
52
+ # @return [Object] The learner training or an error message.
52
53
  def assign_training_to_learner(training_id:, learner_id:)
53
54
  response = send_request(
54
55
  path: "/learners/#{learner_id}/learner_trainings",
@@ -56,7 +57,7 @@ module EasyLlama
56
57
  body: { learner_id:, training_id: }
57
58
  )
58
59
 
59
- parse_response!(response)
60
+ parse_response!(response, 'learner_training')
60
61
  end
61
62
 
62
63
  # Sends a DELETE request to unassign a training from a learner.
@@ -6,9 +6,10 @@ module EasyLlama
6
6
  class Locations < Api
7
7
  # Sends a GET request to retrieve all locations.
8
8
  #
9
- # @return [Object] The locations or an error message.
10
- def all
11
- response = send_request(path: '/locations')
9
+ # @param page [Integer] The page number.
10
+ # @return [Array] The locations or an error message.
11
+ def all(page: 1)
12
+ response = send_request(path: '/locations', body: { page: })
12
13
 
13
14
  parse_response!(response, 'locations')
14
15
  end
@@ -6,9 +6,10 @@ module EasyLlama
6
6
  class Trainings < Api
7
7
  # Sends a GET request to retrieve all trainings.
8
8
  #
9
- # @return [Object] The trainings or an error message.
10
- def all
11
- response = send_request(path: '/trainings')
9
+ # @param page [Integer] The page number.
10
+ # @return [Array] The trainings or an error message.
11
+ def all(page: 1)
12
+ response = send_request(path: '/trainings', body: { page: })
12
13
 
13
14
  parse_response!(response, 'trainings')
14
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyllama-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Kashoid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -48,6 +48,7 @@ files:
48
48
  - lib/easyllama/api.rb
49
49
  - lib/easyllama/client.rb
50
50
  - lib/easyllama/client/version.rb
51
+ - lib/easyllama/learner_trainings.rb
51
52
  - lib/easyllama/learners.rb
52
53
  - lib/easyllama/locations.rb
53
54
  - lib/easyllama/oauth.rb