anypost 1.1.0 → 1.2.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/README.md +1 -1
- data/lib/anypost/resources/email.rb +28 -7
- data/lib/anypost/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: d4f2beb7843c3c48b729699c36fc03b0a839fd0a05c74384f3f0700746695c5e
|
|
4
|
+
data.tar.gz: 0a12d2a076b57cf00fdaa55916e24d53cb159de674df098d8fe53cd26e771a81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1cfad0e0062488f04315140910e1382d0f3dac314df889cb91aac7bea2d3d596c6a8fe97668444342a44336e75beaf32251fa138f18c4d8ea3fab265a6e8bc4c
|
|
7
|
+
data.tar.gz: 1d8915191a1be6229cd56ae3193c42c801d845c618b6e39c955b5da897634fb90a9bc88b28593c7172746017c6c3bd4b2a68d74cf8f59cef6b968ec9687c7de8
|
data/README.md
CHANGED
|
@@ -62,7 +62,7 @@ client.email.send(
|
|
|
62
62
|
)
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
Attachment `content` is the raw file bytes: pass what `File.binread` returns and the SDK base64-encodes it.
|
|
65
|
+
Attachment `content` is the raw file bytes: pass what `File.binread` returns and the SDK base64-encodes it. When the content is already base64 at rest, pass it as `content_base64` instead — that string is sent verbatim, so nothing is decoded just to be re-encoded. Set exactly one of the two. The request body is capped at 5 MB.
|
|
66
66
|
|
|
67
67
|
```ruby
|
|
68
68
|
client.email.send(
|
|
@@ -4,8 +4,12 @@ module Anypost
|
|
|
4
4
|
module Resources
|
|
5
5
|
# Operations on the `/email` endpoints.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
7
|
+
# Give each attachment its content exactly one of two ways: `content` for raw
|
|
8
|
+
# file bytes (e.g. from `File.binread`), which the SDK base64-encodes for
|
|
9
|
+
# transport, or `content_base64` for content that is already base64 at rest,
|
|
10
|
+
# which is sent through verbatim so nothing is decoded just to be re-encoded.
|
|
11
|
+
# Ruby has no type-level distinction between the two — both are Strings — so
|
|
12
|
+
# the key you choose is the signal.
|
|
9
13
|
class Email < Base
|
|
10
14
|
# Send a single message.
|
|
11
15
|
#
|
|
@@ -35,13 +39,30 @@ module Anypost
|
|
|
35
39
|
return message unless attachments.is_a?(Array)
|
|
36
40
|
|
|
37
41
|
message = message.dup
|
|
38
|
-
message[:attachments] = attachments.map
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
message[:attachments] = attachments.map { |attachment| encode_attachment(attachment) }
|
|
43
|
+
message
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Collapse an attachment's two possible content keys onto the single
|
|
47
|
+
# base64 `content` field the API takes.
|
|
48
|
+
def encode_attachment(attachment)
|
|
49
|
+
return attachment unless attachment.is_a?(Hash)
|
|
50
|
+
|
|
51
|
+
raw = attachment[:content]
|
|
52
|
+
encoded = attachment[:content_base64]
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
if raw && encoded
|
|
55
|
+
raise ArgumentError,
|
|
56
|
+
"attachment #{attachment[:filename].inspect} sets both :content and " \
|
|
57
|
+
":content_base64; set exactly one"
|
|
43
58
|
end
|
|
44
|
-
|
|
59
|
+
|
|
60
|
+
return attachment.except(:content_base64).merge(content: encoded) if encoded
|
|
61
|
+
return attachment.merge(content: [raw].pack("m0")) if raw.is_a?(String)
|
|
62
|
+
|
|
63
|
+
raise ArgumentError,
|
|
64
|
+
"attachment #{attachment[:filename].inspect} has no content; set :content " \
|
|
65
|
+
"(raw bytes) or :content_base64"
|
|
45
66
|
end
|
|
46
67
|
end
|
|
47
68
|
end
|
data/lib/anypost/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: anypost
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anypost
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-08-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|