latticehris 0.1.2 → 0.1.3

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: b169eb6fdae407e489088bcce6d77bedc91efec8b80db2cb9c71a5bedf6f93be
4
- data.tar.gz: 6f6bf967eca451146a758dd8c5237ad3a2d921b86adbd1f82179875f2b9b15cc
3
+ metadata.gz: 626641c8778725976c21fbd4b582f3423a65eafc0820ca90648ec01e68a721ac
4
+ data.tar.gz: 31781e62ff9d1048afd2c0ea0e940fa22a2f28762c6e0d0578d40e36615f15cc
5
5
  SHA512:
6
- metadata.gz: f7f5e011da590fa7b3d60fd8e3ac002da52751cedf0e485fd9ce88fb62306c5031a20fa117b31b7a9b636b5c7ba9cdc6ff10487240a768e6612d26d5581340b7
7
- data.tar.gz: 85ed5d15cc3e26ca7dfb0250840448117b693eb4022cc1cd0cd3ce82f68f54ba21a3be6cca2340a73dfdc42891eb4dbd600af7d67e4570e4f5fed42cd10ca4a8
6
+ metadata.gz: 5c303cda8c5da6286d031826f5fdabbd495b55605ee70c98525bea729b4ee09b60f8d5f8a1069cc66fe847bdd49eaa3b15b481cdb49d88c75d572c431313d170
7
+ data.tar.gz: 17266afd1f812e605e3a773515bb020dacaba03e74f2a43c62d4896033742053a1b5485d5e9a26430f8bf592ba136cf33942bb9042c7807dcb96e5c954bce0d1
data/.rubocop.yml CHANGED
@@ -13,4 +13,7 @@ plugins:
13
13
  - rubocop-rspec
14
14
 
15
15
  Style/Documentation:
16
- Enabled: false
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ Max: 15
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.1.3] - 2025-05-09
2
+ - `Lattice::Employees.all` will now do a paginated get to make sure all records are fetched.
3
+
1
4
  ## [0.1.2] - 2025-05-06
2
5
  - Rename gem name from `lattice` to `lattice-hris`
3
6
 
@@ -14,6 +14,33 @@ module Lattice
14
14
  JSON.parse(response.body)
15
15
  end
16
16
 
17
+ # Retrieves all paginated results from the specified API endpoint.
18
+ #
19
+ # @param path [String] The API endpoint path (relative to the base URL).
20
+ # @param params [Hash] Optional query parameters. Supports pagination keys:
21
+ # - `:offset` [Integer] The starting point for the results (default: 0).
22
+ # - `:limit` [Integer] The maximum number of results per page (default: 100).
23
+ # @return [Array<Hash>] An array of all results aggregated from paginated responses.
24
+ # Each result is a hash representing an individual record.
25
+ # @note The API response is expected to include:
26
+ # - `data` [Array<Hash>] The current page of results.
27
+ # - `meta` [Hash] Metadata about the response, including:
28
+ # - `total` [Integer] The total number of available results.
29
+ def self.paginated_get(path, params = {})
30
+ params[:offset] = params[:offset] || 0
31
+ params[:limit] = params[:limit] || 100
32
+ has_more = true
33
+
34
+ all_results = []
35
+ while has_more
36
+ response = get(path, params)
37
+ all_results.concat(response["data"])
38
+ has_more = response["meta"]["total"] > params[:offset] + params[:limit]
39
+ params[:offset] += params[:limit]
40
+ end
41
+ all_results
42
+ end
43
+
17
44
  def self.build_url(path, params)
18
45
  url = "#{BASE_URL}#{path}"
19
46
  url += "?#{URI.encode_www_form(params)}" unless params.empty?
@@ -34,7 +61,7 @@ module Lattice
34
61
  client_secret: Lattice.client_secret,
35
62
  scope: Lattice.scope
36
63
  }
37
- response = RestClient.post(TOKEN_URL, params, { content_type: :x_www_form_urlencoded })
64
+ response = RestClient.post(TOKEN_URL, params, { content_type: "application/x-www-form-urlencoded" })
38
65
  JSON.parse(response.body)["access_token"]
39
66
  end
40
67
  end
@@ -11,7 +11,7 @@ module Lattice
11
11
  # employees = Lattice::Employees.all``
12
12
  # puts employees.first["name"]
13
13
  def self.all
14
- get("/employees")["data"]
14
+ paginated_get("/employees")
15
15
  end
16
16
 
17
17
  # Retrieves a specific employee's details from Lattice by their ID.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lattice
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latticehris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lien Van Den Steen