lara-sdk 1.5.1 → 1.5.2
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/lib/lara/auth_token.rb +1 -1
- data/lib/lara/client.rb +11 -12
- data/lib/lara/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16d7ebfcc581f7cf377274d58579d0d306eb98c83907c28de3de277fefe0c40f
|
|
4
|
+
data.tar.gz: 5ae057fa1538580898d922d41f387fcd6d583726eb98fde453811f0fc0d6a3de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61f703c0ac1fa6059d3f58181ba65d1252a687085e7106b808377da35c13aa7b8f1380d612e451e0e1d2d1dbf734e21cce9cae409fc522d8dca113890a19161b
|
|
7
|
+
data.tar.gz: be6e69b110dbeefe2093f47aa8e741dd6d4c8fe014b4b3c0b3e66cc4929d313a8832cf5f93c4d7c0af50e18ba11d6d592f8f0bb5a059d7d71437de5fbd64d7be
|
data/lib/lara/auth_token.rb
CHANGED
data/lib/lara/client.rb
CHANGED
|
@@ -64,7 +64,8 @@ module Lara
|
|
|
64
64
|
# @yield [Hash] Each partial JSON result from the stream (if streaming)
|
|
65
65
|
# @return [Hash, Array, String, nil] The JSON 'content' from the API, CSV body, or raw bytes.
|
|
66
66
|
def post(path, body: nil, files: nil, headers: nil, raw_response: false, &callback)
|
|
67
|
-
request(:post, path, body: body, files: files, headers: headers, raw_response: raw_response,
|
|
67
|
+
request(:post, path, body: body, files: files, headers: headers, raw_response: raw_response,
|
|
68
|
+
&callback)
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
# Sends a PUT request to the Lara API.
|
|
@@ -88,17 +89,18 @@ module Lara
|
|
|
88
89
|
|
|
89
90
|
private
|
|
90
91
|
|
|
91
|
-
def request(method, path, body: nil, files: nil, headers: nil, params: nil,
|
|
92
|
+
def request(method, path, body: nil, files: nil, headers: nil, params: nil,
|
|
93
|
+
raw_response: false, &callback)
|
|
92
94
|
ensure_valid_token
|
|
93
95
|
|
|
94
96
|
make_request(method, path, body: body, files: files, headers: headers, params: params,
|
|
95
|
-
|
|
97
|
+
raw_response: raw_response, &callback)
|
|
96
98
|
rescue LaraApiError => e
|
|
97
99
|
raise unless e.status_code == 401
|
|
98
100
|
|
|
99
101
|
@auth_mutex.synchronize { refresh_or_reauthenticate }
|
|
100
102
|
make_request(method, path, body: body, files: files, headers: headers, params: params,
|
|
101
|
-
|
|
103
|
+
raw_response: raw_response, &callback)
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
def ensure_valid_token
|
|
@@ -110,7 +112,7 @@ module Lara
|
|
|
110
112
|
end
|
|
111
113
|
|
|
112
114
|
def refresh_or_reauthenticate
|
|
113
|
-
if @auth_token&.refresh_token
|
|
115
|
+
if @auth_token&.refresh_token
|
|
114
116
|
begin
|
|
115
117
|
do_refresh
|
|
116
118
|
return
|
|
@@ -160,8 +162,6 @@ module Lara
|
|
|
160
162
|
data = JSON.parse(response.body)
|
|
161
163
|
refresh_token_value = response.headers["x-lara-refresh-token"]
|
|
162
164
|
|
|
163
|
-
raise LaraError, "Missing refresh token in authentication response" unless refresh_token_value
|
|
164
|
-
|
|
165
165
|
AuthToken.new(data["token"], refresh_token_value)
|
|
166
166
|
end
|
|
167
167
|
|
|
@@ -186,12 +186,11 @@ module Lara
|
|
|
186
186
|
data = JSON.parse(response.body)
|
|
187
187
|
refresh_token_value = response.headers["x-lara-refresh-token"]
|
|
188
188
|
|
|
189
|
-
raise LaraError, "Missing refresh token in refresh response" unless refresh_token_value
|
|
190
|
-
|
|
191
189
|
@auth_token = AuthToken.new(data["token"], refresh_token_value)
|
|
192
190
|
end
|
|
193
191
|
|
|
194
|
-
def make_request(method, path, body: nil, files: nil, headers: nil, params: nil,
|
|
192
|
+
def make_request(method, path, body: nil, files: nil, headers: nil, params: nil,
|
|
193
|
+
raw_response: false, &callback)
|
|
195
194
|
path = "/#{path}" unless path.start_with?("/")
|
|
196
195
|
request_headers = build_request_headers(body, files, headers)
|
|
197
196
|
|
|
@@ -248,7 +247,7 @@ module Lara
|
|
|
248
247
|
|
|
249
248
|
begin
|
|
250
249
|
result = JSON.parse(trimmed_line)
|
|
251
|
-
block
|
|
250
|
+
block&.call(result)
|
|
252
251
|
last_result = result
|
|
253
252
|
rescue JSON::ParserError
|
|
254
253
|
next
|
|
@@ -258,7 +257,7 @@ module Lara
|
|
|
258
257
|
if !buffer.empty? && buffer.strip != ""
|
|
259
258
|
begin
|
|
260
259
|
result = JSON.parse(buffer.strip)
|
|
261
|
-
block
|
|
260
|
+
block&.call(result)
|
|
262
261
|
last_result = result
|
|
263
262
|
rescue JSON::ParserError
|
|
264
263
|
end
|
data/lib/lara/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lara-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Translated
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|