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 +4 -4
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +3 -0
- data/lib/lattice/client.rb +28 -1
- data/lib/lattice/employees.rb +1 -1
- data/lib/lattice/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: 626641c8778725976c21fbd4b582f3423a65eafc0820ca90648ec01e68a721ac
|
4
|
+
data.tar.gz: 31781e62ff9d1048afd2c0ea0e940fa22a2f28762c6e0d0578d40e36615f15cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c303cda8c5da6286d031826f5fdabbd495b55605ee70c98525bea729b4ee09b60f8d5f8a1069cc66fe847bdd49eaa3b15b481cdb49d88c75d572c431313d170
|
7
|
+
data.tar.gz: 17266afd1f812e605e3a773515bb020dacaba03e74f2a43c62d4896033742053a1b5485d5e9a26430f8bf592ba136cf33942bb9042c7807dcb96e5c954bce0d1
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/lattice/client.rb
CHANGED
@@ -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:
|
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
|
data/lib/lattice/employees.rb
CHANGED
data/lib/lattice/version.rb
CHANGED