mock-twilio 1.5.1 → 1.6

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: a52bffd4c72fd567629419247ab70a105749bdc6ecb1949a90c6283d7a7f7605
4
- data.tar.gz: 29b1ea83b4e2e031c9d667eb855291e0ff5c559efc4d8138cff9fd21628b1f2c
3
+ metadata.gz: e02a4a487e0e41196d976f65b65dcc98d038b3c7ebcd24f0e2446c3a9583e99b
4
+ data.tar.gz: 1c353da26f50254df52488d98a0e870a5aa673700fbfa22f1a67d5c0b9565423
5
5
  SHA512:
6
- metadata.gz: bce53334c3db48402acd11ae664af553dd2bdbc6e14f961c7e581dbfa36280d1fa73c7809af595965d0eef3ffdbcedb75c797c057c0e91a57469ca523daad6dc
7
- data.tar.gz: 12a531d4ec3ed53e3047bb2ff9b9fae4115246c30c9694e511298f979fda663191249a0190a949c434395573f7c7f5352a77aee845b00a7750acd1efa37140a6
6
+ metadata.gz: 07cb455b2778cdbfacc3781d36380261efea912ef927bafb7845c2e6b876084a7c74cec68f5ed1c27ddb6a9f02567211e325a68ced19c7fc3472e6edbceeb4ba
7
+ data.tar.gz: 2677a192cf11edd7d88a7cea325f67932fb4f8e1f0e7544e7ce23879e797dcebc61de62cf5166eb51260ffa4de295ba7ca345044719851997796693eca46c1fa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.6] - 2025-02-27
2
+ - Support webhook_client host with and without port
3
+ - Support custom webhook message update url
4
+
1
5
  ## [1.5.1] - 2025-02-24
2
6
  - Fix Scheduler performance
3
7
 
data/README.md CHANGED
@@ -67,11 +67,30 @@ OR
67
67
  ## How to use
68
68
  Initializer sample
69
69
  ```ruby
70
+ # Local Docker/Host
70
71
  Mock::Twilio.configure do |config|
71
- config.host = "http://shunkan-ido-service"
72
- config.forwarded_host = "shunkan-ido-service"
72
+ config.host = "http://shunkan-ido-service:3000"
73
+ config.forwarded_host = "shunkan-ido-service:3000"
73
74
  config.port = "3000"
74
75
  config.proto = "http"
76
+ # optional https://www.twilio.com/docs/messaging/api/message-resource#request-body-parameters
77
+ # Use webhook_message_status_url as the Integration Send webhook from Messaging Service.
78
+ # If you include status_callback parameter with the messaging_service_sid,
79
+ # Twilio uses status_callback URL instead of the Status Callback URL(webhook_message_status_url) of the Messaging Service.
80
+ # config.webhook_message_status_url = "http://shunkan_ido:3000/api/v1/twilio_requests/webhook_message_updates"
81
+ end
82
+
83
+ # Real http(s) url
84
+ Mock::Twilio.configure do |config|
85
+ config.host = "https://my-server"
86
+ config.forwarded_host = "my-server"
87
+ config.port = "443"
88
+ config.proto = "https"
89
+ # optional https://www.twilio.com/docs/messaging/api/message-resource#request-body-parameters
90
+ # Use webhook_message_status_url as the Integration Send webhook from Messaging Service.
91
+ # If you include status_callback parameter with the messaging_service_sid,
92
+ # Twilio uses status_callback URL instead of the Status Callback URL(webhook_message_status_url) of the Messaging Service.
93
+ # config.webhook_message_status_url = "https://my-server/api/v1/twilio_requests/webhook_message_updates"
75
94
  end
76
95
  ```
77
96
 
@@ -4,7 +4,7 @@ module Mock
4
4
  module Twilio
5
5
  module Util
6
6
  class Configuration
7
- attr_accessor :host, :forwarded_host, :port, :proto
7
+ attr_accessor :host, :forwarded_host, :port, :proto, :webhook_message_status_url
8
8
 
9
9
  def host=(value)
10
10
  @host = value
@@ -21,6 +21,10 @@ module Mock
21
21
  def proto=(value)
22
22
  @proto = value
23
23
  end
24
+
25
+ def webhook_message_status_url=(value)
26
+ @webhook_message_status_url = value
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mock
4
4
  module Twilio
5
- VERSION = "1.5.1"
5
+ VERSION = "1.6"
6
6
  end
7
7
  end
@@ -12,7 +12,9 @@ module Mock
12
12
  end
13
13
 
14
14
  def _request(request)
15
- @connection = Faraday.new(url: request.host + ":" + request.port.to_s, ssl: { verify: true }) do |f|
15
+ url = request.host.split(":").last.to_i.zero? ? (request.host + ":" + request.port.to_s) : request.host
16
+
17
+ @connection = Faraday.new(url: url, ssl: { verify: true }) do |f|
16
18
  f.options.params_encoder = Faraday::FlatParamsEncoder
17
19
  f.request :url_encoded
18
20
  f.adapter @adapter
@@ -26,7 +26,7 @@ module Mock
26
26
  end
27
27
 
28
28
  def self.headers
29
- return { 'Host': Mock::Twilio.forwarded_host }.merge!({ 'X-Forwarded-Proto': Mock::Twilio.proto }) if Mock::Twilio.proto == "http"
29
+ return { 'Host': Mock::Twilio.forwarded_host, 'X-Forwarded-Proto': Mock::Twilio.proto } if Mock::Twilio.proto == "http"
30
30
 
31
31
  { 'Host': Mock::Twilio.forwarded_host }
32
32
  end
@@ -8,8 +8,15 @@ module Mock
8
8
  # Wait simulation from twilio
9
9
  sleep DELAY.sample
10
10
 
11
- request_url = callback_url
12
- url = callback_url.split(Mock::Twilio.host).last
11
+ if callback_url
12
+ request_url = callback_url
13
+ url = callback_url.split(Mock::Twilio.host).last
14
+ elsif Mock::Twilio.webhook_message_status_url
15
+ request_url = Mock::Twilio.webhook_message_status_url
16
+ url = Mock::Twilio.webhook_message_status_url.split(Mock::Twilio.host).last
17
+ else
18
+ raise "There is not webhook_message_status_url or status_callback"
19
+ end
13
20
 
14
21
  data = { :MessageSid=>sid, :MessageStatus=>"delivered" }
15
22
 
data/lib/mock/twilio.rb CHANGED
@@ -28,7 +28,7 @@ module Mock
28
28
  module Twilio
29
29
  extend SingleForwardable
30
30
 
31
- def_delegators :configuration, :host, :forwarded_host, :port, :proto
31
+ def_delegators :configuration, :host, :forwarded_host, :port, :proto, :webhook_message_status_url
32
32
 
33
33
  def self.configure(&block)
34
34
  yield configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock-twilio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: '1.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - SchoolStatus Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-24 00:00:00.000000000 Z
11
+ date: 2025-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday