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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd05960749c0262fe3d556d454389a4183d248dc4a89b87828527ae343c77b6a
4
- data.tar.gz: 00e6c1fc23a40ba8b5211e85f5fa2cf946bca67cc5086db91b5fc4ad557cf178
3
+ metadata.gz: 4cba4eea16f1a7f12d7085606bdadee4927918c7f960d2bd95ee4b9f10909f0f
4
+ data.tar.gz: e0519d5dfa0eacecf95237a65669ec5b232d23eb334bf50b9349b501887f1bbb
5
5
  SHA512:
6
- metadata.gz: 20976e6b55d286b1b422cbd7dfef4ed1492bcb434012a55986ac17df905d7dbcb4403f2756bb70437a8f41896d37d305501769c25a757df5b72163b7d4d52afb
7
- data.tar.gz: 668252325045549f3ccc9329b8c9823bb13e1cec9031689cc63cc6852c5f028c72e06b3df563ade3245b6bb7bac16882f2f2b1f44b8106c6c3d8fce5caa956fe
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 params [Hash] Optional query params. Supports the special key
25
- # "$filter" (String or Hash). If provided as a Hash, it will be JSON-encoded
26
- # to match the API expectation (e.g., {"organization_id" => 123} or
27
- # {"and" => [{"gt" => {"metadata.created_at" => "2025-01-01T00:00:00.000Z"}}]}).
28
- # @option params [String, Hash] :$filter JSON string or Ruby Hash representing the filter
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
- # @raise [MiLadyCimaApi::UnauthorizedError, MiLadyCimaApi::NotFoundError, MiLadyCimaApi::ClientError, MiLadyCimaApi::ServerError]
31
- def list(params = {})
32
- params = params.dup || {} || {}
33
- normalize_filter_param!(params)
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({ '$filter' => filter }.merge(extra_params))
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({ '$filter' => filter }.merge(extra_params))
91
+ list(filter: filter, **extra_params)
65
92
  end
66
93
 
67
94
  private
68
95
 
69
- # Mutates params hash to ensure $filter is a JSON string when provided as a Hash
70
- def normalize_filter_param!(params)
71
- # support both symbol and string keys
72
- filter_key = params.key?(:$filter) ? :$filter : (params.key?("$filter") ? "$filter" : nil)
73
- return unless filter_key
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module MiLadyCimaApi
4
4
  # Gem version
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - marcus.salinas