sendly 3.6.0 → 3.8.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 +30 -0
- data/lib/sendly/account_resource.rb +28 -0
- data/lib/sendly/messages.rb +38 -0
- data/lib/sendly/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6f94a917e0e9fe4109e3edc96008fc4381797e46e494f22834f74b4905cdd9c
|
|
4
|
+
data.tar.gz: fcf628838872a190ae6e4c54e2b9be79689d3f1500bac36938daff8e1b6df38e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b07d5bcaadfabd4f532cc27e3179dea0a5356b27492fde834682ae033565feea85a6a0254dfdaa30a927851e08f668b9b4bf09f4dac59cb232d3a5cb6b30033d
|
|
7
|
+
data.tar.gz: 40741e416c8d3a91abd08414c5066180828a582af6782250b7975c50c8b653167cf960067acb1bde3e8e9501abfc7572914da7b547efcc4ff7289281dbaff41d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/SendlyHQ/sendly-ruby/main/.github/header.svg" alt="Sendly Ruby SDK" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://rubygems.org/gems/sendly"><img src="https://img.shields.io/gem/v/sendly.svg?style=flat-square" alt="RubyGems" /></a>
|
|
7
|
+
<a href="https://github.com/SendlyHQ/sendly-ruby/blob/main/LICENSE"><img src="https://img.shields.io/github/license/SendlyHQ/sendly-ruby?style=flat-square" alt="license" /></a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
1
10
|
# Sendly Ruby SDK
|
|
2
11
|
|
|
3
12
|
Official Ruby SDK for the Sendly SMS API.
|
|
@@ -182,6 +191,16 @@ status = client.messages.get_batch("batch_xxx")
|
|
|
182
191
|
|
|
183
192
|
# List all batches
|
|
184
193
|
batches = client.messages.list_batches
|
|
194
|
+
|
|
195
|
+
# Preview batch (dry run) - validates without sending
|
|
196
|
+
preview = client.messages.preview_batch(
|
|
197
|
+
messages: [
|
|
198
|
+
{ to: '+15551234567', text: 'Hello User 1!' },
|
|
199
|
+
{ to: '+447700900123', text: 'Hello UK!' }
|
|
200
|
+
]
|
|
201
|
+
)
|
|
202
|
+
puts "Total credits needed: #{preview.total_credits}"
|
|
203
|
+
puts "Valid: #{preview.valid}, Invalid: #{preview.invalid}"
|
|
185
204
|
```
|
|
186
205
|
|
|
187
206
|
### Iterate All Messages
|
|
@@ -256,6 +275,17 @@ result = client.account.list_api_keys
|
|
|
256
275
|
result.data.each do |key|
|
|
257
276
|
puts "#{key.name}: #{key.prefix}*** (#{key.type})"
|
|
258
277
|
end
|
|
278
|
+
|
|
279
|
+
# Create a new API key
|
|
280
|
+
new_key = client.account.create_api_key(
|
|
281
|
+
name: 'Production Key',
|
|
282
|
+
type: 'live',
|
|
283
|
+
scopes: ['sms:send', 'sms:read']
|
|
284
|
+
)
|
|
285
|
+
puts "New key: #{new_key.key}" # Only shown once!
|
|
286
|
+
|
|
287
|
+
# Revoke an API key
|
|
288
|
+
client.account.revoke_api_key('key_xxx')
|
|
259
289
|
```
|
|
260
290
|
|
|
261
291
|
## Error Handling
|
|
@@ -66,5 +66,33 @@ module Sendly
|
|
|
66
66
|
def api_key_usage(key_id)
|
|
67
67
|
@client.get("/keys/#{key_id}/usage")
|
|
68
68
|
end
|
|
69
|
+
|
|
70
|
+
# Create a new API key
|
|
71
|
+
#
|
|
72
|
+
# @param name [String] Display name for the API key
|
|
73
|
+
# @param expires_at [String, nil] Optional expiration date (ISO 8601)
|
|
74
|
+
# @return [Hash] Contains 'apiKey' (metadata) and 'key' (full secret - only shown once!)
|
|
75
|
+
#
|
|
76
|
+
# @example
|
|
77
|
+
# result = client.account.create_api_key("Production")
|
|
78
|
+
# puts "Save this key: #{result['key']}" # Only shown once!
|
|
79
|
+
def create_api_key(name, expires_at: nil)
|
|
80
|
+
raise ArgumentError, "API key name is required" if name.nil? || name.empty?
|
|
81
|
+
|
|
82
|
+
body = { name: name }
|
|
83
|
+
body[:expiresAt] = expires_at if expires_at
|
|
84
|
+
|
|
85
|
+
@client.post("/account/keys", body)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Revoke an API key
|
|
89
|
+
#
|
|
90
|
+
# @param key_id [String] API key ID to revoke
|
|
91
|
+
# @return [void]
|
|
92
|
+
def revoke_api_key(key_id)
|
|
93
|
+
raise ArgumentError, "API key ID is required" if key_id.nil? || key_id.empty?
|
|
94
|
+
|
|
95
|
+
@client.delete("/account/keys/#{key_id}")
|
|
96
|
+
end
|
|
69
97
|
end
|
|
70
98
|
end
|
data/lib/sendly/messages.rb
CHANGED
|
@@ -282,6 +282,44 @@ module Sendly
|
|
|
282
282
|
client.get("/messages/batches", params.compact)
|
|
283
283
|
end
|
|
284
284
|
|
|
285
|
+
# Preview a batch without sending (dry run)
|
|
286
|
+
#
|
|
287
|
+
# @param messages [Array<Hash>] Array of messages with :to and :text keys
|
|
288
|
+
# @param from [String] Sender ID or phone number (optional, applies to all)
|
|
289
|
+
# @param message_type [String] Message type: "marketing" (default) or "transactional"
|
|
290
|
+
# @return [Hash] Preview showing what would happen if batch was sent
|
|
291
|
+
#
|
|
292
|
+
# @raise [Sendly::ValidationError] If parameters are invalid
|
|
293
|
+
#
|
|
294
|
+
# @example
|
|
295
|
+
# preview = client.messages.preview_batch(
|
|
296
|
+
# messages: [
|
|
297
|
+
# { to: "+15551234567", text: "Hello Alice!" },
|
|
298
|
+
# { to: "+15559876543", text: "Hello Bob!" }
|
|
299
|
+
# ]
|
|
300
|
+
# )
|
|
301
|
+
# puts "Can send: #{preview['canSend']}"
|
|
302
|
+
# puts "Credits needed: #{preview['creditsNeeded']}"
|
|
303
|
+
def preview_batch(messages:, from: nil, message_type: nil)
|
|
304
|
+
raise ValidationError, "Messages array is required" if messages.nil? || messages.empty?
|
|
305
|
+
|
|
306
|
+
messages.each_with_index do |msg, i|
|
|
307
|
+
raise ValidationError, "Message at index #{i} missing 'to'" unless msg[:to] || msg["to"]
|
|
308
|
+
raise ValidationError, "Message at index #{i} missing 'text'" unless msg[:text] || msg["text"]
|
|
309
|
+
|
|
310
|
+
to = msg[:to] || msg["to"]
|
|
311
|
+
text = msg[:text] || msg["text"]
|
|
312
|
+
validate_phone!(to)
|
|
313
|
+
validate_text!(text)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
body = { messages: messages }
|
|
317
|
+
body[:from] = from if from
|
|
318
|
+
body[:messageType] = message_type if message_type
|
|
319
|
+
|
|
320
|
+
client.post("/messages/batch/preview", body)
|
|
321
|
+
end
|
|
322
|
+
|
|
285
323
|
private
|
|
286
324
|
|
|
287
325
|
def validate_phone!(phone)
|
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.8.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-01-
|
|
11
|
+
date: 2026-01-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -131,13 +131,13 @@ files:
|
|
|
131
131
|
- lib/sendly/version.rb
|
|
132
132
|
- lib/sendly/webhooks.rb
|
|
133
133
|
- lib/sendly/webhooks_resource.rb
|
|
134
|
-
homepage: https://github.com/
|
|
134
|
+
homepage: https://github.com/SendlyHQ/sendly-ruby
|
|
135
135
|
licenses:
|
|
136
136
|
- MIT
|
|
137
137
|
metadata:
|
|
138
|
-
homepage_uri: https://github.com/
|
|
139
|
-
source_code_uri: https://github.com/
|
|
140
|
-
changelog_uri: https://github.com/
|
|
138
|
+
homepage_uri: https://github.com/SendlyHQ/sendly-ruby
|
|
139
|
+
source_code_uri: https://github.com/SendlyHQ/sendly-ruby
|
|
140
|
+
changelog_uri: https://github.com/SendlyHQ/sendly-ruby/blob/main/CHANGELOG.md
|
|
141
141
|
documentation_uri: https://sendly.live/docs
|
|
142
142
|
post_install_message:
|
|
143
143
|
rdoc_options: []
|