apertur-sdk 0.1.0 → 0.1.5
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/README.md +8 -0
- data/lib/apertur/http_client.rb +8 -4
- data/lib/apertur/resources/sessions.rb +26 -3
- data/lib/apertur/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: 8e13b276ea448173ed53e96ce31df30060b576c768acd1012bc9df6df2030375
|
|
4
|
+
data.tar.gz: ed633c8bd5e7509b7ef7f7a98e63fa2b8912048ca141e9230e184cff16eca960
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 617cd4b37d3da2fffe8292367cbd336d42076fed098eaa72e77360b1440911b73ba22bb664b104bf73c7d8bc41279c2d3656ae113ba7630ca4c598de3c3b44e9
|
|
7
|
+
data.tar.gz: 3806c669fb2bcb4eac40c7d4ecebed20a98993a6a19e82d13c2f290277e6b47b4d21122d9f525197cf2b65e17fb1d61bb31487e0fd2b5a066a762fa8bdc2dc8a
|
data/README.md
CHANGED
|
@@ -64,7 +64,15 @@ client.sessions.list(page: 1, page_size: 20)
|
|
|
64
64
|
client.sessions.recent(limit: 5)
|
|
65
65
|
client.sessions.qr("uuid", format: "png", size: 300)
|
|
66
66
|
client.sessions.verify_password("uuid", "secret")
|
|
67
|
+
|
|
68
|
+
# Delivery status returns:
|
|
69
|
+
# { "status" => "pending|active|completed|expired",
|
|
70
|
+
# "files" => [...], "lastChanged" => "<ISO 8601>" }
|
|
67
71
|
client.sessions.delivery_status("uuid")
|
|
72
|
+
|
|
73
|
+
# Long-poll: server holds up to 5 min until something changes. Passing
|
|
74
|
+
# `poll_from:` widens the per-request read timeout to 360 s automatically.
|
|
75
|
+
client.sessions.delivery_status("uuid", poll_from: "2026-04-18T12:34:56Z")
|
|
68
76
|
```
|
|
69
77
|
|
|
70
78
|
### Upload
|
data/lib/apertur/http_client.rb
CHANGED
|
@@ -25,9 +25,11 @@ module Apertur
|
|
|
25
25
|
# @param body [Hash, nil] request body to be serialized as JSON
|
|
26
26
|
# @param query [Hash, nil] query parameters
|
|
27
27
|
# @param headers [Hash] additional request headers
|
|
28
|
+
# @param read_timeout [Integer, Float, nil] override the per-request
|
|
29
|
+
# read timeout (seconds). Defaults to the connection default (60s).
|
|
28
30
|
# @return [Hash, Array, nil] parsed JSON response, or nil for 204
|
|
29
31
|
# @raise [Apertur::Error] on API errors
|
|
30
|
-
def request(method, path, body: nil, query: nil, headers: {})
|
|
32
|
+
def request(method, path, body: nil, query: nil, headers: {}, read_timeout: nil)
|
|
31
33
|
uri = build_uri(path, query)
|
|
32
34
|
req = build_request(method, uri, headers)
|
|
33
35
|
|
|
@@ -36,7 +38,7 @@ module Apertur
|
|
|
36
38
|
req.body = body.is_a?(String) ? body : JSON.generate(body)
|
|
37
39
|
end
|
|
38
40
|
|
|
39
|
-
response = execute(uri, req)
|
|
41
|
+
response = execute(uri, req, read_timeout: read_timeout)
|
|
40
42
|
handle_response(response)
|
|
41
43
|
end
|
|
42
44
|
|
|
@@ -119,12 +121,14 @@ module Apertur
|
|
|
119
121
|
|
|
120
122
|
# @param uri [URI]
|
|
121
123
|
# @param req [Net::HTTPRequest]
|
|
124
|
+
# @param read_timeout [Integer, Float, nil] optional override for
|
|
125
|
+
# +Net::HTTP#read_timeout+ (seconds).
|
|
122
126
|
# @return [Net::HTTPResponse]
|
|
123
|
-
def execute(uri, req)
|
|
127
|
+
def execute(uri, req, read_timeout: nil)
|
|
124
128
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
125
129
|
http.use_ssl = (uri.scheme == "https")
|
|
126
130
|
http.open_timeout = 30
|
|
127
|
-
http.read_timeout = 60
|
|
131
|
+
http.read_timeout = read_timeout || 60
|
|
128
132
|
http.request(req)
|
|
129
133
|
end
|
|
130
134
|
|
|
@@ -102,10 +102,33 @@ module Apertur
|
|
|
102
102
|
|
|
103
103
|
# Get the delivery status for a session.
|
|
104
104
|
#
|
|
105
|
+
# Returns a hash with the following shape:
|
|
106
|
+
#
|
|
107
|
+
# {
|
|
108
|
+
# "status" => "pending" | "active" | "completed" | "expired",
|
|
109
|
+
# "files" => [ { "record_id" => ..., "filename" => ..., "size_bytes" => ...,
|
|
110
|
+
# "destinations" => [ { "destination_id" => ..., "status" => ..., ... } ] } ],
|
|
111
|
+
# "lastChanged" => "<ISO 8601>"
|
|
112
|
+
# }
|
|
113
|
+
#
|
|
114
|
+
# When +poll_from+ (ISO 8601 timestamp) is provided, the server long-polls for
|
|
115
|
+
# up to 5 minutes waiting for something to change before responding. This call
|
|
116
|
+
# automatically widens the read timeout to 360 s (6 min) in that case so the
|
|
117
|
+
# server releases first under the happy path.
|
|
118
|
+
#
|
|
105
119
|
# @param uuid [String] the session UUID
|
|
106
|
-
# @
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
# @param poll_from [String, nil] ISO 8601 timestamp; when set, enables long-poll mode
|
|
121
|
+
# @return [Hash] delivery status snapshot
|
|
122
|
+
def delivery_status(uuid, poll_from: nil)
|
|
123
|
+
query = {}
|
|
124
|
+
query["pollFrom"] = poll_from if poll_from
|
|
125
|
+
read_timeout = poll_from ? 360 : nil
|
|
126
|
+
@http.request(
|
|
127
|
+
:get,
|
|
128
|
+
"/api/v1/upload-sessions/#{uuid}/delivery-status",
|
|
129
|
+
query: query,
|
|
130
|
+
read_timeout: read_timeout,
|
|
131
|
+
)
|
|
109
132
|
end
|
|
110
133
|
end
|
|
111
134
|
end
|
data/lib/apertur/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apertur-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Apertur
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Official Ruby client for the Apertur image upload and delivery API. Supports
|
|
14
14
|
session management, image uploads (including client-side encryption), polling, destinations,
|