sendly 3.13.1 → 3.15.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/Gemfile.lock +1 -1
- data/README.md +7 -0
- data/lib/sendly/messages.rb +9 -3
- data/lib/sendly/types.rb +6 -1
- data/lib/sendly/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: 56c908f29c221c85c90e24d73b43066013f4d3cec54aba6fe7517fb227e045b4
|
|
4
|
+
data.tar.gz: d128303727afab0708a108693a8effc1026296ade3b90e2de848286166d8eaea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce1fa34f4d023c436c61fca5edd146f14eb57c8e7b881ed6e34f10d3aa1cfa18a0304fae311251c0c3dcb89ad86b0888ca74297d809d0f7863af6c808371f455
|
|
7
|
+
data.tar.gz: 9b1f5393016e47ec383a5436942c4da13f34acf65b95bb764d32aff4b83f615f3394326213926ad56ca2aa3bcfcecb2320ee07286215f1f8c2d7939b2c2457f7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -108,6 +108,13 @@ message = client.messages.send(
|
|
|
108
108
|
message_type: "transactional"
|
|
109
109
|
)
|
|
110
110
|
|
|
111
|
+
# With custom metadata (max 4KB)
|
|
112
|
+
message = client.messages.send(
|
|
113
|
+
to: "+15551234567",
|
|
114
|
+
text: "Your order #12345 has shipped!",
|
|
115
|
+
metadata: { order_id: "12345", customer_id: "cust_abc" }
|
|
116
|
+
)
|
|
117
|
+
|
|
111
118
|
puts message.id
|
|
112
119
|
puts message.status
|
|
113
120
|
puts message.credits_used
|
data/lib/sendly/messages.rb
CHANGED
|
@@ -15,6 +15,7 @@ module Sendly
|
|
|
15
15
|
# @param to [String] Recipient phone number in E.164 format
|
|
16
16
|
# @param text [String] Message content (max 1600 characters)
|
|
17
17
|
# @param message_type [String] Message type: "marketing" (default) or "transactional"
|
|
18
|
+
# @param metadata [Hash] Custom JSON metadata to attach to the message (max 4KB)
|
|
18
19
|
# @return [Sendly::Message] The sent message
|
|
19
20
|
#
|
|
20
21
|
# @raise [Sendly::ValidationError] If parameters are invalid
|
|
@@ -35,12 +36,13 @@ module Sendly
|
|
|
35
36
|
# text: "Your verification code is 123456",
|
|
36
37
|
# message_type: "transactional"
|
|
37
38
|
# )
|
|
38
|
-
def send(to:, text:, message_type: nil)
|
|
39
|
+
def send(to:, text:, message_type: nil, metadata: nil)
|
|
39
40
|
validate_phone!(to)
|
|
40
41
|
validate_text!(text)
|
|
41
42
|
|
|
42
43
|
body = { to: to, text: text }
|
|
43
44
|
body[:messageType] = message_type if message_type
|
|
45
|
+
body[:metadata] = metadata if metadata
|
|
44
46
|
|
|
45
47
|
response = client.post("/messages", body)
|
|
46
48
|
# API returns message directly at top level
|
|
@@ -129,6 +131,7 @@ module Sendly
|
|
|
129
131
|
# @param scheduled_at [String] ISO 8601 datetime for when to send
|
|
130
132
|
# @param from [String] Sender ID or phone number (optional)
|
|
131
133
|
# @param message_type [String] Message type: "marketing" (default) or "transactional"
|
|
134
|
+
# @param metadata [Hash] Custom JSON metadata to attach to the message (max 4KB)
|
|
132
135
|
# @return [Hash] The scheduled message
|
|
133
136
|
#
|
|
134
137
|
# @raise [Sendly::ValidationError] If parameters are invalid
|
|
@@ -140,7 +143,7 @@ module Sendly
|
|
|
140
143
|
# scheduled_at: "2025-01-20T10:00:00Z"
|
|
141
144
|
# )
|
|
142
145
|
# puts scheduled["id"]
|
|
143
|
-
def schedule(to:, text:, scheduled_at:, from: nil, message_type: nil)
|
|
146
|
+
def schedule(to:, text:, scheduled_at:, from: nil, message_type: nil, metadata: nil)
|
|
144
147
|
validate_phone!(to)
|
|
145
148
|
validate_text!(text)
|
|
146
149
|
raise ValidationError, "scheduled_at is required" if scheduled_at.nil? || scheduled_at.empty?
|
|
@@ -148,6 +151,7 @@ module Sendly
|
|
|
148
151
|
body = { to: to, text: text, scheduledAt: scheduled_at }
|
|
149
152
|
body[:from] = from if from
|
|
150
153
|
body[:messageType] = message_type if message_type
|
|
154
|
+
body[:metadata] = metadata if metadata
|
|
151
155
|
|
|
152
156
|
client.post("/messages/schedule", body)
|
|
153
157
|
end
|
|
@@ -212,6 +216,7 @@ module Sendly
|
|
|
212
216
|
# @param messages [Array<Hash>] Array of messages with :to and :text keys
|
|
213
217
|
# @param from [String] Sender ID or phone number (optional, applies to all)
|
|
214
218
|
# @param message_type [String] Message type: "marketing" (default) or "transactional"
|
|
219
|
+
# @param metadata [Hash] Shared metadata for all messages (max 4KB). Each message can also have its own metadata hash which takes priority.
|
|
215
220
|
# @return [Hash] Batch response with batch_id and status
|
|
216
221
|
#
|
|
217
222
|
# @raise [Sendly::ValidationError] If parameters are invalid
|
|
@@ -225,7 +230,7 @@ module Sendly
|
|
|
225
230
|
# ]
|
|
226
231
|
# )
|
|
227
232
|
# puts "Batch #{result['batchId']}: #{result['queued']} queued"
|
|
228
|
-
def send_batch(messages:, from: nil, message_type: nil)
|
|
233
|
+
def send_batch(messages:, from: nil, message_type: nil, metadata: nil)
|
|
229
234
|
raise ValidationError, "Messages array is required" if messages.nil? || messages.empty?
|
|
230
235
|
|
|
231
236
|
messages.each_with_index do |msg, i|
|
|
@@ -241,6 +246,7 @@ module Sendly
|
|
|
241
246
|
body = { messages: messages }
|
|
242
247
|
body[:from] = from if from
|
|
243
248
|
body[:messageType] = message_type if message_type
|
|
249
|
+
body[:metadata] = metadata if metadata
|
|
244
250
|
|
|
245
251
|
client.post("/messages/batch", body)
|
|
246
252
|
end
|
data/lib/sendly/types.rb
CHANGED
|
@@ -51,6 +51,9 @@ module Sendly
|
|
|
51
51
|
# @return [Time, nil] Delivery timestamp
|
|
52
52
|
attr_reader :delivered_at
|
|
53
53
|
|
|
54
|
+
# @return [Hash, nil] Custom metadata attached to the message
|
|
55
|
+
attr_reader :metadata
|
|
56
|
+
|
|
54
57
|
# Message status constants (sending removed - doesn't exist in database)
|
|
55
58
|
STATUSES = %w[queued sent delivered failed bounced].freeze
|
|
56
59
|
|
|
@@ -74,6 +77,7 @@ module Sendly
|
|
|
74
77
|
@sender_note = data["senderNote"]
|
|
75
78
|
@created_at = parse_time(data["createdAt"])
|
|
76
79
|
@delivered_at = parse_time(data["deliveredAt"])
|
|
80
|
+
@metadata = data["metadata"]
|
|
77
81
|
end
|
|
78
82
|
|
|
79
83
|
# Check if message was delivered
|
|
@@ -113,7 +117,8 @@ module Sendly
|
|
|
113
117
|
warning: warning,
|
|
114
118
|
sender_note: sender_note,
|
|
115
119
|
created_at: created_at&.iso8601,
|
|
116
|
-
delivered_at: delivered_at&.iso8601
|
|
120
|
+
delivered_at: delivered_at&.iso8601,
|
|
121
|
+
metadata: metadata
|
|
117
122
|
}.compact
|
|
118
123
|
end
|
|
119
124
|
|
data/lib/sendly/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sendly
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.15.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sendly
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|