twi 0.3.8 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b171fbeb8926e6e64a7fcfb2f8b3f481c829e1526f2343b71be9571537a3d68
4
- data.tar.gz: f913fb5ac3a25204d6bbb22e0616162559a24d3997ab75f30035063acf0782e8
3
+ metadata.gz: 727c9e8147c7ff29da2287c0a8df35be3bcf750e697baddba487605a99357e6e
4
+ data.tar.gz: b4fd8d8854d21d652649ba542aa578319421900f61d2d17c88b24daea365912f
5
5
  SHA512:
6
- metadata.gz: a117f3869fc1ff69a7c7d8cc68d0dab12a4487bf36db2138857ff3e74b5ac2e914f2e50047913806d2ce512bb2e69d3578cd587310a244c1baeb2c0fa9a92bb1
7
- data.tar.gz: 5617b508576107483322e104991e4c464646cd5dbaa6c89fde95922e4069054809b13842df8d008b2ae8d2bd5898a98f2d74e8e2d3a7c3d3fa74dd90339c0ed4
6
+ metadata.gz: bc4539e765dd8d5d4426cff34b94e8222ba846422462c964c9e48e93f57dba29ef09490a816c628ac63209e701799191dbabd4fd39b1087129fac00f7925ac4b
7
+ data.tar.gz: 2b0a73db81a391abaa10b89b31073a31617fcc18864ea3413b708726b6c2c878d7c7fc03af34ab3fc1f0f8eaa2657ca00cfbbc5d7b0668fa4ffc729940ee334c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.5.0] - 2026-07-27
2
+
3
+ - [New] Add Twi::Delivery#sender
4
+
5
+ ## [0.4.0] - 2026-06-15
6
+
7
+ - [Fix] Include proxy_address in conversation participant
8
+
9
+ ## [0.3.9] - 2026-06-08
10
+
11
+ - [Fix] Make Twi::Mock::Message.id not null
12
+
1
13
  ## [0.3.8] - 2026-06-02
2
14
 
3
15
  - [Fix] Make Twi::Message.id not null
@@ -4,8 +4,8 @@ module Twi
4
4
  class Conversation < Resource
5
5
  attr_reader :id, :status
6
6
 
7
- def create_with(participants:)
8
- params = create_params_for participants
7
+ def create_with(host:, participant_phones:)
8
+ params = create_params_for host, participant_phones
9
9
  conversation = conversation_service.conversation_with_participants.create **params
10
10
 
11
11
  @params = { id: conversation.sid, status: conversation.state }
@@ -65,22 +65,19 @@ module Twi
65
65
  conversation_service.conversations id
66
66
  end
67
67
 
68
- def create_params_for(participants)
68
+ def create_params_for(host, participant_phones)
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(participants),
71
+ friendly_name: @params[:friendly_name], participant: participant_params_for(host, participant_phones),
72
72
  }
73
73
  end
74
74
 
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)
75
+ def participant_params_for(host, participant_phones)
76
+ params = [{ messaging_binding: { projected_address: "+1#{host[:phone]}" }, identity: host[:identity] }]
77
+ participant_phones.map do |participant_phone|
78
+ params << { messaging_binding: { address: "+1#{participant_phone}", proxy_address: "+1#{host[:phone]}" } }
79
+ end
80
+ params.map(&:to_json)
84
81
  end
85
82
 
86
83
  def message_params_for(content, image_ids)
data/lib/twi/delivery.rb CHANGED
@@ -12,6 +12,9 @@ module Twi
12
12
  # @return [String, nil] error code
13
13
  def code = @params['ErrorCode']
14
14
 
15
+ # @return [String] phone number that delivered the message.
16
+ def sender = @params['From']
17
+
15
18
  # @return [String] documentation URL for given error code.
16
19
  def self.url_for(code)
17
20
  "https://www.twilio.com/docs/api/errors/#{code}"
@@ -1,6 +1,6 @@
1
1
  module Twi
2
2
  class Mock::Conversation < Conversation
3
- def create_with(participants:)
3
+ def create_with(host:, participant_phones:)
4
4
  if error = Twi.mock.conversation_error
5
5
  Twi.mock.conversation_error = nil
6
6
  case error[:code]
@@ -11,10 +11,10 @@ module Twi
11
11
  Twi.mock.message_error = nil
12
12
  raise Error, error
13
13
  elsif Twi.mock.message
14
- @id = Twi.mock.message[:id]
14
+ @params[:id] = Twi.mock.message[:id]
15
15
  @status = Twi.mock.message[:status]
16
16
  else
17
- @id = "SM#{rand}"
17
+ @params[:id] = "SM#{rand}"
18
18
  @status = 'delivered'
19
19
  end
20
20
  end
data/lib/twi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Twi
4
- VERSION = '0.3.8'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo