milady-cima-api 0.2.0 → 0.2.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/CHANGELOG.md +10 -0
- data/lib/milady_cima_api/client.rb +4 -1
- data/lib/milady_cima_api/resources/courses.rb +43 -26
- data/lib/milady_cima_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cba4eea16f1a7f12d7085606bdadee4927918c7f960d2bd95ee4b9f10909f0f
|
|
4
|
+
data.tar.gz: e0519d5dfa0eacecf95237a65669ec5b232d23eb334bf50b9349b501887f1bbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e872f0ae20e5bb564e219625426e4f853cc65ff48ac20a36c73879b7e7dcc4351c22ff6ce5fdb0aee612e11f76fce8cf38588005f54777897c2257c162c630f6
|
|
7
|
+
data.tar.gz: 4aedb0de4d77fa84fc8d430fb4dfc3df3ca61e6279785a7dd4750490493ee1cfec2003e8b5583d5d5f7afef19a1a5007ed8b12a0a83fb786bfcb4cf2499f9201
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.1] - 2025-12-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Added `verify_ssl` option to `Client` initialization (defaults to `true`) to allow disabling SSL verification for testing or development.
|
|
7
|
+
- Added `Courses#find` method to retrieve a single course.
|
|
8
|
+
- Added live integration tests for `Courses` and `Assessments` filters (skipped by default).
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Updated `Courses#list` to use explicit keyword arguments for better documentation and usability, matching `Assessments#list`.
|
|
12
|
+
|
|
3
13
|
## [0.2.0] - 2025-12-04
|
|
4
14
|
|
|
5
15
|
### Added
|
|
@@ -10,13 +10,15 @@ module MiLadyCimaApi
|
|
|
10
10
|
API_PAGE_LIMIT = 100
|
|
11
11
|
|
|
12
12
|
attr_reader :api_key, :base_url
|
|
13
|
+
attr_reader :api_key, :base_url, :verify_ssl
|
|
13
14
|
attr_reader :users, :organizations, :courses
|
|
14
15
|
|
|
15
|
-
def initialize(api_key:, base_url: DEFAULT_BASE_URL)
|
|
16
|
+
def initialize(api_key:, base_url: DEFAULT_BASE_URL, verify_ssl: true)
|
|
16
17
|
raise ArgumentError, 'api_key is required' if api_key.nil? || api_key.strip.empty?
|
|
17
18
|
|
|
18
19
|
@api_key = api_key
|
|
19
20
|
@base_url = base_url.chomp('/')
|
|
21
|
+
@verify_ssl = verify_ssl
|
|
20
22
|
@users = MiLadyCimaApi::Resources::Users.new(self)
|
|
21
23
|
@organizations = MiLadyCimaApi::Resources::Organizations.new(self)
|
|
22
24
|
@courses = MiLadyCimaApi::Resources::Courses.new(self)
|
|
@@ -100,6 +102,7 @@ module MiLadyCimaApi
|
|
|
100
102
|
def perform_request(uri, request)
|
|
101
103
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
102
104
|
http.use_ssl = uri.scheme == 'https'
|
|
105
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless verify_ssl
|
|
103
106
|
response = http.request(request)
|
|
104
107
|
handle_response(response)
|
|
105
108
|
end
|
|
@@ -21,19 +21,46 @@ module MiLadyCimaApi
|
|
|
21
21
|
# List courses
|
|
22
22
|
#
|
|
23
23
|
# GET /courses
|
|
24
|
-
# @param
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# @
|
|
24
|
+
# @param filter [Hash, String] Filter using JSON structure
|
|
25
|
+
# @param limit [Integer] Limit the number of returned objects (default 10, max 100)
|
|
26
|
+
# @param offset [Integer] Used for paging through a small dataset
|
|
27
|
+
# @param after [Integer] Used for fast paging
|
|
28
|
+
# @param count [Boolean] If true, just return the number of list items
|
|
29
|
+
# @param order [String] Comma separated attribute names to sort by
|
|
30
|
+
# @param include [String] Comma separated list of relationships to include
|
|
29
31
|
# @return [Array, Hash] Parsed JSON response from the API
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
def list(filter: nil, limit: nil, offset: nil, after: nil, count: nil, order: nil, include: nil)
|
|
33
|
+
if limit && limit > 100
|
|
34
|
+
raise ArgumentError, 'limit cannot be greater than 100'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
params = {}
|
|
38
|
+
params['$filter'] = normalize_filter(filter) if filter
|
|
39
|
+
params['$limit'] = limit if limit
|
|
40
|
+
params['$offset'] = offset if offset
|
|
41
|
+
params['$after'] = after if after
|
|
42
|
+
params['$count'] = count if count
|
|
43
|
+
params['$order'] = order if order
|
|
44
|
+
params['$include'] = include if include
|
|
45
|
+
|
|
34
46
|
@client.get('/courses', params: params)
|
|
35
47
|
end
|
|
36
48
|
|
|
49
|
+
# Get a single course
|
|
50
|
+
#
|
|
51
|
+
# GET /courses/{id}
|
|
52
|
+
# @param id [Integer, String] ID of the course
|
|
53
|
+
# @param include [String] Comma separated list of relationships to include
|
|
54
|
+
# @return [Hash] Parsed JSON response from the API
|
|
55
|
+
def find(id:, include: nil)
|
|
56
|
+
raise ArgumentError, 'id is required' if id.nil?
|
|
57
|
+
|
|
58
|
+
params = {}
|
|
59
|
+
params['$include'] = include if include
|
|
60
|
+
|
|
61
|
+
@client.get("/courses/#{id}", params: params)
|
|
62
|
+
end
|
|
63
|
+
|
|
37
64
|
# Convenience: List courses by organization
|
|
38
65
|
# @param organization_id [Integer, String]
|
|
39
66
|
# @param extra_params [Hash] Additional query params (e.g., pagination)
|
|
@@ -41,7 +68,7 @@ module MiLadyCimaApi
|
|
|
41
68
|
def by_organization(organization_id:, **extra_params)
|
|
42
69
|
raise ArgumentError, 'organization_id is required' if organization_id.nil?
|
|
43
70
|
filter = { 'organization_id' => organization_id }
|
|
44
|
-
list(
|
|
71
|
+
list(filter: filter, **extra_params)
|
|
45
72
|
end
|
|
46
73
|
|
|
47
74
|
# Convenience: List courses filtered by created_at with comparison operator
|
|
@@ -61,26 +88,16 @@ module MiLadyCimaApi
|
|
|
61
88
|
{ 'and' => [time_filter, { 'organization_id' => organization_id }] }
|
|
62
89
|
end
|
|
63
90
|
|
|
64
|
-
list(
|
|
91
|
+
list(filter: filter, **extra_params)
|
|
65
92
|
end
|
|
66
93
|
|
|
67
94
|
private
|
|
68
95
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
value = params[filter_key]
|
|
76
|
-
case value
|
|
77
|
-
when Hash
|
|
78
|
-
params[filter_key] = JSON.generate(value)
|
|
79
|
-
when String
|
|
80
|
-
# pass through
|
|
81
|
-
else
|
|
82
|
-
raise ArgumentError, "$filter must be a String (JSON) or a Hash"
|
|
83
|
-
end
|
|
96
|
+
def normalize_filter(filter)
|
|
97
|
+
return filter if filter.is_a?(String)
|
|
98
|
+
return JSON.generate(filter) if filter.is_a?(Hash)
|
|
99
|
+
|
|
100
|
+
raise ArgumentError, 'filter must be a String (JSON) or a Hash'
|
|
84
101
|
end
|
|
85
102
|
end
|
|
86
103
|
end
|