sendly 3.25.0 → 3.27.1
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 +2 -2
- data/lib/sendly/client.rb +7 -0
- data/lib/sendly/conversations_resource.rb +11 -0
- data/lib/sendly/rules_resource.rb +41 -0
- data/lib/sendly/templates_resource.rb +7 -0
- data/lib/sendly/types.rb +92 -0
- data/lib/sendly/version.rb +1 -1
- data/lib/sendly/webhooks.rb +4 -2
- data/lib/sendly.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68163da427953fe0e6323698c1f535ff209375de0d3ef39636a6baa058ec2e73
|
|
4
|
+
data.tar.gz: 51e7b707e397c788fa7d93360ff20970df48bd9c89510c3acc8c55ecf68e3f9a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4885dadab414fb8f67f61eb2bd333294081ccb7c2db7c26be3d6e2ebfa283c6318fae433e23d1de126d87108bc1d0970c680607df6d025ef4fa473eb64a463e8
|
|
7
|
+
data.tar.gz: 992233c97e17dcb0af07df5caf61e4031fb1bf378fb653e6dba158ea831e4d5ed18917a4429683daf77cda6783893e78486b01fde6dd7d51303d8feaa8d79951
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sendly (3.
|
|
4
|
+
sendly (3.27.1)
|
|
5
5
|
faraday (~> 2.0)
|
|
6
6
|
faraday-retry (~> 2.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
addressable (2.
|
|
11
|
+
addressable (2.9.0)
|
|
12
12
|
public_suffix (>= 2.0.2, < 8.0)
|
|
13
13
|
ast (2.4.3)
|
|
14
14
|
bigdecimal (3.3.1)
|
data/lib/sendly/client.rb
CHANGED
|
@@ -121,6 +121,13 @@ module Sendly
|
|
|
121
121
|
@drafts ||= DraftsResource.new(self)
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
+
# Access the Rules resource
|
|
125
|
+
#
|
|
126
|
+
# @return [Sendly::RulesResource]
|
|
127
|
+
def rules
|
|
128
|
+
@rules ||= RulesResource.new(self)
|
|
129
|
+
end
|
|
130
|
+
|
|
124
131
|
# Access the Enterprise resource
|
|
125
132
|
#
|
|
126
133
|
# @return [Sendly::EnterpriseResource]
|
|
@@ -96,6 +96,17 @@ module Sendly
|
|
|
96
96
|
@client.delete("/conversations/#{encoded_id}/labels/#{encoded_label_id}")
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
def get_context(id, max_messages: nil)
|
|
100
|
+
raise ValidationError, "Conversation ID is required" if id.nil? || id.empty?
|
|
101
|
+
|
|
102
|
+
params = {}
|
|
103
|
+
params[:max_messages] = max_messages if max_messages
|
|
104
|
+
|
|
105
|
+
encoded_id = URI.encode_www_form_component(id)
|
|
106
|
+
response = @client.get("/conversations/#{encoded_id}/context", params.compact)
|
|
107
|
+
ConversationContext.new(response)
|
|
108
|
+
end
|
|
109
|
+
|
|
99
110
|
def each(status: nil, batch_size: 100, &block)
|
|
100
111
|
return enum_for(:each, status: status, batch_size: batch_size) unless block_given?
|
|
101
112
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sendly
|
|
4
|
+
class RulesResource
|
|
5
|
+
def initialize(client)
|
|
6
|
+
@client = client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def list
|
|
10
|
+
response = @client.get("/rules")
|
|
11
|
+
(response["data"] || []).map { |r| Rule.new(r) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create(name:, conditions:, actions:, priority: nil)
|
|
15
|
+
body = { name: name, conditions: conditions, actions: actions }
|
|
16
|
+
body[:priority] = priority if priority
|
|
17
|
+
|
|
18
|
+
response = @client.post("/rules", body)
|
|
19
|
+
Rule.new(response)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def update(id, name: nil, conditions: nil, actions: nil, priority: nil)
|
|
23
|
+
raise ValidationError, "Rule ID is required" if id.nil? || id.empty?
|
|
24
|
+
|
|
25
|
+
body = {}
|
|
26
|
+
body[:name] = name if name
|
|
27
|
+
body[:conditions] = conditions if conditions
|
|
28
|
+
body[:actions] = actions if actions
|
|
29
|
+
body[:priority] = priority if priority
|
|
30
|
+
|
|
31
|
+
response = @client.patch("/rules/#{URI.encode_www_form_component(id)}", body)
|
|
32
|
+
Rule.new(response)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def delete(id)
|
|
36
|
+
raise ValidationError, "Rule ID is required" if id.nil? || id.empty?
|
|
37
|
+
|
|
38
|
+
@client.delete("/rules/#{URI.encode_www_form_component(id)}")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -111,5 +111,12 @@ module Sendly
|
|
|
111
111
|
response = @client.post("/templates/#{id}/clone", body)
|
|
112
112
|
Template.new(response)
|
|
113
113
|
end
|
|
114
|
+
|
|
115
|
+
def generate(description:, category: nil)
|
|
116
|
+
body = { description: description }
|
|
117
|
+
body[:category] = category if category
|
|
118
|
+
response = @client.post("/templates/generate", body)
|
|
119
|
+
GeneratedTemplate.new(response)
|
|
120
|
+
end
|
|
114
121
|
end
|
|
115
122
|
end
|
data/lib/sendly/types.rb
CHANGED
|
@@ -746,4 +746,96 @@ module Sendly
|
|
|
746
746
|
end
|
|
747
747
|
end
|
|
748
748
|
end
|
|
749
|
+
|
|
750
|
+
# ============================================================================
|
|
751
|
+
# Conversation Context
|
|
752
|
+
# ============================================================================
|
|
753
|
+
|
|
754
|
+
class ConversationContext
|
|
755
|
+
attr_reader :context, :conversation, :token_estimate, :business
|
|
756
|
+
|
|
757
|
+
def initialize(data)
|
|
758
|
+
@context = data["context"]
|
|
759
|
+
@conversation = {
|
|
760
|
+
id: data.dig("conversation", "id"),
|
|
761
|
+
phone_number: data.dig("conversation", "phoneNumber") || data.dig("conversation", "phone_number"),
|
|
762
|
+
status: data.dig("conversation", "status"),
|
|
763
|
+
message_count: data.dig("conversation", "messageCount") || data.dig("conversation", "message_count") || 0,
|
|
764
|
+
unread_count: data.dig("conversation", "unreadCount") || data.dig("conversation", "unread_count") || 0
|
|
765
|
+
}
|
|
766
|
+
@token_estimate = data["tokenEstimate"] || data["token_estimate"] || 0
|
|
767
|
+
if data["business"]
|
|
768
|
+
@business = {
|
|
769
|
+
name: data.dig("business", "name"),
|
|
770
|
+
use_case: data.dig("business", "useCase") || data.dig("business", "use_case")
|
|
771
|
+
}
|
|
772
|
+
end
|
|
773
|
+
end
|
|
774
|
+
|
|
775
|
+
def to_h
|
|
776
|
+
result = {
|
|
777
|
+
context: context,
|
|
778
|
+
conversation: conversation,
|
|
779
|
+
token_estimate: token_estimate
|
|
780
|
+
}
|
|
781
|
+
result[:business] = business if business
|
|
782
|
+
result
|
|
783
|
+
end
|
|
784
|
+
end
|
|
785
|
+
|
|
786
|
+
# ============================================================================
|
|
787
|
+
# Rules
|
|
788
|
+
# ============================================================================
|
|
789
|
+
|
|
790
|
+
class Rule
|
|
791
|
+
attr_reader :id, :name, :conditions, :actions, :priority, :created_at, :updated_at
|
|
792
|
+
|
|
793
|
+
def initialize(data)
|
|
794
|
+
@id = data["id"]
|
|
795
|
+
@name = data["name"]
|
|
796
|
+
@conditions = data["conditions"] || {}
|
|
797
|
+
@actions = data["actions"] || {}
|
|
798
|
+
@priority = data["priority"]
|
|
799
|
+
@created_at = parse_time(data["createdAt"] || data["created_at"])
|
|
800
|
+
@updated_at = parse_time(data["updatedAt"] || data["updated_at"])
|
|
801
|
+
end
|
|
802
|
+
|
|
803
|
+
def to_h
|
|
804
|
+
{
|
|
805
|
+
id: id, name: name, conditions: conditions, actions: actions,
|
|
806
|
+
priority: priority, created_at: created_at&.iso8601,
|
|
807
|
+
updated_at: updated_at&.iso8601
|
|
808
|
+
}.compact
|
|
809
|
+
end
|
|
810
|
+
|
|
811
|
+
private
|
|
812
|
+
|
|
813
|
+
def parse_time(value)
|
|
814
|
+
return nil if value.nil?
|
|
815
|
+
Time.parse(value)
|
|
816
|
+
rescue ArgumentError
|
|
817
|
+
nil
|
|
818
|
+
end
|
|
819
|
+
end
|
|
820
|
+
|
|
821
|
+
# ============================================================================
|
|
822
|
+
# Generated Template
|
|
823
|
+
# ============================================================================
|
|
824
|
+
|
|
825
|
+
class GeneratedTemplate
|
|
826
|
+
attr_reader :name, :text, :variables, :category
|
|
827
|
+
|
|
828
|
+
def initialize(data)
|
|
829
|
+
@name = data["name"]
|
|
830
|
+
@text = data["text"]
|
|
831
|
+
@variables = data["variables"] || []
|
|
832
|
+
@category = data["category"]
|
|
833
|
+
end
|
|
834
|
+
|
|
835
|
+
def to_h
|
|
836
|
+
{
|
|
837
|
+
name: name, text: text, variables: variables, category: category
|
|
838
|
+
}.compact
|
|
839
|
+
end
|
|
840
|
+
end
|
|
749
841
|
end
|
data/lib/sendly/version.rb
CHANGED
data/lib/sendly/webhooks.rb
CHANGED
|
@@ -146,7 +146,7 @@ module Sendly
|
|
|
146
146
|
attr_reader :id, :status, :to, :from, :direction, :organization_id,
|
|
147
147
|
:text, :error, :error_code, :delivered_at, :failed_at,
|
|
148
148
|
:created_at, :segments, :credits_used, :message_format, :media_urls,
|
|
149
|
-
:retry_count, :metadata
|
|
149
|
+
:retry_count, :metadata, :batch_id
|
|
150
150
|
|
|
151
151
|
def initialize(data)
|
|
152
152
|
@id = data[:id] || data[:message_id] || ''
|
|
@@ -167,6 +167,7 @@ module Sendly
|
|
|
167
167
|
@media_urls = data[:media_urls]
|
|
168
168
|
@retry_count = data[:retry_count]
|
|
169
169
|
@metadata = data[:metadata]
|
|
170
|
+
@batch_id = data[:batch_id]
|
|
170
171
|
end
|
|
171
172
|
|
|
172
173
|
def message_id
|
|
@@ -185,7 +186,8 @@ module Sendly
|
|
|
185
186
|
delivered_at: @delivered_at,
|
|
186
187
|
failed_at: @failed_at,
|
|
187
188
|
segments: @segments,
|
|
188
|
-
credits_used: @credits_used
|
|
189
|
+
credits_used: @credits_used,
|
|
190
|
+
batch_id: @batch_id
|
|
189
191
|
}.compact
|
|
190
192
|
end
|
|
191
193
|
end
|
data/lib/sendly.rb
CHANGED
|
@@ -19,6 +19,7 @@ require_relative "sendly/contacts_resource"
|
|
|
19
19
|
require_relative "sendly/conversations_resource"
|
|
20
20
|
require_relative "sendly/labels_resource"
|
|
21
21
|
require_relative "sendly/drafts_resource"
|
|
22
|
+
require_relative "sendly/rules_resource"
|
|
22
23
|
require_relative "sendly/enterprise"
|
|
23
24
|
|
|
24
25
|
# Sendly Ruby SDK
|
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.27.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sendly
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -135,6 +135,7 @@ files:
|
|
|
135
135
|
- lib/sendly/labels_resource.rb
|
|
136
136
|
- lib/sendly/media.rb
|
|
137
137
|
- lib/sendly/messages.rb
|
|
138
|
+
- lib/sendly/rules_resource.rb
|
|
138
139
|
- lib/sendly/templates_resource.rb
|
|
139
140
|
- lib/sendly/types.rb
|
|
140
141
|
- lib/sendly/verify.rb
|