twi 0.5.0 → 0.7.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 +9 -0
- data/lib/twi/conversation.rb +13 -10
- data/lib/twi/mock/conversation.rb +3 -1
- data/lib/twi/mocking.rb +7 -0
- data/lib/twi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c06bf91d26d756f01fff17c5740c7ea254ce49474b3be83ea8d57dd3e6ed472
|
|
4
|
+
data.tar.gz: 0125a4facf8ed3d4bdc592e11c1c0bb376e43f451f985c13ec90e01de9a9047e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62883cef19ef0ee4520ddbcfb62fcf0a64186836f3e8389242007e4c76f8ddfbd70d848832788358524ed19f4d5e74dfb8aa468b7372dd80631052ff0b63eede
|
|
7
|
+
data.tar.gz: 2db626b561d48b858ba37d8703d3c03f11e2e3b6886a8ccfbce728caa5bf6f2f5a503fc418949a3990a0a5be58bda125507a17d61de8cc05203a85d10bbfb0fe
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [0.7.0] - 2026-08-19
|
|
2
|
+
|
|
3
|
+
- [New] Add Twi.reset_mock, to stop a mocked answer outliving the test that arranged it
|
|
4
|
+
- [Fix] Answer an unarranged Twi::Mock::Conversation#create_with, as Message#create does
|
|
5
|
+
|
|
6
|
+
## [0.6.0] - 2026-07-27
|
|
7
|
+
|
|
8
|
+
- [Fix] Remove proxy_address from conversation participant
|
|
9
|
+
|
|
1
10
|
## [0.5.0] - 2026-07-27
|
|
2
11
|
|
|
3
12
|
- [New] Add Twi::Delivery#sender
|
data/lib/twi/conversation.rb
CHANGED
|
@@ -4,8 +4,8 @@ module Twi
|
|
|
4
4
|
class Conversation < Resource
|
|
5
5
|
attr_reader :id, :status
|
|
6
6
|
|
|
7
|
-
def create_with(
|
|
8
|
-
params = create_params_for
|
|
7
|
+
def create_with(participants:)
|
|
8
|
+
params = create_params_for participants
|
|
9
9
|
conversation = conversation_service.conversation_with_participants.create **params
|
|
10
10
|
|
|
11
11
|
@params = { id: conversation.sid, status: conversation.state }
|
|
@@ -65,19 +65,22 @@ module Twi
|
|
|
65
65
|
conversation_service.conversations id
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
def create_params_for(
|
|
68
|
+
def create_params_for(participants)
|
|
69
69
|
{
|
|
70
70
|
messaging_service_sid: Twi.lio.messaging_sid, x_twilio_webhook_enabled: 'true',
|
|
71
|
-
friendly_name: @params[:friendly_name], participant: participant_params_for(
|
|
71
|
+
friendly_name: @params[:friendly_name], participant: participant_params_for(participants),
|
|
72
72
|
}
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def participant_params_for(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
def participant_params_for(participants)
|
|
76
|
+
participants.map do |participant|
|
|
77
|
+
phone = "+1#{participant[:phone]}"
|
|
78
|
+
if participant[:identity]
|
|
79
|
+
{ messaging_binding: { projected_address: phone }, identity: participant[:identity] }
|
|
80
|
+
else
|
|
81
|
+
{ messaging_binding: { address: phone } }
|
|
82
|
+
end
|
|
83
|
+
end.map(&:to_json)
|
|
81
84
|
end
|
|
82
85
|
|
|
83
86
|
def message_params_for(content, image_ids)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Twi
|
|
2
2
|
class Mock::Conversation < Conversation
|
|
3
|
-
def create_with(
|
|
3
|
+
def create_with(participants:)
|
|
4
4
|
if error = Twi.mock.conversation_error
|
|
5
5
|
Twi.mock.conversation_error = nil
|
|
6
6
|
case error[:code]
|
|
@@ -9,6 +9,8 @@ module Twi
|
|
|
9
9
|
end
|
|
10
10
|
elsif Twi.mock.conversation
|
|
11
11
|
@params = { id: Twi.mock.conversation[:id], status: Twi.mock.conversation[:status] }
|
|
12
|
+
else
|
|
13
|
+
@params = { id: "CH#{rand}", status: 'initializing' }
|
|
12
14
|
end
|
|
13
15
|
end
|
|
14
16
|
|
data/lib/twi/mocking.rb
CHANGED
|
@@ -4,6 +4,13 @@ module Twi
|
|
|
4
4
|
@mock ||= Twi::Mock.new
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
+
# Forgets every answer arranged so far and starts mocking again from nothing.
|
|
8
|
+
# A test suite calls this before each test: the mock lives on the module, so
|
|
9
|
+
# without it one test answers for the next.
|
|
10
|
+
def reset_mock
|
|
11
|
+
@mock = Twi::Mock.new
|
|
12
|
+
end
|
|
13
|
+
|
|
7
14
|
def create_phone(...)
|
|
8
15
|
phone(...).tap &:create
|
|
9
16
|
end
|
data/lib/twi/version.rb
CHANGED