sendly 4.1.0 → 4.3.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 +98 -0
- data/Gemfile.lock +3 -3
- data/README.md +829 -150
- data/examples/list_messages.rb +1 -1
- data/examples/send_sms.rb +6 -2
- data/lib/sendly/account_resource.rb +16 -4
- data/lib/sendly/business_upgrade_resource.rb +3 -2
- data/lib/sendly/calls_resource.rb +29 -14
- data/lib/sendly/campaigns_resource.rb +59 -8
- data/lib/sendly/client.rb +55 -21
- data/lib/sendly/conversations_resource.rb +17 -5
- data/lib/sendly/drafts_resource.rb +2 -1
- data/lib/sendly/enterprise.rb +21 -10
- data/lib/sendly/errors.rb +46 -18
- data/lib/sendly/messages.rb +31 -11
- data/lib/sendly/numbers_resource.rb +2 -1
- data/lib/sendly/templates_resource.rb +0 -4
- data/lib/sendly/types.rb +165 -26
- data/lib/sendly/version.rb +1 -1
- data/lib/sendly/voice_resource.rb +721 -0
- data/lib/sendly/webhooks_resource.rb +30 -7
- data/lib/sendly/whatsapp_resource.rb +595 -44
- data/lib/sendly.rb +1 -0
- metadata +3 -2
|
@@ -16,6 +16,8 @@ module Sendly
|
|
|
16
16
|
# @param mode [String, nil] Event mode filter: "all", "test", or "live" (live requires verification)
|
|
17
17
|
# @param metadata [Hash, nil] Custom metadata
|
|
18
18
|
# @return [Sendly::WebhookCreatedResponse]
|
|
19
|
+
# @raise [ArgumentError] If +url+ is not an https:// URL or +events+ is
|
|
20
|
+
# empty; no request is sent
|
|
19
21
|
#
|
|
20
22
|
# @example
|
|
21
23
|
# webhook = client.webhooks.create(
|
|
@@ -65,6 +67,8 @@ module Sendly
|
|
|
65
67
|
# @param mode [String, nil] Event mode filter: "all", "test", or "live"
|
|
66
68
|
# @param metadata [Hash, nil] Custom metadata
|
|
67
69
|
# @return [Sendly::Webhook]
|
|
70
|
+
# @raise [ArgumentError] If +webhook_id+ does not start with +whk_+ or
|
|
71
|
+
# +url+ is not an https:// URL; no request is sent
|
|
68
72
|
def update(webhook_id, url: nil, events: nil, description: nil, is_active: nil, mode: nil, metadata: nil)
|
|
69
73
|
validate_webhook_id!(webhook_id)
|
|
70
74
|
raise ArgumentError, "Webhook URL must be HTTPS" if url && !url.start_with?("https://")
|
|
@@ -94,7 +98,9 @@ module Sendly
|
|
|
94
98
|
# Test a webhook endpoint
|
|
95
99
|
#
|
|
96
100
|
# @param webhook_id [String] Webhook ID
|
|
97
|
-
# @return [Sendly::WebhookTestResult]
|
|
101
|
+
# @return [Sendly::WebhookTestResult] The delivered test, with its status code and timing
|
|
102
|
+
# @raise [Sendly::ValidationError] If the test delivery fails; the message
|
|
103
|
+
# is the API's, e.g. "Test webhook failed: ..."
|
|
98
104
|
def test(webhook_id)
|
|
99
105
|
validate_webhook_id!(webhook_id)
|
|
100
106
|
response = @client.post("/webhooks/#{URI.encode_www_form_component(webhook_id)}/test")
|
|
@@ -139,8 +145,10 @@ module Sendly
|
|
|
139
145
|
# Backfill missed webhook events from the underlying message log.
|
|
140
146
|
#
|
|
141
147
|
# Use when a circuit-breaker outage left events with no audit row (the
|
|
142
|
-
# case {#redeliver} cannot recover). Synthesized events
|
|
143
|
-
#
|
|
148
|
+
# case {#redeliver} cannot recover). Synthesized message events carry the
|
|
149
|
+
# same event id the original dispatch used, so dedupe on event.id. Do not
|
|
150
|
+
# dedupe on event.data.object.id: a message's sent and delivered events
|
|
151
|
+
# share it.
|
|
144
152
|
# Rejects with HTTP 409 if the circuit is currently open — call
|
|
145
153
|
# {#reset_circuit} first.
|
|
146
154
|
#
|
|
@@ -162,6 +170,11 @@ module Sendly
|
|
|
162
170
|
|
|
163
171
|
# Rotate the webhook signing secret
|
|
164
172
|
#
|
|
173
|
+
# Deliveries are signed with the new secret as soon as this returns, and
|
|
174
|
+
# the old secret is not kept, so have your endpoint accept both secrets
|
|
175
|
+
# while you deploy the new one. The new secret is shown only once, on
|
|
176
|
+
# {Sendly::WebhookSecretRotation#new_secret}.
|
|
177
|
+
#
|
|
165
178
|
# @param webhook_id [String] Webhook ID
|
|
166
179
|
# @return [Sendly::WebhookSecretRotation]
|
|
167
180
|
def rotate_secret(webhook_id)
|
|
@@ -170,14 +183,24 @@ module Sendly
|
|
|
170
183
|
WebhookSecretRotation.new(response)
|
|
171
184
|
end
|
|
172
185
|
|
|
173
|
-
# Get delivery history for a webhook
|
|
186
|
+
# Get delivery history for a webhook, newest first
|
|
174
187
|
#
|
|
175
188
|
# @param webhook_id [String] Webhook ID
|
|
189
|
+
# @param limit [Integer, nil] Maximum deliveries to return (the API defaults to 50, max 100)
|
|
190
|
+
# @param offset [Integer, nil] Number of deliveries to skip
|
|
191
|
+
# @param status [String, nil] Only deliveries with this status
|
|
192
|
+
# (see {Sendly::WebhookDelivery::STATUSES})
|
|
176
193
|
# @return [Array<Sendly::WebhookDelivery>]
|
|
177
|
-
def deliveries(webhook_id)
|
|
194
|
+
def deliveries(webhook_id, limit: nil, offset: nil, status: nil)
|
|
178
195
|
validate_webhook_id!(webhook_id)
|
|
179
|
-
|
|
180
|
-
|
|
196
|
+
params = {}
|
|
197
|
+
params[:limit] = limit unless limit.nil?
|
|
198
|
+
params[:offset] = offset unless offset.nil?
|
|
199
|
+
params[:status] = status unless status.nil?
|
|
200
|
+
|
|
201
|
+
response = @client.get("/webhooks/#{URI.encode_www_form_component(webhook_id)}/deliveries", params)
|
|
202
|
+
items = response.is_a?(Hash) ? response["deliveries"] : response
|
|
203
|
+
(items || []).map { |data| WebhookDelivery.new(data) }
|
|
181
204
|
end
|
|
182
205
|
|
|
183
206
|
# Retry a failed delivery
|