sentdm 0.31.0 → 0.32.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 +7 -0
- data/README.md +1 -1
- data/lib/sentdm/models/channel_event.rb +78 -0
- data/lib/sentdm/models/channel_event_payload.rb +128 -0
- data/lib/sentdm/models/contact_event.rb +69 -0
- data/lib/sentdm/models/contact_event_payload.rb +111 -0
- data/lib/sentdm/models/inbound_message_event.rb +16 -8
- data/lib/sentdm/models/message_event.rb +16 -8
- data/lib/sentdm/models/message_event_payload.rb +11 -1
- data/lib/sentdm/models/template.rb +36 -5
- data/lib/sentdm/models/template_body.rb +20 -11
- data/lib/sentdm/models/template_body_content.rb +35 -3
- data/lib/sentdm/models/template_button.rb +8 -2
- data/lib/sentdm/models/template_button_props.rb +12 -1
- data/lib/sentdm/models/template_definition.rb +14 -2
- data/lib/sentdm/models/template_event.rb +16 -8
- data/lib/sentdm/models/template_event_payload.rb +31 -4
- data/lib/sentdm/models/template_variable.rb +20 -3
- data/lib/sentdm/models/webhook_list_events_response.rb +17 -9
- data/lib/sentdm/models.rb +8 -0
- data/lib/sentdm/resources/templates.rb +28 -2
- data/lib/sentdm/version.rb +1 -1
- data/lib/sentdm.rb +4 -0
- data/rbi/sentdm/models/channel_event.rbi +128 -0
- data/rbi/sentdm/models/channel_event_payload.rbi +189 -0
- data/rbi/sentdm/models/contact_event.rbi +110 -0
- data/rbi/sentdm/models/contact_event_payload.rbi +164 -0
- data/rbi/sentdm/models/inbound_message_event.rbi +18 -10
- data/rbi/sentdm/models/message_event.rbi +18 -10
- data/rbi/sentdm/models/message_event_payload.rbi +12 -0
- data/rbi/sentdm/models/template.rbi +58 -4
- data/rbi/sentdm/models/template_body.rbi +22 -13
- data/rbi/sentdm/models/template_body_content.rbi +59 -1
- data/rbi/sentdm/models/template_button.rbi +14 -2
- data/rbi/sentdm/models/template_button_props.rbi +22 -0
- data/rbi/sentdm/models/template_definition.rbi +20 -2
- data/rbi/sentdm/models/template_event.rbi +18 -10
- data/rbi/sentdm/models/template_event_payload.rbi +51 -8
- data/rbi/sentdm/models/template_variable.rbi +28 -1
- data/rbi/sentdm/models/webhook_list_events_response.rbi +18 -12
- data/rbi/sentdm/models.rbi +8 -0
- data/rbi/sentdm/resources/templates.rbi +28 -2
- data/sig/sentdm/models/channel_event.rbs +44 -0
- data/sig/sentdm/models/channel_event_payload.rbs +63 -0
- data/sig/sentdm/models/contact_event.rbs +44 -0
- data/sig/sentdm/models/contact_event_payload.rbs +63 -0
- data/sig/sentdm/models/inbound_message_event.rbs +5 -0
- data/sig/sentdm/models/message_event.rbs +5 -0
- data/sig/sentdm/models/message_event_payload.rbs +5 -0
- data/sig/sentdm/models/template.rbs +5 -0
- data/sig/sentdm/models/template_event.rbs +5 -0
- data/sig/sentdm/models/template_event_payload.rbs +9 -6
- data/sig/sentdm/models/webhook_list_events_response.rbs +2 -0
- data/sig/sentdm/models.rbs +8 -0
- metadata +14 -2
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Sentdm
|
|
4
|
+
module Models
|
|
5
|
+
class ChannelEventPayload < Sentdm::Internal::Type::BaseModel
|
|
6
|
+
OrHash =
|
|
7
|
+
T.type_alias do
|
|
8
|
+
T.any(Sentdm::ChannelEventPayload, Sentdm::Internal::AnyHash)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# The market's destination country as an ISO 3166-1 alpha-2 code, for example XK.
|
|
12
|
+
# Always present, and the property that identifies this payload among the
|
|
13
|
+
# delivered envelopes — see DeliveredWebhookEvents. Every event in this family
|
|
14
|
+
# reports one market, and a market has a country.
|
|
15
|
+
sig { returns(String) }
|
|
16
|
+
attr_accessor :country
|
|
17
|
+
|
|
18
|
+
# The account whose market this is, named as on every other family. When an
|
|
19
|
+
# organization receives an event for one of its sender profiles this is the
|
|
20
|
+
# profile, so a reseller compares it with its own id and anything different is one
|
|
21
|
+
# of its profiles.
|
|
22
|
+
sig { returns(T.nilable(String)) }
|
|
23
|
+
attr_reader :account_id
|
|
24
|
+
|
|
25
|
+
sig { params(account_id: String).void }
|
|
26
|
+
attr_writer :account_id
|
|
27
|
+
|
|
28
|
+
# The channel this market belongs to: sms, whatsapp, or rcs. Never sent — that
|
|
29
|
+
# value belongs to message events, where it names the smart-routing brand rather
|
|
30
|
+
# than a channel that can be provisioned.
|
|
31
|
+
sig { returns(T.nilable(String)) }
|
|
32
|
+
attr_reader :channel
|
|
33
|
+
|
|
34
|
+
sig { params(channel: String).void }
|
|
35
|
+
attr_writer :channel
|
|
36
|
+
|
|
37
|
+
# The kind of sender the market uses, for example TEN_DLC, LOCAL, or ALPHANUMERIC.
|
|
38
|
+
# Omitted when the subject has no sender type of its own.
|
|
39
|
+
sig { returns(T.nilable(String)) }
|
|
40
|
+
attr_accessor :number_type
|
|
41
|
+
|
|
42
|
+
# Why the market reached this state, when a reason was given — a correction
|
|
43
|
+
# explained, or a campaign lapse. Free text, passed through from the registry or
|
|
44
|
+
# carrier that wrote it, so treat it as a message to show a human rather than a
|
|
45
|
+
# value to branch on.
|
|
46
|
+
sig { returns(T.nilable(String)) }
|
|
47
|
+
attr_accessor :reason
|
|
48
|
+
|
|
49
|
+
# The sender itself — a number in E.164, or an alphanumeric sender ID.
|
|
50
|
+
#
|
|
51
|
+
# Always present, and null until a sender exists. The key is on every delivery so
|
|
52
|
+
# a subscriber reads one shape rather than branching on whether the field arrived
|
|
53
|
+
# — the same choice template_id makes on the message payload.
|
|
54
|
+
#
|
|
55
|
+
# It can carry a value at any point in the lifecycle, not only once the market is
|
|
56
|
+
# live: a number ordered and not yet active at the carrier is already known during
|
|
57
|
+
# PROVISIONING, and an alphanumeric sender the customer chose themselves is known
|
|
58
|
+
# before anything is filed. It is null while the market is still waiting on a
|
|
59
|
+
# number, which for a US 10DLC registration is every event up to
|
|
60
|
+
# channel.activated.
|
|
61
|
+
sig { returns(T.nilable(String)) }
|
|
62
|
+
attr_accessor :sender_value
|
|
63
|
+
|
|
64
|
+
# Where the market stands: PENDING_REVIEW, ACTION_NEEDED, PROVISIONING, ACTIVE or
|
|
65
|
+
# INACTIVE. PENDING_REVIEW means a registry or a carrier holds it and the wait is
|
|
66
|
+
# theirs; ACTION_NEEDED means it is yours; PROVISIONING means the verdict is in
|
|
67
|
+
# and Sent is acquiring the sender; INACTIVE means it had a working sender and no
|
|
68
|
+
# longer does.
|
|
69
|
+
#
|
|
70
|
+
# Each event name is the transition into one of these, but the two are separate
|
|
71
|
+
# fields and may legitimately differ. A resubmission filed against a market whose
|
|
72
|
+
# sender is already live is channel.submitted carrying ACTIVE: a correction is
|
|
73
|
+
# with the registry and the sender keeps working. Read both.
|
|
74
|
+
sig { returns(T.nilable(String)) }
|
|
75
|
+
attr_reader :status
|
|
76
|
+
|
|
77
|
+
sig { params(status: String).void }
|
|
78
|
+
attr_writer :status
|
|
79
|
+
|
|
80
|
+
# When the transition happened, in UTC (yyyy-MM-ddTHH:mm:ssZ).
|
|
81
|
+
sig { returns(T.nilable(String)) }
|
|
82
|
+
attr_reader :updated_at
|
|
83
|
+
|
|
84
|
+
sig { params(updated_at: String).void }
|
|
85
|
+
attr_writer :updated_at
|
|
86
|
+
|
|
87
|
+
# Body of a channel event: where one of the customer's channels stands in
|
|
88
|
+
# provisioning and compliance. Delivered when a milestone moves — a registration
|
|
89
|
+
# filed, a verdict returned, a resubmission asked for, a sender gone live — so a
|
|
90
|
+
# customer's own onboarding UI does not have to poll GET /v3/channels.
|
|
91
|
+
#
|
|
92
|
+
# The subject is one item, never the account. A customer's "SMS channel" has no
|
|
93
|
+
# status; a market does. Country, NumberType and SenderValue name which one, so a
|
|
94
|
+
# customer terminating only to Kosovo never receives an event about US 10DLC.
|
|
95
|
+
#
|
|
96
|
+
# Status is the stable half of the contract. It is the same four-value set GET
|
|
97
|
+
# /v3/channels publishes, computed through the same code, so an event and a read
|
|
98
|
+
# of the same market cannot disagree. A subscriber that reads nothing but the
|
|
99
|
+
# status and the subject fields is a correct subscriber. The sub-type on the
|
|
100
|
+
# envelope names the specific milestone and is additive — that vocabulary comes
|
|
101
|
+
# from registries and carriers, which are parties Sent does not control.
|
|
102
|
+
#
|
|
103
|
+
# Status means provisioning and compliance are complete, not that a send will
|
|
104
|
+
# succeed right now. An account can be suspended, or a destination blocked by a
|
|
105
|
+
# routing rule, without either showing up here. Those are separate surfaces and
|
|
106
|
+
# deliberately not modelled on this payload.
|
|
107
|
+
sig do
|
|
108
|
+
params(
|
|
109
|
+
country: String,
|
|
110
|
+
account_id: String,
|
|
111
|
+
channel: String,
|
|
112
|
+
number_type: T.nilable(String),
|
|
113
|
+
reason: T.nilable(String),
|
|
114
|
+
sender_value: T.nilable(String),
|
|
115
|
+
status: String,
|
|
116
|
+
updated_at: String
|
|
117
|
+
).returns(T.attached_class)
|
|
118
|
+
end
|
|
119
|
+
def self.new(
|
|
120
|
+
# The market's destination country as an ISO 3166-1 alpha-2 code, for example XK.
|
|
121
|
+
# Always present, and the property that identifies this payload among the
|
|
122
|
+
# delivered envelopes — see DeliveredWebhookEvents. Every event in this family
|
|
123
|
+
# reports one market, and a market has a country.
|
|
124
|
+
country:,
|
|
125
|
+
# The account whose market this is, named as on every other family. When an
|
|
126
|
+
# organization receives an event for one of its sender profiles this is the
|
|
127
|
+
# profile, so a reseller compares it with its own id and anything different is one
|
|
128
|
+
# of its profiles.
|
|
129
|
+
account_id: nil,
|
|
130
|
+
# The channel this market belongs to: sms, whatsapp, or rcs. Never sent — that
|
|
131
|
+
# value belongs to message events, where it names the smart-routing brand rather
|
|
132
|
+
# than a channel that can be provisioned.
|
|
133
|
+
channel: nil,
|
|
134
|
+
# The kind of sender the market uses, for example TEN_DLC, LOCAL, or ALPHANUMERIC.
|
|
135
|
+
# Omitted when the subject has no sender type of its own.
|
|
136
|
+
number_type: nil,
|
|
137
|
+
# Why the market reached this state, when a reason was given — a correction
|
|
138
|
+
# explained, or a campaign lapse. Free text, passed through from the registry or
|
|
139
|
+
# carrier that wrote it, so treat it as a message to show a human rather than a
|
|
140
|
+
# value to branch on.
|
|
141
|
+
reason: nil,
|
|
142
|
+
# The sender itself — a number in E.164, or an alphanumeric sender ID.
|
|
143
|
+
#
|
|
144
|
+
# Always present, and null until a sender exists. The key is on every delivery so
|
|
145
|
+
# a subscriber reads one shape rather than branching on whether the field arrived
|
|
146
|
+
# — the same choice template_id makes on the message payload.
|
|
147
|
+
#
|
|
148
|
+
# It can carry a value at any point in the lifecycle, not only once the market is
|
|
149
|
+
# live: a number ordered and not yet active at the carrier is already known during
|
|
150
|
+
# PROVISIONING, and an alphanumeric sender the customer chose themselves is known
|
|
151
|
+
# before anything is filed. It is null while the market is still waiting on a
|
|
152
|
+
# number, which for a US 10DLC registration is every event up to
|
|
153
|
+
# channel.activated.
|
|
154
|
+
sender_value: nil,
|
|
155
|
+
# Where the market stands: PENDING_REVIEW, ACTION_NEEDED, PROVISIONING, ACTIVE or
|
|
156
|
+
# INACTIVE. PENDING_REVIEW means a registry or a carrier holds it and the wait is
|
|
157
|
+
# theirs; ACTION_NEEDED means it is yours; PROVISIONING means the verdict is in
|
|
158
|
+
# and Sent is acquiring the sender; INACTIVE means it had a working sender and no
|
|
159
|
+
# longer does.
|
|
160
|
+
#
|
|
161
|
+
# Each event name is the transition into one of these, but the two are separate
|
|
162
|
+
# fields and may legitimately differ. A resubmission filed against a market whose
|
|
163
|
+
# sender is already live is channel.submitted carrying ACTIVE: a correction is
|
|
164
|
+
# with the registry and the sender keeps working. Read both.
|
|
165
|
+
status: nil,
|
|
166
|
+
# When the transition happened, in UTC (yyyy-MM-ddTHH:mm:ssZ).
|
|
167
|
+
updated_at: nil
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
sig do
|
|
172
|
+
override.returns(
|
|
173
|
+
{
|
|
174
|
+
country: String,
|
|
175
|
+
account_id: String,
|
|
176
|
+
channel: String,
|
|
177
|
+
number_type: T.nilable(String),
|
|
178
|
+
reason: T.nilable(String),
|
|
179
|
+
sender_value: T.nilable(String),
|
|
180
|
+
status: String,
|
|
181
|
+
updated_at: String
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
end
|
|
185
|
+
def to_hash
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Sentdm
|
|
4
|
+
module Models
|
|
5
|
+
class ContactEvent < Sentdm::Internal::Type::BaseModel
|
|
6
|
+
OrHash =
|
|
7
|
+
T.type_alias { T.any(Sentdm::ContactEvent, Sentdm::Internal::AnyHash) }
|
|
8
|
+
|
|
9
|
+
# The specific event within the family, for example message.delivered,
|
|
10
|
+
# message.received or contact.opt_out. Absent on events that have no subtype, so
|
|
11
|
+
# treat it as optional.
|
|
12
|
+
sig { returns(T.nilable(String)) }
|
|
13
|
+
attr_accessor :event
|
|
14
|
+
|
|
15
|
+
# The event family, for example message, templates or contact. Route on this
|
|
16
|
+
# first, then on event for the specific change.
|
|
17
|
+
sig { returns(T.nilable(String)) }
|
|
18
|
+
attr_reader :field
|
|
19
|
+
|
|
20
|
+
sig { params(field: String).void }
|
|
21
|
+
attr_writer :field
|
|
22
|
+
|
|
23
|
+
# Body of a contact.opt_in, contact.opt_out or contact.help event. Delivered when
|
|
24
|
+
# a contact signals a consent change or asks for help.
|
|
25
|
+
#
|
|
26
|
+
# These events state the signal outright, so you do not have to recognise keywords
|
|
27
|
+
# in the text of a message.received event. They also cover cases that produce no
|
|
28
|
+
# inbound message at all, such as a network handling an opt-out on your behalf.
|
|
29
|
+
#
|
|
30
|
+
# Fields are ordered identity → resulting state → provenance → join key. Nothing
|
|
31
|
+
# here restates the envelope: which of the three signals occurred is the
|
|
32
|
+
# envelope's event, and when it was emitted is its timestamp. Retries carry the
|
|
33
|
+
# same X-Webhook-Event-ID header, which is what to deduplicate on.
|
|
34
|
+
sig { returns(T.nilable(Sentdm::ContactEventPayload)) }
|
|
35
|
+
attr_reader :payload
|
|
36
|
+
|
|
37
|
+
sig do
|
|
38
|
+
params(payload: T.nilable(Sentdm::ContactEventPayload::OrHash)).void
|
|
39
|
+
end
|
|
40
|
+
attr_writer :payload
|
|
41
|
+
|
|
42
|
+
# The event-specific body.
|
|
43
|
+
sig { returns(T.nilable(String)) }
|
|
44
|
+
attr_accessor :request_id
|
|
45
|
+
|
|
46
|
+
# When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
|
|
47
|
+
# time, not the time the underlying change happened. Use the timestamp inside the
|
|
48
|
+
# payload for the latter.
|
|
49
|
+
sig { returns(T.nilable(String)) }
|
|
50
|
+
attr_reader :timestamp
|
|
51
|
+
|
|
52
|
+
sig { params(timestamp: String).void }
|
|
53
|
+
attr_writer :timestamp
|
|
54
|
+
|
|
55
|
+
# The envelope Sent POSTs to a subscribed webhook endpoint. Every event shares
|
|
56
|
+
# this shape and varies only in Payload.
|
|
57
|
+
sig do
|
|
58
|
+
params(
|
|
59
|
+
event: T.nilable(String),
|
|
60
|
+
field: String,
|
|
61
|
+
payload: T.nilable(Sentdm::ContactEventPayload::OrHash),
|
|
62
|
+
request_id: T.nilable(String),
|
|
63
|
+
timestamp: String
|
|
64
|
+
).returns(T.attached_class)
|
|
65
|
+
end
|
|
66
|
+
def self.new(
|
|
67
|
+
# The specific event within the family, for example message.delivered,
|
|
68
|
+
# message.received or contact.opt_out. Absent on events that have no subtype, so
|
|
69
|
+
# treat it as optional.
|
|
70
|
+
event: nil,
|
|
71
|
+
# The event family, for example message, templates or contact. Route on this
|
|
72
|
+
# first, then on event for the specific change.
|
|
73
|
+
field: nil,
|
|
74
|
+
# Body of a contact.opt_in, contact.opt_out or contact.help event. Delivered when
|
|
75
|
+
# a contact signals a consent change or asks for help.
|
|
76
|
+
#
|
|
77
|
+
# These events state the signal outright, so you do not have to recognise keywords
|
|
78
|
+
# in the text of a message.received event. They also cover cases that produce no
|
|
79
|
+
# inbound message at all, such as a network handling an opt-out on your behalf.
|
|
80
|
+
#
|
|
81
|
+
# Fields are ordered identity → resulting state → provenance → join key. Nothing
|
|
82
|
+
# here restates the envelope: which of the three signals occurred is the
|
|
83
|
+
# envelope's event, and when it was emitted is its timestamp. Retries carry the
|
|
84
|
+
# same X-Webhook-Event-ID header, which is what to deduplicate on.
|
|
85
|
+
payload: nil,
|
|
86
|
+
# The event-specific body.
|
|
87
|
+
request_id: nil,
|
|
88
|
+
# When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
|
|
89
|
+
# time, not the time the underlying change happened. Use the timestamp inside the
|
|
90
|
+
# payload for the latter.
|
|
91
|
+
timestamp: nil
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
sig do
|
|
96
|
+
override.returns(
|
|
97
|
+
{
|
|
98
|
+
event: T.nilable(String),
|
|
99
|
+
field: String,
|
|
100
|
+
payload: T.nilable(Sentdm::ContactEventPayload),
|
|
101
|
+
request_id: T.nilable(String),
|
|
102
|
+
timestamp: String
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
def to_hash
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Sentdm
|
|
4
|
+
module Models
|
|
5
|
+
class ContactEventPayload < Sentdm::Internal::Type::BaseModel
|
|
6
|
+
OrHash =
|
|
7
|
+
T.type_alias do
|
|
8
|
+
T.any(Sentdm::ContactEventPayload, Sentdm::Internal::AnyHash)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Whether the contact is opted out after this signal — the state to write to your
|
|
12
|
+
# own record. Same meaning as opt_out on the contact resource. On contact.help
|
|
13
|
+
# this reports the contact's existing state, which help does not change.
|
|
14
|
+
#
|
|
15
|
+
# Two signals from the same contact can arrive out of order, because each one is
|
|
16
|
+
# queued on its own rather than against the contact. Compare the envelope's
|
|
17
|
+
# timestamp before you overwrite a newer state with an older one. That timestamp
|
|
18
|
+
# is second-precision, so treat two signals stamped in the same second as
|
|
19
|
+
# unordered and read the contact resource to settle them.
|
|
20
|
+
sig { returns(T::Boolean) }
|
|
21
|
+
attr_accessor :opt_out
|
|
22
|
+
|
|
23
|
+
# How the signal reached us. INBOUND_KEYWORD means the contact sent a message
|
|
24
|
+
# whose text matched one of the keywords; PROVIDER_SIGNAL means the network
|
|
25
|
+
# reported it. A provider signal usually carries no message_id or text, so read
|
|
26
|
+
# both for null rather than inferring them from this field.
|
|
27
|
+
sig { returns(String) }
|
|
28
|
+
attr_accessor :source
|
|
29
|
+
|
|
30
|
+
# The account the contact belongs to. Present so one endpoint can serve several
|
|
31
|
+
# accounts.
|
|
32
|
+
sig { returns(T.nilable(String)) }
|
|
33
|
+
attr_reader :account_id
|
|
34
|
+
|
|
35
|
+
sig { params(account_id: String).void }
|
|
36
|
+
attr_writer :account_id
|
|
37
|
+
|
|
38
|
+
# The channel the signal arrived on, for example sms or whatsapp.
|
|
39
|
+
sig { returns(T.nilable(String)) }
|
|
40
|
+
attr_reader :channel
|
|
41
|
+
|
|
42
|
+
sig { params(channel: String).void }
|
|
43
|
+
attr_writer :channel
|
|
44
|
+
|
|
45
|
+
# The contact who raised the signal. Always populated, including for contact.help
|
|
46
|
+
# from a number you have not messaged before — the contact is created if it does
|
|
47
|
+
# not exist yet, so this identifier is always resolvable against the contacts API.
|
|
48
|
+
sig { returns(T.nilable(String)) }
|
|
49
|
+
attr_reader :contact_id
|
|
50
|
+
|
|
51
|
+
sig { params(contact_id: String).void }
|
|
52
|
+
attr_writer :contact_id
|
|
53
|
+
|
|
54
|
+
# The inbound message that carried the signal, matching message_id on the
|
|
55
|
+
# corresponding message.received event so the two can be joined.
|
|
56
|
+
#
|
|
57
|
+
# Sent as null when the signal did not arrive as a message — for example when a
|
|
58
|
+
# network processed an opt-out on your behalf — and also when the message belongs
|
|
59
|
+
# to a different account than this event, which can happen on a shared WhatsApp
|
|
60
|
+
# number. The field is always present, so read it and check for null rather than
|
|
61
|
+
# checking whether the key exists.
|
|
62
|
+
sig { returns(T.nilable(String)) }
|
|
63
|
+
attr_accessor :message_id
|
|
64
|
+
|
|
65
|
+
# The contact's number in E.164 format. Same value as phone_number on the contact
|
|
66
|
+
# resource.
|
|
67
|
+
sig { returns(T.nilable(String)) }
|
|
68
|
+
attr_reader :phone_number
|
|
69
|
+
|
|
70
|
+
sig { params(phone_number: String).void }
|
|
71
|
+
attr_writer :phone_number
|
|
72
|
+
|
|
73
|
+
# The text the contact sent, for example STOP or UNSUBSCRIBE. Sent as null when
|
|
74
|
+
# the signal did not arrive as text. The field is always present, so read it and
|
|
75
|
+
# check for null rather than checking whether the key exists.
|
|
76
|
+
sig { returns(T.nilable(String)) }
|
|
77
|
+
attr_accessor :text
|
|
78
|
+
|
|
79
|
+
# Body of a contact.opt_in, contact.opt_out or contact.help event. Delivered when
|
|
80
|
+
# a contact signals a consent change or asks for help.
|
|
81
|
+
#
|
|
82
|
+
# These events state the signal outright, so you do not have to recognise keywords
|
|
83
|
+
# in the text of a message.received event. They also cover cases that produce no
|
|
84
|
+
# inbound message at all, such as a network handling an opt-out on your behalf.
|
|
85
|
+
#
|
|
86
|
+
# Fields are ordered identity → resulting state → provenance → join key. Nothing
|
|
87
|
+
# here restates the envelope: which of the three signals occurred is the
|
|
88
|
+
# envelope's event, and when it was emitted is its timestamp. Retries carry the
|
|
89
|
+
# same X-Webhook-Event-ID header, which is what to deduplicate on.
|
|
90
|
+
sig do
|
|
91
|
+
params(
|
|
92
|
+
opt_out: T::Boolean,
|
|
93
|
+
source: String,
|
|
94
|
+
account_id: String,
|
|
95
|
+
channel: String,
|
|
96
|
+
contact_id: String,
|
|
97
|
+
message_id: T.nilable(String),
|
|
98
|
+
phone_number: String,
|
|
99
|
+
text: T.nilable(String)
|
|
100
|
+
).returns(T.attached_class)
|
|
101
|
+
end
|
|
102
|
+
def self.new(
|
|
103
|
+
# Whether the contact is opted out after this signal — the state to write to your
|
|
104
|
+
# own record. Same meaning as opt_out on the contact resource. On contact.help
|
|
105
|
+
# this reports the contact's existing state, which help does not change.
|
|
106
|
+
#
|
|
107
|
+
# Two signals from the same contact can arrive out of order, because each one is
|
|
108
|
+
# queued on its own rather than against the contact. Compare the envelope's
|
|
109
|
+
# timestamp before you overwrite a newer state with an older one. That timestamp
|
|
110
|
+
# is second-precision, so treat two signals stamped in the same second as
|
|
111
|
+
# unordered and read the contact resource to settle them.
|
|
112
|
+
opt_out:,
|
|
113
|
+
# How the signal reached us. INBOUND_KEYWORD means the contact sent a message
|
|
114
|
+
# whose text matched one of the keywords; PROVIDER_SIGNAL means the network
|
|
115
|
+
# reported it. A provider signal usually carries no message_id or text, so read
|
|
116
|
+
# both for null rather than inferring them from this field.
|
|
117
|
+
source:,
|
|
118
|
+
# The account the contact belongs to. Present so one endpoint can serve several
|
|
119
|
+
# accounts.
|
|
120
|
+
account_id: nil,
|
|
121
|
+
# The channel the signal arrived on, for example sms or whatsapp.
|
|
122
|
+
channel: nil,
|
|
123
|
+
# The contact who raised the signal. Always populated, including for contact.help
|
|
124
|
+
# from a number you have not messaged before — the contact is created if it does
|
|
125
|
+
# not exist yet, so this identifier is always resolvable against the contacts API.
|
|
126
|
+
contact_id: nil,
|
|
127
|
+
# The inbound message that carried the signal, matching message_id on the
|
|
128
|
+
# corresponding message.received event so the two can be joined.
|
|
129
|
+
#
|
|
130
|
+
# Sent as null when the signal did not arrive as a message — for example when a
|
|
131
|
+
# network processed an opt-out on your behalf — and also when the message belongs
|
|
132
|
+
# to a different account than this event, which can happen on a shared WhatsApp
|
|
133
|
+
# number. The field is always present, so read it and check for null rather than
|
|
134
|
+
# checking whether the key exists.
|
|
135
|
+
message_id: nil,
|
|
136
|
+
# The contact's number in E.164 format. Same value as phone_number on the contact
|
|
137
|
+
# resource.
|
|
138
|
+
phone_number: nil,
|
|
139
|
+
# The text the contact sent, for example STOP or UNSUBSCRIBE. Sent as null when
|
|
140
|
+
# the signal did not arrive as text. The field is always present, so read it and
|
|
141
|
+
# check for null rather than checking whether the key exists.
|
|
142
|
+
text: nil
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
sig do
|
|
147
|
+
override.returns(
|
|
148
|
+
{
|
|
149
|
+
opt_out: T::Boolean,
|
|
150
|
+
source: String,
|
|
151
|
+
account_id: String,
|
|
152
|
+
channel: String,
|
|
153
|
+
contact_id: String,
|
|
154
|
+
message_id: T.nilable(String),
|
|
155
|
+
phone_number: String,
|
|
156
|
+
text: T.nilable(String)
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
end
|
|
160
|
+
def to_hash
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -8,14 +8,14 @@ module Sentdm
|
|
|
8
8
|
T.any(Sentdm::InboundMessageEvent, Sentdm::Internal::AnyHash)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
# The specific event within the family, for example message.delivered
|
|
12
|
-
# message.received. Absent on events that have no subtype, so
|
|
13
|
-
# optional.
|
|
11
|
+
# The specific event within the family, for example message.delivered,
|
|
12
|
+
# message.received or contact.opt_out. Absent on events that have no subtype, so
|
|
13
|
+
# treat it as optional.
|
|
14
14
|
sig { returns(T.nilable(String)) }
|
|
15
15
|
attr_accessor :event
|
|
16
16
|
|
|
17
|
-
# The event family, for example message or
|
|
18
|
-
# event for the specific change.
|
|
17
|
+
# The event family, for example message, templates or contact. Route on this
|
|
18
|
+
# first, then on event for the specific change.
|
|
19
19
|
sig { returns(T.nilable(String)) }
|
|
20
20
|
attr_reader :field
|
|
21
21
|
|
|
@@ -34,6 +34,10 @@ module Sentdm
|
|
|
34
34
|
end
|
|
35
35
|
attr_writer :payload
|
|
36
36
|
|
|
37
|
+
# The event-specific body.
|
|
38
|
+
sig { returns(T.nilable(String)) }
|
|
39
|
+
attr_accessor :request_id
|
|
40
|
+
|
|
37
41
|
# When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
|
|
38
42
|
# time, not the time the underlying change happened. Use the timestamp inside the
|
|
39
43
|
# payload for the latter.
|
|
@@ -50,20 +54,23 @@ module Sentdm
|
|
|
50
54
|
event: T.nilable(String),
|
|
51
55
|
field: String,
|
|
52
56
|
payload: T.nilable(Sentdm::InboundMessageEventPayload::OrHash),
|
|
57
|
+
request_id: T.nilable(String),
|
|
53
58
|
timestamp: String
|
|
54
59
|
).returns(T.attached_class)
|
|
55
60
|
end
|
|
56
61
|
def self.new(
|
|
57
|
-
# The specific event within the family, for example message.delivered
|
|
58
|
-
# message.received. Absent on events that have no subtype, so
|
|
59
|
-
# optional.
|
|
62
|
+
# The specific event within the family, for example message.delivered,
|
|
63
|
+
# message.received or contact.opt_out. Absent on events that have no subtype, so
|
|
64
|
+
# treat it as optional.
|
|
60
65
|
event: nil,
|
|
61
|
-
# The event family, for example message or
|
|
62
|
-
# event for the specific change.
|
|
66
|
+
# The event family, for example message, templates or contact. Route on this
|
|
67
|
+
# first, then on event for the specific change.
|
|
63
68
|
field: nil,
|
|
64
69
|
# Body of a message.received event. Delivered when a contact messages one of your
|
|
65
70
|
# numbers.
|
|
66
71
|
payload: nil,
|
|
72
|
+
# The event-specific body.
|
|
73
|
+
request_id: nil,
|
|
67
74
|
# When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
|
|
68
75
|
# time, not the time the underlying change happened. Use the timestamp inside the
|
|
69
76
|
# payload for the latter.
|
|
@@ -77,6 +84,7 @@ module Sentdm
|
|
|
77
84
|
event: T.nilable(String),
|
|
78
85
|
field: String,
|
|
79
86
|
payload: T.nilable(Sentdm::InboundMessageEventPayload),
|
|
87
|
+
request_id: T.nilable(String),
|
|
80
88
|
timestamp: String
|
|
81
89
|
}
|
|
82
90
|
)
|
|
@@ -6,14 +6,14 @@ module Sentdm
|
|
|
6
6
|
OrHash =
|
|
7
7
|
T.type_alias { T.any(Sentdm::MessageEvent, Sentdm::Internal::AnyHash) }
|
|
8
8
|
|
|
9
|
-
# The specific event within the family, for example message.delivered
|
|
10
|
-
# message.received. Absent on events that have no subtype, so
|
|
11
|
-
# optional.
|
|
9
|
+
# The specific event within the family, for example message.delivered,
|
|
10
|
+
# message.received or contact.opt_out. Absent on events that have no subtype, so
|
|
11
|
+
# treat it as optional.
|
|
12
12
|
sig { returns(T.nilable(String)) }
|
|
13
13
|
attr_accessor :event
|
|
14
14
|
|
|
15
|
-
# The event family, for example message or
|
|
16
|
-
# event for the specific change.
|
|
15
|
+
# The event family, for example message, templates or contact. Route on this
|
|
16
|
+
# first, then on event for the specific change.
|
|
17
17
|
sig { returns(T.nilable(String)) }
|
|
18
18
|
attr_reader :field
|
|
19
19
|
|
|
@@ -31,6 +31,10 @@ module Sentdm
|
|
|
31
31
|
end
|
|
32
32
|
attr_writer :payload
|
|
33
33
|
|
|
34
|
+
# The event-specific body.
|
|
35
|
+
sig { returns(T.nilable(String)) }
|
|
36
|
+
attr_accessor :request_id
|
|
37
|
+
|
|
34
38
|
# When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
|
|
35
39
|
# time, not the time the underlying change happened. Use the timestamp inside the
|
|
36
40
|
# payload for the latter.
|
|
@@ -47,21 +51,24 @@ module Sentdm
|
|
|
47
51
|
event: T.nilable(String),
|
|
48
52
|
field: String,
|
|
49
53
|
payload: T.nilable(Sentdm::MessageEventPayload::OrHash),
|
|
54
|
+
request_id: T.nilable(String),
|
|
50
55
|
timestamp: String
|
|
51
56
|
).returns(T.attached_class)
|
|
52
57
|
end
|
|
53
58
|
def self.new(
|
|
54
|
-
# The specific event within the family, for example message.delivered
|
|
55
|
-
# message.received. Absent on events that have no subtype, so
|
|
56
|
-
# optional.
|
|
59
|
+
# The specific event within the family, for example message.delivered,
|
|
60
|
+
# message.received or contact.opt_out. Absent on events that have no subtype, so
|
|
61
|
+
# treat it as optional.
|
|
57
62
|
event: nil,
|
|
58
|
-
# The event family, for example message or
|
|
59
|
-
# event for the specific change.
|
|
63
|
+
# The event family, for example message, templates or contact. Route on this
|
|
64
|
+
# first, then on event for the specific change.
|
|
60
65
|
field: nil,
|
|
61
66
|
# Body of an outbound message lifecycle event. Delivered once per status change,
|
|
62
67
|
# so a single message produces several of these as it moves toward a terminal
|
|
63
68
|
# status.
|
|
64
69
|
payload: nil,
|
|
70
|
+
# The event-specific body.
|
|
71
|
+
request_id: nil,
|
|
65
72
|
# When Sent emitted the event, in UTC (yyyy-MM-ddTHH:mm:ssZ). This is the emission
|
|
66
73
|
# time, not the time the underlying change happened. Use the timestamp inside the
|
|
67
74
|
# payload for the latter.
|
|
@@ -75,6 +82,7 @@ module Sentdm
|
|
|
75
82
|
event: T.nilable(String),
|
|
76
83
|
field: String,
|
|
77
84
|
payload: T.nilable(Sentdm::MessageEventPayload),
|
|
85
|
+
request_id: T.nilable(String),
|
|
78
86
|
timestamp: String
|
|
79
87
|
}
|
|
80
88
|
)
|
|
@@ -25,6 +25,12 @@ module Sentdm
|
|
|
25
25
|
sig { returns(T.nilable(String)) }
|
|
26
26
|
attr_accessor :agent_id
|
|
27
27
|
|
|
28
|
+
# The rendered message body, as plain text. Sent as null when we aren't asserting
|
|
29
|
+
# a body for this event. The field is always present, so read it and check for
|
|
30
|
+
# null rather than checking whether the key exists. Truncated to 3072 characters.
|
|
31
|
+
sig { returns(T.nilable(String)) }
|
|
32
|
+
attr_accessor :body
|
|
33
|
+
|
|
28
34
|
# The channel the message went out on, for example sms or whatsapp. A message that
|
|
29
35
|
# falls back to another channel reports the channel actually used.
|
|
30
36
|
sig { returns(T.nilable(String)) }
|
|
@@ -72,6 +78,7 @@ module Sentdm
|
|
|
72
78
|
message_status: String,
|
|
73
79
|
account_id: String,
|
|
74
80
|
agent_id: T.nilable(String),
|
|
81
|
+
body: T.nilable(String),
|
|
75
82
|
channel: String,
|
|
76
83
|
message_id: String,
|
|
77
84
|
outbound_number: String,
|
|
@@ -89,6 +96,10 @@ module Sentdm
|
|
|
89
96
|
account_id: nil,
|
|
90
97
|
# The agent attributed to the send, when the send was attributed to one.
|
|
91
98
|
agent_id: nil,
|
|
99
|
+
# The rendered message body, as plain text. Sent as null when we aren't asserting
|
|
100
|
+
# a body for this event. The field is always present, so read it and check for
|
|
101
|
+
# null rather than checking whether the key exists. Truncated to 3072 characters.
|
|
102
|
+
body: nil,
|
|
92
103
|
# The channel the message went out on, for example sms or whatsapp. A message that
|
|
93
104
|
# falls back to another channel reports the channel actually used.
|
|
94
105
|
channel: nil,
|
|
@@ -113,6 +124,7 @@ module Sentdm
|
|
|
113
124
|
message_status: String,
|
|
114
125
|
account_id: String,
|
|
115
126
|
agent_id: T.nilable(String),
|
|
127
|
+
body: T.nilable(String),
|
|
116
128
|
channel: String,
|
|
117
129
|
message_id: String,
|
|
118
130
|
outbound_number: String,
|