milady-cima-api 0.3.0 → 0.4.0
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/CHANGELOG.md +10 -0
- data/lib/milady_cima_api/resources/users/course_learners.rb +43 -0
- data/lib/milady_cima_api/resources/users.rb +43 -41
- data/lib/milady_cima_api/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7a0502a36b75c80c03711804558c9396a5e0b8bc28aa904ee4fbca86a7c28ba
|
|
4
|
+
data.tar.gz: 8a32eabd2e1a6d6157bdae2c1cb64428e6572aba4cb11a6ba4b4cf904b8d6e1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74f6e46875750a10b53cf5051d2b1ba543fb9dcc7ab4f3ef2e5eb1c7bb7e85c3884aa3b51d5878bd850c0cdeb51fca57ea3be4277becac23ddec1d5c9facf33a
|
|
7
|
+
data.tar.gz: 9348229a5ff3940265d8afa641cb64fa1ba6b0c3fdd036cb17f3b9b02988c12c4a3e6fb45223b4f66494fc9105b21eaeac62fb023f6031f0b26cc0e2c32cfd61
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.4.0] - 2025-12-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Added `CourseLearners` resource under `Users` to support `GET /users/{id}/course_learners`.
|
|
7
|
+
- Added `Users#find` method to retrieve a single user.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Updated `Users#list` to use explicit keyword arguments for better documentation and usability.
|
|
11
|
+
- Removed custom `Users#list_by_organization` and `Users#list_learners_by_organization` methods in favor of standardized `list` with filters.
|
|
12
|
+
|
|
3
13
|
## [0.3.0] - 2025-12-04
|
|
4
14
|
|
|
5
15
|
### Added
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../base'
|
|
4
|
+
|
|
5
|
+
module MiLadyCimaApi
|
|
6
|
+
module Resources
|
|
7
|
+
class Users
|
|
8
|
+
# CourseLearners resource exposes endpoints under /users/{id}/course_learners
|
|
9
|
+
class CourseLearners < Resources::Base
|
|
10
|
+
|
|
11
|
+
# List user course learners
|
|
12
|
+
#
|
|
13
|
+
# GET /users/{id}/course_learners
|
|
14
|
+
# @param user_id [Integer, String] ID of the user
|
|
15
|
+
# @param after [Integer] Used for fast paging
|
|
16
|
+
# @param count [Boolean] If true, just return the number of list items
|
|
17
|
+
# @param filter [Hash, String] Filter using JSON structure
|
|
18
|
+
# @param include [String] Comma separated list of relationships to include
|
|
19
|
+
# @param limit [Integer] Limit the number of returned objects (default 10, max 100)
|
|
20
|
+
# @param offset [Integer] Used for paging through a small dataset
|
|
21
|
+
# @return [Array, Hash] Parsed JSON response from the API
|
|
22
|
+
def list(user_id:, after: nil, count: nil, filter: nil, include: nil, limit: nil, offset: nil)
|
|
23
|
+
raise ArgumentError, 'user_id is required' if user_id.nil?
|
|
24
|
+
|
|
25
|
+
if limit && limit > 100
|
|
26
|
+
raise ArgumentError, 'limit cannot be greater than 100'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
params = {}
|
|
30
|
+
params['$after'] = after if after
|
|
31
|
+
params['$count'] = count if count
|
|
32
|
+
params['$filter'] = normalize_filter(filter) if filter
|
|
33
|
+
params['$include'] = include if include
|
|
34
|
+
params['$limit'] = limit if limit
|
|
35
|
+
params['$offset'] = offset if offset
|
|
36
|
+
|
|
37
|
+
@client.get("/users/#{user_id}/course_learners", params: params)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -1,60 +1,62 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'base'
|
|
4
|
+
|
|
3
5
|
module MiLadyCimaApi
|
|
4
6
|
module Resources
|
|
5
7
|
# Users resource exposes endpoints under /users
|
|
6
|
-
class Users
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
class Users < Base
|
|
9
|
+
|
|
10
|
+
# @return [MiLadyCimaApi::Resources::Users::CourseLearners]
|
|
11
|
+
def course_learners
|
|
12
|
+
@course_learners ||= CourseLearners.new(@client)
|
|
10
13
|
end
|
|
11
14
|
|
|
12
|
-
# List users
|
|
15
|
+
# List users
|
|
13
16
|
#
|
|
14
17
|
# GET /users
|
|
15
|
-
# @param
|
|
18
|
+
# @param after [Integer] Used for fast paging
|
|
19
|
+
# @param count [Boolean] If true, just return the number of list items
|
|
20
|
+
# @param filter [Hash, String] Filter using JSON structure
|
|
21
|
+
# @param include [String] Comma separated list of relationships to include
|
|
22
|
+
# @param limit [Integer] Limit the number of returned objects (default 10, max 100)
|
|
23
|
+
# @param offset [Integer] Used for paging through a small dataset
|
|
24
|
+
# @param order [String] Comma separated attribute names to sort by
|
|
16
25
|
# @return [Array, Hash] Parsed JSON response from the API
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
def list(after: nil, count: nil, filter: nil, include: nil, limit: nil, offset: nil, order: nil)
|
|
27
|
+
if limit && limit > 100
|
|
28
|
+
raise ArgumentError, 'limit cannot be greater than 100'
|
|
29
|
+
end
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def list_by_organization(organization_id, role: nil, **params)
|
|
31
|
-
filter = build_organization_filter(organization_id, role: role)
|
|
32
|
-
@client.get('/users', params: params.merge('$filter': filter))
|
|
33
|
-
end
|
|
31
|
+
params = {}
|
|
32
|
+
params['$after'] = after if after
|
|
33
|
+
params['$count'] = count if count
|
|
34
|
+
params['$filter'] = normalize_filter(filter) if filter
|
|
35
|
+
params['$include'] = include if include
|
|
36
|
+
params['$limit'] = limit if limit
|
|
37
|
+
params['$offset'] = offset if offset
|
|
38
|
+
params['$order'] = order if order
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
#
|
|
37
|
-
# GET /users with organization and Learner role filter
|
|
38
|
-
# @param organization_id [String, Integer] Organization ID to filter by
|
|
39
|
-
# @param params [Hash] Optional additional query params (e.g., pagination)
|
|
40
|
-
# @return [Array, Hash] Parsed JSON response from the API
|
|
41
|
-
# @raise [MiLadyCimaApi::UnauthorizedError, MiLadyCimaApi::NotFoundError, MiLadyCimaApi::ClientError, MiLadyCimaApi::ServerError]
|
|
42
|
-
def list_learners_by_organization(organization_id, **params)
|
|
43
|
-
list_by_organization(organization_id, role: 'Learner', **params)
|
|
40
|
+
@client.get('/users', params: params)
|
|
44
41
|
end
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
# Get user
|
|
44
|
+
#
|
|
45
|
+
# GET /users/{id}
|
|
46
|
+
# @param id [Integer, String] ID of the user
|
|
47
|
+
# @param include [String] Comma separated list of relationships to include
|
|
48
|
+
# @return [Hash] Parsed JSON response from the API
|
|
49
|
+
def find(id:, include: nil)
|
|
50
|
+
raise ArgumentError, 'id is required' if id.nil?
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# @param role [String, nil]
|
|
51
|
-
# @return [Hash] Filter hash
|
|
52
|
-
def build_organization_filter(organization_id, role: nil)
|
|
53
|
-
conditions = [{ eq: { organization_id: organization_id } }]
|
|
54
|
-
conditions << { contains: { roles: role } } if role
|
|
52
|
+
params = {}
|
|
53
|
+
params['$include'] = include if include
|
|
55
54
|
|
|
56
|
-
{
|
|
55
|
+
@client.get("/users/#{id}", params: params)
|
|
57
56
|
end
|
|
57
|
+
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
-
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
require_relative 'users/course_learners'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: milady-cima-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- marcus.salinas
|
|
@@ -33,6 +33,7 @@ files:
|
|
|
33
33
|
- lib/milady_cima_api/resources/courses/learners.rb
|
|
34
34
|
- lib/milady_cima_api/resources/organizations.rb
|
|
35
35
|
- lib/milady_cima_api/resources/users.rb
|
|
36
|
+
- lib/milady_cima_api/resources/users/course_learners.rb
|
|
36
37
|
- lib/milady_cima_api/version.rb
|
|
37
38
|
homepage: https://github.com/jippylong12/milady-cima-api
|
|
38
39
|
licenses:
|