ruby-anvil 0.1.0.pre.rc.1 → 0.1.0
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/CHANGELOG.md +5 -0
- data/README.md +5 -3
- data/lib/anvil/client.rb +2 -1
- data/lib/anvil/response.rb +12 -0
- data/lib/anvil/types/base.rb +12 -0
- data/lib/anvil/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: 33dbeede67d488e138f6162a5ea09e0a870975d5559ec16c6c272f520d688f48
|
|
4
|
+
data.tar.gz: db49b64c22709a49a1ccd0eef0478b695b5fef4a63ff396c5d1258d4f07cb4b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd8af9ba11d639cfcb33ce3ef27f0c8c61a9a2f6071a9c39c5e3a8345d847f93a1a957adbac6f0e47dc4cdfed15e67209571caede67f75c0a1ac27124d7c3225
|
|
7
|
+
data.tar.gz: 19f25b7321fb42eb3721d5b85e4b0a8956ad4a4567abfb5c9b6068d5bb73fb47a8e17d87ae1f10ff8351ed485c96c69a48e9a6ba2f16db1edf5609f5c727a727
|
data/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,8 @@ as they land.
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [v0.1.0] - 2026-11-23
|
|
14
|
+
|
|
13
15
|
The first release: the Anvil API in Ruby, with the same coverage as the
|
|
14
16
|
[Node client](https://github.com/anvilco/node-anvil).
|
|
15
17
|
|
|
@@ -34,6 +36,8 @@ The first release: the Anvil API in Ruby, with the same coverage as the
|
|
|
34
36
|
- `:string`, `:io`, `:stream` and `:json` response types, so a large PDF or zip
|
|
35
37
|
never has to be held in memory whole.
|
|
36
38
|
- `get_current_user`, reading whoever the credentials belong to.
|
|
39
|
+
- `dig` on GraphQL responses and on response types, alongside `[]`, so a nested
|
|
40
|
+
value can be read in one call without checking each level for nil.
|
|
37
41
|
- An `ANVIL_API_KEY` environment variable fallback, so a client built with no
|
|
38
42
|
arguments works.
|
|
39
43
|
- Retries for the responses the API could not give: 500, 502, 503 and 504, and
|
|
@@ -59,3 +63,4 @@ few behaviors match python-anvil and dotnet-anvil rather than node-anvil:
|
|
|
59
63
|
`Retry-After` it named capped at a minute.
|
|
60
64
|
- A 2xx whose body carries only a `name` or a `message` is not an error.
|
|
61
65
|
node-anvil treats it as one; that is a known divergence.
|
|
66
|
+
|
data/README.md
CHANGED
|
@@ -424,8 +424,9 @@ response = client.request_graphql(
|
|
|
424
424
|
variables: { eid: "nxflNZqxDUbltLUbYWK" }
|
|
425
425
|
)
|
|
426
426
|
|
|
427
|
-
response["weldData"]["isComplete"]
|
|
428
|
-
response.
|
|
427
|
+
response["weldData"]["isComplete"] # the result of one operation
|
|
428
|
+
response.dig("weldData", "isComplete") # the same, without checking each level
|
|
429
|
+
response.data # the whole GraphQL data map
|
|
429
430
|
response.status_code
|
|
430
431
|
```
|
|
431
432
|
|
|
@@ -682,6 +683,7 @@ packet.details_url # a declared field
|
|
|
682
683
|
packet.created_at # timestamps are parsed into Time
|
|
683
684
|
packet.document_group.signers # nested objects are typed too
|
|
684
685
|
packet["someFieldAddedYesterday"] # anything else, by its API name
|
|
686
|
+
packet.dig("documentGroup", "signers", 0, "eid") # down a path, nils and all
|
|
685
687
|
packet.to_h # the response exactly as it arrived
|
|
686
688
|
```
|
|
687
689
|
|
|
@@ -693,7 +695,7 @@ are generated and kept in step with production.
|
|
|
693
695
|
|
|
694
696
|
A custom `response_query` works with this: fields you did not select read as
|
|
695
697
|
`nil`, and fields the type does not declare are still in `to_h` and reachable
|
|
696
|
-
with `[]`.
|
|
698
|
+
with `[]` or `dig`.
|
|
697
699
|
|
|
698
700
|
## Development
|
|
699
701
|
|
data/lib/anvil/client.rb
CHANGED
|
@@ -538,9 +538,10 @@ module Anvil
|
|
|
538
538
|
request
|
|
539
539
|
end
|
|
540
540
|
|
|
541
|
+
# An empty payload still goes as `{}`: a request with no content type is
|
|
542
|
+
# refused for that rather than for the field the caller left out.
|
|
541
543
|
def apply_body(request, body)
|
|
542
544
|
return if body.nil?
|
|
543
|
-
return if body.respond_to?(:empty?) && body.empty? && !body.is_a?(String)
|
|
544
545
|
|
|
545
546
|
if body.is_a?(String)
|
|
546
547
|
request.body = body
|
data/lib/anvil/response.rb
CHANGED
|
@@ -80,5 +80,17 @@ module Anvil
|
|
|
80
80
|
def [](name)
|
|
81
81
|
data[name.to_s]
|
|
82
82
|
end
|
|
83
|
+
|
|
84
|
+
# Reaches into the operation's result.
|
|
85
|
+
#
|
|
86
|
+
# response.dig("createEtchPacket", "documentGroup", "eid")
|
|
87
|
+
#
|
|
88
|
+
# @param name [String, Symbol] the operation's name in the response
|
|
89
|
+
# @param rest [Array<String, Symbol, Integer>] the path within its result
|
|
90
|
+
# @return [Object, nil]
|
|
91
|
+
def dig(name, *rest)
|
|
92
|
+
value = self[name]
|
|
93
|
+
rest.empty? ? value : value&.dig(*rest)
|
|
94
|
+
end
|
|
83
95
|
end
|
|
84
96
|
end
|
data/lib/anvil/types/base.rb
CHANGED
|
@@ -121,6 +121,18 @@ module Anvil
|
|
|
121
121
|
raw[key.to_s].nil? ? raw[key.to_sym] : raw[key.to_s]
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
+
# Reaches into a field the way {#[]} does, and on down the path.
|
|
125
|
+
#
|
|
126
|
+
# packet.dig("documentGroup", "signers", 0, "eid")
|
|
127
|
+
#
|
|
128
|
+
# @param key [String, Symbol]
|
|
129
|
+
# @param rest [Array<String, Symbol, Integer>]
|
|
130
|
+
# @return [Object, nil]
|
|
131
|
+
def dig(key, *rest)
|
|
132
|
+
value = self[key]
|
|
133
|
+
rest.empty? ? value : value&.dig(*rest)
|
|
134
|
+
end
|
|
135
|
+
|
|
124
136
|
# @return [Hash] the object as the API returned it
|
|
125
137
|
def to_h
|
|
126
138
|
raw
|
data/lib/anvil/version.rb
CHANGED