sendly 3.0.0 → 3.4.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/Gemfile.lock +3 -3
- data/lib/sendly/messages.rb +19 -4
- data/lib/sendly/types.rb +5 -1
- data/lib/sendly/version.rb +1 -1
- data/lib/sendly/webhooks_resource.rb +8 -3
- 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: 589daabda1501b7726c11abf2bceb8877978c98548a36ac6a23334979307c475
|
|
4
|
+
data.tar.gz: 292ac38cf1420e2dad947ec2969b527672ba306cfe8f1ef228bf492e5d60cec2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b26012a6d67959dc56643c51bb40639867350754482171d4e93980c29c37d4ed8ae7d3ee831360bcd45d1313bc727cf079aae9709b229a1a39a954aa21001a86
|
|
7
|
+
data.tar.gz: a9890cd4bd6bfcec7e37063b331f2b1b72713024781bc41a0765a015aba2c58f502cf0dc3b99c05e5648de38d41ca1fc1306b7a351d3da49099008760766bce1
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sendly (3.
|
|
4
|
+
sendly (3.4.0)
|
|
5
5
|
faraday (~> 2.0)
|
|
6
6
|
faraday-retry (~> 2.0)
|
|
7
7
|
|
|
@@ -36,7 +36,7 @@ GEM
|
|
|
36
36
|
ast (~> 2.4.1)
|
|
37
37
|
racc
|
|
38
38
|
prism (1.6.0)
|
|
39
|
-
public_suffix (
|
|
39
|
+
public_suffix (6.0.2)
|
|
40
40
|
racc (1.8.1)
|
|
41
41
|
rainbow (3.1.1)
|
|
42
42
|
rake (13.3.1)
|
|
@@ -92,4 +92,4 @@ DEPENDENCIES
|
|
|
92
92
|
webmock (~> 3.0)
|
|
93
93
|
|
|
94
94
|
BUNDLED WITH
|
|
95
|
-
2.
|
|
95
|
+
2.5.23
|
data/lib/sendly/messages.rb
CHANGED
|
@@ -14,6 +14,7 @@ module Sendly
|
|
|
14
14
|
#
|
|
15
15
|
# @param to [String] Recipient phone number in E.164 format
|
|
16
16
|
# @param text [String] Message content (max 1600 characters)
|
|
17
|
+
# @param message_type [String] Message type: "marketing" (default) or "transactional"
|
|
17
18
|
# @return [Sendly::Message] The sent message
|
|
18
19
|
#
|
|
19
20
|
# @raise [Sendly::ValidationError] If parameters are invalid
|
|
@@ -27,11 +28,21 @@ module Sendly
|
|
|
27
28
|
# )
|
|
28
29
|
# puts message.id
|
|
29
30
|
# puts message.status
|
|
30
|
-
|
|
31
|
+
#
|
|
32
|
+
# @example Transactional message (bypasses quiet hours)
|
|
33
|
+
# message = client.messages.send(
|
|
34
|
+
# to: "+15551234567",
|
|
35
|
+
# text: "Your verification code is 123456",
|
|
36
|
+
# message_type: "transactional"
|
|
37
|
+
# )
|
|
38
|
+
def send(to:, text:, message_type: nil)
|
|
31
39
|
validate_phone!(to)
|
|
32
40
|
validate_text!(text)
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
body = { to: to, text: text }
|
|
43
|
+
body[:messageType] = message_type if message_type
|
|
44
|
+
|
|
45
|
+
response = client.post("/messages", body)
|
|
35
46
|
# API returns message directly at top level
|
|
36
47
|
Message.new(response)
|
|
37
48
|
end
|
|
@@ -117,6 +128,7 @@ module Sendly
|
|
|
117
128
|
# @param text [String] Message content (max 1600 characters)
|
|
118
129
|
# @param scheduled_at [String] ISO 8601 datetime for when to send
|
|
119
130
|
# @param from [String] Sender ID or phone number (optional)
|
|
131
|
+
# @param message_type [String] Message type: "marketing" (default) or "transactional"
|
|
120
132
|
# @return [Hash] The scheduled message
|
|
121
133
|
#
|
|
122
134
|
# @raise [Sendly::ValidationError] If parameters are invalid
|
|
@@ -128,13 +140,14 @@ module Sendly
|
|
|
128
140
|
# scheduled_at: "2025-01-20T10:00:00Z"
|
|
129
141
|
# )
|
|
130
142
|
# puts scheduled["id"]
|
|
131
|
-
def schedule(to:, text:, scheduled_at:, from: nil)
|
|
143
|
+
def schedule(to:, text:, scheduled_at:, from: nil, message_type: nil)
|
|
132
144
|
validate_phone!(to)
|
|
133
145
|
validate_text!(text)
|
|
134
146
|
raise ValidationError, "scheduled_at is required" if scheduled_at.nil? || scheduled_at.empty?
|
|
135
147
|
|
|
136
148
|
body = { to: to, text: text, scheduledAt: scheduled_at }
|
|
137
149
|
body[:from] = from if from
|
|
150
|
+
body[:messageType] = message_type if message_type
|
|
138
151
|
|
|
139
152
|
client.post("/messages/schedule", body)
|
|
140
153
|
end
|
|
@@ -198,6 +211,7 @@ module Sendly
|
|
|
198
211
|
#
|
|
199
212
|
# @param messages [Array<Hash>] Array of messages with :to and :text keys
|
|
200
213
|
# @param from [String] Sender ID or phone number (optional, applies to all)
|
|
214
|
+
# @param message_type [String] Message type: "marketing" (default) or "transactional"
|
|
201
215
|
# @return [Hash] Batch response with batch_id and status
|
|
202
216
|
#
|
|
203
217
|
# @raise [Sendly::ValidationError] If parameters are invalid
|
|
@@ -211,7 +225,7 @@ module Sendly
|
|
|
211
225
|
# ]
|
|
212
226
|
# )
|
|
213
227
|
# puts "Batch #{result['batchId']}: #{result['queued']} queued"
|
|
214
|
-
def send_batch(messages:, from: nil)
|
|
228
|
+
def send_batch(messages:, from: nil, message_type: nil)
|
|
215
229
|
raise ValidationError, "Messages array is required" if messages.nil? || messages.empty?
|
|
216
230
|
|
|
217
231
|
messages.each_with_index do |msg, i|
|
|
@@ -226,6 +240,7 @@ module Sendly
|
|
|
226
240
|
|
|
227
241
|
body = { messages: messages }
|
|
228
242
|
body[:from] = from if from
|
|
243
|
+
body[:messageType] = message_type if message_type
|
|
229
244
|
|
|
230
245
|
client.post("/messages/batch", body)
|
|
231
246
|
end
|
data/lib/sendly/types.rb
CHANGED
|
@@ -194,7 +194,7 @@ module Sendly
|
|
|
194
194
|
|
|
195
195
|
# Represents a configured webhook endpoint
|
|
196
196
|
class Webhook
|
|
197
|
-
attr_reader :id, :url, :events, :description, :is_active, :failure_count,
|
|
197
|
+
attr_reader :id, :url, :events, :description, :mode, :is_active, :failure_count,
|
|
198
198
|
:last_failure_at, :circuit_state, :circuit_opened_at, :api_version,
|
|
199
199
|
:metadata, :created_at, :updated_at, :total_deliveries,
|
|
200
200
|
:successful_deliveries, :success_rate, :last_delivery_at
|
|
@@ -202,11 +202,15 @@ module Sendly
|
|
|
202
202
|
# Circuit state constants
|
|
203
203
|
CIRCUIT_STATES = %w[closed open half_open].freeze
|
|
204
204
|
|
|
205
|
+
# Webhook mode constants
|
|
206
|
+
MODES = %w[all test live].freeze
|
|
207
|
+
|
|
205
208
|
def initialize(data)
|
|
206
209
|
@id = data["id"]
|
|
207
210
|
@url = data["url"]
|
|
208
211
|
@events = data["events"] || []
|
|
209
212
|
@description = data["description"]
|
|
213
|
+
@mode = data["mode"] || "all"
|
|
210
214
|
# Handle both snake_case API response and camelCase
|
|
211
215
|
@is_active = data["is_active"] || data["isActive"] || false
|
|
212
216
|
@failure_count = data["failure_count"] || data["failureCount"] || 0
|
data/lib/sendly/version.rb
CHANGED
|
@@ -13,21 +13,24 @@ module Sendly
|
|
|
13
13
|
# @param url [String] HTTPS endpoint URL
|
|
14
14
|
# @param events [Array<String>] Event types to subscribe to
|
|
15
15
|
# @param description [String, nil] Optional description
|
|
16
|
+
# @param mode [String, nil] Event mode filter: "all", "test", or "live" (live requires verification)
|
|
16
17
|
# @param metadata [Hash, nil] Custom metadata
|
|
17
18
|
# @return [Sendly::WebhookCreatedResponse]
|
|
18
19
|
#
|
|
19
20
|
# @example
|
|
20
21
|
# webhook = client.webhooks.create(
|
|
21
22
|
# url: "https://example.com/webhooks",
|
|
22
|
-
# events: ["message.delivered", "message.failed"]
|
|
23
|
+
# events: ["message.delivered", "message.failed"],
|
|
24
|
+
# mode: "all"
|
|
23
25
|
# )
|
|
24
26
|
# puts "Secret: #{webhook.secret}" # Save this - only shown once!
|
|
25
|
-
def create(url:, events:, description: nil, metadata: nil)
|
|
27
|
+
def create(url:, events:, description: nil, mode: nil, metadata: nil)
|
|
26
28
|
raise ArgumentError, "Webhook URL must be HTTPS" unless url&.start_with?("https://")
|
|
27
29
|
raise ArgumentError, "At least one event type is required" if events.nil? || events.empty?
|
|
28
30
|
|
|
29
31
|
body = { url: url, events: events }
|
|
30
32
|
body[:description] = description if description
|
|
33
|
+
body[:mode] = mode if mode
|
|
31
34
|
body[:metadata] = metadata if metadata
|
|
32
35
|
|
|
33
36
|
response = @client.post("/webhooks", body)
|
|
@@ -59,9 +62,10 @@ module Sendly
|
|
|
59
62
|
# @param events [Array<String>, nil] New event subscriptions
|
|
60
63
|
# @param description [String, nil] New description
|
|
61
64
|
# @param is_active [Boolean, nil] Enable/disable webhook
|
|
65
|
+
# @param mode [String, nil] Event mode filter: "all", "test", or "live"
|
|
62
66
|
# @param metadata [Hash, nil] Custom metadata
|
|
63
67
|
# @return [Sendly::Webhook]
|
|
64
|
-
def update(webhook_id, url: nil, events: nil, description: nil, is_active: nil, metadata: nil)
|
|
68
|
+
def update(webhook_id, url: nil, events: nil, description: nil, is_active: nil, mode: nil, metadata: nil)
|
|
65
69
|
validate_webhook_id!(webhook_id)
|
|
66
70
|
raise ArgumentError, "Webhook URL must be HTTPS" if url && !url.start_with?("https://")
|
|
67
71
|
|
|
@@ -70,6 +74,7 @@ module Sendly
|
|
|
70
74
|
body[:events] = events unless events.nil?
|
|
71
75
|
body[:description] = description unless description.nil?
|
|
72
76
|
body[:is_active] = is_active unless is_active.nil?
|
|
77
|
+
body[:mode] = mode unless mode.nil?
|
|
73
78
|
body[:metadata] = metadata unless metadata.nil?
|
|
74
79
|
|
|
75
80
|
response = @client.patch("/webhooks/#{webhook_id}", body)
|
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.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sendly
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-12-
|
|
11
|
+
date: 2025-12-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -139,7 +139,7 @@ metadata:
|
|
|
139
139
|
source_code_uri: https://github.com/sendly-live/sendly-ruby
|
|
140
140
|
changelog_uri: https://github.com/sendly-live/sendly-ruby/blob/main/CHANGELOG.md
|
|
141
141
|
documentation_uri: https://sendly.live/docs
|
|
142
|
-
post_install_message:
|
|
142
|
+
post_install_message:
|
|
143
143
|
rdoc_options: []
|
|
144
144
|
require_paths:
|
|
145
145
|
- lib
|
|
@@ -154,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
154
154
|
- !ruby/object:Gem::Version
|
|
155
155
|
version: '0'
|
|
156
156
|
requirements: []
|
|
157
|
-
rubygems_version: 3.
|
|
158
|
-
signing_key:
|
|
157
|
+
rubygems_version: 3.3.5
|
|
158
|
+
signing_key:
|
|
159
159
|
specification_version: 4
|
|
160
160
|
summary: Official Ruby SDK for the Sendly SMS API
|
|
161
161
|
test_files: []
|